diff --git a/README_zh.md b/README_zh.md index 27ad5abed9665603e2bf925f5e59b5dcf221f658..b0ec331ced4a7496ab9d861007667b804bc19ed1 100644 --- a/README_zh.md +++ b/README_zh.md @@ -18,7 +18,7 @@ master:最新开发版本。 -发布OpenHarmony 3.1 Beta版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.1-beta.md)。 +发布OpenHarmony 3.1 Release版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.1-release.md)。 发布OpenHarmony 3.0 LTS版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)。该版本已更新至OpenHarmony 3.0.2 LTS,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md)。 diff --git a/en/application-dev/ability/Readme-EN.md b/en/application-dev/ability/Readme-EN.md index e0fb613133dd0854672bc5e27f44dbc63d9061ca..8be4858131c0b947639fdeed77bf4f99b3dfb10c 100644 --- a/en/application-dev/ability/Readme-EN.md +++ b/en/application-dev/ability/Readme-EN.md @@ -1,10 +1,9 @@ # Ability Development - - [Ability Framework Overview](ability-brief.md) - - FA Model - - [FA Model Overview](fa-brief.md) - - [Page Ability Development](fa-pageability.md) - - [Service Ability Development](fa-serviceability.md) - - [Data Ability Development](fa-dataability.md) - - [FA Widget Development](fa-formability.md) +- [FA Model Overview](fa-brief.md) +- [Page Ability Development](fa-pageability.md) +- [Service Ability Development](fa-serviceability.md) +- [Data Ability Development](fa-dataability.md) +- [FA Widget Development](fa-formability.md) + - Other - [Ability Assistant Usage](ability-assistant-guidelines.md) diff --git a/en/application-dev/ability/ability-brief.md b/en/application-dev/ability/ability-brief.md deleted file mode 100644 index c923f428b579b94ed3745b711341c77ce8f870eb..0000000000000000000000000000000000000000 --- a/en/application-dev/ability/ability-brief.md +++ /dev/null @@ -1,19 +0,0 @@ -# Ability Framework Overview - -An ability is an abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more **Ability** instances. - -The ability framework model has two forms. The first form is the FA model, which applies to application development using API 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service and Data abilities. The stage model is introduced since API 9. In the stage model, there are Page abilities and Extension abilities. The Extension ability is further extended to Service Extension, Form Extension, Data Share Extension, and more. - -The stage model is designed to make complex application development easier in a distributed environment. The two models have differences in the following aspects: - -* Ability type and API usage - - ![favsstage](figures/favsstage.png) - -* Ability lifecycle - - ![lifecycle](figures/lifecycle.png) - -* Application configuration files and application package structure (The differences are reflected in the application packages generated by the IDE.) - -For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md). diff --git a/en/application-dev/ability/ability-continuation.md b/en/application-dev/ability/ability-continuation.md deleted file mode 100644 index 57a4de48b4f7bbd7c745a94da0048d746a9eeab1..0000000000000000000000000000000000000000 --- a/en/application-dev/ability/ability-continuation.md +++ /dev/null @@ -1,173 +0,0 @@ -# Ability Continuation Development - -## When to Use - -With ability continuation APIs, you can migrate the current application task, including some page data and stack information, to a remote device. If the migration is successful, the local task will be cleared. If the migration fails, the local task can be migrated again. - - - -## Available APIs - -The following table lists the API used for ability continuation. For details about the API, see the interface document. - -**Table 1** Ability continuation API - -|API| Description| -|:------ | :------| -| onContinue(wantParams : {[key: string]: any}) | A callback used to store the data required for migration and indicate whether the migration is accepted. The value **true** means that the migration is accepted, and **false** means the opposite.| - - - -## How to Develop - -### Migrating an Ability - - - -1. Configure data. - - - Configure the ability to support migration. - - ​ Set the **continuable** field in the **config.json** file to **true**, which indicates that migration is supported. The default value is **false**. - - ``` - "continuable": true - ``` - - Abilities with the **continuable** field set to **false** cannot be migrated. - - * Configure the ability startup type. - - ​ Currently, only multi-instance abilities can be migrated. Therefore, you must set the **launchType** field in the **config.json** file to **standard**. - - ``` - "launchType": "standard" - ``` - - - -2. Implement the **onContinue** API. - - Modules to Import - - ``` - import Ability from '@ohos.application.Ability'; - ``` - - - To implement migration, you must implement this API and have the value **true** returned. - - - - Example - - ```javascript - onContinue(wantParams : {[key: string]: any}) { - console.log("MainAbility onContinue") - return true; - } - ``` - - - -3. Implement the migration logic in the **onCreate** API. - - - On the remote device, determine whether the startup is **LaunchReason.CONTINUATION** (3) based on **launchReason** in **onCreate**. - - - - After data restore is complete, call **restoreWindowStage** to trigger page restoration. - - - * Example - - ```javascript - onCreate(want , launchParam) { - // The ability is being created. Initialize resources for this ability. - console.log("MainAbility onCreate", launchParam.launchReason); - if (launchParam.launchReason == LaunchReason.CONTINUATION) { - this.contentStorage = new ContenStorage(); - this.context.restoreWindowStage(this.contentStorage); - } - } - - ``` - - - -### Migrating Data - -1. Use custom data. - - - You can fill custom data in the key-value format in the **wantParams** parameter, through which the data will be transferred to the remote device. The **key** type is string, and therefore it is used to carry simple and lightweight data. - - - ```javascript - onContinue(wantParams : {[key: string]: any}) { - console.log("Continue My Data") - wantParams["myData"] = "my1234567"; - return true; - } - ``` - - - If the remote device detects a migration, it obtains the custom data saved at the initiator from **want.parameters**. - - ```javascript - onCreate(want , launchParam) { - if (launchParam.launchReason == LaunchReason.CONTINUATION) { - console.log("onCreate LaunchReason = CONTINUATION",want.parameters["myData"]); // my1234567 - ... - this.context.restoreWindowStage(this.contentStorage); - } - } - - ``` - - - -2. Use distributed objects. - - You can use distributed objects to transfer more data to a remote device. For details, see the distributed object interface document. - - - In **onContinue**, the initiator saves the data to be migrated to the distributed object, sets the session ID, and sends the session ID to the remote device through **wantParams**. - - - - The remote device obtains the session ID from **onCreate**, creates a distributed object, and associates the distributed object with the session ID. In this way, the distributed object can be synchronized. Before calling **restoreWindowStage**, ensure that all distributed objects required for migration have been associated for correct data retrieval. - - - * Example - - ```javascript - import Ability from '@ohos.application.Ability'; - import distributedObject from '@ohos.data.distributedDataObject'; - - var g_object = distributedObject.createDistributedObject({name:undefined}); - - export default class MainAbility extends Ability { - contentStorage : ContenStorage - sessionId : string; - onCreate(want , launchParam) { - if (launchParam.launchReason == 3) { - this.sessionId = want.parameters["session"] // Obtain the session ID. - - function statusCallback(sessionId, networkid, status) { - console.info("object status change sessionId: " + sessionId + " status: " + status + - "g_object.name: " + g_object.name); // The synchronized distributed object content "name = Amy" can be obtained from the callback. - } - g_object.on("status", statusCallback); // Register a callback to listen for the distributed object synchronization result. - - g_object.setSessionId(this.sessionId); // Associate the local distributed object with the session ID of the initiator. - - this.contentStorage = new ContenStorage(); - this.context.restoreWindowStage(this.contentStorage); - } - } - - onContinue(wantParams : {[key: string]: any}) { - console.log("using distributedObject") - this.sessionId = "654321"; - g_object.setSessionId(this.sessionId); // Set the session ID of the distributed object. - g_object.name = "Amy"; // Fill data. - wantParams["session"] = this.sessionId; // Send the session ID to the remote device through the want object. - return true; - } - ``` - - diff --git a/en/application-dev/ability/figures/favsstage.png b/en/application-dev/ability/figures/favsstage.png deleted file mode 100644 index 45f6b0ef255b01730dc42023430391e1141291c2..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ability/figures/favsstage.png and /dev/null differ diff --git a/en/application-dev/ability/figures/lifecycle.png b/en/application-dev/ability/figures/lifecycle.png deleted file mode 100644 index 694238d99c7e70d16d6bd1a37c86bcd599a9b2f3..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ability/figures/lifecycle.png and /dev/null differ diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md index df0b9f869d373543e436d3c0c2ee131627b9fdfd..a75e8a98756df5d76400d52724e64a2e7f6c5c7b 100644 --- a/en/application-dev/application-dev-guide.md +++ b/en/application-dev/application-dev-guide.md @@ -2,9 +2,9 @@ The application development documents provide reference for you to develop applications using the APIs provided by OpenHarmony. The documents provided walk you through how to use JavaScript \(JS\) APIs to develop applications on the standard system. -To get a glimpse of the basic methods for developing applications, see [Basics](quick-start/Readme-EN.md). For details about the API list and references, see [Reference](reference/Readme-EN.md). +To get a glimpse of the basic methods for developing applications, see [Basics](quick-start/start-overview.md). For details about the API list and references, see [Reference](reference/apis/js-apis-featureAbility.md). -To better understand frequently used modules, see the development guidelines for [UI](ui/Readme-EN.md), [Media](media/Readme-EN.md), and [Connectivity](connectivity/Readme-EN.md). +To better understand frequently used modules, see the development guidelines for [Ability](ability/fa-brief.md), [UI](ui/arkui-overview.md), [Media](media/Readme-EN.md), etc. For details about the principles and basic information of each subsystem, see the README file in **docs/en/readme**. diff --git a/en/application-dev/application-dev-website.md b/en/application-dev/application-dev-website.md index f2367108230f24f71b60d0570855d9c251fb5b7f..fd812ea600eecbea31a52b9e3e069edea818a952 100644 --- a/en/application-dev/application-dev-website.md +++ b/en/application-dev/application-dev-website.md @@ -1,20 +1,11 @@ +# Application Development + - [Application Development Overview](application-dev-guide.md) - Quick Start - - Getting Started with Application Development - - DevEco Studio (OpenHarmony) User Guide - - [Overview](quick-start/deveco-studio-overview.md) - - [Version Change History](quick-start/deveco-studio-release-notes.md) - - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - Creating an OpenHarmony Project - - [Using the Project Wizard to Create a Project](quick-start/use-wizard-to-create-project.md) - - [Importing a Sample to Create a Project](quick-start/import-sample-to-create-project.md) - - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) - - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) - [Directory Structure](quick-start/package-structure.md) - [Resource File Categories](quick-start/basic-resource-file-categories.md) - Development - - [Ability Development](ability/Readme-EN.md) - - [Ability Framework Overview](ability/ability-brief.md) + - Ability Development - FA Model - [FA Model Overview](ability/fa-brief.md) - [Page Ability Development](ability/fa-pageability.md) @@ -24,7 +15,7 @@ - Other - [Ability Assistant Usage](ability/ability-assistant-guidelines.md) - - [UI]](ui/Readme-EN.md) + - UI - JavaScript-based Web-Like Development Paradigm - [Overview](ui/ui-js-overview.md) - Framework @@ -58,16 +49,17 @@ - [Stepper](ui/ui-js-components-stepper.md) - [Tabs](ui/ui-js-component-tabs.md) - Basic Components - - [Text](ui/ui-js-components-text.md) - - [Input](ui/ui-js-components-input.md) - - [Button](ui/ui-js-components-button.md) - - [Picker](ui/ui-js-components-picker.md) - - [Image](ui/ui-js-components-images.md) + - [Text](ui/ui-js-components-text.md) + - [Input](ui/ui-js-components-input.md) + - [Button](ui/ui-js-components-button.md) + - [Picker](ui/ui-js-components-picker.md) + - [Image](ui/ui-js-components-images.md) - Animation Development Guidelines - CSS Animation - [Defining Attribute Style Animations](ui/ui-js-animate-attribute-style.md) - [Defining Animations with the transform Attribute](ui/ui-js-animate-transform.md) - [Defining Animations with the background-position Attribute](ui/ui-js-animate-background-position-style.md) + - [Defining Animations for SVG Components](ui/ui-js-animate-svg.md) - JS Animation - [Component Animation](ui/ui-js-animate-component.md) - Interpolator Animation @@ -82,6 +74,8 @@ - [Rules for Accessing Application Code Files](ui/ts-framework-file-access-rules.md) - ["js" Tag](ui/ts-framework-js-tag.md) - Resource Access + - [Accessing Application Resources](ui/ts-application-resource-access.md) + - [Accessing System Resources](ui/ts-system-resource-access.md) - [Media Resource Types](ui/ts-media-resource-type.md) - [Pixel Units](ui/ts-pixel-units.md) - [Types](ui/ts-types.md) @@ -153,12 +147,11 @@ - Audio - [Audio Overview](media/audio-overview.md) - [Audio Playback Development](media/audio-playback.md) - - [Audio Playback Development Using AudioRenderer](media/audio-renderer.md) + - [Audio Rendering Development](media/audio-renderer.md) - [Audio Recording Development](media/audio-recorder.md) - - [Audio Recorder Development Using AudioCapturer](media/audio-capturer) + - [Audio Capture Development](media/audio-capturer.md) - Video - [Video Playback Development](media/video-playback.md) - - [Video Recording Development](media/video-recorder.md) - Image - [Image Development](media/image.md) - Security @@ -199,6 +192,9 @@ - Sensor - [Sensor Overview](device/sensor-overview.md) - [Sensor Development](device/sensor-guidelines.md) + - Vibrator + - [Vibrator Overview](device/vibrator-overview.md) + - [Vibrator Development](device/vibrator-guidelines.md) - Device Usage Statistics - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) @@ -212,14 +208,12 @@ - Distributed Call Chain Tracing - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) + - Internationalization + - [Overview](internationalization/international-overview.md) + - [Internationalization Development (intl)](internationalization/intl-guidelines.md) + - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - Tools - - DevEco Studio (OpenHarmony) User Guide - - [Overview](quick-start/deveco-studio-overview.md) - - [Version Change History](quick-start/deveco-studio-release-notes.md) - - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [Creating an OpenHarmony Project](quick-start/create-openharmony-project.md) - - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) - - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) + - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - API References @@ -322,8 +316,7 @@ - [Event Parameter](reference/arkui-js/js-components-custom-event-parameter.md) - [slot](reference/arkui-js/js-components-custom-slot.md) - [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md) - - Appendix - - [Type Attributes](reference/arkui-js/js-appendix-types.md) + - [Type Attributes](reference/arkui-js/js-appendix-types.md) - Compent Reference (TypeScript-based Declarative Development Paradigm) - Components - Universal Components @@ -335,7 +328,7 @@ - [Key Event](reference/arkui-ts/ts-universal-events-key.md) - [Focus Event](reference/arkui-ts/ts-universal-focus-event.md) - [Mouse Event](reference/arkui-ts/ts-universal-mouse-key.md) - - [Component Area Change Event](reference/arkui-ts/ts-universal-events-component-area-change.md) + - [Component Area Change Event](reference/arkui-ts/ts-universal-component-area-change-event.md) - Universal Attributes - [Size](reference/arkui-ts/ts-universal-attributes-size.md) - [Location](reference/arkui-ts/ts-universal-attributes-location.md) @@ -380,24 +373,36 @@ - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) - [Image](reference/arkui-ts/ts-basic-components-image.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [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) + - [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) - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [Search](reference/arkui-ts/ts-basic-components-search.md) - [Select](reference/arkui-ts/ts-basic-components-select.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [Text](reference/arkui-ts/ts-basic-components-text.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [Web](reference/arkui-ts/ts-basic-components-web.md) + - [Xcomponent](reference/arkui-ts/ts-basic-components-xcomponent.md) - Container Components - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - [Badge](reference/arkui-ts/ts-container-badge.md) @@ -410,19 +415,17 @@ - [GridItem](reference/arkui-ts/ts-container-griditem.md) - [List](reference/arkui-ts/ts-container-list.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md) - - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Navigation](reference/arkui-ts/ts-container-navigation.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Row](reference/arkui-ts/ts-container-row.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [ScrollBar](reference/arkui-ts/ts-container-scrollbar.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [Stack](reference/arkui-ts/ts-container-stack.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - Media Components - [Video](reference/arkui-ts/ts-media-components-video.md) - Drawing Components @@ -454,7 +457,6 @@ - [Matrix Transformation](reference/arkui-ts/ts-matrix-transformation.md) - [Interpolation Calculation](reference/arkui-ts/ts-interpolation-calculation.md) - Global UI Methods - - [Image Cache](reference/arkui-ts/ts-methods-image-cache.md) - Dialog Box - [Alert Dialog Box](reference/arkui-ts/ts-methods-alert-dialog-box.md) - [Action Sheet](reference/arkui-ts/ts-methods-action-sheet.md) @@ -462,122 +464,201 @@ - [Date Picker Dialog Box](reference/arkui-ts/ts-methods-datepicker-dialog.md) - [Text Picker Dialog Box](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [Menu](reference/arkui-ts/ts-methods-menu.md) - - Appendix - - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) + - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - APIs - Ability Framework - - [FeatureAbility Module](reference/apis/js-apis-featureAbility.md) - - [ParticleAbility Module](reference/apis/js-apis-particleAbility.md) - - [DataAbilityHelper Module](reference/apis/js-apis-dataAbilityHelper.md) - - [DataUriUtils Module](reference/apis/js-apis-DataUriUtils.md) - - [Bundle Module](reference/apis/js-apis-Bundle.md) - - [Context Module](reference/apis/js-apis-Context.md) - - Event Notification - - [CommonEvent Module](reference/apis/js-apis-commonEvent.md) - - [Notification Module](reference/apis/js-apis-notification.md) - - [Reminder Agent](reference/apis/js-apis-reminderAgent.md) - - Resource Management - - [Resource Manager](reference/apis/js-apis-resource-manager.md) - - [Internationalization (intl)](reference/apis/js-apis-intl.md) - - [Internationalization (i18n)](reference/apis/js-apis-i18n.md) + + - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) + - [@ohos.application.Ability](reference/apis/js-apis-application-ability.md) + - [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage ](reference/apis/js-apis-application-abilitystage.md) + - [@ohos.application.appManager](reference/apis/js-apis-appmanager.md) + - [@ohos.application.Configuration](reference/apis/js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant](reference/apis/js-apis-configurationconstant.md) + - [@ohos.ability.featureAbility](reference/apis/js-apis-featureAbility.md) + - [@ohos.application.formBindingData](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.FormExtension](reference/apis/js-apis-formextension.md) + - [@ohos.application.missionManager](reference/apis/js-apis-missionManager.md) + - [@ohos.application.formProvider](reference/apis/js-apis-formprovider.md) + - [@ohos.ability.particleAbility](reference/apis/js-apis-particleAbility.md) + - [@ohos.application.ServiceExtensionAbility](reference/apis/js-apis-service-extension-ability.md) + - [@ohos.application.uriPermissionManager](reference/apis/js-apis-uripermissionmanager.md) + - [@ohos.wantAgent](reference/apis/js-apis-wantAgent.md) + - [dataAbilityHelper](reference/apis/js-apis-dataAbilityHelper.md) + - [context](reference/apis/js-apis-Context.md) + - [AbilityContext](reference/apis/js-apis-ability-context.md) + - [AbilityRunningInfo](reference/apis/js-apis-abilityrunninginfo.md) + - [AbilityStageContext](reference/apis/js-apis-abilitystagecontext.md) + - [Context](reference/apis/js-apis-application-context.md) + - [ExtensionContext](reference/apis/js-apis-extension-context.md) + - [ExtensionRunningInfo](reference/apis/js-apis-extensionrunninginfo.md) + - [FormExtensionContext](reference/apis/js-apis-formextensioncontext.md) + - [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md) + - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) + - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) + - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) + + - Common Event and Notification + + - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) + - [@ohos.events.emitter](reference/apis/js-apis-emitter.md) + - [@ohos.notification](reference/apis/js-apis-notification.md) + - [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md) + - [EventHub](reference/apis/js-apis-eventhub.md) + + - Bundle Management + + - [@ohos.bundle](reference/apis/js-apis-Bundle.md) + - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.zlib](reference/apis/js-apis-zlib.md) + + - UI Page + + - [@ohos.animator](reference/apis/js-apis-animator.md) + + - Graphics + + - [@ohos.display ](reference/apis/js-apis-display.md) + - [@ohos.screenshot](reference/apis/js-apis-screenshot.md) + - [@ohos.window](reference/apis/js-apis-window.md) + - [webgl](reference/apis/js-apis-webgl.md) + - [webgl2](reference/apis/js-apis-webgl2.md) + - Media - - [Audio Management](reference/apis/js-apis-audio.md) - - [Media](reference/apis/js-apis-media.md) - - [Image Processing](reference/apis/js-apis-image.md) - - [Camera](reference/apis/js-apis-camera.md) + + - [@ohos.multimedia.audio](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.image](reference/apis/js-apis-image.md) + - [@ohos.multimedia.media](reference/apis/js-apis-media.md) + - [@ohos.multimedia.medialibrary](reference/apis/js-apis-medialibrary.md) + + - Resource Management + - [@ohos.i18n](reference/apis/js-apis-i18n.md) + - [@ohos.intl](reference/apis/js-apis-intl.md) + - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) + + - Resource Scheduling + + - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) + + - Custom Management + + - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) + - Security - - [User Authentication](reference/apis/js-apis-useriam-userauth.md) - - [Access Control](reference/apis/js-apis-abilityAccessCtrl.md) + + - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) + - Data Management - - [Lightweight Storage](reference/apis/js-apis-data-preferences.md) - - [Distributed Data Management](reference/apis/js-apis-distributed-data.md) - - [Relational Database](reference/apis/js-apis-data-rdb.md) - - [Result Set](reference/apis/js-apis-data-resultset.md) - - [DataAbilityPredicates](reference/apis/js-apis-data-ability.md) - - [Settings](reference/apis/js-apis-settings.md) + + - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) + - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) + - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) + - [@ohos.settings](reference/apis/js-apis-settings.md) + - [resultSet](reference/apis/js-apis-data-resultset.md) + - File Management - - [File Management](reference/apis/js-apis-fileio.md) - - [Statfs](reference/apis/js-apis-statfs.md) - - [Environment](reference/apis/js-apis-environment.md) - - [Public File Access and Management](reference/apis/js-apis-filemanager.md) - - [App Storage Statistics](reference/apis/js-apis-storage-statistics.md) - - [Volume Management](reference/apis/js-apis-volumemanager.md) - - Account Management - - [OS Account Management](reference/apis/js-apis-osAccount.md) - - [Distributed Account Management](reference/apis/js-apis-distributed-account.md) - - [App Account Management](reference/apis/js-apis-appAccount.md) + + - [@ohos.environment](reference/apis/js-apis-environment.md) + - [@ohos.fileio](reference/apis/js-apis-fileio.md) + - [@ohos.fileManager](reference/apis/js-apis-filemanager.md) + - [@ohos.statfs](reference/apis/js-apis-statfs.md) + - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) + - Telephony Service - - [Call](reference/apis/js-apis-call.md) - - [SMS](reference/apis/js-apis-sms.md) - - [SIM Management](reference/apis/js-apis-sim.md) - - [Radio](reference/apis/js-apis-radio.md) - - [Observer](reference/apis/js-apis-observer.md) - - [Cellular Data](reference/apis/js-apis-telephony-data.md) + + - [@ohos.contact](reference/apis/js-apis-contact.md) + - [@ohos.telephony.call](reference/apis/js-apis-call.md) + - [@ohos.telephony.observer](reference/apis/js-apis-observer.md) + - [@ohos.telephony.radio](reference/apis/js-apis-radio.md) + - [@ohos.telephony.sim](reference/apis/js-apis-sim.md) + - [@ohos.telephony.sms](reference/apis/js-apis-sms.md) + - [@ohos.telephony.data](reference/apis/js-apis-telephony-data.md) + - Network Management - - [Network Connection Management](js-apis-net-connection.md) - - [Socket Connection](js-apis-socket.md) - - [WebSocket Connection](js-apis-webSocket.md) - - [Data Request](js-apis-http.md) - - Network and Connectivity - - [WLAN](reference/apis/js-apis-wifi.md) - - [Bluetooth](reference/apis/js-apis-bluetooth.md) - - [RPC](reference/apis/js-apis-rpc.md) - - Device Management - - [Sensor](reference/apis/js-apis-sensor.md) - - [Vibrator](reference/apis/js-apis-vibrator.md) - - [Brightness](reference/apis/js-apis-brightness.md) - - [Battery Info](reference/apis/js-apis-battery-info.md) - - [Power Management](reference/apis/js-apis-power.md) - - [Thermal Management](reference/apis/js-apis-thermal.md) - - [Running Lock](reference/apis/js-apis-runninglock.md) - - [Device Info](reference/apis/js-apis-device-info.md) - - [systemParameter](reference/apis/js-apis-system-parameter.md) - - [Device Management](reference/apis/js-apis-device-manager.md) - - [Window](reference/apis/js-apis-window.md) - - [Display](reference/apis/js-apis-display.md) - - [Update](reference/apis/js-apis-update.md) - - [USB](reference/apis/js-apis-usb.md) - - [Location](reference/apis/js-apis-geolocation.md) + - [@ohos.net.connection](reference/apis/js-apis-net-connection.md) + - [@ohos.net.http](reference/apis/js-apis-http.md) + - [@ohos.request](reference/apis/js-apis-request.md) + - [@ohos.net.socket](reference/apis/js-apis-socket.md) + - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) + + - Connectivity + + - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) + - [@ohos.rpc](reference/apis/js-apis-rpc.md) + - [@ohos.wifi](reference/apis/js-apis-wifi.md) + - [@ohos.wifiext](reference/apis/js-apis-wifiext.md) + - Basic Features - - [Application Context](reference/apis/js-apis-basic-features-app-context.md) - - [Console Logs](reference/apis/js-apis-basic-features-logs.md) - - [Page Routing](reference/apis/js-apis-basic-features-routes.md) - - [Timer](reference/apis/js-apis-basic-features-timer.md) - - [Setting the System Time](reference/apis/js-apis-system-time.md) - - [Animation](reference/apis/js-apis-basic-features-animator.md) - - [WebGL](reference/apis/js-apis-webgl.md) - - [WebGL2](reference/apis/js-apis-webgl2.md) - - [Screenshot](reference/apis/js-apis-screenshot.md) - - [Accessibility](reference/apis/js-apis-accessibility.md) - - DFX - - [HiAppEvent](reference/apis/js-apis-hiappevent.md) - - [Performance Tracing](reference/apis/js-apis-hitracemeter.md) - - [Fault Logger](reference/apis/js-apis-faultLogger.md) - - [Distributed Call Chain Tracing](reference/apis/js-apis-hitracechain.md) - - [HiLog](reference/apis/js-apis-hilog.md) - - [HiChecker](reference/apis/js-apis-hichecker.md) - - [HiDebug](reference/apis/js-apis-hidebug.md) + + - [@ohos.accessibility](reference/apis/js-apis-accessibility.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](reference/apis/js-apis-hidebug.md) + - [@ohos.hilog](reference/apis/js-apis-hilog.md) + - [@ohos.hiTraceChain](reference/apis/js-apis-hitracechain.md) + - [@ohos.hiTraceMeter](reference/apis/js-apis-hitracemeter.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.wallpaper](reference/apis/js-apis-wallpaper.md) + - [Timer](reference/apis/js-apis-timer.md) + + - Device Management + + - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.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.multimodalInput.inputConsumer](reference/apis/js-apis-inputconsumer.md) + - [@ohos.multimodalInput.inputDevice](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputMonitor](reference/apis/js-apis-inputmonitor.md) + - [@ohos.power](reference/apis/js-apis-power.md) + - [@ohos.runningLock](reference/apis/js-apis-runninglock.md) + - [@ohos.sensor](reference/apis/js-apis-sensor.md) + - [@ohos.systemParameter](reference/apis/js-apis-system-parameter.md) + - [@ohos.thermal](reference/apis/js-apis-thermal.md) + - [@ohos.update](reference/apis/js-apis-update.md) + - [@ohos.usb](reference/apis/js-apis-usb.md) + - [@ohos.vibrator](reference/apis/js-apis-vibrator.md) + + - Account Management + + - [@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) + - Language Base Class Library - - [Obtaining Process Information](reference/apis/js-apis-process.md) - - [URL String Parsing](reference/apis/js-apis-url.md) - - [URI String Parsing](reference/apis/js-apis-uri.md) - - [Util](reference/apis/js-apis-util.md) - - [XML Parsing and Generation](reference/apis/js-apis-xml.md) - - [XML-to-JavaScript Conversion](reference/apis/js-apis-convertxml.md) - - [Worker Startup](reference/apis/js-apis-worker.md) - - [Linear Container ArrayList](reference/apis/js-apis-arraylist.md) - - [Linear Container Deque](reference/apis/js-apis-deque.md) - - [Linear Container List](reference/apis/js-apis-list.md) - - [Linear Container LinkedList](reference/apis/js-apis-linkedlist.md) - - [Linear Container Queue](reference/apis/js-apis-queue.md) - - [Linear Container Stack](reference/apis/js-apis-stack.md) - - [Linear Container Vector](reference/apis/js-apis-vector.md) - - [Nonlinear Container HashSet](reference/apis/js-apis-hashset.md) - - [Nonlinear Container HashMap](reference/apis/js-apis-hashmap.md) - - [Nonlinear Container PlainArray](reference/apis/js-apis-plainarray.md) - - [Nonlinear Container TreeMap](reference/apis/js-apis-treemap.md) - - [Nonlinear Container TreeSet](reference/apis/js-apis-treeset.md) - - [Nonlinear Container LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [Nonlinear Container LightWeightSet](reference/apis/js-apis-lightweightset.md) - - Custom Management - - [Configuration Policy](reference/apis/js-apis-config-policy.md) + + - [@ohos.convertxml](reference/apis/js-apis-convertxml.md) + - [@ohos.process](reference/apis/js-apis-process.md) + - [@ohos.uri](reference/apis/js-apis-uri.md) + - [@ohos.url](reference/apis/js-apis-url.md) + - [@ohos.util](reference/apis/js-apis-util.md) + - [@ohos.util.ArrayList](reference/apis/js-apis-arraylist.md) + - [@ohos.util.Deque](reference/apis/js-apis-deque.md) + - [@ohos.util.HashMap](reference/apis/js-apis-hashmap.md) + - [@ohos.util.HashSet](reference/apis/js-apis-hashset.md) + - [@ohos.util.LightWeightMap](reference/apis/js-apis-lightweightmap.md) + - [@ohos.util.LightWeightSet](reference/apis/js-apis-lightweightset.md) + - [@ohos.util.LinkedList](reference/apis/js-apis-linkedlist.md) + - [@ohos.util.List](reference/apis/js-apis-list.md) + - [@ohos.util.PlainArray](reference/apis/js-apis-plainarray.md) + - [@ohos.util.Queue](reference/apis/js-apis-queue.md) + - [@ohos.util.Stack](reference/apis/js-apis-stack.md) + - [@ohos.util.TreeMap](reference/apis/js-apis-treemap.md) + - [@ohos.util.TreeSet](reference/apis/js-apis-treeset.md) + - [@ohos.util.Vector](reference/apis/js-apis-vector.md) + - [@ohos.worker](reference/apis/js-apis-worker.md) + - [@ohos.xml](reference/apis/js-apis-xml.md) + + - APIs No Longer Maintained + + - [@ohos.bytrace](reference/apis/js-apis-bytrace.md) + - [@ohos.data.storage](reference/apis/js-apis-data-storage.md) + - [@system.sensor](reference/apis/js-apis-system-sensor.md) + - [@system.vibrator](reference/apis/js-apis-system-vibrate.md) + - [console](reference/apis/js-apis-logs.md) \ No newline at end of file diff --git a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index 2858f1dd5fea1dd9a37c9eceb7fe9c57e0f177fc..cb31281e693400790ddb2f438ebb744d77ddaf89 100644 --- a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -563,12 +563,12 @@ Publish a 10-second countdown reminder. } ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, title: "this is title", content: "this is content", @@ -625,12 +625,12 @@ calendar: { }, ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, ringDuration: 5, snoozeTimes: 2, @@ -663,12 +663,12 @@ alarm: { }, ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, ringDuration: 5, snoozeTimes: 2, diff --git a/en/application-dev/connectivity/ipc-rpc.md b/en/application-dev/connectivity/ipc-rpc.md deleted file mode 100644 index b975f79f44de7309bab85c41e97c90717125ded4..0000000000000000000000000000000000000000 --- a/en/application-dev/connectivity/ipc-rpc.md +++ /dev/null @@ -1,9 +0,0 @@ -# IPC & RPC - -- **[IPC & RPC Overview](ipc-rpc-overview.md)** - -- **[IPC & RPC Development Guidelines](ipc-rpc-development-guideline.md)** - -- **[Subscribing to State Changes of a Remote Object](subscribe-remote-state.md)** - - diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md index db4a15e18c101ba89b842ba8e6997ae2f32fc472..4bdf8cfb5be2a0207b0ba4ca2650085d9ff7ad8d 100644 --- a/en/application-dev/device/Readme-EN.md +++ b/en/application-dev/device/Readme-EN.md @@ -7,3 +7,9 @@ - [Location Overview](device-location-overview.md) - [Obtaining Device Location Information](device-location-info.md) - [Geocoding and Reverse Geocoding Capabilities](device-location-geocoding.md) +- Sensor + - [Sensor Overview](sensor-overview.md) + - [Sensor Development](sensor-guidelines.md) +- Vibrator + - [vibrator-Overview.md](vibrator-overview.md) + - [Vibrator Development](vibrator-guidelines.md) \ No newline at end of file diff --git a/en/application-dev/device/figures/en-us_image_0000001180249428.png b/en/application-dev/device/figures/en-us_image_0000001180249428.png new file mode 100644 index 0000000000000000000000000000000000000000..efd258b98d9a4eb2a72767bd808eef4f49900d32 Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001180249428.png differ diff --git a/en/application-dev/device/sensor-overview.md b/en/application-dev/device/sensor-overview.md index ea75d0b5dfc4a0611d118d5ddb9fbbaac1345bc5..c45dd69eea4372c41a1d5f1dbf93de14e4b40ea5 100644 --- a/en/application-dev/device/sensor-overview.md +++ b/en/application-dev/device/sensor-overview.md @@ -1,88 +1,43 @@ # Sensor Overview -Sensors in OpenHarmony are an abstraction of underlying hardware-based sensors. Your application can access the underlying sensors via OpenHarmony sensors. Using the APIs provided by OpenHarmony sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, fitness and health, and games applications. +Sensors in OpenHarmony are an abstraction of underlying hardware-based sensors. Your application can access the underlying sensors via the sensors. Using the APIs provided by sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, fitness and health, and games applications. -The sensors are classified into the following categories based on their functions: motion, environment, orientation, light, body, and other categories (such as Hall effect sensors). Each category includes different sensor types. A sensor type may be a single physical sensor or a composite of multiple physical sensors. +A sensor is a device to detect events or changes in an environment and send messages about the events or changes to another device (for example, a CPU). Generally, a sensor is composed of sensitive components and conversion components. Sensors are the cornerstone of the IoT. A unified sensor management framework is required to achieve data sensing at a low latency and low power consumption, thereby keeping up with requirements of "1+8+N" products or business in the Seamless AI Life Strategy. The sensor list is as follows: +| Sensor Type | Sensor Name | Description | Usage | +| --------------------------------------- | ------------------ | ------------------------------------------------------------ | ---------------------------------------- | +| SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2.| Detecting the motion status | +| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor| Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2.| Measuring the acceleration bias estimation | +| SENSOR_TYPE_LINEAR_ACCELERATION | Linear acceleration sensor | Measures the linear acceleration (excluding the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2.| Detecting the linear acceleration in each axis | +| SENSOR_TYPE_GRAVITY | Gravity sensor | Measures the gravity acceleration applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2.| Measuring the gravity | +| SENSOR_TYPE_GYROSCOPE | Gyroscope sensor | Measures the rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s.| Measuring the rotation angular velocity | +| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | Uncalibrated gyroscope sensor| Measures the uncalibrated rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s.| Measuring the bias estimation of the rotation angular velocity | +| SENSOR_TYPE_SIGNIFICANT_MOTION | Significant motion sensor | Checks whether a device has a significant motion on three physical axes (X, Y, and Z). The value **0** means that the device does not have a significant motion, and **1** means the opposite.| Detecting significant motions of a device | +| SENSOR_TYPE_PEDOMETER_DETECTION | Pedometer detection sensor | Detects whether a user takes a step. The value can be **0** (the user does not take a step) or **1** (the user takes a step).| Detecting whether a user takes a step | +| SENSOR_TYPE_PEDOMETER | Pedometer sensor | Records the number of steps a user has walked. | Providing the number of steps a user has walked | +| SENSOR_TYPE_AMBIENT_TEMPERATURE | Ambient temperature sensor | Measures the ambient temperature, in the unit of degree Celsius (°C). | Measuring the ambient temperature | +| SENSOR_TYPE_MAGNETIC_FIELD | Magnetic field sensor | Measures the magnetic field on three physical axes (X, Y, and Z), in the unit of μT.| Creating a compass | +| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | Uncalibrated magnetic field sensor | Measures the uncalibrated magnetic field on three physical axes (X, Y, and Z), in the unit of μT.| Measuring the magnetic field bias estimation | +| SENSOR_TYPE_HUMIDITY | Humidity sensor | Measures the ambient relative humidity, in a percentage (%). | Monitoring the dew point, absolute humidity, and relative humidity | +| SENSOR_TYPE_BAROMETER | Barometer sensor | Measures the barometric pressure, in the unit of hPa or mbar. | Measuring the barometric pressure | +| SENSOR_TYPE_ORIENTATION | Orientation sensor | Measures the rotation angles of a device on three physical axes (X, Y, and Z), in the unit of rad.| Providing the three orientation angles of the screen | +| SENSOR_TYPE_ROTATION_VECTOR | Rotation vector sensor | Measures the rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor, magnetic field sensor, and gyroscope sensor.| Detecting the orientation of a device in the East, North, Up (ENU) Cartesian coordinate system | +| SENSOR_TYPE_PROXIMITY | Proximity sensor | Measures the distance between a visible object and the device screen. | Measuring the distance between a person and the device during a call | +| SENSOR_TYPE_AMBIENT_LIGHT | Ambient light sensor | Measures the ambient light intensity of a device, in the unit of lux. | Automatically adjusting the screen brightness and checking whether the screen is covered on the top| +| SENSOR_TYPE_HEART_RATE | Heart rate sensor | Measures the heart rate of a user. | Providing users' heart rate data | +| SENSOR_TYPE_WEAR_DETECTION | Wear detection sensor | Checks whether a user is wearing a wearable device. | Detecting wearables | +| SENSOR_TYPE_HALL | Hall effect sensor | Detects a magnetic field around a device. | Smart cover mode of the device | - **Table1** Motion - ohos.sensor.agent.CategoryMotionAgent -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Detecting the motion status | -| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor | Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Measuring the acceleration bias estimation | -| SENSOR_TYPE_LINEAR_ACCELERATION | Linear acceleration sensor | Measures the linear acceleration (excluding the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Detecting the linear acceleration in each axis | -| SENSOR_TYPE_GRAVITY | Gravity sensor | Measures the gravity acceleration applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Measuring the gravity | -| SENSOR_TYPE_GYROSCOPE | Gyroscope sensor | Measures the rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the rotation angular velocity | -| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | Uncalibrated gyroscope sensor | Measures the uncalibrated rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the bias estimation of the rotation angular velocity | -| SENSOR_TYPE_SIGNIFICANT_MOTION | Significant motion sensor | Checks whether a device has a significant motion on three physical axes (X, Y, and Z). The value can be **0** (having no significant motion) or **1** (having a significant motion). | Detecting significant motions of a device | -| SENSOR_TYPE_DROP_DETECTION | Drop detection sensor | Detects the device drop status. The value can be **0** (the device is not dropped) or **1** (the device is dropped). | Detecting whether a device is dropped | -| SENSOR_TYPE_PEDOMETER_DETECTION | Pedometer detection sensor | Detects whether a user takes a step. The value can be **0** (the user does not take a step) or **1** (the user takes a step). | Detecting whether a user takes a step | -| SENSOR_TYPE_PEDOMETER | Pedometer sensor | Records the number of steps a user has walked. | Providing the number of steps a user has walked | +## Working Principles +The following modules work cooperatively to implement OpenHarmony sensors: Sensor API, Sensor Framework, Sensor Service, and HDF layer. - **Table2** Environment - ohos.sensor.agent.CategoryOrientationAgent + **Figure 1** How the sensor works -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_AMBIENT_TEMPERATURE | Ambient temperature sensor. | Measures the ambient temperature, in the unit of degree Celsius (°C). | Measuring the ambient temperature | -| SENSOR_TYPE_MAGNETIC_FIELD | Magnetic field sensor | Measures the magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Creating a compass | -| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | Uncalibrated magnetic field sensor | Measures the uncalibrated magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Measuring the magnetic field bias estimation | -| SENSOR_TYPE_HUMIDITY | Humidity sensor | Measures the ambient relative humidity, in a percentage (%). | Monitoring the dew point, absolute humidity, and relative humidity | -| SENSOR_TYPE_BAROMETER | Barometer sensor | Measures the barometric pressure, in the unit of hPa or mbar. | Measuring the barometric pressure | -| SENSOR_TYPE_SAR | Specific Absorption Rate (SAR) sensor | Measures the SAR, in the unit of W/kg. | Measuring the SAR of electromagnetic waves for a device | - - - **Table3** Orientation - ohos.sensor.agent.CategoryOrientationAgent - -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_6DOF | Degrees of Freedom (DoF) sensor | Measures the forward/backward, up/down, and left/right translational movement of a device on the three axes (X, Y, and Z) in the unit of m or mm as well as the roll, pitch, and yaw rotation angles on the three axes (X, Y, and Z) in the unit of rad. | Positioning an object by detecting its freedom of translational and rotational motions, for example, VR | -| SENSOR_TYPE_SCREEN_ROTATION | Screen rotation sensor | Checks the rotation status of the device screen. | Detecting whether the device screen is rotating | -| SENSOR_TYPE_DEVICE_ORIENTATION | Device orientation sensor | Measures the rotation angles of the device, in the unit of rad. | Measuring the angles that a device has rotated | -| SENSOR_TYPE_ORIENTATION | Orientation sensor | Measures the rotation angles of a device on three physical axes (X, Y, and Z), in the unit of rad. | Providing the three orientation angles of the screen | -| SENSOR_TYPE_ROTATION_VECTOR | Rotation vector sensor | Measures the rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor, magnetic field sensor, and gyroscope sensor. | Detecting the orientation of a device in the East, North, Up (ENU) Cartesian coordinate system | -| SENSOR_TYPE_GAME_ROTATION_VECTOR
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | Game rotation vector sensor
Geomagnetic rotation vector sensor | Measures the game rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and gyroscope sensor.
Measures the geomagnetic rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and magnetic field sensor. | Applied in games
Measuring the geomagnetic rotation vector | - - - **Table4** Light - ohos.sensor.agent.CategoryLightAgent - -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_PROXIMITY | Proximity sensor | Measures the distance between a visible object and the device screen. | Measuring the distance between a person and the device during a call | -| SENSOR_TYPE_TOF | Time of flight (ToF) sensor | Measures the time required for light to travel a distance in the medium. | Facial recognition | -| SENSOR_TYPE_AMBIENT_LIGHT | Ambient light sensor | Measures the ambient light intensity of a device, in the unit of lux. | Automatically adjusting the screen brightness and checking whether the screen is covered on the top | -| SENSOR_TYPE_COLOR_TEMPERATURE | Color temperature sensor | Measures the ambient color temperature. | Image processing on the device | -| SENSOR_TYPE_COLOR_RGB | RGB color sensor | Measures the ambient RGB color values. | Color detection implemented by the reflectance of RGB colors | -| SENSOR_TYPE_COLOR_XYZ | XYZ color sensor | Measures the ambient XYZ color values. | Identifying true-color spots to reproduce more natural colors | - - - **Table5** Body - ohos.sensor.agent.CategoryBodyAgent - -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_HEART_RATE | Heart rate sensor | Measures the heart rate of a user. | Providing users' heart rate data | -| SENSOR_TYPE_WEAR_DETECTION | Wear detection sensor | Checks whether a user is wearing a wearable device. | Detecting wearables | - - - **Table6** Others - -| Sensor Type | Sensor Name | Description | Usage | -| -------- | -------- | -------- | -------- | -| SENSOR_TYPE_HALL | Hall effect sensor | Detects a magnetic field around a device. | Smart cover mode of the device | -| SENSOR_TYPE_GRIP_DETECTOR | Grip detection sensor | Detects grip force applied on a device. | Detecting whether the device is gripped on its sides | -| SENSOR_TYPE_MAGNET_BRACKET | Magnet bracket sensor | Checks whether a device is magnetized. | Detecting an in-vehicle or indoor device | -| SENSOR_TYPE_PRESSURE_DETECTOR | Pressure detection sensor | Detects pressure force applied on a device. | Detecting pressure on the top of the device | - - -## How a Service Is Shared Using Huawei Share - -The following modules work cooperatively to implement OpenHarmony sensors: Sensor API, Sensor Framework, Sensor Service, and HD_IDL. - - **Figure1** Working principles for OpenHarmony sensors - ![en-us_image_0000001226521897](figures/en-us_image_0000001226521897.png) +![fad1a124-a90e-460f-84fc-e87d6caebb21](figures/fad1a124-a90e-460f-84fc-e87d6caebb21.png) - Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler. @@ -90,22 +45,22 @@ The following modules work cooperatively to implement OpenHarmony sensors: Senso - Sensor Service: interacts with the HD_IDL module to receive, parse, and distribute data, manages foreground and background policies and sensors of a device, and controls sensor permissions. -- HD_IDL: selects proper policies based on the hardware first in first out (FIFO) and frequency, and adapts to different devices. +- HDF layer: selects proper policies based on the hardware first in first out (FIFO) and frequency, and adapts to different devices. -## Limitations and Constraints +## Constraints -To obtain data of the following sensors, you must claim the required permissions. +1. To obtain data of the following sensors, you must claim the required permissions. + Table 7 Sensor data permissions - **Table7** Sensor data permission + | Sensor | Permission | Sensitivity | Permission Description | + | ------------------------- | -------------------------------- | ------------ | ----------------------- | + | Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows your application to subscribe to data of these acceleration-related sensors in the motion category.| + | Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows an application to subscribe to data of the gyroscope-related sensors in the motion category.| + | Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. | + | Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. | -| Sensor | Permission Name | Sensitivity | Permission Description | -| -------- | -------- | -------- | -------- | -| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor | ohos.permission.ACCELEROMETER | system_grant | Allows your application to subscribe to data of these acceleration-related sensors in the motion category. | -| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows your application to subscribe to data of these gyroscope-related sensors in the motion category. | -| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows your application to subscribe to the motion status. | -| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows your application to read health data. | -The APIs for subscribing to and unsubscribing from sensor data work in pairs. If you do not need sensor data, call the unsubscription API to stop sensor data reporting. +2. The APIs for subscribing to and unsubscribing from sensor data work in pairs. If you do not need sensor data, call the unsubscription API to stop sensor data reporting. diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..88bdeb6884eee52e1591993ec60099d31eb77e3c --- /dev/null +++ b/en/application-dev/device/vibrator-guidelines.md @@ -0,0 +1,84 @@ +# Vibrator Development + + +## When to Use + +You can set different vibration effects as needed, for example, customizing vibration effects with different intensities and durations for buttons on the device, and customizing one-shot or periodic vibration effects with different intensities and durations for alarm clocks and incoming calls. + + +## Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.vibrator | vibrate(duration: number): Promise<void> | Triggers vibration with the specified duration. This API uses a promise to return the result. | +| ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | Triggers vibration with the specified duration. This API uses a callback to return the result. | +| ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | Triggers vibration with the specified effect. This API uses a promise to return the result. | +| ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | Triggers vibration with the specified effect. This API uses a callback to return the result. | +| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | Stops vibration. This API uses a promise to return the result. | +| ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | Stops vibration. This API uses a callback to return the result. | + + +## How to Develop + +1. Declare the permissions required for controlling vibrators on the hardware device in the **config.json** file. + + ``` + "reqPermissions":[ + { + "name":"ohos.permission.ACCELEROMETER", + "reason"":"", + "usedScene":{ + "ability""[ + ".MainAbility" + ], + "when":"inuse" + } + }, + { + "name":"ohos.permission.VIBRATE", + "reason"":"", + "usedScene":{ + "ability""[ + ".MainAbility" + ], + "when":"inuse" + } + }, + { + "name":"ohos.permission.ACTIVITY_MOTION", + "reason"":"", + "usedScene":{ + "ability""[ + ".MainAbility" + ], + "when":"inuse" + } + }, + ] + ``` + +2. Trigger the device to vibrate. + + ``` + import vibrator from "@ohos.vibrator" + vibrator.vibrate(duration: number).then((error)=>{ + if(error){// The call fails, and error.code and error.message are printed. + console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); + }else{// The call succeeded. The device starts to vibrate. + console.log("Promise returned to indicate a successful vibration.") + }; + }) + ``` + +3. Stop the vibration. + + ``` + import vibrator from "@ohos.vibrator" + vibrator.stop(stopMode: VibratorStopMode).then((error)=>{ + if(error){// The call fails, and error.code and error.message are printed. + console.log("Promise return failed. error.code"+error.code+"error.message"+error.message); + }else{// The call succeeded. The device stops vibration. + Console.log("Promise returned to indicate a successful stop."); + }; + }) + ``` diff --git a/en/application-dev/device/vibrator-overview.md b/en/application-dev/device/vibrator-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..3d8f187054dd1f0da3e3099bd10e3cb28e5a9b15 --- /dev/null +++ b/en/application-dev/device/vibrator-overview.md @@ -0,0 +1,25 @@ +# Vibrator Overview + + +The vibrator service opens up the latest capabilities of the vibrator hardware to the maximum extent. By expanding the native vibrator service to implement integrated vibration and interaction design, the service delivers an exquisite integrated vibration experience and differentiated experience, and improves user interaction efficiency and usability. + + +## Working Principles + +The vibrator is a Misc device that consists of four modules: Vibrator API, Vibrator Framework, Vibrator Service, and HD_IDL. + + **Figure1** Vibrator in Misc devices + ![en-us_image_0000001180249428](figures/en-us_image_0000001180249428.png) + +- Vibrator API: provides basic vibrator APIs, including the APIs for querying the vibrator list, querying the vibrator by effect, and triggering and stopping vibration. + +- Vibrator Framework: manages the framework layer of the vibrator and communicates with the Misc Device Service. + +- Vibrator Service: manages services of vibrators. + +- HD_IDL: adapts to different devices. + + +## Constraints + +When using a vibrator, you need to declare and obtain the **ohos.permission.VIBRATE** permission first so that you can control the vibration effect. diff --git a/en/application-dev/internationalization/Readme-EN.md b/en/application-dev/internationalization/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..4a1435843d6842dfaacbd1a56419efc6ef5b7487 --- /dev/null +++ b/en/application-dev/internationalization/Readme-EN.md @@ -0,0 +1,5 @@ +# Internationalization + +- [Overview](international-overview.md) +- [Internationalization Development (intl)](intl-guidelines.md) +- [Internationalization Development (i18n)](i18n-guidelines.md) diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..0ded9fd39da8131472cdb600ffd6d3ebc7daff5f --- /dev/null +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -0,0 +1,363 @@ +# Internationalization Development (i18n) + + +## Obtaining System Language and Region Information + +APIs are provided to access the system language and region information. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | getSystemLanguage(): string | Obtains the system language. | +| ohos.i18n | getSystemRegion(): string | Obtains the system region. | +| ohos.i18n | getSystemLocale(): string | Obtains the system locale. | +| ohos.i18n | isRTL(locale: string): boolean7+ | Checks whether the locale uses a right-to-left (RTL) language. | +| ohos.i18n | is24HourClock(): boolean7+ | Checks whether the system uses a 24-hour clock. | +| ohos.i18n | getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a language. | +| ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a country. | + + +### How to Develop + +1. Obtain the system language. + Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module). + + + ``` + var language = i18n.getSystemLanguage(); + ``` + +2. Obtains the system region. + Call the **getSystemRegion** method to obtain the system region. + + ``` + var region = i18n.getSystemRegion(); + ``` + +3. Obtain the system locale. + Call the **getSystemLocale** method to obtain the system locale. + + ``` + var locale = i18n.getSystemLocale(); + ``` + +4. Check whether the locale's language is RTL. + Call the **isRTL** method to check whether the locale's language is RTL. + + + ``` + var rtl = i18n.isRTL("zh-CN"); + ``` + +5. Check whether the system uses a 24-hour clock. + Call the **is24HourClock** method to check whether the system uses a 24-hour clock. + + ``` + var hourClock = i18n.is24HourClock(); + ``` + +6. Obtain the localized display of a language. + Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. + + ``` + var language = "en"; + var locale = "zh-CN"; + var sentenceCase = false; + var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase); + ``` + +7. Obtain the localized display of a country. + Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. + + ``` + var country = "US"; + var locale = "zh-CN"; + var sentenceCase = false; + var localizedCountry = i18n.getDisplayCountry(country, locale, sentenceCase); + ``` + + +## Obtaining Calendar Information + +[Calendar](../reference/apis/js-apis-intl.md) APIs are used to obtain calendar information, for example, the localized display of the calendar, the first day of a week, and the minimum count of days in the first week of a year. + + +### Available APIs + +| Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | getCalendar(locale: string, type?: string): Calendar8+ | Obtains the **Calendar** object for a specific locale and type. | +| ohos.i18n | setTime(date: Date): void8+ | Sets the date for the **Calendar** object. | +| ohos.i18n | setTime(time: number): void8+ | Sets the time for the **Calendar** object. | +| ohos.i18n | set(year: number, month: number, date: number, hour?: number, minute?: number, second?: number): void8+ | Sets the year, month, day, hour, minute, and second for the **Calendar** object. | +| ohos.i18n | setTimeZone(timezone: string): void8+ | Sets the time zone for the **Calendar** object. | +| ohos.i18n | getTimeZone(): string8+ | Obtains the time zone for the **Calendar** object. | +| ohos.i18n | getFirstDayOfWeek(): number8+ | Obtains the first day of a week for the **Calendar** object. | +| ohos.i18n | setFirstDayOfWeek(value: number): void8+ | Sets the first day of a week for the **Calendar** object. | +| ohos.i18n | getMinimalDaysInFirstWeek(): number8+ | Obtains the minimum count of days in the first week of a year. | +| ohos.i18n | setMinimalDaysInFirstWeek(value: number): void8+ | Sets the minimum count of days in the first week of a year. | +| ohos.i18n | getDisplayName(locale: string): string8+ | Obtains the localized display of the **Calendar** object. | +| ohos.i18n | isWeekend(date?: Date): boolean8+ | Checks whether a given date is a weekend. | + + +### How to Develop + +1. Instantiate a **Calendar** object. + Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used. + + + ``` + var calendar = i18n.getCalendar("zh-CN", "gregory); + ``` + +2. Set the time for the **Calendar** object. + Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT. + + ``` + var date1 = new Date(); + calendar.setTime(date1); + var date2 = 1000; + calendar.setTime(date2); + ``` + +3. Set the year, month, day, hour, minute, and second for the **Calendar** object. + Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. + + ``` + calendar.set(2021, 12, 21, 6, 0, 0) + ``` + +4. Set and obtain the time zone for the **Calendar** object. + Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set. + + + ``` + calendar.setTimeZone("Asia/Shanghai"); + var timezone = calendar.getTimeZone(); + ``` + +5. Set and obtain the first day of a week for the **Calendar** object. + Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday. + + + ``` + calendar.setFirstDayOfWeek(1); + var firstDayOfWeek = calendar.getFirstDayOfWeek(); + ``` + +6. Set and obtain the minimum count of days in the first week for the **Calendar** object. + Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. + + ``` + calendar.setMinimalDaysInFirstWeek(3); + var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); + ``` + +7. Obtain the localized display of the **Calendar** object. + Call the **getDisplayName** method to obtain the localized display of the **Calendar** object. + + + ``` + var localizedName = calendar.getDisplayName("zh-CN"); + ``` + +8. Check whether a date is a weekend. + Call the **isWeekend** method to determine whether the input date is a weekend. + + + ``` + var date = new Date(); + var weekend = calendar.isWeekend(date); + ``` + + +## Formatting a Phone Number + +[PhoneNumberFormat](../reference/apis/js-apis-intl.md) APIs are used to format phone numbers in different countries and check whether the phone number formats are correct. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)8+ | Instantiates a **PhoneNumberFormat** object. | +| ohos.i18n | isValidNumber(number: string): boolean8+ | Checks whether the value of **number** is a phone number in the correct format. | +| ohos.i18n | format(number: string): string8+ | Formats the value of **number** based on the specified country and style. | + + +### How to Develop + +1. Instantiate a **PhoneNumberFormat** object. + Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**. + + + ``` + var phoneNumberFormat = new i18n.PhoneNubmerFormat("CN", {type: "E164"}); + ``` + +2. Check whether the phone number format is correct. + Call the **isValidNumber** method to check whether the format of the input phone number is correct. + + ``` + var validNumber = phoneNumberFormat.isValidNumber("15812341234"); + ``` + +3. Format a phone number. + Call the **format** method of **PhoneNumberFormat** to format the input phone number. + + ``` + var formattedNumber = phoneNumberFormat.format("15812341234"); + ``` + + +## Measurement Conversion + +An API can be called to implement measurement conversion. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string8+ | Converts one measurement unit (**fromUnit**) into another (**toUnit**) and formats the unit based on the specified locale and style. | + + +### How to Develop + +1. Convert a measurement unit. + Call the [unitConvert](../reference/apis/js-apis-intl.md) method to convert a measurement unit and format the display result. + + + ``` + var fromUnit = {unit: "cup", measureSystem: "US"}; + var toUnit = {unit: "liter", measureSystem: "SI"}; + var number = 1000; + var locale = "en-US"; + var style = "long"; + i18n.Util.unitConvert(fromUtil, toUtil, number, locale, style); + ``` + + +## Alphabet Index + +[IndexUtil](../reference/apis/js-apis-intl.md) APIs are used to obtain the alphabet indexes of different locales and calculate the index to which a string belongs. + + +### Available APIs + +| Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | getInstance(locale?: string): IndexUtil8+ | Instantiates an **IndexUtil** object. | +| ohos.i18n | getIndexList(): Array<string>8+ | Obtains the index list of the current locale. | +| ohos.i18n | addLocale(locale: string): void8+ | Adds the index of a new locale to the index list. | +| ohos.i18n | getIndex(text: string): string8+ | Obtains the index of **text**. | + + +### How to Develop + +1. Instantiate an **IndexUtil** object. + Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale. + + + ``` + var indexUtil = getInstance("zh-CN"); + ``` + +2. Obtain the index list. + Call the **getIndexList** method to obtain the alphabet index list of the current locale. + + ``` + var indexList = indexUtil.getIndexList(); + ``` + +3. Add an index. + Call the **addLocale** method to add the alphabet index of a new locale to the current index list. + + ``` + indexUtil.addLocale("ar") + ``` + +4. Obtain the index of a string. + Call the **getIndex** method to obtain the alphabet index of a string. + + ``` + var text = "access index"; + indexUtil.getIndex(text); + ``` + + +## Obtaining Line Breaks of Text + +When a text is displayed in more than one line, [BreakIterator](../reference/apis/js-apis-intl.md) APIs are used to obtain the line break positions of the text. + + +### Available APIs + +| Module | API | Description | +| -------- | -------- | -------- | +| ohos.i18n | getLineInstance(locale: string): BreakIterator8+ | Instantiates a **BreakIterator** object. | +| ohos.i18n | setLineBreakText(text: string): void8+ | Sets the text to be processed. | +| ohos.i18n | getLineBreakText(): string8+ | Obtains the text to be processed. | +| ohos.i18n | current(): number8+ | Obtains the current position of a **BreakIterator** object in the text being processed. | +| ohos.i18n | first(): number8+ | Sets a **BreakIterator** object to the first breakable point. | +| ohos.i18n | last(): number8+ | Sets a **BreakIterator** object to the last breakable point. | +| ohos.i18n | next(index?: number): number8+ | Moves a **BreakIterator** object to the break point according to **index**. | +| ohos.i18n | previous(): number8+ | Moves a **BreakIterator** object to the previous break point. | +| ohos.i18n | following(offset: number): number8+ | Moves a **BreakIterator** object to the break point following the position specified by **offset**. | +| ohos.i18n | isBoundary(offset: number): boolean8+ | Determines whether a position is a break point. | + + +### How to Develop + +1. Instantiate a **BreakIterator** object. + Call the **getLineInstance** method to instantiate a **BreakIterator** object. + + + ``` + var locale = "en-US" + var breakIterator = i18n.getLineInstance(locale); + ``` + +2. Set and access the text that requires line breaking. + Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking. + + + ``` + var text = "Apple is my favorite fruit"; + breakIterator.setLineBreakText(text); + var breakText = breakIterator.getLineBreakText(); + ``` + +3. Obtain the current position of the **BreakIterator** object. + Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed. + + + ``` + var pos = breakIterator.current(); + ``` + +4. Set the position of a **BreakIterator** object. + The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed. + + + ``` + var firstPos = breakIterator.first(); // Sets a BreakIterator object to the first break point, that is, the start position of the text. + var lastPos = breakIterator.last(); // Sets a BreakIterator object to the last break point, that is, the position after the text end. + // Moves a BreakIterator object forward or backward by a certain number of break points. + // If a positive number is input, move backward. If a negative number is input, move forward. If no value is input, move one position backward. + // When the object is moved out of the text length range, -1 is returned. + var nextPos = breakIterator.next(-2); + var previousPos = breakIterator.previous(); // Moves a BreakIterator object to the previous break point. When the text length is out of the range, -1 is returned. + // Moves a BreakIterator object to the break point following the position specified by offset. If the object is moved out of the text length range, -1 is returned. + var followingPos = breakIterator.following(10); + ``` + +5. Determine whether a position is a break point. + Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position. + + + ``` + var isboundary = breakIterator.isBoundary(5); + ``` diff --git a/en/application-dev/internationalization/international-overview.md b/en/application-dev/internationalization/international-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..f41f6b0cb00c105e9a69e9e94388713c638ad658 --- /dev/null +++ b/en/application-dev/internationalization/international-overview.md @@ -0,0 +1,24 @@ +# Overview + + +If an application is targeted for users and markets in different regions with different languages and time zones, it is necessary for you to provide localized versions to ensure good experience for your users. + + +Internationalization capabilities determine how hard or easy application localization will be. With the rich internationalization APIs provided by the system, localization is much more efficient and cost-effective, accelerating your design and implementation of a well-internationalized application. + + +## Basic Concepts + +- Locale: an abstract representation of the commonalities of a group in terms of language, script, country or region, and other regional features such as calendar, sorting, and currency. + +- Preferred language: the language that the user prefers to use in a service or system. You can add a preferred language by choosing **Settings** > **System & updates** > **Language & input** > **Language and region** > **ADD LANGUAGE** on your mobile phone. + + +## Working Principles + +You just need to specify a locale when calling internationalization APIs, and localization will be automatically implemented for that locale. Locale information can be hard coded, but it is more common for users to set the system language and region by themselves. + + +## Constraints + +None diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..9bbfa269163f903889cca28307472c808752a130 --- /dev/null +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -0,0 +1,302 @@ +# Internationalization Development (intl) + + +## Setting Locale Information + +[Locale](../reference/apis/js-apis-intl.md) APIs are used to maximize or minimize locale information. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Instantiates a **Locale** object. | +| ohos.intl | constructor(locale?: string, options?: options) | Instantiates a **Locale** object based on the locale parameter and options. | +| ohos.intl | toString(): string | Converts locale information into a string. | +| ohos.intl | maximize(): Locale | Maximizes locale information. | +| ohos.intl | minimize(): Locale | Minimizes locale information. | + + +### How to Develop + +1. Instantiate a **Locale** object. + Create a **Locale** object using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list (**intl** is the name of the imported module). + + + ``` + var locale = "zh-CN"; + var options = {caseFirst: false, calendar: "chinese", collation: pinyin}; + var localeObj = new intl.Locale(locale, options); + ``` + +2. Obtain the string representing a **Locale** object. + Call the **toString** method to obtain the string representing a **Locale** object, including the language, region, and other options. + + ``` + var localeStr = localeObj.toString(); + ``` + +3. Maximize locale information. + Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. + + ``` + var maximizedLocale = localeObj.maximize(); + ``` + +4. Minimize locale information. + Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. + + ``` + var minimizedLocale = localeObj.minimize(); + ``` + + +## Formatting the Date and Time + +[DateTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the date and time for a specific locale. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Creates a **DateTimeFormat** object. | +| ohos.intl | constructor(locale: string \| Array<string>, options?: DateTimeOptions) | Creates a **DateTimeFormat** object and sets the locale and other formatting-related attributes. | +| ohos.intl | format(date: Date): string | Calculates the date and time based on the locale and other formatting-related attributes of the **DateTimeFormat** object. | +| ohos.intl | formatRange(startDate: Date, endDate: Date): string | Calculates the period based on the locale and other formatting-related attributes of the **DateTimeFormat** object. | +| ohos.intl | resolvedOptions(): DateTimeOptions | Obtains the related attributes of the **DateTimeFormat** object. | + + +### How to Develop + +1. Instantiate a **DateTimeFormat** object. + Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object (**intl** is the name of the imported module). + + + ``` + var dateTimeFormat = new intl.DateTimeFormat(); + ``` + + Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). + + ``` + var options = {dateStyle: "full", timeStyle: "full"}; + var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options); + ``` + +2. Format the date and time. + Use the **format** method of **DateTimeFormat** to format a **Date** object. A string is returned as the formatting result. + + ``` + Date date = new Date(); + var formatResult = dateTimeFormat.format(date); + ``` + +3. Format a period. + Use the **formatRange** method of **DateTimeFormat** to format a period. This method requires the input of two **Date** objects, which respectively indicate the start date and end date of a period. A string is returned as the formatting result. + + ``` + Date startDate = new Date(); + Date endDate = new Date(); + var formatResult = dateTimeFormat.formatRange(startDate, endDate); + ``` + +4. Access the attributes of the **DateTimeFormat** object. + The **resolvedOptions** method of **DateTimeFormat** returns an object that contains all related attributes and values of the **DateTimeFormat** object. + + ``` + var options = dateTimeFormat.resolvedOptions(); + ``` + + +## Number Formatting + +[NumberFormat](../reference/apis/js-apis-intl.md) APIs are used to format a number for a specific locale. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Creates a **NumberFormat** object. | +| ohos.intl | constructor(locale: string \| Array<string>, options?: NumberOptions) | Creates a **NumberFormat** object and sets the locale and other formatting-related attributes. | +| ohos.intl | format(number: number): string | Calculates the number based on the locale and other formatting-related attributes of the **NumberFormat** object. | +| ohos.intl | resolvedOptions(): NumberOptions | Obtains the attributes of the **NumberFormat** object. | + + +### How to Develop + +1. Instantiate a **NumberFormat** object. + Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **NumberFormat** object (**intl** is the name of the imported module). + + + ``` + var numberFormat = new intl.NumberFormat(); + ``` + + Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). + + ``` + var options = {compactDisplay: "short", notation: "compact"}; + var numberFormat = new intl.NumberFormat("zh-CN", options); + ``` + +2. Format a number. + Use the **format** method of **NumberFormat** to format a number. A string is returned as the formatting result. + + ``` + var number = 1234.5678 + var formatResult = numberFormat.format(number); + ``` + +3. Access the attributes of the **NumberFormat** object. + The **resolvedOptions** method of NumberFormat returns an object that contains all related attributes and values of the **NumberFormat** object. + + ``` + var options = numberFormat.resolvedOptions(); + ``` + + +## String Sorting + +Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md) APIs are used to sort strings based on a specific locale. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Creates a **Collator** object. | +| ohos.intl | constructor(locale: string \| Array<string>, options?: CollatorOptions)8+ | Creates a **Collator** object and sets the locale and other related attributes. | +| ohos.intl | compare(first: string, second: string): number8+ | Calculates the comparison result of two strings based on the locale and other attributes of the **Collator** object. | +| ohos.intl | resolvedOptions(): CollatorOptions8+ | Obtains the attributes of the **Collator** object. | + + +### How to Develop + +1. Instantiate a **Collator** object. + Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **Collator** object (**intl** is the name of the imported module). + + + ``` + var collator = new intl.Collator(); + ``` + + Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). + + ``` + var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}; + ``` + +2. Compare two strings. + Use the **compare** method of **Collator** to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. + + ``` + var str1 = "first string"; + var str2 = "second string"; + var compareResult = collator.compare(str1, str2); + ``` + +3. Access the attributes of the **Collator** object. + The **resolvedOptions** method of **Collator** returns an object that contains all related attributes and values of the **Collator** object. + + ``` + var options = collator.resolvedOptions(); + ``` + + +## Determining the Singular-Plural Type + +According to grammars in certain languages, the singular or plural form of a noun depends on the number prior to the noun. [PluralRules](../reference/apis/js-apis-intl.md) APIs are used to determine the singular-plural type for a specific locale. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Creates a **PluralRules** object. | +| ohos.intl | constructor(locale: string \| Array<string>, options?: PluralRulesOptions)8+ | Creates a **PluralRules** object and sets the locale and other related attributes. | +| ohos.intl | select(n: number): string8+ | Determines the singular-plural type based on the locale and other formatting-related attributes of the **PluralRules** object. | + + +### How to Develop + +1. Instantiate a **PluralRules** object. + Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **PluralRules** object (**intl** is the name of the imported module). + + + ``` + var pluralRules = new intl.PluralRules(); + ``` + + Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). + + ``` + var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}; + ``` + +2. Determine the singular or plural category. + Use the **select** method of **PluralRules** to determine the singular-plural type for an input number. This method returns a string as the category of the input number, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. + + ``` + var number = 1234.5678 + var categoryResult = plurals.select(number); + ``` + + +## Formatting Relative Time + +[RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the relative time for a specific locale. + + +### Available APIs + + | Module | API | Description | +| -------- | -------- | -------- | +| ohos.intl | constructor()8+ | Creates a **RelativeTimeFormat** object. | +| ohos.intl | constructor(locale: string \| Array<string>, options?: RelativeTimeFormatInputOptions)8+ | Creates a **RelativeTimeFormat** object and sets the locale and other formatting-related attributes. | +| ohos.intl | format(value: number, unit: string): string8+ | Calculates the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | +| ohos.intl | formatToParts(value: number, unit: string): Array<object>8+ | Returns each part of the relative time format based on the locale and other formatting-related attributes of the **RelativeTimeFormat** object. | +| ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions8+ | Obtains the attributes of the **RelativeTimeFormat** object. | + + +### How to Develop + +1. Instantiate a **RelativeTimeFormat** object. + Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **RelativeTimeFormat** object (**intl** is the name of the imported module). + + + ``` + var relativeTimeFormat = new intl.RelativeTimeFormat(); + ``` + + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). + + ``` + var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}; + ``` + +2. Format the relative time. + Use the **format** method of **RelativeTimeFormat** to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. A string is returned as the formatting result. + + ``` + var number = 2; + var unit = "year" + var formatResult = relativeTimeFormat.format(number, unit); + ``` + +3. Obtain each part of the relative time format. + On obtaining each part of the relative time format, customize the relative time formatting result. + + ``` + var number = 2; + var unit = "year" + var formatResult = relativeTimeFormat.formatToParts(number, unit); + ``` + +4. Access the attributes of the **RelativeTimeFormat** object. + The **resolvedOptions** method of **RelativeTimeFormat** returns an object that contains all related attributes and values of the **RelativeTimeFormat** object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). + + ``` + var options = numberFormat.resolvedOptions(); + ``` diff --git a/en/application-dev/internationalization/public_sys-resources/icon-caution.gif b/en/application-dev/internationalization/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-caution.gif differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-danger.gif b/en/application-dev/internationalization/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-danger.gif differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-note.gif b/en/application-dev/internationalization/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-note.gif differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-notice.gif b/en/application-dev/internationalization/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-notice.gif differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-tip.gif b/en/application-dev/internationalization/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-tip.gif differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-warning.gif b/en/application-dev/internationalization/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/internationalization/public_sys-resources/icon-warning.gif differ diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index cb35fe17513b8b7111db96b57c7fa00605121b1f..f58cdcbec9ef695965bfdde9703880fbbc5e6ac8 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -1,14 +1,12 @@ -# Basics +# Quick Start -- [DevEco Studio \(OpenHarmony\) User Guide](deveco-studio-user-guide-for-openharmony.md) - - [Overview](deveco-studio-overview.md) - - [Version Change History](deveco-studio-release-notes.md) - - [Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md) - - [Creating an OpenHarmony Project](create-openharmony-project.md) - - [Using the Project Wizard to Create a Project](use-wizard-to-create-project.md) - - [Importing a Sample to Create a Project](import-sample-to-create-project.md) - - - [Configuring the OpenHarmony App Signature](configuring-openharmony-app-signature.md) - - [Installing and Running Your OpenHarmony App](installing-openharmony-app.md) -- [Directory Structure](package-structure.md) +- Getting Started + - [Preparations](start-overview.md) + - [Getting Started with eTS](start-with-ets.md) + - [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md) + - [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md) + +- Development Fundamentals + - [Directory Structure](package-structure.md) + - [Resource File](basic-resource-file-categories.md) diff --git a/en/application-dev/quick-start/configuring-openharmony-app-signature.md b/en/application-dev/quick-start/configuring-openharmony-app-signature.md deleted file mode 100644 index d2d7da5cb09c862978fac8648d46a62baf5e6953..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/configuring-openharmony-app-signature.md +++ /dev/null @@ -1,178 +0,0 @@ -# Configuring the OpenHarmony App Signature - -- [Generating a Key Store and CSR](#section153146467405) - - [In DevEco Studio](#section1298903211472) - - [In a Command-Line Tool](#section1276462024811) - -- [Generating an App Certificate](#section136609429562) -- [Generating the App Profile](#section2048641015325) -- [Configuring App Signature Information](#section10152423193310) - -Before running and debugging the OpenHarmony app on a real device, you need to sign the app. This section describes how to configure the signature of an OpenHarmony app. Operation instructions are the same in _HUAWEI DevEco Studio User Guide_ except this section. For details, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387). See the following figure for the process of configuring app signature information. - -![](figures/en-us_image_0000001113808114.png) - -## Generating a Key Store and CSR - -OpenHarmony uses digital certificates \(.cer\) and **Profile** files \(.p7b\) to ensure app integrity. Before applying for these files, you need to generate a key store \(.p12\) and a certificate signing request \(.csr\). You can do so in DevEco Studio or a command-line tool. - -### In DevEco Studio - -1. On the menu bar, choose **Build** \> **Generate Key and CSR**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you have a local key, click **Skip** in the **Generate Key** window and use the key to generate a CSR file. - -2. In **Key Store File**, click **Choose Existing** to select an existing key store \(.p12 file that contains a key\) or **New** to create one. The following describes how to create a key store. - - ![](figures/en-us_image_0000001119560738.png) - -3. In the **Create Key Store** dialog box, set the following parameters and click **OK**. - - - **Key Store File**: Select the path for storing the key store. - - **Password**: Set the key store password, which must contain at least 8 characters that include two types of the following: uppercase letters, lowercase letters, digits, and special characters. Do not lose the password as it will be used later in configuring the signature. - - **Confirm Password**: Enter the key store password again. - - ![](figures/en-us_image_0000001152674854.png) - -4. In the **Generate Key** window, set the following parameters and click **Next**. - - - **Alias**: Enter the alias of the key, which is used to identify the key name. Do not lose the alias as it will be used later in configuring the signature. - - **Password**: password of the key, which is automatically filled in and the same as the keystore password. - - **Validity**: Specify the certificate validity period. A validity period of 25 years or longer is recommended to cover the entire lifecycle of your app/service. - - **Certificate**: Enter basic certificate information. - - ![](figures/en-us_image_0000001117639668.png) - -5. In the **Generate CSR** window, select the key and set the storage path of the CSR file. - - ![](figures/en-us_image_0000001117479776.png) - -6. Click **OK**. You can then obtain the generated keystore file \(.p12\) and CSR file \(.csr\) from the storage path. - - ![](figures/en-us_image_0000001163839541.png) - - -### In a Command-Line Tool - -Use the Keytool in the Open JDK to generate a CSR. - -1. Run the Keytool as an administrator. - - ![](figures/en-us_image_0000001248045243.png) - -2. Switch to the directory where the Keytool is located. - - ![](figures/en-us_image_0000001247125297.png) - -3. Run the following command to generate a key store. This example creates a key store named **ide\_demo\_app.p12** and saves it to the root directory of the D drive. - - ``` - keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=Organization,OU=Unit,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc - ``` - - Parameters in the key store: - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >Record the values of **alias**, **storepass**, and **keypass**, which will be used in [Configuring App Signature Information](#section10152423193310). - - - **alias**: alias of the key, which is used to identify the key name. - - **sigalg**: signature algorithm, which is automatically set to **SHA256withECDSA** and cannot be changed. - - **dname**: - - **C**: country/region code, such as **CN**. - - **O**: organization name, such as **Organization**. - - **OU**: organization unit name, such as **Unit**. - - **CN**: your first name and last name. Set this parameter to be the same as **alias**. - - - **validity**: certificate validity period. It is recommended that you set this parameter to **9125** \(25 years\). - - **storepass**: key store password, which must contain at least 8 characters that include two types of the following: uppercase letters, lowercase letters, digits, and special characters. Do not lose the password as it will be used later in configuring the signature. - - **keypass**: password of the key. The value must be the same as that of **storepass**. - -4. Run the following command. After the command is executed, enter the **storepass** to generate a CSR in .csr format. - - ``` - keytool -certreq -alias "ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -file d:\\idedemokey.csr - ``` - - Parameters in the CSR: - - - **alias**: The value must be the same as the alias set in 3. - - **file**: name of the generated CSR. The file name extension is .csr. - - -## Generating an App Certificate - -Use the CSR generated in [Generating a Key Store and CSR](#section153146467405) to generate the digital certificate required for app signing. The method is as follows: - -Go to the **Sdk\\toolchains\\lib** directory where the OpenHarmony SDK is saved \(see [Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md) for details\) in the DevEco Studio installation directory, and run the following command in the CLI. If the **keytool** command cannot be executed, add the JDK environment variables to the system environment variables. You only need to modify the input and output to quickly generate a certificate. That is, modify **-infile** to specify the path of the CSR and **-outfile** to specify the name and path of the output certificate. - -``` -keytool -gencert -alias "OpenHarmony Application CA" -infile myApplication_ohos.csr -outfile myApplication_ohos.cer -keystore OpenHarmony.p12 -sigalg SHA384withECDSA -storepass 123456 -ext KeyUsage:"critical=digitalSignature" -validity 3650 -rfc -``` - -Refer to the following descriptions about the parameters in the command: - -- **alias**: alias of the CA private key used for issuing certificates. The CA private key of the OpenHarmony community is stored in the **OpenHarmony.p12** key store file. This parameter cannot be modified. -- **infile**: path of the CSR file. -- **outfile**: name and path of the certificate chain file. -- **keystore**: path of the CA key store for issuing certificates. The name of the OpenHarmony key store file is **OpenHarmony.p12**. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified. Note that the **OpenHarmony.p12** file is not the .p12 file generated in [Generating a Key Store and CSR](#section153146467405). -- **sigalg**: certificate signature algorithm. This parameter cannot be modified. -- **storepass**: key store password. The password is **123456** and cannot be changed. -- **ext**: certificate extension. This parameter cannot be modified. -- **validity**: certificate validity period, which is user-defined. -- **rfc**: specifies the output file format. This parameter cannot be modified. - -## Generating the App Profile - -The profile contains the following information about the OpenHarmony app: bundle name, digital certificate information, certificate permissions that can be applied for by the app, and devices where the app can be debugged \(the device list will be empty if the app type is Release\). Each app package must contain a profile file. - -Go to the **Sdk\\toolchains\\lib** directory, open the command-line tool, and run the following command. - -``` -java -jar provisionsigtool.jar sign --in UnsgnedReleasedProfileTemplate.json --out myApplication_ohos_Provision.p7b --keystore OpenHarmony.p12 --storepass 123456 --alias "OpenHarmony Application Profile Release" --sigAlg SHA256withECDSA --cert OpenHarmonyProfileRelease.pem --validity 365 --developer-id ohosdeveloper --bundle-name app bundle name --permission restricted permission name (optional) --permission restricted permission name (optional) --distribution-certificate myApplication_ohos.cer -``` - -Refer to the following descriptions about the parameters in the command: - -- **provisionsigtool**: tool for generating the profile which is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. -- **in**: path of the profile template which is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified. -- **out**: name and path of the profile. -- **keystore**: path of the key store for issuing certificates. The name of the OpenHarmony key store file is **OpenHarmony.p12**. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified. -- **storepass**: key store password. The password is **123456** and cannot be changed. -- **alias**: alias of the private key used for app signing. The CA private key of the OpenHarmony community is stored in the **OpenHarmony.p12** key store file. This parameter cannot be modified. -- **sigalg**: certificate signature algorithm. This parameter cannot be modified. -- **cert**: path of the certificate of the signature profile. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified. -- **validity**: certificate validity period, which is user-defined. -- **developer-id**: developer ID, which is a user-defined character string. -- **bundle-name**: app bundle name. -- **permission** \(optional\): If permissions are not required, this field can be left empty. You can add multiple restricted permissions in the following way: ohos.permission.READ\_CONTACTS, ohos.permission.WRITE\_CONTACTS. -- **distribution-certificate**: certificate generated in [Generating an App Certificate](#section136609429562). - -## Configuring App Signature Information - -Before debugging on a real device, use the private key file \(.p12\), certificate file \(.cer\), and profile file \(.p7b\) to sign the target module. - -Go to **File** \> **Project Structure** \> **Project** \> **Signing Configs** \> **debug**, deselect **Automatically generate signing**, and configure the signature information of the specified module. - -- **Store File**: Select the key store file with the file name extension .p12, which is generated in [Generating a Key Store and CSR](#section153146467405). -- **Store Password**: Enter the key store password, which is the same as the key store password entered in [Generating a Key Store and CSR](#section153146467405). -- **Key Alias**: Enter the alias of the key, which is the same as the alias entered in [Generating a Key Store and CSR](#section153146467405). -- **Key Password**: Enter the key password, which is the same as the value of **Store Password**. -- **Sign Alg**: Specify the signature algorithm, which has a fixed value of **SHA256withECDSA**. -- **Profile File**: Select the .p7b profile file generated in [Generating the App Profile](#section2048641015325). -- **Certpath File**: Select the .cer debug certificate generated in [Generating an App Certificate](#section136609429562). - -![](figures/en-us_image_0000001155643492.png) - -Click **OK** to save your configurations. Then you can view the signature configuration information in **build.gradle** of the project. - -![](figures/en-us_image_0000001202722349.png) - -By default, the type of a HAP package compiled using DevEco Studio is set to **debug**. For a release type, click the **OhosBuild Variants** tab in the lower left corner of the project and set the type to **release**. For details about how to compile and build the HAP, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_hap-0000001053342418). - -![](figures/en-us_image_0000001115066116.png) - -After the compilation is complete, you can obtain the HAP package of your OpenHarmony app from the **build** directory of the project. - -![](figures/en-us_image_0000001163918627.png) - diff --git a/en/application-dev/quick-start/configuring-openharmony-sdk.md b/en/application-dev/quick-start/configuring-openharmony-sdk.md deleted file mode 100644 index fa4b76112a1e0055332535e019d9178f8ab4ffe3..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/configuring-openharmony-sdk.md +++ /dev/null @@ -1,195 +0,0 @@ -# Configuring the OpenHarmony SDK - -- [Prerequisites](#section164161442154812) -- [Configuring the SDK Information](#section1265592425017) -- [References](#section0384143616409) - - [Setting Up the DevEco Studio Proxy](#section10129720184214) - - [Setting Up the npm Proxy](#section19984059114316) - - [Setting Up the Gradle Proxy](#section164211820465) - - -To set up the OpenHarmony app development environment, configure the corresponding SDK information in DevEco Studio first. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The OpenHarmony SDK is not applicable to HarmonyOS app development, with some necessary toolchains removed. - -## Prerequisites - -[DevEco Studio 3.0 Beta1](https://developer.harmonyos.com/cn/develop/deveco-studio#download) or later has been downloaded and installed. - -## Configuring the SDK Information - -DevEco Studio manages SDKs and toolchains using SDK Manager. OpenHarmony contains the following SDK packages: - - - - - - - - - - - - - - - - - - - - - - -

Type

-

Package Name

-

Description

-

SDK

-

JS

-

SDK for JS.

-

eTS

-

SDK for Extended TypeScript (eTS).

-

SDK Tool

-

Toolchains

-

Includes compiling, packaging, signing, database management, and other tools that are required to develop OpenHarmony apps.

-

Previewer

-

OpenHarmony app previewer, which can be used to view the UI layout during app development.

-
- -1. Open DevEco Studio. If this is the first time you are using it, select **Do not import settings** and click **OK**. -2. Follow the wizard to set **npm registry**. DevEco Studio has been preconfigured with the corresponding registry. Click **Start using DevEco Studio** to go to the next step. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the **Set up HTTP Proxy** page is displayed, it indicates that your network requires a proxy. In this case, set up the DevEco Studio proxy, npm proxy, and Gradle proxy according to [References](#section0384143616409), and then download the OpenHarmony SDK. - - ![](figures/en-us_image_0000001163314102.png) - -3. Follow the wizard to download the SDK. By default, the OpenHarmony SDK will be downloaded. You can download the SDK to the default **user** directory or a local path that does not contain any Chinese characters. Then click **Next**. - - ![](figures/en-us_image_0000001208394019.png) - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are not using DevEco Studio for the first time, the SDK download page may not be displayed. In this case, go to **Configure** \(or ![](figures/en-us_image_0000001208274069.png)\) \> **Settings** \> **SDK Manager** \> **OpenHarmony SDK** and click **OpenHarmony SDK Location** to download the SDK. - -4. On the **Settings Confirmation** page, click **Next**. When the **License Agreement** dialog box appears, click **Accept**. - - ![](figures/en-us_image_0000001163472654.png) - -5. After the OpenHarmony SDK and tools are downloaded, click **Finish** to access the DevEco Studio welcome page. - - ![](figures/en-us_image_0000001163632602.png) - - -## References - -Setting up the development environment requires that your network can directly access the Internet. - -Generally, only some enterprise networks rather than personal area networks or home networks require a proxy to access the Internet. - -If you are using DevEco Studio for the first time and the **Set up HTTP Proxy** page is displayed, it indicates that your network requires a proxy. In this case, set up the DevEco Studio proxy, npm proxy, and Gradle proxy. - -![](figures/en-us_image_0000001166582138.png) - -### Setting Up the DevEco Studio Proxy - -1. Start DevEco Studio. On the **Set up HTTP Proxy** page that is displayed, select **Manual proxy configuration** and set the HTTP proxy. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If this is not the first time you are using DevEco Studio: - >- On the welcome page, choose **Configure** \(or ![](figures/en-us_image_0000001212142015.png)\)** \> Settings \> Appearance & Behavior \> System Settings \> HTTP Proxy** to access the HTTP Proxy settings. \(For macOS, choose **Configure \> Preferences \> Appearance & Behavior \> System Settings \> HTTP Proxy**.\) - >- When on a project page, choose **File \> Settings \> Appearance & Behavior \> System Settings \> HTTP Proxy** to access the HTTP Proxy settings. \(For macOS, choose **DevEco Studio \> Preferences \> Appearance & Behavior \> System Settings \> HTTP Proxy**.\) - - - **HTTP** parameters: **If you are not sure about the information, contact your network administrator.** - - **Host name**: Enter the host name or IP address of the proxy server. - - **Port number**: Enter the port number of the proxy server. - - **No proxy for**: Enter the URLs or IP addresses which the PC can directly connect to without a proxy server. Use commas \(,\) to separate URLs and IP addresses. - - - **Proxy authentication** parameters: Set the parameters only when the proxy server requires authentication. - - **Login**: Enter the user name used to access the proxy server. - - **Password**: Enter the password used to access the proxy server. - - **Remember**: Select this option to remember the password. - - ![](figures/en-us_image_0000001212062065.png) - -2. When you have finished, click **Check connection** and enter a URL to check the network connectivity. If the message "Connection successful" is displayed, it indicates that the proxy was set up successfully. -3. Click **Next: Configure npm** to set up the npm proxy. For details, see [Setting Up the npm Proxy](#section19984059114316). - -### Setting Up the npm Proxy - -Follow the configuration wizard of DevEco Studio to configure the npm proxy information, which will be written into the **.npmrc** file in the **users/**_user name_ directory. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The configuration wizard is displayed only the first time you install DevEco Studio. If the wizard is not displayed, manually add the proxy information to the **.npmrc** file in the **users/**_user name_ directory. - -- **npm registry**: Set the address of the npm registry. You are advised to select this option. -- **HTTP proxy**: Proxy server information. By default, the value is the same as that of **HTTP proxy** of DevEco Studio. -- **Enable Https Proxy**: Indicates whether to configure HTTPS proxy. You are advised to select this option. - -![](figures/en-us_image_0000001164577336.png) - -Click **Start using DevEco Studio**. - -If your proxy server requires the user name and password for authentication, set the user name and password as follows. If your proxy server does not require authentication, skip this step and follow the instructions in [Configuring the SDK Information](#section1265592425017). - -![](figures/en-us_image_0000001209817299.png) - -1. Go to the **Users** directory and open the **.npmrc** file. -2. Modify the npm proxy information. Add the **user** and **password** fields to **proxy** and **https-proxy**. Note that the values may vary depending on the proxy. The following is an example: - - ``` - proxy=http://user:password@proxy.server.com:80 - https-proxy=http://user:password@proxy.server.com:80 - ``` - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If the password contains special characters, such as @, \#, and \*, the configuration may not take effect. You are advised to replace the special characters with ASCII codes and add "%" before the ASCII codes. Refer to the following for the mapping between common symbols and ASCII codes. - >- !: %21 - >- @: %40 - >- \#: %23 - >- ¥: %24 - >- &: %26 - >- \*: %2A - -3. After the proxy is configured, open the CLI and run the following command to check whether the network is normal. - - ``` - npm info express - ``` - - If the following information is displayed after running the command, it indicates that the proxy has been set up successfully. - - ![](figures/en-us_image_0000001164417356.png) - -4. When you are done, follow the instructions in [Configuring the SDK Information](#section1265592425017). - -### Setting Up the Gradle Proxy - -1. Open **This PC**, and enter **%userprofile%** in the address box to access the user profile. \(For macOS, choose **Go** \> **Home**.\) - - ![](figures/en-us_image_0000001166740700.png) - -2. Create a **.gradle** folder if there is none. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >Before creating a **.gradle** folder in macOS, set the system to show hidden files. - -3. Open the **.gradle** folder, create a **gradle** file, and change the file name extension to .properties. -4. Add the following script to the **gradle.properties** file and save the file: - - Modify the host name, port number, user name, password, and proxy exceptions \(**nonProxyHosts**\) based on the actual condition. Separate values for **nonProxyHosts** with a vertical bar \(|\). - - ``` - systemProp.http.proxyHost=proxy.server.com - systemProp.http.proxyPort=8080 - systemProp.http.nonProxyHosts=*.company.com|10.*|100.* - systemProp.http.proxyUser=userId - systemProp.http.proxyPassword=password - systemProp.https.proxyHost=proxy.server.com - systemProp.https.proxyPort=8080 - systemProp.https.nonProxyHosts=*.company.com|10.*|100.* - systemProp.https.proxyUser=userId - systemProp.https.proxyPassword=password - ``` - - diff --git a/en/application-dev/quick-start/create-openharmony-project.md b/en/application-dev/quick-start/create-openharmony-project.md deleted file mode 100644 index dcc274abe55e41f628a507fd3c57bbb02612e845..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/create-openharmony-project.md +++ /dev/null @@ -1,7 +0,0 @@ -# Creating an OpenHarmony Project - -- **[Using the Project Wizard to Create a Project](use-wizard-to-create-project.md)** - -- **[Importing a Sample to Create a Project](import-sample-to-create-project.md)** - - diff --git a/en/application-dev/quick-start/deveco-studio-overview.md b/en/application-dev/quick-start/deveco-studio-overview.md deleted file mode 100644 index b3b27928b539baebc573322dab9c3d20a26442d4..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/deveco-studio-overview.md +++ /dev/null @@ -1,93 +0,0 @@ -# Overview - -- [About the Document](#section189422248491) -- [Restrictions](#section65191625782) -- [DevEco Studio Evolution Roadmap](#section187875207166) - -## About the Document - -DevEco Studio is an integrated development environment \(IDE\) of HarmonyOS apps. As HarmonyOS is developed based on OpenHarmony, DevEco Studio can also be used to develop OpenHarmony apps. - -The process of developing an OpenHarmony app using DevEco Studio is the same as that of developing a HarmonyOS app. This document describes the differences between OpenHarmony and HarmonyOS app development. - -- **Environment setup**: You need to manually install the OpenHarmony SDK for the OpenHarmony app development. For details, see [Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md). -- **Creating an OpenHarmony project**: Create a project by using the project wizard or by importing a sample project. For details, see [Using the Project Wizard to Create a Project](use-wizard-to-create-project.md). -- **Signature configuration for debugging**: To run an OpenHarmony app on a real device, you need to sign the app first. For instructions, see [Configuring the OpenHarmony App Signature](configuring-openharmony-app-signature.md). -- **App running on a real device**: Push the OpenHarmony HAP package to the real device for installation. For details, see [Installing and Running Your OpenHarmony App](installing-openharmony-app.md). - -For details about how to use DevEco Studio, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387). - -## Restrictions - -- OpenHarmony supports only app development in eTS and JS. -- Developing OpenHarmony apps in DevEco Studio is supported on Windows. - -DevEco Studio serves as a development tool for both OpenHarmony and HarmonyOS apps. Refer to the following table for descriptions about the functions not supported for OpenHarmony. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Feature

-

HarmonyOS

-

OpenHarmony

-

Service widgets

-

-

X

-

Automatic signing

-

-

X

-

Remote emulator

-

-

X

-

Local emulator

-

-

X

-

Using DevEco Studio for log viewing and optimization

-

-

X

-

Cloud testing

-

-

X

-

Security testing

-

-

X

-
- -## DevEco Studio Evolution Roadmap - -Refer to the following figure for when the HUAWEI DevEco Studio support for OpenHarmony app development is available in different phases. - -![](figures/en-us_image_0000001210018359.png) - diff --git a/en/application-dev/quick-start/deveco-studio-release-notes.md b/en/application-dev/quick-start/deveco-studio-release-notes.md deleted file mode 100644 index 267eadfc90914db13d9edd4dc2391f0ba0dea243..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/deveco-studio-release-notes.md +++ /dev/null @@ -1,87 +0,0 @@ -# Version Change History - -- [V3.0 Beta2 \(2021-12-31\)](#section18825185716537) - - [Version Compatibility](#section8155205312218) - - [Version Change History](#section1655415918226) - -- [V3.0 Beta1 \(2021-09-29\)](#section21092033115018) - -## V3.0 Beta2 \(2021-12-31\) - -### Version Compatibility - -DevEco Studio 3.0 Beta2 is compatible with the module versions listed below. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Module

-

Version

-

Description

-

Gradle

-

7.3 (7.2 at minimum)

-

DevEco Studio has Gradle 7.3 preinstalled. No separate installation is required.

-

JDK

-

11.0.x

-

DevEco Studio has JDK 11 preinstalled. No separate installation is required.

-

OpenHarmony SDK

-

3.1.0.0 (API Version 8 Beta)

-

This version is compatible with SDKs of earlier versions.

-

Toolchinas

-

3.1.0.0

-

Update them to the latest version.

-

hap plug-in

-

3.0.5.2

-

decctest plug-in

-

1.2.7.2

-
- -### Version Change History - - - - -

New Features

-
  • Introduced the Chinese UI. By default, the UI is displayed in English. To enable the Chinese UI, go to Settings, choose Plugins > installed, and select Chinese (Simplified). Then, restart DevEco Studio for the settings to take effect.
  • Introduced support for OpenHarmony apps and services, with various debugging features, from breakpoint management and variable observation to stepping.
-

-

Enhanced Features

-
  • Updated the OpenHarmony SDK to 3.1.0.0, whose API version is API 8 Beta and corresponding compilation and building plugin is 3.0.5.2.
  • Added an ability template that supports low-code development: [Standard]Empty Ability.
  • Added eTS component preview: allows previewing of eTS components; requires compileSdkVersion 8 or later.
  • Added eTS livee preview: allows viewing of the attribute changes in real time as you make them; requires compileSdkVersion 8 or later.
-
- -## V3.0 Beta1 \(2021-09-29\) - - - - -
New Features
  • Added support for OpenHarmony SDK management. You can use SDK Manager to download and manage OpenHarmony SDKs.
  • Allowed for building of a single module during HAP compilation and building to accelerate building for multi-module projects; allowed for one-click re-building of HAPs, by automatically conducting the Clean Project operation before a HAP build.
-
-
Enhanced Features
  • Updated the compilation and building plugin to version 3.0.3.2.
  • Improved the JSON editor, which now enables quick rectification of resource index errors and instant access to resource values.
  • Provided Ohos and Project (default) views for projects, which you can switch between easily.
  • Enabled OpenHarmony projects to support Ark build.
  • Moved the supportSystem "standard" field, which is exclusive to OpenHarmony projects, from the module-level build.gradle file to the project-level build.gradle file.
-
-
- diff --git a/en/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md b/en/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md index 0ea1419dd6fd0c0f323e0b8264802d28149c91b7..3051831470bdb57400a00583c97913cbfda2523f 100644 --- a/en/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md +++ b/en/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md @@ -1,15 +1,2 @@ -# DevEco Studio \(OpenHarmony\) User Guide - -- **[Overview](deveco-studio-overview.md)** - -- **[Version Change History](deveco-studio-release-notes.md)** - -- **[Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md)** - -- **[Creating an OpenHarmony Project](create-openharmony-project.md)** - -- **[Configuring the OpenHarmony App Signature](configuring-openharmony-app-signature.md)** - -- **[Installing and Running Your OpenHarmony App](installing-openharmony-app.md)** - +# DevEco Studio \(OpenHarmony\) User Guide diff --git a/en/application-dev/quick-start/figures/1.png b/en/application-dev/quick-start/figures/1.png deleted file mode 100755 index cb05a7cb0fa33a9d9074f4424a3851478935ff33..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/1.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/2.png b/en/application-dev/quick-start/figures/2.png deleted file mode 100755 index afdab82267fcd7d5eacae76eba500baa3bbecd40..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/2.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/3.png b/en/application-dev/quick-start/figures/3.png deleted file mode 100755 index 85345789b60927729e9243798fe122c64ca92687..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/3.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001113808114.png b/en/application-dev/quick-start/figures/en-us_image_0000001113808114.png deleted file mode 100644 index 406baf7cc191f03cb51b1376bddce9d40751ef03..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001113808114.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001115066116.png b/en/application-dev/quick-start/figures/en-us_image_0000001115066116.png deleted file mode 100644 index 357798e173fa7e3b419cc5990aa0737925e1f7b9..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001115066116.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001117479776.png b/en/application-dev/quick-start/figures/en-us_image_0000001117479776.png deleted file mode 100644 index 9250f90cf1e377c8bb33adf9965436ed7ddbadbf..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001117479776.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001117639668.png b/en/application-dev/quick-start/figures/en-us_image_0000001117639668.png deleted file mode 100644 index ba3923fef0ad89fa38fa170d2680931d1eb1ea55..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001117639668.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001118018088.png b/en/application-dev/quick-start/figures/en-us_image_0000001118018088.png deleted file mode 100644 index d4e1c7bd6773fc5b3ab5b473e28593110f3c820f..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001118018088.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001118018452.png b/en/application-dev/quick-start/figures/en-us_image_0000001118018452.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001118018452.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001119560738.png b/en/application-dev/quick-start/figures/en-us_image_0000001119560738.png deleted file mode 100644 index 9a84c3f66275c8ea2a50b9ba9ab0ead3842274cc..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001119560738.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001152459178.png b/en/application-dev/quick-start/figures/en-us_image_0000001152459178.png deleted file mode 100644 index 5ee6a55e53e57843300bd5ec0cce4a175e97a29e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001152459178.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001152674854.png b/en/application-dev/quick-start/figures/en-us_image_0000001152674854.png deleted file mode 100644 index 6bef885f7c487473ca1b329d41c6414735555b42..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001152674854.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001155643492.png b/en/application-dev/quick-start/figures/en-us_image_0000001155643492.png deleted file mode 100644 index 9e3afd2b96c1a01b3e966c37e60755d1f179363c..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001155643492.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001162463400.png b/en/application-dev/quick-start/figures/en-us_image_0000001162463400.png deleted file mode 100644 index 48239f38c31b907155d7b0501401ca9dd8635d73..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001162463400.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163314102.png b/en/application-dev/quick-start/figures/en-us_image_0000001163314102.png deleted file mode 100644 index 286a49def18618c79088deeb49203969ac6ce4c0..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163314102.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163472654.png b/en/application-dev/quick-start/figures/en-us_image_0000001163472654.png deleted file mode 100644 index 5328a3c1b62eb8281e316d5ae4a6ca11694ec4a2..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163472654.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163632602.png b/en/application-dev/quick-start/figures/en-us_image_0000001163632602.png deleted file mode 100644 index 10c5cf41ab78ea58c194fe1ed0429352e85a88a8..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163632602.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163839541.png b/en/application-dev/quick-start/figures/en-us_image_0000001163839541.png deleted file mode 100644 index f278f73fb4cd0dba70cae1835dd7a45d2686038b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163839541.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163915523.png b/en/application-dev/quick-start/figures/en-us_image_0000001163915523.png deleted file mode 100644 index 352eaed40ac96dc5d3bae82591e5c801daaa8d56..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163915523.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001163918627.png b/en/application-dev/quick-start/figures/en-us_image_0000001163918627.png deleted file mode 100644 index 6967c6b140c7e07003fc4548989ea78d9e5fc940..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001163918627.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001164417356.png b/en/application-dev/quick-start/figures/en-us_image_0000001164417356.png deleted file mode 100644 index 97795b40abbea9f58aabe62dd7643eca208315e3..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001164417356.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001164498191.png b/en/application-dev/quick-start/figures/en-us_image_0000001164498191.png deleted file mode 100644 index 30efd063397893ff925743b681f943696f10512b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001164498191.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001164577336.png b/en/application-dev/quick-start/figures/en-us_image_0000001164577336.png deleted file mode 100644 index 1127bbfabc9ef766284eec12c574096f8bb45ac3..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001164577336.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001166582138.png b/en/application-dev/quick-start/figures/en-us_image_0000001166582138.png deleted file mode 100644 index 36dc2d05ca4eb23505a73cb0d1606afd3bf844d8..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001166582138.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001166740700.png b/en/application-dev/quick-start/figures/en-us_image_0000001166740700.png deleted file mode 100644 index cedbb0ed07d4249c736f2b358593141f2f4cdc8e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001166740700.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001196050928.png b/en/application-dev/quick-start/figures/en-us_image_0000001196050928.png deleted file mode 100644 index dd75ea8e2b874aae201ecab3254fac3a7bce8fbc..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001196050928.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001202722349.png b/en/application-dev/quick-start/figures/en-us_image_0000001202722349.png deleted file mode 100644 index 99330a4f3ef2978dd6736d96e00c88cea8d25f32..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001202722349.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001207744539.png b/en/application-dev/quick-start/figures/en-us_image_0000001207744539.png deleted file mode 100644 index 5e1269e9e8fb620f8ed6051395c727590e6dc1bc..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001207744539.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001208006117.png b/en/application-dev/quick-start/figures/en-us_image_0000001208006117.png deleted file mode 100644 index 5c576d84b0ca4b369cdaac5aa7de19718628bc37..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001208006117.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001208274069.png b/en/application-dev/quick-start/figures/en-us_image_0000001208274069.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001208274069.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001208394019.png b/en/application-dev/quick-start/figures/en-us_image_0000001208394019.png deleted file mode 100644 index aa7f5ffb0d59c7ab7a1784bfde775aeccc16a424..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001208394019.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001209817299.png b/en/application-dev/quick-start/figures/en-us_image_0000001209817299.png deleted file mode 100644 index aa7f5ffb0d59c7ab7a1784bfde775aeccc16a424..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001209817299.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001210018359.png b/en/application-dev/quick-start/figures/en-us_image_0000001210018359.png deleted file mode 100644 index 87932d32907fb35dbafef1180daabbf6191d022a..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001210018359.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001212062065.png b/en/application-dev/quick-start/figures/en-us_image_0000001212062065.png deleted file mode 100644 index 708b49814e270289c6d1c96520aa6d90ba0edb9c..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001212062065.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001212142015.png b/en/application-dev/quick-start/figures/en-us_image_0000001212142015.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001212142015.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png b/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png new file mode 100644 index 0000000000000000000000000000000000000000..d3afe4570f4a839aaa531dea2b1889f318c81f71 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png b/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png new file mode 100644 index 0000000000000000000000000000000000000000..e90d0dbca27908da2964babcba1bc74876b04991 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png b/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png new file mode 100644 index 0000000000000000000000000000000000000000..e2444e0c8488f6632a098585409352a8ce8c7303 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png b/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png new file mode 100644 index 0000000000000000000000000000000000000000..d3afe4570f4a839aaa531dea2b1889f318c81f71 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png b/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png new file mode 100644 index 0000000000000000000000000000000000000000..335548669bb32a22f146d76f9ab88527e52f515a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png b/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png new file mode 100644 index 0000000000000000000000000000000000000000..890e12eee8b4534a2b94206c6b73edc81d1ee3ee Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png b/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png new file mode 100644 index 0000000000000000000000000000000000000000..890e12eee8b4534a2b94206c6b73edc81d1ee3ee Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png b/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png new file mode 100644 index 0000000000000000000000000000000000000000..a8fac2a024e51aeb0439463dab83f2763fa3fa76 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png b/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png new file mode 100644 index 0000000000000000000000000000000000000000..fbbde9923a131d3ab69257b28cfe33ca2a1040cf Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png b/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png new file mode 100644 index 0000000000000000000000000000000000000000..0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png b/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png new file mode 100644 index 0000000000000000000000000000000000000000..7795d74c5ec4915a1f2d6164e0625e308704528a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216446670.gif b/en/application-dev/quick-start/figures/en-us_image_0000001216446670.gif new file mode 100644 index 0000000000000000000000000000000000000000..5a7b05bfcdeb8063c3a0c16dae62f3f7168f783d Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216446670.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216448880.gif b/en/application-dev/quick-start/figures/en-us_image_0000001216448880.gif new file mode 100644 index 0000000000000000000000000000000000000000..bc9bca615d9243ccb1121983f66ba30a8b9e3b05 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216448880.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216600980.gif b/en/application-dev/quick-start/figures/en-us_image_0000001216600980.gif new file mode 100644 index 0000000000000000000000000000000000000000..58fa6bc0485a3bca823313c4c84e3be37a1ecb05 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216600980.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216614132.gif b/en/application-dev/quick-start/figures/en-us_image_0000001216614132.gif new file mode 100644 index 0000000000000000000000000000000000000000..14709a48539ea940ae74ae9c3a4a4e569a4d3b75 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001216614132.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png b/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png b/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png new file mode 100644 index 0000000000000000000000000000000000000000..2c026736133d41d80a1b92eb0db230dd6c0a7feb Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png b/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png new file mode 100644 index 0000000000000000000000000000000000000000..0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png b/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png new file mode 100644 index 0000000000000000000000000000000000000000..42b475577bcc805372336be8971afa5c69c284bd Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png b/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png b/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png b/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png new file mode 100644 index 0000000000000000000000000000000000000000..b9c3f899421f61b39480b831a662eebf6530100f Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png b/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png b/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png new file mode 100644 index 0000000000000000000000000000000000000000..14dc492cb36d22c79d22bea78d0f66508867291e Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png b/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png new file mode 100644 index 0000000000000000000000000000000000000000..75910aaf0daa22be2c0b56ae94febaa672df7424 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png b/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png new file mode 100644 index 0000000000000000000000000000000000000000..8ed9b0d3565e5fbb2f7897bc876369ebae5a8598 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png b/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png new file mode 100644 index 0000000000000000000000000000000000000000..02d730cadf10899edd91f94ce4cb8badd3ba821c Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png b/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png new file mode 100644 index 0000000000000000000000000000000000000000..9ce82237297b06c04113d0368d7145661de0d997 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png b/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png new file mode 100644 index 0000000000000000000000000000000000000000..045487dc8fa30e8f87cd3fdd5c87e8ec17715c94 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001239855207.png b/en/application-dev/quick-start/figures/en-us_image_0000001239855207.png deleted file mode 100644 index 83ef94f222a2cc30f036057908960badedd4aeca..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001239855207.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001247125297.png b/en/application-dev/quick-start/figures/en-us_image_0000001247125297.png deleted file mode 100644 index 32771bf5f9639aa8ebdd1922f8088965404674ca..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001247125297.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001248045243.png b/en/application-dev/quick-start/figures/en-us_image_0000001248045243.png deleted file mode 100644 index 61535cb2fe6b4197e95cff8691fe27973c5ecde8..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001248045243.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png b/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png new file mode 100644 index 0000000000000000000000000000000000000000..335548669bb32a22f146d76f9ab88527e52f515a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png b/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png new file mode 100644 index 0000000000000000000000000000000000000000..335548669bb32a22f146d76f9ab88527e52f515a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png b/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png new file mode 100644 index 0000000000000000000000000000000000000000..d3afe4570f4a839aaa531dea2b1889f318c81f71 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png b/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png new file mode 100644 index 0000000000000000000000000000000000000000..335548669bb32a22f146d76f9ab88527e52f515a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png b/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png new file mode 100644 index 0000000000000000000000000000000000000000..6d8b4f343d3744e245a656987a85a6da2c9bb18e Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png b/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png new file mode 100644 index 0000000000000000000000000000000000000000..d3afe4570f4a839aaa531dea2b1889f318c81f71 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png b/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png new file mode 100644 index 0000000000000000000000000000000000000000..2c026736133d41d80a1b92eb0db230dd6c0a7feb Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260928361.gif b/en/application-dev/quick-start/figures/en-us_image_0000001260928361.gif new file mode 100644 index 0000000000000000000000000000000000000000..43a0ab27545eb4f8095eec4bbb9490607317f05d Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001260928361.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261017331.gif b/en/application-dev/quick-start/figures/en-us_image_0000001261017331.gif new file mode 100644 index 0000000000000000000000000000000000000000..240e9fb76b0f27d35d53b5b1bd304e39fc80aaf5 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001261017331.gif differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png b/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png new file mode 100644 index 0000000000000000000000000000000000000000..86ff220370fc26319a4a23434d70e2508d8f1b9a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png b/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png new file mode 100644 index 0000000000000000000000000000000000000000..164371727ee8a351e2c42f4b3ecab9175e088e7c Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png b/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png b/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png new file mode 100644 index 0000000000000000000000000000000000000000..86ff220370fc26319a4a23434d70e2508d8f1b9a Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png b/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png b/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png b/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png b/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png b/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png b/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png new file mode 100644 index 0000000000000000000000000000000000000000..55d41f7eb98b1c80bc5f85ea99be6b73bcdd7c1d Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png b/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png b/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png differ diff --git a/en/application-dev/quick-start/import-sample-to-create-project.md b/en/application-dev/quick-start/import-sample-to-create-project.md deleted file mode 100644 index b05970a735b5a22a45f5717436f9261e721e91dc..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/import-sample-to-create-project.md +++ /dev/null @@ -1,33 +0,0 @@ -# Importing a Sample to Create a Project - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->This feature applies to OpenHarmony projects created using DevEco Studio 2.1 Release or later. - -After the OpenHarmony SDK is configured, you can get started to develop your app by **importing a sample project**. - -1. On the DevEco Studio welcome page, select **Configure** or click the ![](figures/en-us_image_0000001118018452.png) icon, and choose **Settings** \> **Version Control** \> **Git**. Then click **Test** to check whether the Git tool has been installed. - - If the tool has been installed, import a sample by following the instructions in Step 2. - - ![](figures/en-us_image_0000001118018088.png) - - - If the tool hasn't been installed, click **Download and Install**. DevEco Studio will automatically download and install it. Then import a sample by following the instructions in Step 2. - - ![](figures/en-us_image_0000001164498191.png) - -2. On the DevEco Studio welcome page, click **Import Sample** to import a sample project. - - ![](figures/en-us_image_0000001208006117.png) - -3. Choose **OpenHarmony Samples** \> **common** \> **JsHelloWorld** \> **Next**. - - ![](figures/en-us_image_0000001152459178.png) - -4. Configure **App Name** and **Project Location** and click **Finish**. Wait until the sample project is imported. - - ![](figures/en-us_image_0000001207744539.png) - -5. When the project is successfully synced, start developing your OpenHarmony app. - - ![](figures/en-us_image_0000001163915523.png) - - diff --git a/en/application-dev/quick-start/installing-openharmony-app.md b/en/application-dev/quick-start/installing-openharmony-app.md deleted file mode 100644 index 79277bcccc4d9c24b3786b7d71b78c8e01dade63..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/installing-openharmony-app.md +++ /dev/null @@ -1,33 +0,0 @@ -# Installing and Running Your OpenHarmony App - -You can install your OpenHarmony app in either of the following methods: - -- DevEco Studio: Connect your device where the app is stored to DevEco Studio, and then click ![](figures/en-us_image_0000001239855207.png) to install the app. -- hdc: Run commands to install the app. - - You can manually obtain the hdc tool from the open-source repository. Then, run the tool commands to install an HAP file on the device. - - The tool commands are as follows: - - - App installation - - **install \[-r/-d/-g\] _package_** - - Example: - - ``` - hdc_std install E:\hwadmin.hap - ``` - - - Log capturing - - **hilog** - - Example: - - ``` - hdc_std hilog - ``` - - For details about how to use hdc and the command format, see [hdc\_std Usage Guidelines](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md). - diff --git a/en/application-dev/quick-start/package-structure.md b/en/application-dev/quick-start/package-structure.md index 60e37c8be42abf03840aa7a0236e00a5810aa542..b9e4caa013ad468f43ca0a7a3ee486623018a028 100644 --- a/en/application-dev/quick-start/package-structure.md +++ b/en/application-dev/quick-start/package-structure.md @@ -24,7 +24,7 @@ The following is an example of the configuration file: "package": "com.example.myapplication.entrymodule", "name": ".MyApplication", "deviceType": [ - "phone" + "default" ], "distro": { "deliveryWithInstall": true, diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..4d3323b64842149c07d51dc14745bae8d3f969c9 --- /dev/null +++ b/en/application-dev/quick-start/start-overview.md @@ -0,0 +1,46 @@ +# Preparations + +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 pages. The following figure shows how the pages look on the DevEco Studio Previewer. + + +![en-us_image_0000001261809595](figures/en-us_image_0000001261809595.png) + + +Before you begin, there are some basic concepts that will help you better understand OpenHarmony: UI framework and ability. + + +## Basic Concepts + + +### UI Framework + +OpenHarmony provides a UI development framework, known as ArkUI. ArkUI provides capabilities you may need for application UI development, including a wide array of components, 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. + +| **Development Paradigm** | **Language** | **UI Update Mode** | **Applicable To** | **Intended Audience** | +| -------- | -------- | -------- | -------- | -------- | +| Web-like development paradigm | JavaScript | Data-driven | Applications and service widgets with simple UIs | Frontend web developers | +| Declarative development paradigm | Extended TypeScript (eTS) | Data-driven | Applications involving technological sophistication and teamwork | Mobile application and system application developers | + +For DevEco Studio V2.2 Beta1 and later versions, both the traditional coding mode and the low-code mode are supported when the JS language is used for development. On the OpenHarmony low-code development pages, you can design your app UI in an efficient, intuitive manner, with a wide array of UI editing features complying with JS Development Specifications. + + +### Ability + +An ability is an abstraction of a capability that an application can provide. The **Ability** class is an essential component to OpenHarmony applications. An application may provide various capabilities, and so it can have multiple abilities. These abilities can be deployed together or independently from each other. + +Abilities are classified into two types: [Feature Ability (FA)](../../glossary.md#f) and [Particle Ability (PA)](../../glossary.md#p). Each type has their respective templates for different capabilities. FAs support only the Page template (also called the [Page ability](../ability/fa-pageability.md)), which is used to provide the capability of interacting with users. A Page ability consists of one or more pages. The figure below shows the relationship between a Page ability and pages. + +![en-us_image_0000001215206886](figures/en-us_image_0000001215206886.png) + +This document provides a Page ability instance with two pages. For more information about ability development, see [Ability Development](../ability/fa-brief.md). + + +## Tool Preparation + +1. Install the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony). + +2. Install DevEco Studio and configure the development environment. For details, see [Configuring the OpenHarmony SDK](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](start-with-ets.md),[Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md), and [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md). diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md new file mode 100644 index 0000000000000000000000000000000000000000..81510bef091d24e28c39acca75ab2f701151eaab --- /dev/null +++ b/en/application-dev/quick-start/start-with-ets.md @@ -0,0 +1,250 @@ +# Getting Started with eTS + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later. +> +> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. + + +## Creating an eTS Project + +1. Open DevEco Studio, choose **File** > **New** > **Create Project**, select **Empty Ability**, and click **Next**. + ![en-us_image_0000001223556342](figures/en-us_image_0000001223556342.png) + +2. On the project configuration page, set **UI Syntax** to **eTS** and retain the default values for other parameters. + ![en-us_image_0000001223716826](figures/en-us_image_0000001223716826.png) + +3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. + + +## eTS Project Files + +- **entry** : OpenHarmony project module, which can be built into an ability package (HAP). + - **src > main > ets** : a collection of eTS source code. + - **src > main > ets > MainAbility** : entry to your application/service. + - **src > main > ets > MainAbility > pages** : pages contained in **MainAbility**. + - **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. + - **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. + - **build-profile.json5** : module information and build configuration options, including **buildOption target**. + - **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. +- **build-profile.json5** : application-level configuration information, including the signature and product configuration. +- **hvigorfile.js** : application-level compilation and build task script. + + +## Building the First Page + +1. Use the **Text** 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 **<Text>** component. The sample code in the **index.ets** file is shown below: + + + ``` + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } + } + ``` + +2. Add a **<Button>** component. + On the default page, add a **<Button>** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: + + + ``` + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // Add a button to accept user clicks. + Button() { + Text('Next') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') + } + .height('100%') + } + } + ``` + +3. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. + + ![en-us_image_0000001216239356](figures/en-us_image_0000001216239356.png) + + +## Building the Second Page + +1. Create the second page. + In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder: + + ![en-us_image_0000001223397122](figures/en-us_image_0000001223397122.png) + +2. Add **<Text>** and **<Button>** components. + Add **<Text>** and **<Button>** components and set their styles, as you do for the first page. The sample code in the **second.ets** file is shown below: + + + ``` + @Entry + @Component + struct Second { + @State message: string = 'Hi there' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') + } + .height('100%') + } + } + ``` + + +## Implementing Page Redirection + +You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below: + +1. Implement redirection from the first page to the second page. + In the **index.ets** file of the first page, bind the **onClick** event to the **Next** button so that clicking the button redirects the user to the second page. The sample code in the **index.ets** file is shown below: + + + ``` + import router from '@system.router'; + + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // Add a button to accept user clicks. + Button() { + Text('Next') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // Bind the onClick event to the Next button so that clicking the button redirects the user to the second page. + .onClick(() => { + router.push({ uri: 'pages/second' }) + }) + } + .width('100%') + } + .height('100%') + } + } + ``` + +2. Implement redirection from the second page to the first page. + In the **second.ets** file of the second page, bind the **onClick** event to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.ets** file is shown below: + + + ``` + import router from '@system.router'; + + @Entry + @Component + struct Second { + @State message: string = 'Hi there' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // Bind the onClick event to the Back button so that clicking the button redirects the user back to the first page. + .onClick(() => { + router.back() + }) + } + .width('100%') + } + .height('100%') + } + } + ``` + +3. Open the **index.ets** file and click ![en-us_image_0000001262219043](figures/en-us_image_0000001262219043.png) in the Previewer to refresh the file. The figure below shows the effect. + ![en-us_image_0000001260684127](figures/en-us_image_0000001260684127.png) + + +## Running the Application on a Real Device + +1. Connect the development board running the OpenHarmony standard system to the computer. + +2. Choose **File** > **Project Structure** > **Project** > **Signing Configs**, select **Automatically generate signing**, wait until the automatic signing is complete, and click **OK**, as shown below. + ![en-us_image_0000001268077317](figures/en-us_image_0000001268077317.png) + +3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001262206247](figures/en-us_image_0000001262206247.png). The display effect is shown in the figure below. + ![en-us_image_0000001217526428](figures/en-us_image_0000001217526428.png) + +Congratulations! You have finished developing your OpenHarmony application in eTS. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md new file mode 100644 index 0000000000000000000000000000000000000000..572e49f734ae2f32a98695576229a0a058d468b0 --- /dev/null +++ b/en/application-dev/quick-start/start-with-js-low-code.md @@ -0,0 +1,156 @@ +# Getting Started with JavaScript in the Low-Code Approach + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> This feature will be available in DevEco Studio V2.2 Beta1 and later versions. +> +> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. + + +On the OpenHarmony low-code development pages, you can design your app UI in an efficient, intuitive manner, with a wide array of UI editing features complying with JS Development Specifications. + + +You can develop applications or services in the low-code approach using either of the following methods: + + +- Create a project that supports low-code development. This method is used as an example in this topic. + +- In an existing project, create a Visual file for development. + + +## Creating a Project That Supports Low-Code Development + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> This feature is available in DevEco Studio 3.0 Beta2 and later versions and works with compileSdkVersion 7 or later. + +1. Open DevEco Studio, choose **File** > **New** > **Create Project**, select **Empty Ability**, and click **Next**. + ![en-us_image_0000001268198893](figures/en-us_image_0000001268198893.png) +2. Go to the project configuration page, select **Enable Super Visual**, set **UI Syntax** to **JS**, and retain the default values for other parameters. + + ![en-us_image_0000001223717294](figures/en-us_image_0000001223717294.png) + +3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. + + +## Low-code Project Files + +After the project synchronization is complete, a low-code directory structure is automatically generated in the project, as shown below. + +![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) + +- **entry > src > main > js > MainAbility > pages > index > index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** + > To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** > **MainAbility** > **pages** > **index**. +- **entry > src > main > supervisual > MainAbility > pages > index > index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. + + +## Building the First Page + +After the project synchronization is complete, the default first page contains the **Div** and **Text** (**Hello World**) components. To better understand low-code development, we'll delete these template components from the canvas and set the page from scratch. + +Add **Div**, **Text**, and **Button** components to the first page. + +1. Delete the existing template components from the canvas. + Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations. + + ![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) + +2. Add a **Div** component and set its styles and attributes. + Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations. + + ![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) + +3. Add a **Text** component. + Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes & Styles** area, click ![en-us_image_0000001215066868](figures/en-us_image_0000001215066868.png)**Properties** and set **Content** of the **Text** component to **Hello World**. Click ![en-us_image_0000001215386842](figures/en-us_image_0000001215386842.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. + + ![en-us_image_0000001216446670](figures/en-us_image_0000001216446670.gif) + +4. Add a **Button** component. + Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001260106745](figures/en-us_image_0000001260106745.png)**Properties** and set **Value** of the **Button** component to **Next**. Click ![en-us_image_0000001259866741](figures/en-us_image_0000001259866741.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. + + ![en-us_image_0000001260928361](figures/en-us_image_0000001260928361.gif) + +5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. + ![en-us_image_0000001216288558](figures/en-us_image_0000001216288558.png) + + +## Building the Second Page + +1. Create the second page. + In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder: + + ![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) + +2. [Delete the existing template components from the canvas.](#delete_origin_content) + +3. [Add a Div component and set its styles and attributes.](#add_container) + +4. Add a **Text** component. + Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes & Styles** area, click ![en-us_image_0000001260227453](figures/en-us_image_0000001260227453.png)**Properties** and set **Content** of the **Text** component to **Hi there**. Click ![en-us_image_0000001260107497](figures/en-us_image_0000001260107497.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. + + ![en-us_image_0000001216614132](figures/en-us_image_0000001216614132.gif) + +5. Add a **Button** component. + Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001215227618](figures/en-us_image_0000001215227618.png)**Properties** and set **Value** of the **Button** component to **Back**. Click ![en-us_image_0000001259987441](figures/en-us_image_0000001259987441.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. + + ![en-us_image_0000001261017331](figures/en-us_image_0000001261017331.gif) + + +## Implementing Page Redirection + +You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: + +1. Implement redirection from the first page to the second page. + In the files of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. This operation needs to be completed in both .js and .visual files. + - In the **index.js** file: + + ``` + import router from '@system.router'; + + export default { + onclick() { + router.push({ + uri:'pages/second/second', // Specify the page to be redirected to. + }) + } + } + ``` + + - In the index.visual file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001215388136](figures/en-us_image_0000001215388136.png)**Events** and set **Click** to **onclick**. + + ![en-us_image_0000001223722586](figures/en-us_image_0000001223722586.png) + +2. Implement redirection from the second page to the first page. + In the files of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. + + This operation needs to be completed in both .js and .visual files. + + - In the **second.js** file: + + ``` + import router from '@system.router'; + + export default { + back() { + router.back() + } + } + ``` + - In the second.visual file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001215388262](figures/en-us_image_0000001215388262.png)**Events** and set **Click** to **back**. + + ![en-us_image_0000001268082945](figures/en-us_image_0000001268082945.png) + +3. Open the **index.visual** or **index.js** file and click ![en-us_image_0000001261979271](figures/en-us_image_0000001261979271.png) in the Previewer to refresh the file. The figure below shows the effect. + ![en-us_image_0000001261142799](figures/en-us_image_0000001261142799.png) + + +## Running the Application on a Real Device + +1. Connect the development board running the OpenHarmony standard system to the computer. + +2. Choose **File** > **Project Structure** > **Project** > **Signing Configs**, select **Automatically generate signing**, wait until the automatic signing is complete, and click **OK**, as shown below. + ![en-us_image_0000001268283201](figures/en-us_image_0000001268283201.png) + +3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001262207811](figures/en-us_image_0000001262207811.png). The display effect is shown in the figure below. + ![en-us_image_0000001262127855](figures/en-us_image_0000001262127855.png) + +Congratulations! You have finished developing your OpenHarmony app in JavaScript in the low-code approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md new file mode 100644 index 0000000000000000000000000000000000000000..b2ad7acd9e16e6e0f667facc4e5608860f0853e2 --- /dev/null +++ b/en/application-dev/quick-start/start-with-js.md @@ -0,0 +1,205 @@ +# Getting Started with JavaScript in the Traditional Coding Approach + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. + + +## Creating a JavaScript Project + +1. Open DevEco Studio, choose **File** > **New** > **Create Project**, select **Empty Ability**, and click **Next**. + ![en-us_image_0000001223558814](figures/en-us_image_0000001223558814.png) + +2. On the project configuration page, set **UI Syntax** to **JS** and retain the default values for other parameters. + ![en-us_image_0000001223877162](figures/en-us_image_0000001223877162.png) + +3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. + + +## JavaScript Project Files + +- **entry** : OpenHarmony project module, which can be built into an ability package (HAP). + - **src > main > js** : a collection of JS source code. + - **src > main > js > MainAbility** : entry to your application/service. + - **src > main > js > MainAbility > i18n** : resources in different languages, for example, UI strings and image paths. + - **src > main > js > MainAbility > pages** : pages contained in **MainAbility**. + - **src > main > js > MainAbility > app.js** : 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. + - **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. + - **build-profile.json5** : module information and build configuration options, including **buildOption target**. + - **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. +- **build-profile.json5** : application-level configuration information, including the signature and product configuration. +- **hvigorfile.js** : application-level compilation and build task script. + + +## Building the First Page + +1. Use the **Text** component. + After the project synchronization is complete, choose **entry** > **src** > **main** > **js** > **MainAbility** > **pages** > **index** in the **Project** window and open the **index.hml** file. You can see that the file contains a **<Text>** component. The sample code in the **index.hml** file is shown below: + + + ``` +
+ + Hello World + +
+ ``` + +2. Add a button and bind the **onclick** method to this button. + On the default page, add an **<input>** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: + + + ``` +
+ + Hello World + + + + +
+ ``` + +3. Set the page style in the **index.css** file. + From the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility** > **pages** > **index**, open the **index.css** file, and set the page styles, such as the width, height, font size, and spacing. The sample code in the **index.css** file is shown below: + + + ``` + .container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + } + + .title { + font-size: 100px; + font-weight: bold; + text-align: center; + width: 100%; + margin: 10px; + } + + .btn { + font-size: 60px; + font-weight: bold; + text-align: center; + width: 40%; + height: 5%; + margin-top: 20px; + } + ``` + +4. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. + + ![en-us_image_0000001216084724](figures/en-us_image_0000001216084724.png) + + +## Building the Second Page + +1. Create the second page. + In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below is the structure of the **second** folder: + + ![en-us_image_0000001223877210](figures/en-us_image_0000001223877210.png) + +2. Add **<Text>** and **<Button>** components. + Add **<Text>** and **<Button>** components and set their styles, as you do for the first page. The sample code in the **second.hml** file is shown below: + + + ``` +
+ + Hi there + + + + +
+ ``` + +3. Set the page style in the **second.css** file. The sample code in the **second.css** file is shown below: + + ``` + .container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + } + + .title { + font-size: 100px; + font-weight: bold; + text-align: center; + width: 100%; + margin: 10px; + } + + .btn { + font-size: 60px; + font-weight: bold; + text-align: center; + width: 40%; + height: 5%; + margin-top: 20px; + } + ``` + + +## Implementing Page Redirection + +You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: + +1. Implement redirection from the first page to the second page. + In the **index.js** file of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. The sample code in the **index.js** file is shown below: + + + ``` + import router from '@system.router'; + + export default { + onclick: function () { + router.push({ + uri: "pages/second/second" + }) + } + } + ``` + +2. Implement redirection from the second page to the first page. + In the **second.ets** file of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.js** file is shown below: + + + ``` + import router from '@system.router'; + + export default { + back: function () { + router.back() + } + } + ``` + +3. Open any file in the **index** folder and click ![en-us_image_0000001262339067](figures/en-us_image_0000001262339067.png) in the Previewer to refresh the file. The figure below shows the effect. + ![en-us_image_0000001216269940](figures/en-us_image_0000001216269940.png) + + +## Running the Application on a Real Device + +1. Connect the development board running the OpenHarmony standard system to the computer. + +2. Choose **File** > **Project Structure** > **Project** > **Signing Configs**, select **Automatically generate signing**, wait until the automatic signing is complete, and click **OK**, as shown below. + ![en-us_image_0000001223557290](figures/en-us_image_0000001223557290.png) + +3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001217047316](figures/en-us_image_0000001217047316.png). The display effect is shown in the figure below. + ![en-us_image_0000001217527892](figures/en-us_image_0000001217527892.png) + +Congratulations! You have finished developing your OpenHarmony application in JavaScript in the traditional coding approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) diff --git a/en/application-dev/quick-start/use-wizard-to-create-project.md b/en/application-dev/quick-start/use-wizard-to-create-project.md deleted file mode 100644 index ad79e3e8cb207af84457352188a15ce4c4ea898b..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/use-wizard-to-create-project.md +++ /dev/null @@ -1,47 +0,0 @@ -# Using the Project Wizard to Create a Project - -- [Prerequisites](#section13642104391619) -- [Procedure](#section132671712101714) - -If you are using DevEco Studio 2.2 Beta1 or later, you can use the project wizard to create a project. If you are using DevEco Studio 2.1 Release, create a project by following instructions in [Importing a Sample to Create a Project](import-sample-to-create-project.md). - -## Prerequisites - -The OpenHarmony SDK has been installed. For details, see [Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md). - -## Procedure - -1. Open the project wizard using either of the following methods: - - If no project is open, select **Create Project** on the welcome page. - - If a project is already open, choose **File** \> **New** \> **New Project** on the menu bar. - -2. Select the **\[Standard\]Empty Ability** template and click **Next**. - - ![](figures/en-us_image_0000001162463400.png) - -3. Click **Next** and configure the project. - - **Project name**: customized project name. - - **Project type**: project type, which can be an [atomic service](https://developer.harmonyos.com/en/docs/documentation/doc-guides/atomic-service-definition-0000001090840664) or an ordinary app that requires download before use. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you're creating an atomic service: - >- There is no app icon on the home screen while running or debugging an atomic service. Use the debugging and running functions of DevEco Studio as an alternative. - >- Atomic services are installation free. This is done by automatically adding the **installationFree** field to the **config.json** file, with its value set to **true**. - >- If the value of the **installationFree** field of the entry module is set to **true**, the value of the **installationFree** field of all the related HAP modules is **true** by default. If the** installationFree field** of the entry module is set to **false**, the **installationFree** field of all the related HAP modules can be set to **true** or **false**. - >- When compiling and building an app, make sure that the size of each HAP package does not exceed 10 MB. - - - **Bundle name**: bundle name. By default, this name will also be used as your app ID. Your app must have a unique ID to be released. If **Project type** is set to **Atomic service**, the **Bundle name** must end with **.hmservice**. - - **Save location**: local path for storing the project file. - - **Development mode**: development mode. The **Super Visual** option is available if the project template supports low-code development. - - **Language**: supported programming language. - - **Compatible API version**: earliest SDK version compatible with your app. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If **compileSdkVersion 7** or later is configured for the OpenHarmony project, the corresponding module will be compiled using ArkCompiler by default. To use a compiler other than ArkCompiler, add the **arkEnable false** field to the **ohos** closure in the module-level **build.gradle** file. - - - **Device Type**: device type supported by the project template. - - ![](figures/en-us_image_0000001196050928.png) - -4. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. - diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 8deb55f2e962ec65a9fc44f4b260d71c1d34f158..0887ba201b14be493ae22929539fa98aef908bc2 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -24,7 +24,6 @@ - [User Authentication](js-apis-useriam-userauth.md) - [Access Control](js-apis-abilityAccessCtrl.md) - Data Management - - [Lightweight Storage9+](js-apis-data-preferences.md) - [Lightweight Storage](js-apis-data-storage.md) - [Distributed Data Management](js-apis-distributed-data.md) - [Relational Database](js-apis-data-rdb.md) @@ -37,12 +36,11 @@ - [Environment](js-apis-environment.md) - [Public File Access and Management](js-apis-filemanager.md) - [App Storage Statistics](js-apis-storage-statistics.md) - - [Volume Management](js-apis-volumemanager.md) -- Account Management +- Account Management - [OS Account Management](js-apis-osAccount.md) - [Distributed Account Management](js-apis-distributed-account.md) - [App Account Management](js-apis-appAccount.md) -- Telephony Service +- Telephony Service - [Call](js-apis-call.md) - [SMS](js-apis-sms.md) - [SIM Management](js-apis-sim.md) @@ -58,6 +56,7 @@ - [WLAN](js-apis-wifi.md) - [Bluetooth](js-apis-bluetooth.md) - [RPC](js-apis-rpc.md) + - [Upload and Download](js-apis-request.md) - Device Management - [Sensor](js-apis-sensor.md) - [Vibrator](js-apis-vibrator.md) @@ -79,7 +78,10 @@ - [Console Logs](js-apis-basic-features-logs.md) - [Page Routing](js-apis-basic-features-routes.md) - [Timer](js-apis-basic-features-timer.md) + - [Screen Lock Management](js-apis-screen-lock.md) - [Setting the System Time](js-apis-system-time.md) + - [Wallpaper](js-apis-wallpaper.md) + - [Pasteboard](js-apis-pasteboard.md) - [Animation](js-apis-basic-features-animator.md) - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md deleted file mode 100644 index 8e0c427520a549e74f6b9e8dec02ac219d734054..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ /dev/null @@ -1,51 +0,0 @@ -# Work Scheduler Callbacks - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - - -## Modules to Import - -``` -import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' -``` - -## WorkSchedulerExtensionAbility.onWorkStart -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler - -- **API** -onWorkStart(workInfo: WorkInfo); - -- **Description** -Triggered when the Work Scheduler task starts. - -- **Example** - - ``` - export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { - onWorkStart(workInfo) { - console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); - } - } - ``` - -## WorkSchedulerExtensionAbility.onWorkStop -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler - -- **API** -onWorkStop(workInfo: WorkInfo); - -- **Description** -Triggered when the Work Scheduler task stops. - -- **Example** - - ``` - export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { - onWorkStop(workInfo) { - console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); - } - } - ``` diff --git a/en/application-dev/reference/apis/js-apis-basic-features-animator.md b/en/application-dev/reference/apis/js-apis-animator.md similarity index 100% rename from en/application-dev/reference/apis/js-apis-basic-features-animator.md rename to en/application-dev/reference/apis/js-apis-animator.md diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index bf7a006160c46af9bf7a2da5365253d084921607..f8414adaa9aa458914b66d9aaf503183c299095c 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -387,7 +387,7 @@ Checks whether an app account allows application data synchronization. This meth ### setAccountCredential -setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void +setAccountCredential(name: string, credentialType: string, credential: string callback: AsyncCallback<void>): void Sets a credential for an app account. This method uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-application-MissionInfo.md b/en/application-dev/reference/apis/js-apis-application-MissionInfo.md deleted file mode 100644 index c707cbf2efba04e7135468409b417bd85290ef67..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-application-MissionInfo.md +++ /dev/null @@ -1,35 +0,0 @@ -# MissionInfo - -> **NOTE** -> The initial APIs of this module are supported since API 8. - - -Provides mission information of an ability. - - -## Modules to Import - -Import **Want** before use. - - -``` -import Want from "../@ohos.application.Want"; -``` - - -## MissionInfo - -Describes the mission information. - -**System capability**: SystemCapability.Ability.AbilityBase - -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| missionId | number | Yes| Yes| Mission ID.| -| runningState | number | Yes| Yes| Running state of the mission.| -| lockedState | boolean | Yes| Yes| Locked state of the mission.| -| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| -| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.| -| label | string | Yes| Yes| Label of the mission.| -| iconPath | string | Yes| Yes| Path of the mission icon.| -| continuable | boolean | Yes| Yes| Whether the mission is continuable.| diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 71f5f2a90b50513c194c3dad027b86abcb296984..4ae4ecd6a7843cd4781431ba5eed30afd0989f11 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -434,18 +434,6 @@ Enumerates the interrupt types. | INTERRUPT_TYPE_BEGIN | 1 | Audio playback interruption started. | | INTERRUPT_TYPE_END | 2 | Audio playback interruption ended. | - -## InterruptForceType9+ - -Enumerates the interrupt force types. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -| Name | Default Value | Description | -| :-------------- | :------------ | :----------------------------------------- | -| INTERRUPT_FORCE | 0 | Forced action taken by system. | -| INTERRUPT_SHARE | 1 | App can choose to take action or ignore. | - ## InterruptHint Enumerates the interrupt hints. @@ -542,20 +530,6 @@ Describes audio capturer configuration options. | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | Yes | Stream information. | | capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Capturer information. | -## InterruptEvent9+ - -Describes the interrupt event received by the app when playback is interrupted. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -**Parameters:** - -| Name | Type | Mandatory | Description | -| :-------- | :-------------------------------------------- | :-------- | :---------------------------------------------------------------- | -| eventType | [InterruptType](#interrupttype) | Yes | Whether the interruption has started or finished. | -| forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the action is taken by system or to be taken by the app. | -| hintType | [InterruptHint](#interrupthint) | Yes | Type of action. | - ## AudioInterrupt The parameters passed in by the audio listener event. @@ -2560,52 +2534,6 @@ audioRenderer.getRenderRate().then((renderRate) => { }); ``` - -### on('interrupt')9+ - -on(type: 'interrupt', callback: Callback\): void - -Subscribes to audio interrupt events. This API uses a callback to get interrupt events. The interrupt event is triggered when audio rendering is interrupted. - -**System capability:** SystemCapability.Multimedia.Audio.Renderer - -**Parameters:** - -| Name | Type | Mandatory | Description | -| :------- | :-------------------------------------------- | :-------- | :---------------------------------------------- | -| type | string | Yes | Type of the playback event to subscribe to. | -| callback | Callback<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to listen for interrupt callback. | - -**Example:** - -``` -audioRenderer.on('interrupt', (interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.log('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.log('Resume force paused renderer or ignore'); - startRenderer(); - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Choose to pause or ignore'); - pauseRenderer(); - break; - } - } -}); -``` - ### on('markReach')8+ on(type: 'markReach', frame: number, callback: (position: number) => {}): void diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index cec4fab99d6e078c65937a10e8825f0844445c29..7787a551160a0afdb84af786ef1efd133a078bf6 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -22,15 +22,15 @@ The default duration of delayed suspension is 180000 when the battery level is h **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | reason | string | Yes| Reason for delayed transition to the suspended state.| - | callback | Callback<void> | Yes| Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ---------------------------------------- | +| reason | string | Yes | Reason for delayed transition to the suspended state. | +| callback | Callback<void> | Yes | Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out. | **Return value** - | Type| Description| - | -------- | -------- | - | [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay.| +| Type | Description | +| ------------------------------------- | --------------------------------------- | +| [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay. | **Example** ```js @@ -50,12 +50,13 @@ Obtains the remaining duration before the application is suspended. This API use **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | requestId | number | Yes| ID of the suspension delay request.| - | callback | AsyncCallback<number> | Yes| Callback used to return the remaining duration before the application is suspended, in milliseconds.| +| Name | Type | Mandatory | Description | +| --------- | --------------------------- | --------- | ---------------------------------------- | +| requestId | number | Yes | ID of the suspension delay request. | +| callback | AsyncCallback<number> | Yes | Callback used to return the remaining duration before the application is suspended, in milliseconds. | **Example** + ```js let id = 1; backgroundTaskManager.getRemainingDelayTime(id, (err, res) => { @@ -77,14 +78,14 @@ Obtains the remaining duration before the application is suspended. This API use **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | requestId | number | Yes| ID of the suspension delay request.| +| Name | Type | Mandatory | Description | +| --------- | ------ | --------- | ----------------------------------- | +| requestId | number | Yes | ID of the suspension delay request. | **Return value** - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the remaining duration before the application is suspended, in milliseconds.| +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<number> | Promise used to return the remaining duration before the application is suspended, in milliseconds. | **Example** ```js @@ -106,9 +107,9 @@ Cancels the suspension delay. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | requestId | number | Yes| ID of the suspension delay request.| +| Name | Type | Mandatory | Description | +| --------- | ------ | --------- | ----------------------------------- | +| requestId | number | Yes | ID of the suspension delay request. | **Example** ```js @@ -127,12 +128,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Application context.| - | bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.| - | wantAgent | [WantAgent](js-apis-notification.md#WantAgent)| Yes| Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------- | --------- | ---------------------------------------- | +| context | [Context](js-apis-Context.md) | Yes | Application context. | +| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js @@ -178,17 +179,17 @@ Requests a continuous task from the system. This API uses a promise to return th **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Application context.| - | bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.| - | wantAgent | [WantAgent](js-apis-notification.md#WantAgent)| Yes| Notification parameter, which is used to specify the target page when a continuous task notification is clicked.| - + +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------- | --------- | ---------------------------------------- | +| context | [Context](js-apis-Context.md) | Yes | Application context. | +| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page when a continuous task notification is clicked. | + **Return value** - | Type | Description | - | -------------- | ------------------------- | - | Promise\ | Promise used to return the result.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js @@ -225,15 +226,13 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo Requests to cancel a continuous task. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING - **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Application context.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ----------------------------- | --------- | ----------------------------------- | +| context | [Context](js-apis-Context.md) | Yes | Application context. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js @@ -258,19 +257,17 @@ stopBackgroundRunning(context: Context): Promise<void> Requests to cancel a continuous task. This API uses a promise to return the result. -**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING - **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Application context.| +| Name | Type | Mandatory | Description | +| ------- | ----------------------------- | --------- | -------------------- | +| context | [Context](js-apis-Context.md) | Yes | Application context. | **Return value** - | Type | Description | - | -------------- | ------------------------- | - | Promise\ | Promise used to return the result.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js @@ -291,24 +288,24 @@ Provides the information about the suspension delay. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| requestId | number | Yes| ID of the suspension delay request.| -| actualDelayTime | number | Yes| Actual suspension delay duration of the application, in milliseconds.
The default duration is 180000 when the battery level is higher than or equal to the broadcast low battery level and 60000 when the battery level is lower than the broadcast low battery level.| +| Name | Type | Mandatory | Description | +| --------------- | ------ | --------- | ---------------------------------------- | +| requestId | number | Yes | ID of the suspension delay request. | +| actualDelayTime | number | Yes | Actual suspension delay duration of the application, in milliseconds.
The default duration is 180000 when the battery level is higher than or equal to the broadcast low battery level and 60000 when the battery level is lower than the broadcast low battery level. | ## BackgroundMode8+ **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| Name | Value| Description| -| ----------------------- | -------- | -------- | -| DATA_TRANSFER | 1 | Data transfer.| -| AUDIO_PLAYBACK | 2 | Audio playback.| -| AUDIO_RECORDING | 3 | Audio recording.| -| LOCATION | 4 | Positioning and navigation.| -| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task.| -| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection.| -| WIFI_INTERACTION | 7 | WLAN-related (reserved).| -| VOIP | 8 | Voice and video call (reserved).| -| TASK_KEEPING | 9 | Computing task (for PC only).| +| Name | Value | Description | +| ----------------------- | ----- | -------------------------------- | +| DATA_TRANSFER | 1 | Data transfer. | +| AUDIO_PLAYBACK | 2 | Audio playback. | +| AUDIO_RECORDING | 3 | Audio recording. | +| LOCATION | 4 | Positioning and navigation. | +| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | +| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | +| WIFI_INTERACTION | 7 | WLAN-related (reserved). | +| VOIP | 8 | Voice and video call (reserved). | +| TASK_KEEPING | 9 | Computing task. | diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md deleted file mode 100644 index 6a51a41b6fba50c1c4f7a061d313482e1df57ad9..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ /dev/null @@ -1,2798 +0,0 @@ -# Camera - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -``` -import camera from '@ohos.multimedia.camera'; -``` - -## Required Permissions - -``` -ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets a **CameraManager** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CameraManager instance | - -**Example** - -``` -camera.getCameraManager(context, (err, cameraManager) => { - if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); - return; - } - console.log('Callback returned with the CameraManager instance'); -}); -``` - -## getCameraManager(context: Context): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets a **CameraManager** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------| -| context | Context | Yes | Application context | - -**Return values** - -| Type | Description | -|-------------------------|--------------------------------------------------------| -| Promise | Promise used to return the **CameraManager** instance | - -**Example** - -``` -camera.getCameraManager(context).then((cameraManger) => { - console.log('Promise returned with the CameraManager instance.'); -}) -``` - -## CameraStatus - -Enumerates camera status types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default Value | Description | -|---------------------------|---------------|--------------------| -| CAMERA_STATUS_APPEAR | 0 | Camera appear | -| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear | -| CAMERA_STATUS_AVAILABLE | 2 | Camera available | -| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable | - - -## CameraPosition - -Enumerates the camera positions. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|-----------------------------|---------------|-----------------------| -| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position | -| CAMERA_POSITION_BACK | 1 | Rear camera | -| CAMERA_POSITION_FRONT | 2 | Front camera | - -## CameraType - -Enumerates the camera types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|-------------------------|---------------|-------------------------| -| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type | -| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera | -| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera | -| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera | -| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera | - - -## ConnectionType - -Enumerates camera connection types. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|------------------------------|---------------|----------------------------| -| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB | -| CAMERA_CONNECTION_REMOTE | 2 | Remote camera | - -## CameraManager - -Implements camera management, including getting supported cameras and creating **CameraInput** instances. - -### getCameras(callback: AsyncCallback\>): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets all cameras supported by the device. This method uses an asynchronous callback to return the array of supported cameras. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|---------------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras. | - -**Example** - -``` -cameraManager.getCameras((err, cameras) => { - if (err) { - console.error('Failed to get the cameras. ${err.message}'); - return; - } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); -}) -``` - -### getCameras(): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets all cameras supported by the device. This method uses a promise to return the array of supported cameras. - -**Return values** - -| Type | Description | -|------------------------|--------------------------------------------------------| -| Promise\> | Promise used to return an array of supported cameras | - - -**Example** - -``` -cameraManager.getCameras().then((cameraArray) => { - console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); -}) -``` - -### createCameraInput(cameraId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera ID. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Default value | Mandatory | Description | -|----------|------------------------------|-----------|--------------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance.'); -}) -``` - -### createCameraInput(cameraId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera ID. This method uses a promise to return the instance. - -**Parameters** - -| Name | Default value | Mandatory | Description | -|----------|-----------------------------|-----------|------------------------------------------| -| cameraId | string | Yes | Camera ID used to create the instance | - -**Return values** - -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); -}) -``` - -### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-----------------------------|-----------|---------------------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | -| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance'); -}) -``` - -### createCameraInput(position: CameraPosition, type: CameraType): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CameraInput** instance with the specified camera position and camera type. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------------|-----------|----------------------------------------| -| position | CameraPosition | Yes | Camera position | -| type | CameraType | Yes | Camera type | - -**Return values** - -| Type | Description | -|-------------------------|-------------------------------------------------| -| Promise | Promise used to return the CameraInput instance | - -**Example** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); -}) -``` - -### on(type: 'cameraStatus', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for camera status changes. This method uses a callback to get camera status changes. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | Camera status event. | -| callback | Callback | Yes | Callback used to get the camera status change. | - -**Example** - -``` -cameraManager.on('cameraStatus', (cameraStatusInfo) => { - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); -}) -``` - -## Camera - -when we call *cameraManager.getCameras()* API, then it will return the **Camera** class which will have all camera-related metadata such as *cameraId, cameraPosition, cameraType & connectionType*. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Fields** - -| Name | Type | Access | Description | -|----------------|----------------|----------|------------------------| -| cameraId | string | readonly | Camera ID | -| cameraPosition | cameraPosition | readonly | Camera position | -| cameraType | cameraType | readonly | Camera type | -| connectionType | connectionType | readonly | Camera connection type | - -``` -async function getCameraInfo() { - var cameraManager = await camera.getCameraManager(); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var cameraId = cameraObj.connectionType; -} - -``` - -## CameraStatusInfo - -This interface is a CameraManager callback API return. **CameraStatusInfo** will have *Camera* class & *CameraStatus* predefine constants.From *Camera* class, we can have all camera-related metadata & from *CameraStatus* constants, we will have information such as *APPEAR, DISAPPEAR, AVAILABLE & UNAVAILABLE*. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Fields** - -| Name | Type | Description | -|----------------|----------------|------------------| -| camera | Camera | Camera object | -| status | CameraStatus | Camera status | - - -## CameraInput - -Implements a **CameraInput** instance. - -### getCameraId(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the camera ID based on which this **CameraInput** instance is created. This method uses an asynchronous callback to return the camera ID. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|------------------------|-----------|---------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the camera ID | - -``` -cameraInput.getCameraId((err, cameraId) => { - if (err) { - console.error('Failed to get the camera ID. ${err.message}'); - return; - } - console.log('Callback returned with the camera ID: ' + cameraId); -}) -``` - -### getCameraId(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the camera ID based on which this **CameraInput** instance is created. This method uses a promise to return the camera ID. - -**Return values** - -| Type | Description | -|------------------------|--------------------------------------| -| Promise | Promise used to return the camera ID | - -**Example** - -``` -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); -}) -``` - -### hasFlash(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether the device has flash light. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------|-----------|----------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the flash light support status | - -**Example** - -``` -cameraInput.hasFlash((err, status) => { - if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); - return; - } - console.log('Callback returned with flash light support status: ' + status); -}) -``` - -### hasFlash(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether the device has flash light. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|--------------------------------------------------------| -| Promise | Promise used to return the flash light support status | - -**Example** - -``` -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); -}) -``` - -### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified flash mode is supported. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the device flash support status | - -**Example** - -``` -cameraInput.isFlashModeSupported(flashMode, (err, status) => { - if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the flash mode support status: ' + status); -}) -``` - -### isFlashModeSupported(flashMode: FlashMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified flash mode is supported. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return flash mode support status. | - -**Example** - -``` -cameraInput.isFlashModeSupported(flashMode).then((status) => { - console.log('Promise returned with flash mode support status.' + status); -}) -``` - -### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets flash mode. This method uses an asynchronous callback to return the result. - -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setFlashMode(flashMode, (err) => { - if (err) { - console.error('Failed to set the flash mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFlashMode.'); -}) -``` - -### setFlashMode(flashMode: FlashMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets flash mode. This method uses a promise to return the result. - -Note: Before setting the flash mode, check the support for the flash light (hasFlash method) and flash mode support (isFlashModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | Flash mode | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setFlashMode(flashMode).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); -}) -``` - -### getFlashMode(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current flash mode. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current flash mode | - -**Example** - -``` -cameraInput.getFlashMode((err, flashMode) => { - if (err) { - console.error('Failed to get the flash mode ${err.message}'); - return; - } - console.log('Callback returned with current flash mode: ' + flashMode); -}) -``` - -### getFlashMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current flash mode. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the flash mode | - -**Example** - -``` -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); -}) -``` - -### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified focus mode is supported. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|----------------------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the device focus support status | - -**Example** - -``` -cameraInput.isFocusModeSupported(afMode, (err, status) => { - if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the focus mode support status: ' + status); -}) -``` - -### isFocusModeSupported(afMode: FocusMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Checks whether a specified focus mode is supported. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode support status. | - -**Example** - -``` -cameraInput.isFocusModeSupported(afMode).then((status) => { - console.log('Promise returned with focus mode support status.' + status); -}) -``` - -### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets focus mode. This method uses an asynchronous callback to return the result. - -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| afMode | FocusMode | Yes | Focus mode | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setFocusMode(afMode, (err) => { - if (err) { - console.error('Failed to set the focus mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFocusMode.'); -}) -``` - -### setFocusMode(afMode: FocusMode): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets focus mode. This method uses a promise to return the result. - -Note: Before setting the focus mode, check focus mode support (isFocusModeSupported method); - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|-----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | Focus mode | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setFocusMode(afMode).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); -}) -``` - -### getFocusMode(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the current focus mode. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current focus mode | - -**Example** - -``` -cameraInput.getFocusMode((err, afMode) => { - if (err) { - console.error('Failed to get the focus mode ${err.message}'); - return; - } - console.log('Callback returned with current focus mode: ' + afMode); -}) -``` - -### getFocusMode(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the current focus mode. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the focus mode | - -**Example** - -``` -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); -}) -``` - -### getZoomRatioRange\(callback: AsyncCallback\>\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the zoom ratios of all zoom values. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range | - -**Example** - -``` -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { - if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); - return; - } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### getZoomRatioRange\(\): Promise\>; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets the zoom ratios of all zoom values. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|------------------------|---------------------------------------------| -| Promise\> | Promise used to return the zoom ratio range | - -**Example** - -``` -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets a zoom ratio. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|------------------------|-----------|------------------------------------| -| zoomRatio | number | Yes | Zoom ratio | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.setZoomRatio(zoomRatio, (err) => { - if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setZoomRatio.'); -}) -``` - -### setZoomRatio(zoomRatio: number): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Sets a zoom ratio. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|----------|-----------|-------------| -| zoomRatio | number | Yes | zoom ratio | - -**Return values** - -| Type | Description | -|-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.setZoomRatio(zoomRatio).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); -}) -``` - -### getZoomRatio(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current zoom ratio value. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-----------|---------------------------|-----------|------------------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio value | - -**Example** - -``` -cameraInput.getZoomRatio((err, zoomRatio) => { - if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); - return; - } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); -}) -``` - -### getZoomRatio(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Gets current zoom ratio value. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the zoom ratio vaule | - -**Example** - -``` -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); -}) -``` - -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CameraInput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -cameraInput.release((err) => { - if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CameraInput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); -}) -``` - -### on(type: 'focusStateChange', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for focus state changes. This method uses a callback to get focus state changes. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the focus state change. | - -**Example** - -``` -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **CameraInput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Camera input error event. | -| callback | Callback | Yes | Callback used to get the camera input errors. | - -**Example** - -``` -cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); -}) -``` - -## FlashMode - -Enumerates the flash modes. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|------------------------|---------------|------------------------| -| FLASH_MODE_CLOSE | 0 | Flash mode close | -| FLASH_MODE_OPEN | 1 | Flash mode open | -| FLASH_MODE_AUTO | 2 | Flash mode auto | -| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open | - -## FocusMode - -Enumerates the focus modes. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|----------------------------|---------------|----------------------------| -| FOCUS_MODE_MANUAL | 0 | Focus mode manual | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Focus mode continuous auto | -| FOCUS_MODE_AUTO | 2 | Focus mode auto | -| FOCUS_MODE_LOCKED | 3 | Focus mode locked | - -## createCaptureSession\(context: Context, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CaptureSession** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|--------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | -| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | - -**Example** - -``` -captureSession.createCaptureSession((context), (err, captureSession) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); -``` - -## createCaptureSession(context: Context\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **CaptureSession** instance. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | Application context | - -**Return values** - -| Type | Description | -|---------------------------|---------------------------------------------------| -| Promise | Promise used to return the CaptureSession instance. | - -**Example** - -``` -captureSession.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); -}) -``` - -## CaptureSession - -Implements session capture. - -### beginConfig\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.beginConfig((err) => { - if (err) { - console.error('Failed to start the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the begin config success.'); -}); -``` - -### beginConfig\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts configuration for this CaptureSession instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.beginConfig().then(() => { - console.log('Promise returned to indicate the begin config success.'); -}) -``` - -### commitConfig\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Commits the configuration for this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.commitConfig((err) => { - if (err) { - console.error('Failed to commit the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the commit config success.'); -}); -``` - -### commitConfig\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Commits the configuration for this CaptureSession instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.commitConfig().then(() => { - console.log('Promise returned to indicate the commit config success.'); -}) -``` - -### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a CameraInput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|---------------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addInput(cameraInput, (err) => { - if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); -``` - -### addInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a CameraInput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|-------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to add | - -**Return values** - -| Type | Description | -|----------------|------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); -}) -``` - -### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PreviewOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|-------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); -}); -``` - -### addOutput\(previewOutput: PreviewOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PreviewOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to add | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); -}) -``` - -### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PhotoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); -}); -``` - -### addOutput\(photoOutput: PhotoOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a PhotoOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to add | - -**Return values** - -| Type | Description | -|---------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); -}) -``` - -### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a VideoOutput instance to this CaptureSession instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.addOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); -``` - -### addOutput\(videoOutput: VideoOutput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Add a VideoOutput instance to this CaptureSession instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|--------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to add | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); -}) -``` - -### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|----------------------|-----------|------------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeInput(cameraInput, (err) => { - if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the cameraInput instance is removed.'); -}); -``` - -### removeInput\(cameraInput: CameraInput\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **CameraInput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|-------------|---------------------|-----------|---------------------------------| -| cameraInput | CameraInput | Yes | CameraInput instance to remove | - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.removeInput(cameraInput).then(() => { - console.log('Promise returned to indicate that the cameraInput instance is removed.'); -}) -``` - -### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); -}); -``` - -### removeOutput(previewOutput: PreviewOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|-----------------------------------| -| previewOutput | PreviewOutput | Yes | PreviewOutput instance to remove | - - -**Return values** - -| Type | Description | -|---------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); -}) -``` - -### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); -}); -``` - -### removeOutput(photoOutput: PhotoOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| photoOutput | PhotoOutput | Yes | PhotoOutput instance to remove | - - -**Return values** - -| Type | Description | -|---------------|------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); -}) -``` - -### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|----------------------|-----------|------------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.removeOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); -}); -``` - -### removeOutput(videoOutput: VideoOutput): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Removes a **VideoOutput** instance from this **CaptureSession** instance. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|---------------|---------------------|-----------|---------------------------------| -| videoOutput | VideoOutput | Yes | VideoOutput instance to remove | - - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); -}) -``` - -### start\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.start((err) => { - if (err) { - console.error('Failed to start the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session start success.'); -}); -``` - -### start\(\): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); -}) -``` - -### stop\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.stop((err) => { - if (err) { - console.error('Failed to stop the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session stop success.'); -}); -``` - -### stop(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.stop().then(() => { - console.log('Promise returned to indicate the session stop success.'); -}) -``` - -### release\(callback: AsyncCallback\): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CaptureSession** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -captureSession.release((err) => { - if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **CaptureSession** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -captureSession.release().then(() => { - console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **CaptureSession** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Capture session error event. | -| callback | Callback | Yes | Callback used to get the capture session errors. | - -**Example** - -``` -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); -}) -``` - -## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PreviewOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | -| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | - -**Example** - -``` -camera.createPreviewOutput((surfaceId), (err, previewOutput) => { - if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with previewOutput instance'); -}); -``` - -## createPreviewOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PreviewOutput** instance. This method uses a promise to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from XComponent view | - -**Return values** - -| Type | Description | -|-------------------------|---------------------------------------------------| -| Promise | Promise used to return the PreviewOutput instance | - -**Example** - -``` -camera.createPreviewOutput(surfaceId).then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); -}) -``` - -## PreviewOutput - -Implements preview output. - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PreviewOutput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.release((err) => { - if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PreviewOutput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|-----------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); -}) -``` - -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for preview frame start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.on('frameStart', () => { - console.log('Preview frame started'); -}) -``` - -### on(type: 'frameEnd', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for preview frame end event. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -previewOutput.on('frameEnd', () => { - console.log('Preview frame ended'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **PreviewOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Preview output error event. | -| callback | Callback | Yes | Callback used to get the preview output errors. | - -**Example** - -``` -previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); -}) -``` - -## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PhotoOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | -| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | - -**Example** - -``` -camera.createPhotoOutput((surfaceId), (err, photoOutput) => { - if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the PhotoOutput instance.'); -}); -``` - -## createPhotoOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **PhotoOutput** instance. This method uses a promise to return the PhotoOutput instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from ImageReceiver | - -**Return values** - -| Type | Description | -|-------------------------|--------------------------------------------------| -| Promise | Promise used to return the PhotoOutput instance | - -**Example** - -``` -camera.createPhotoOutput(surfaceId).then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); -}) -``` -## ImageRotation - -Enumerates the image rotation angles. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default Value | Description | -|--------------|---------------|----------------------------------------| -| ROTATION_0 | 0 | The capture image rotates 0 degrees | -| ROTATION_90 | 90 | The capture image rotates 90 degrees | -| ROTATION_180 | 180 | The capture image rotates 180 degrees | -| ROTATION_270 | 270 | The capture image rotates 270 degrees | - - -## Location - -Defines the location of a captured image. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Type | Access | Description | -|-----------|--------|--------------|-------------| -| latitude | number | read / write | Latitude | -| longitude | number | read / write | Longitude | - -## QualityLevel - -Enumerates the image quality levels. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Default value | Description | -|----------------------|---------------|----------------------| -| QUALITY_LEVEL_HIGH | 0 | High image quality | -| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality | -| QUALITY_LEVEL_LOW | 2 | Low image quality | - - -## PhotoCaptureSetting - -Defines the settings for image capture. - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -| Name | Type | Mandatory | Description | -|----------|---------------|-----------|---------------------| -| quality | QualityLevel | Optional | Photo image quality | -| rotation | ImageRotation | Optional | Photo rotation | - - -## PhotoOutput - -Implements photo output. - -### capture(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.capture((err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo with the specified capture settings. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | Yes | Photo capture settings | -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.capture(settings, (err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture(setting?: PhotoCaptureSetting): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Captures a photo with the specified capture settings. This method uses a promise to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|---------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | No | Photo capture settings | - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); -}) -``` - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PhotoOutput** instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -photoOutput.release((err) => { - if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this **PhotoOutput** instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); -}) -``` - -### on(type: 'captureStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for photo capture start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture ID. | - -**Example** - -``` -photoOutput.on('captureStart', (captureId) => { - console.log('photo capture stated, captureId : ' + captureId); -}) -``` - -### on(type: 'frameShutter', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for frame shutter events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the frame shutter information.| - -**Example** - -``` -photoOutput.on('frameShutter', (frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); -}) -``` - -### on(type: 'captureEnd', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for photo capture end events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :------------------------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to get the capture end information | - -**Example** - -``` -photoOutput.on('captureEnd', (captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); -}) -``` - -### on(type: 'error', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for **PhotoOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Photo output error event. | -| callback | Callback | Yes | Callback used to get the photo output errors. | - -**Example** - -``` -photoOutput.on('error', (photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); -}) -``` - -## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **VideoOutput** instance. This method uses an asynchronous callback to return the instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | -| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | - -**Example** - -``` -camera.createVideoOutput((surfaceId), (err, videoOutput) => { - if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the VideoOutput instance'); -}); -``` - -## createVideoOutput(surfaceId: string): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Creates a **VideoOutput** instance. This method uses a promise to return the VideoOutput instance. - -**Parameters** - -| Name | Type | Mandatory | Description | -|------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | Surface ID received from VideoRecorder | - -**Return values** - -| Type | Description | -|---------------------------------------|-------------------------------------------------| -| Promise<[VideoOutput](#videooutput)\> | Promise used to return the VideoOutput instance | - -**Example** - -``` -camera.createVideoOutput(surfaceId).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); -}) -``` -## VideoOutput - -Implements video output. - -### start(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts the video output. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.start((err) => { - if (err) { - console.error('Failed to start the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output start success.'); -}); -``` - -### start(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Starts the video output. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); -}) -``` - -### stop(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops the video output. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.stop((err) => { - if (err) { - console.error('Failed to stop the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output stop success.'); -}); -``` - -### stop(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Stops the video output. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - -**Example** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); -}) -``` - -### release(callback: AsyncCallback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this VideoOutput instance. This method uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory | Description | -|----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.release((err) => { - if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); -``` - -### release(): Promise; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Releases this VideoOutput instance. This method uses a promise to return the result. - -**Return values** - -| Type | Description | -|----------------|---------------------------------------------| -| Promise | Promise used to return the result | - - -**Example** - -``` -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); -}) -``` - -### on(type: 'frameStart', callback: Callback): void; - -**System Capabilities:** - -SystemCapability.Multimedia.Camera.Core - -**Description** - -Listens for video frame start events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.on('frameStart', () => { - console.log('Video frame started'); -}) -``` - -### on(type: 'frameEnd', callback: Callback): void; - -Listens for video frame end events. This method uses a callback to get the event information. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | Name of the event to listen for. | -| callback | Callback | Yes | Callback used to return the result | - -**Example** - -``` -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); -}) -``` - -### on(type: 'error', callback: Callback): void; - -Listens for **VideoOutput** errors. This method uses a callback to get errors. - -**Parameters** - -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Video output error event. | -| callback | Callback | Yes | Callback used to get the video output errors. | - -**Example** - -``` -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); -}) -``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md deleted file mode 100644 index 31d9f3831681723461ec95cbcae475230187c346..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ /dev/null @@ -1,623 +0,0 @@ -# Lightweight Storage - -Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - - -## Modules to Import - -``` -import data_Preferences from '@ohos.data.preferences' -``` - -## Attributes - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It is 80 bytes.| -| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value of the string type. It is 8192 bytes.| - - -## data_Preferences.getPreferences - -getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void - -Reads a file and loads the data to the **Preferences** instance. This method uses an asynchronous callback to return the execution result. - - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the execution result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - var path = this.context.getDataBaseDir() - data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, path: " + path + '/mystore') - return; - } - preferences.putSync('startup', 'auto') - preferences.flushSync() - }) - ``` - - -## data_Preferences.getPreferences - -getPreferences(context: Context, name: string): Promise<Preferences> - -Reads a file and loads the data to the **Preferences** instance. This method uses a promise to return the execution result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<[Preferences](#preferences)> | Promise used to return the result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - var path = this.context.getDataBaseDir() - let promisePre = data_Preferences.getPreferences(this.context, 'mystore') - promisePre.then((preferences) => { - preferences.putSync('startup', 'auto') - preferences.flushSync() - }).catch((err) => { - console.info("Get the preferences failed, path: " + path + '/mystore') - }) - ``` - - -## data_Preferences.deletePreferences - -deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void - -Removes the singleton **Preferences** instance of the specified file from the memory, and deletes the specified file, its backup file, and corrupted files. After the specified files are deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This method uses an asynchronous callback to return the execution result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - data_Preferences.deletePreferences(this.context, 'mystore', function (err) { - if (err) { - console.info("Deleted failed with err: " + err) - return - } - console.info("Deleted successfully.") - }) - ``` - - -## data_Preferences.deletePreferences - -deletePreferences(context: Context, name: string): Promise<void> - -Removes the singleton **Preferences** instance of the specified file from the memory, and deletes the specified file, its backup file, and corrupted files. After the specified files are deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This method uses a promise to return the execution result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - let promisedelPre = data_Preferences.deletePreferences(this.context, 'mystore') - promisedelPre.then(() => { - console.info("Deleted successfully.") - }).catch((err) => { - console.info("Deleted failed with err: " + err) - }) - ``` - - -## data_Preferences.removePreferencesFromCache - -removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<void>): void - -Removes the singleton **Preferences** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - data_Preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { - if (err) { - console.info("Removed preferences from cache failed with err: " + err) - return - } - console.info("Removed preferences from cache successfully.") - }) - ``` - - -## data_Preferences.removePreferencesFromCache - -removePreferencesFromCache(context: Context, name: string): Promise<void> - -Removes the singleton **Preferences** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | context | Context | Yes| Context of the app or functionality.| - | name | string | Yes| Name of the app's internal data storage.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - let promiserevPre = data_Preferences.removePreferencesFromCache(this.context, 'mystore') - promiserevPre.then(() => { - console.info("Removed preferences from cache successfully.") - }).catch((err) => { - console.info("Removed preferences from cache failed with err: " + err) - }) - ``` - - -## Preferences - -Provides APIs for obtaining and modifying storage data. - - -### get - -get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void - -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| - | defValue | ValueType | Yes| Default value to be returned. It can be a number, string, or Boolean value.| - | callback | AsyncCallback<ValueType> | Yes| Callback used to return the execution result.| - -- Example - ``` - preferences.get('startup', 'default', function(err, value) { - if (err) { - console.info("Get the value of startup failed with err: " + err) - return - } - console.info("The value of startup is " + value) - }) - ``` - - -### get - -get(key: string, defValue: ValueType): Promise<ValueType> - -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| - | defValue | ValueType | Yes| Default value to be returned. It can be a number, string, or Boolean value.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<ValueType> | Promise used to return the result.| - -- Example - ``` - let promiseget = preferences.get('startup', 'default') - promiseget.then((value) => { - console.info("The value of startup is " + value) - }).catch((err) => { - console.info("Get the value of startup failed with err: " + err) - }) - ``` - - -### put - -put(key: string, value: ValueType, callback: AsyncCallback<void>): void - -Obtains the **Preferences** instance corresponding to the specified file, writes data to the **Preferences** instance using a **Preferences** API, and saves data to the file using **flush()** or **flushSync()**. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data to modify. It cannot be empty.| - | value | ValueType | Yes| New value to store. It can be a number, string, or Boolean value.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed with err: " + err) - return - } - console.info("Put the value of startup successfully.") - }) - ``` - - -### put - -put(key: string, value: ValueType): Promise<void> - -Obtains the **Preferences** instance corresponding to the specified file, writes data to the **Preferences** instance using a **Preferences** API, and saves data to the file using **flush()** or **flushSync()**. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data to modify. It cannot be empty.| - | value | ValueType | Yes| New value to store. It can be a number, string, or Boolean value.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - let promiseput = preferences.put('startup', 'auto') - promiseput.then(() => { - console.info("Put the value of startup successfully.") - }).catch((err) => { - console.info("Put the value of startup failed with err: " + err) - }) - ``` - - -### has - -has(key: string, callback: AsyncCallback<boolean>): boolean - -Checks whether the **Preference** object contains data with a given key. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| - | callback | AsyncCallback<boolean> | Yes| Callback used to return the execution result.| - -- Return value - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the **Preference** object contains data with the specified key; returns **false** otherwise.| - -- Example - ``` - preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Check the key of startup failed with err: " + err) - return - } - if (isExist) { - console.info("The key of startup is contained.") - } - }) - ``` - - -### has - -has(key: string): Promise<boolean> - -Checks whether the **Preference** object contains data with a given key. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return the result.| - -- Example - ``` - let promisehas = preferences.has('startup') - promisehas.then((isExist) => { - if (isExist) { - console.info("The key of startup is contained.") - } - }).catch((err) => { - console.info("Check the key of startup failed with err: " + err) - }) - ``` - - -### delete - -delete(key: string, callback: AsyncCallback<void>): void - -Deletes data with the specified key from this **Preference** object. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - preferences.delete('startup', function (err) { - if (err) { - console.info("Delete startup key failed with err: " + err) - return - } - console.info("Deleted startup key successfully.") - }) - ``` - - -### delete - -delete(key: string): Promise<void> - -Deletes data with the specified key from this **Preference** object. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data.| - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - let promisedel = preferences.delete('startup') - promisedel.then(() => { - console.info("Deleted startup key successfully.") - }).catch((err) => { - console.info("Delete startup key failed with err: " + err) - }) - ``` - - -### flush - -flush(callback: AsyncCallback<void>): void - -Saves the modification of this object to the **Preferences** instance and synchronizes the modification to the file. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed with err: " + err) - return - } - console.info("Flushed to file successfully.") - }) - ``` - - -### flush - -flush(): Promise<void> - -Saves the modification of this object to the **Preferences** instance and synchronizes the modification to the file. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - let promiseflush = preferences.flush() - promiseflush.then(() => { - console.info("Flushed to file successfully.") - }).catch((err) => { - console.info("Flush to file failed with err: " + err) - }) - ``` - - -### clear - -clear(callback: AsyncCallback<void>): void - -Clears this **Preferences** object. - -This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| - -- Example - ``` - preferences.clear(function (err) { - if (err) { - console.info("Clear to file failed with err: " + err) - return - } - console.info("Cleared to file successfully.") - }) - ``` - - -### clear - -clear(): Promise<void> - -Clears this **Preferences** object. - -This method uses a promise to return the result. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Return value - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| - -- Example - ``` - let promiseclear = preferences.clear() - promiseclear.then(() => { - console.info("Cleared to file successfully.") - }).catch((err) => { - console.info("Clear to file failed with err: " + err) - }) - ``` - - -### on('change') - -on(type: 'change', callback: Callback<{ key : string }>): void - -Subscribes to data changes. When the value of the subscribed key changes, a callback will be invoked after the **flush()** method is executed. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Description| - | -------- | -------- | -------- | - | type | string | Event type. The value **change** indicates data change events.| - | callback | Callback<{ key : string }> | Callback used to return data changes.| - -- Example - ``` - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - preferences.on('change', observer) - preferences.put('startup', 'auto') - preferences.flush() // observer will be called. - ``` - - -### off('change') - -off(type: 'change', callback: Callback<{ key : string }>): void - -Unsubscribes from data changes. - -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core - -- Parameters - | Name| Type| Description| - | -------- | -------- | -------- | - | type | string | Event type. The value **change** indicates data change events.| - | callback | Callback<{ key : string }> | Callback used to return data changes.| - -- Example - ``` - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - preferences.off('change', observer) - ``` diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index 6f563185d3e06f23f584f13b2974074299b6c445..1f77fa17150dfa3b26394418a7b4411cde17a986 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -4,7 +4,7 @@ Lightweight storage provides applications with data processing capability and al > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs of this module are no longer maintained since API Version 9. You are advised to use [@ohos.data.preferences](js-apis-data-preferences.md). +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -45,7 +45,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() let storage = dataStorage.getStorageSync(path + '/mystore') @@ -72,7 +72,7 @@ Reads a file and loads the data to the **Storage** instance. This method uses an ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() dataStorage.getStorage(path + '/mystore', function (err, storage) { @@ -108,7 +108,7 @@ Reads a file and loads the data to the **Storage** instance. This method uses a ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() let promisegetSt = dataStorage.getStorage(path + '/mystore') diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index d0c2ad5562ab851003c8e33828fdeb25f5f68847..8a787a420d2f2ec87d298c42f5f0b9533d5953e6 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -38,7 +38,7 @@ Describes the attributes of a display. | id | number | Yes| No| ID of the display.| | name | string | Yes| No| Name of the display.| | alive | boolean | Yes| No| Whether the display is alive.| -| state | [DisplayState](#DisplayState) | Yes| No| State of the display.| +| state | [DisplayState](#displaystate) | Yes| No| State of the display.| | refreshRate | number | Yes| No| Refresh rate of the display.| | rotation | number | Yes| No| Screen rotation angle of the display.| | width | number | Yes| No| Width of the display, in pixels.| @@ -61,7 +61,7 @@ Obtains the default display object. - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Display](#Display)> | Yes| Callback used to return the default display object.| + | callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the default display object.| - Example ``` @@ -88,7 +88,7 @@ Obtains the default display object. | Type | Description | | ---------------------------------- | ---------------------------------------------- | - | Promise<[Display](#Display)> | Promise used to return the default display object.| + | Promise<[Display](#display)> | Promise used to return the default display object.| - Example @@ -113,7 +113,7 @@ Obtains all the display objects. | Name | Type | Mandatory| Description | | -------- | ---------------------------------------------------- | ---- | ------------------------------- | - | callback | AsyncCallback<Array<[Display](Display)>> | Yes | Callback used to return all the display objects.| + | callback | AsyncCallback<Array<[Display](#display)>> | Yes | Callback used to return all the display objects.| - Example @@ -139,7 +139,7 @@ Obtains all the display objects. | Type | Description | | ----------------------------------------------- | ------------------------------------------------------- | - | Promise<Array<[Display](#Display)>> | Promise used to return an array containing all the display objects.| + | Promise<Array<[Display](#display)>> | Promise used to return an array containing all the display objects.| - Example diff --git a/en/application-dev/reference/apis/js-apis-basic-features-logs.md b/en/application-dev/reference/apis/js-apis-logs.md similarity index 100% rename from en/application-dev/reference/apis/js-apis-basic-features-logs.md rename to en/application-dev/reference/apis/js-apis-logs.md diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 89c0c298d6a369fcf7ac7fc3abc63be304b56977..ae07870d380fb69569ef860b469f865b2d3baad6 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -125,73 +125,6 @@ Creates an **AudioRecorder** instance to control audio recording. let audiorecorder = media.createAudioRecorder(); ``` -## media.createVideoRecorder9+ - -createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void - -Creates a **VideoRecorder** instance in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance created.| - -**Example** - -```js -let videoRecorder - -media.createVideoRecorder((error, video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info(`video createVideoRecorder fail, error:${error.message}`); - } -}); -``` - -## media.createVideoRecorder9+ - -createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> - -Creates a **VideoRecorder** instance in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance created.| - -**Example** - -```js -let videoRecorder - -function failureCallback(error) { - console.info(`video failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`video catchCallback, error:${error.message}`); -} - -await media.createVideoRecorder.then((video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info('video createVideoRecorder fail'); - } -}, failureCallback).catch(catchCallback); -``` - - - ## MediaErrorCode8+ Enumerates the media error codes. @@ -1836,662 +1769,6 @@ Enumerates the audio output formats. | AMR_WB | 4 | AMR_WB.
This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.| -## VideoRecorder9+ - -Implements video recording. Before calling an API of the **VideoRecorder** class, you must call [createVideoRecorder()](#mediacreatevideorecorder9) to create a [VideoRecorder](#videorecorder9) instance. - -For details about the video recording demo, see [Video Recording Development](../../media/video-recorder.md). - -### Attributes - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Readable| Writable| Description | -| ------------------ | -------------------------------------- | ---- | ---- | ---------------- | -| state8+ | [VideoRecordState](#videorecordstate9) | Yes | No | Video recording state.| - -### prepare9+ - -prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; - -Sets video recording parameters in asynchronous mode. This API uses a callback to return the result. - -**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------------- | ---- | ----------------------------------- | -| config | [VideoRecorderConfig](#videorecorderconfig9) | Yes | Video recording parameters to set. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // The file must be created by the caller and granted with proper permissions. - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// asyncallback -let videoRecorder = null; -let events = require('events'); -let eventEmitter = new events.EventEmitter(); - -eventEmitter.on('prepare', () => { - videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { - console.info('prepare success'); - } else { - console.info('prepare failed and error is ' + err.message); - } - }); -}); - -media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - eventEmitter.emit('prepare'); // Trigger the 'prepare' event. - } else { - console.info('createVideoRecorder failed and error is ' + err.message); - } -}); -``` - -### prepare9+ - -prepare(config: VideoRecorderConfig): Promise\; - -Sets video recording parameters in asynchronous mode. This API uses a promise to return the result. - -**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | -------------------------------------------- | ---- | ------------------------ | -| config | [VideoRecorderConfig](#videorecorderconfig9) | Yes | Video recording parameters to set.| - -**Return value** - -| Type | Description | -| -------------- | ---------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // The file must be created by the caller and granted with proper permissions. - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// promise -let videoRecorder = null; -await media.createVideoRecorder().then((recorder) => { - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - } else { - console.info('createVideoRecorder failed'); - } -}, (err) => { - console.info('error hanppend message is ' + err.message); -}).catch((err) => { - console.info('catch err error message is ' + err.message); -}); - -await videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); -}, (err) => { - console.info('prepare failed and error is ' + err.message); -}).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); -}); -``` - -### getInputSurface9+ - -getInputSurface(callback: AsyncCallback\): void; - -Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data. - -Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time. - -This API can be called only after [prepare()](#videorecorder_prepare1) is called. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | --------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to obtain the result.| - -**Example** - -```js -// asyncallback -let surfaceID = null; // Surface ID passed to the external system. -videoRecorder.getInputSurface((err, surfaceId) => { - if (typeof (err) == 'undefined') { - console.info('getInputSurface success'); - surfaceID = surfaceId; - } else { - console.info('getInputSurface failed and error is ' + err.message); - } -}); -``` - -### getInputSurface9+ - -getInputSurface(): Promise\; - - Obtains the surface required for recording in asynchronous mode. This surface is provided for the caller. The caller obtains the **surfaceBuffer** from this surface and fills in the corresponding data. - -Note that the video data must carry the timestamp (in ns) and buffer size, and the start time of the timestamp is based on the system startup time. - -This API can be called only after [prepare()](#videorecorder_prepare1) is called. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| ---------------- | -------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -let surfaceID = null; // Surface ID passed to the external system. -await videoRecorder.getInputSurface().then((surfaceId) => { - console.info('getInputSurface success'); - surfaceID = surfaceId; -}, (err) => { - console.info('getInputSurface failed and error is ' + err.message); -}).catch((err) => { - console.info('getInputSurface failed and catch error is ' + err.message); -}); -``` - -### start9+ - -start(callback: AsyncCallback\): void; - -Starts video recording in asynchronous mode. This API uses a callback to return the result. - -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { - console.info('start videorecorder success'); - } else { - console.info('start videorecorder failed and error is ' + err.message); - } -}); -``` - -### start9+ - -start(): Promise\; - -Starts video recording in asynchronous mode. This API uses a promise to return the result. - -This API can be called only after [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) are called, because the data source must pass data to the surface first. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.start().then(() => { - console.info('start videorecorder success'); -}, (err) => { - console.info('start videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('start videorecorder failed and catch error is ' + err.message); -}); -``` - -### pause9+ - -pause(callback: AsyncCallback\): void; - -Pauses video recording in asynchronous mode. This API uses a callback to return the result. - -This API can be called only after [start()](#videorecorder_start1) is called. You can resume recording by calling [resume()](#videorecorder_resume1). - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { - console.info('pause videorecorder success'); - } else { - console.info('pause videorecorder failed and error is ' + err.message); - } -}); -``` - -### pause9+ - -pause(): Promise\; - -Pauses video recording in asynchronous mode. This API uses a promise to return the result. - -This API can be called only after [start()](#videorecorder_start1) is called. You can resume recording by calling [resume()](#videorecorder_resume1). - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.pause().then(() => { - console.info('pause videorecorder success'); -}, (err) => { - console.info('pause videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('pause videorecorder failed and catch error is ' + err.message); -}); -``` - -### resume9+ - -resume(callback: AsyncCallback\): void; - -Resumes video recording in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { - console.info('resume videorecorder success'); - } else { - console.info('resume videorecorder failed and error is ' + err.message); - } -}); -``` - -### resume9+ - -resume(): Promise\; - -Resumes video recording in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.resume().then(() => { - console.info('resume videorecorder success'); -}, (err) => { - console.info('resume videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('resume videorecorder failed and catch error is ' + err.message); -}); -``` - -### stop9+ - -stop(callback: AsyncCallback\): void; - -Stops video recording in asynchronous mode. This API uses a callback to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { - console.info('stop videorecorder success'); - } else { - console.info('stop videorecorder failed and error is ' + err.message); - } -}); -``` - -### stop9+ - -stop(): Promise\; - -Stops video recording in asynchronous mode. This API uses a promise to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.stop().then(() => { - console.info('stop videorecorder success'); -}, (err) => { - console.info('stop videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('stop videorecorder failed and catch error is ' + err.message); -}); -``` - -### release9+ - -release(callback: AsyncCallback\): void; - -Releases the video recording resource in asynchronous mode. This API uses a callback to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { - console.info('release videorecorder success'); - } else { - console.info('release videorecorder failed and error is ' + err.message); - } -}); -``` - -### release9+ - -release(): Promise\; - -Releases the video recording resource in asynchronous mode. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ----------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.release().then(() => { - console.info('release videorecorder success'); -}, (err) => { - console.info('release videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('release videorecorder failed and catch error is ' + err.message); -}); -``` - -### reset9+ - -reset(callback: AsyncCallback\): void; - -Resets video recording in asynchronous mode. This API uses a callback to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// asyncallback -videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { - console.info('reset videorecorder success'); - } else { - console.info('reset videorecorder failed and error is ' + err.message); - } -}); -``` - -### reset9+ - -reset(): Promise\; - -Resets video recording in asynchronous mode. This API uses a promise to return the result. - -To start another recording, you must call [prepare()](#videorecorder_prepare1) and [getInputSurface()](#getinputsurface8) again. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Return value** - -| Type | Description | -| -------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// promise -await videoRecorder.reset().then(() => { - console.info('reset videorecorder success'); -}, (err) => { - console.info('reset videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('reset videorecorder failed and catch error is ' + err.message); -}); -``` - -### on('error')9+ - -on(type: 'error', callback: ErrorCallback): void - -Subscribes to the video recording error event. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to, which is 'error' in this API.
The 'error' event is triggered when an error occurs during video recording.| -| callback | ErrorCallback | Yes | Callback invoked when the event is triggered. | - -**Example** - -```js -videoRecorder.on('error', (error) => { // Set the 'error' event callback. - console.info(`audio error called, errName is ${error.name}`); // Print the error name. - console.info(`audio error called, errCode is ${error.code}`); // Print the error code. - console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type. -}); -// This event is reported when an error occurs during the retrieval of videoRecordState. -``` - -## VideoRecordState9+ - -Enumerates the video recording states. You can obtain the state through the **state** attribute. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Description | -| -------- | ------ | ---------------------- | -| idle | string | The video recorder is idle. | -| prepared | string | The video recording parameters are set.| -| playing | string | Video recording is in progress. | -| paused | string | Video recording is paused. | -| stopped | string | Video recording is stopped. | -| error | string | Audio playback is in the error state. | - -## VideoRecorderConfig9+ - -Describes the video recording parameters. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Mandatory| Description | -| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype9) | Yes | Type of the audio source for video recording. | -| videoSourceType | [VideoSourceType](#videosourcetype9) | Yes | Type of the video source for video recording. | -| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. | -| rotation | number | No | Rotation angle of the recorded video. | -| location | [Location](#location) | No | Geographical location of the recorded video. | -| url | string | Yes | Video output URL. Supported: fd://xx (fd number)
![](figures/en-us_image_url.png)
The file must be created by the caller and granted with proper permissions.| - -## AudioSourceType9+ - -Enumerates the audio source types for video recording. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Value | Description | -| ------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT | 0 | Default audio input source.| -| AUDIO_SOURCE_TYPE_MIC | 1 | Mic audio input source. | - -## VideoSourceType9+ - -Enumerates the video source types for video recording. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Value | Description | -| ----------------------------- | ---- | ------------------------------- | -| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | The input surface carries raw data.| -| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | The input surface carries ES data. | - -## VideoRecorderProfile9+ - -Describes the video recording profile. - -**System capability**: SystemCapability.Multimedia.Media.VideoRecorder - -| Name | Type | Mandatory| Description | -| ---------------- | -------------------------------------------- | ---- | ---------------- | -| audioBitrate | number | Yes | Audio encoding bit rate.| -| audioChannels | number | Yes | Number of audio channels.| -| audioCodec | [CodecMimeType](#codecmimetype8) | Yes | Audio encoding format. | -| audioSampleRate | number | Yes | Audio sampling rate. | -| fileFormat | [ContainerFormatType](#containerformattype8) | Yes | Container format of a file.| -| videoBitrate | number | Yes | Video encoding bit rate.| -| videoCodec | [CodecMimeType](#codecmimetype8) | Yes | Video encoding format. | -| videoFrameWidth | number | Yes | Width of the recorded video frame.| -| videoFrameHeight | number | Yes | Height of the recorded video frame.| -| videoFrameRate | number | Yes | Video frame rate. | - ## ContainerFormatType8+ Enumerates the container format types (CFTs). diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md new file mode 100644 index 0000000000000000000000000000000000000000..f6bfa278469a5c930c2140078ceee5f0613ec56b --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-pasteboard.md @@ -0,0 +1,1047 @@ +# Pasteboard + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + + +``` +import pasteboard from '@ohos.pasteboard'; +``` + + +## Attributes + +**System capability**: SystemCapability.MiscServices.Pasteboard + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| MAX_RECORD_NUM7+ | number | Yes | No | Maximum number of records allowed in a **PasteData** object. | +| MIMETYPE_TEXT_HTML7+ | string | Yes | No | MIME type of the HTML text. | +| MIMETYPE_TEXT_WANT7+ | string | Yes | No | MIME type of the Want text. | +| MIMETYPE_TEXT_PLAIN7+ | string | Yes | No | MIME type of the plain text. | +| MIMETYPE_TEXT_URI7+ | string | Yes | No | MIME type of the URI text. | + + +## pasteboard.createPlainTextData + +createPlainTextData(text:string): PasteData + +Creates a **PasteData** object for plain text. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | text | string | Yes | Plain text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteData](#pastedata) | **PasteData** object with the specified content. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("content"); + ``` + + +## pasteboard.createHtmlData7+ + +createHtmlData(htmlText:string): PasteData + +Creates a **PasteData** object for HTML text. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | htmlText | string | Yes | HTML text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteData](#pastedata) | **PasteData** object with the specified content. | + +- Example + + ``` + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + ``` + + +## pasteboard.createWantData7+ + +createWantData(want:Want): PasteData + +Creates a **PasteData** object for Want text. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#want) | Yes | Want text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteData](#pastedata) | **PasteData** object with the specified content. | + +- Example + + ``` + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + ``` + + +## pasteboard.createUriData7+ + +createUriData(uri:string): PasteData + +Creates a **PasteData** object for URI text. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uri | string | Yes | URI text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteData](#pastedata) | **PasteData** object with the specified content. | + +- Example + + ``` + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + ``` + + +## pasteboard.createPlainTextRecord7+ + +createPlainTextRecord(text:string): PasteDataRecord + +Creates a **PasteDataRecord** object of the plain text type. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | text | string | Yes | Plain text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataRecord](#pastedatarecord7) | New plain text record. | + +- Example + + ``` + var record = pasteboard.createPlainTextRecord("hello"); + ``` + + +## pasteboard.createHtmlTextRecord7+ + +createHtmlTextRecord(htmlText:string): PasteDataRecord + +Creates a **PasteDataRecord** object of the HTML text type. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | htmlText | string | Yes | HTML text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataRecord](#pastedatarecord7) | New HTML record. | + +- Example + + ``` + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var record = pasteboard.createHtmlTextRecord(html); + ``` + + +## pasteboard.createWantRecord7+ + +createWantRecord(want:Want): PasteDataRecord + +Creates a **PasteDataRecord** object of the Want text type. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#want) | Yes | Want text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataRecord](#pastedatarecord7) | New Want record. | + +- Example + + ``` + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var record = pasteboard.createWantRecord(object); + ``` + + +## pasteboard.createUriRecord7+ + +createUriRecord(uri:string): PasteDataRecord + +Creates a **PasteDataRecord** object of the URI text type. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uri | string | Yes | URI text. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataRecord](#pastedatarecord7) | New URI record. | + +- Example + + ``` + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` + + +## PasteDataProperty7+ + +Defines the properties of all data records on the pasteboard, including the timestamp, data type, and additional data. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| additions | {[key: string]: object} | Yes | Yes | Additional property data. | +| mimeTypes | Array<string> | Yes | No | Non-repeating data types of the data records on the pasteboard. | +| tag | string | Yes | Yes | User-defined tag. | +| timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. | +| localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard.
- The default value is **true**.
- **true**: The **PasteData** is set for local access only.
- **false**: The **PasteData** can be shared between devices. | + + +## PasteDataRecord7+ + +A data record is an abstract definition of the content on the pasteboard. The pasteboard content consists of one or more plain text, HTML, URI, or Want records. + + +### Attributes + +**System capability**: SystemCapability.MiscServices.Pasteboard + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| htmlText7+ | string | Yes | No | HTML text. | +| want7+ | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. | +| mimeType7+ | string | Yes | No | Data type. | +| plainText7+ | string | Yes | No | Plain text. | +| uri7+ | string | Yes | No | URI text. | + + +### convertToText7+ + +convertToText(): Promise<string> + +Forcibly converts the content in this **PasteData** object to the plain text. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. If the operation is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | + +- Example + + ``` + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + record.convertToText().then((data) => { + console.info('convertToText success data : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('convertToText failed because ' + JSON.stringify(error)); + }); + ``` + + +### convertToText7+ + +convertToText(callback: AsyncCallback<string>): void + +Forcibly converts the content in this **PasteData** object to the plain text. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. If this callback is successful, the plain text content after conversion is returned. Otherwise, error information is returned. | + +- Example + + ``` + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + record.convertToText((err, data) => { + if (err) { + console.error('convertToText failed because ' + JSON.stringify(err)); + return; + } + console.info('convertToText success data : ' + JSON.stringify(data)); + }); + ``` + + +## PasteData + +Before calling any **PasteData** method, you must obtain a **PasteData** object. + +**System capability**: SystemCapability.MiscServices.Pasteboard + + +### getPrimaryText + + +getPrimaryText(): string + + +Obtains the plain text of the primary record. + + +**System capability**: SystemCapability.MiscServices.Pasteboard + + +- Parameters + None + + +- Return values + | Type | Description | + | -------- | -------- | + | string | Plain text. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var plainText = pasteData.getPrimaryText(); + ``` + + +### getPrimaryHtml7+ + +getPrimaryHtml(): string + +Obtains the HTML text of the primary record. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | string | HTML text. | + +- Example + + ``` + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + var htmlText = pasteData.getPrimaryHtml(); + ``` + + +### getPrimaryWant7+ + +getPrimaryWant(): Want + +Obtains the **Want** object of the primary record. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | [Want](js-apis-featureAbility.md#want) | Want object. | + +- Example + + ``` + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + var want = pasteData.getPrimaryWant(); + ``` + + +### getPrimaryUri7+ + +getPrimaryUri(): string + +Obtains the URI text of the primary record. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | string | URI text. | + +- Example + + ``` + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var uri = pasteData.getPrimaryUri(); + ``` + + +### addTextRecord7+ + +addTextRecord(text: string): void + +Adds a plain text record to this pasteboard, and adds **MIME_TEXT_PLAIN** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails. + +The pasteboard supports a maximum number of 128 data records. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | text | string | Yes | Plain text. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addTextRecord("good"); + ``` + + +### addHtmlRecord7+ + +addHtmlRecord(htmlText: string): void + +Adds an HTML text record to this pasteboard, and adds **MIMETYPE_TEXT_HTML** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails. + +The pasteboard supports a maximum number of 128 data records. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | htmlText | string | Yes | HTML text. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + pasteData.addHtmlRecord(html); + ``` + + +### addWantRecord7+ + +addWantRecord(want: Want): void + +Adds a Want text record to this pasteboard, and adds **MIMETYPE_TEXT_WANT** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails. + +The pasteboard supports a maximum number of 128 data records. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#want) | Yes | Want object. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + pasteData.addWantRecord(object); + ``` + + +### addUriRecord7+ + +addUriRecord(uri: string): void + +Adds a URI text record to this pasteboard, and adds **MIMETYPE_TEXT_URI** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails. + +The pasteboard supports a maximum number of 128 data records. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uri | string | Yes | URI text. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` + + +### addRecord7+ + +addRecord(record: PasteDataRecord): void + +Adds a data record to this pasteboard, and adds its type to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails. + +The pasteboard supports a maximum number of 128 data records. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | record | [PasteDataRecord](#pastedatarecord7) | Yes | Record to add. | + +- Example + + ``` + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var textRecord = pasteboard.createPlainTextRecord("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var htmlRecord = pasteboard.createHtmlTextRecord(html); + pasteData.addRecord(textRecord); + pasteData.addRecord(htmlRecord); + ``` + + +### getMimeTypes7+ + +getMimeTypes(): Array<string> + +Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this pasteboard. If the pasteboard is empty, the returned list is also empty. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | Array<string> | List of non-duplicate MIME types. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var types = pasteData.getMimeTypes(); + ``` + + +### getPrimaryMimeType7+ + +getPrimaryMimeType(): string + +Obtains the data type of the primary record. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | string | Data type of the primary record. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var type = pasteData.getPrimaryMimeType(); + ``` + + +### getProperty7+ + +getProperty(): PasteDataProperty + +Obtains the property description object. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataProperty](#pastedataproperty7) | Property description object. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var property = pasteData.getProperty(); + ``` + + +### getRecordAt7+ + +getRecordAt(index: number): PasteDataRecord + +Obtains the record with the specified index. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | index | number | Yes | Index of the specified record. | + +- Return values + | Type | Description | + | -------- | -------- | + | [PasteDataRecord](#pastedatarecord7) | Record with the specified index. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteData.getRecordAt(0); + ``` + + +### getRecordCount7+ + +getRecordCount(): number + +Obtains the number of data records in this pasteboard. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | number | Number of records. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var count = pasteData.getRecordCount(); + ``` + + +### getTag7+ + +getTag(): string + +Obtains the user-defined tag content. If the tag content is not set, null is returned. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | string | User-defined tag content if obtained and null if no tag is set. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var tag = pasteData.getTag(); + ``` + + +### hasMimeType7+ + +hasMimeType(mimeType: string): boolean + +Checks whether the content of this pasteboard contains the specified data type. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | mimeType | string | Yes | Type of the data to query. | + +- Return values + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the specified data type exists; returns **false** otherwise. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); + ``` + + +### removeRecordAt7+ + +removeRecordAt(index: number): boolean + +Removes the data record with a specified index from this pasteboard. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | index | number | Yes | Specified index. | + +- Return values + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var isRemove = pasteData.removeRecordAt(0); + ``` + + +### replaceRecordAt7+ + +replaceRecordAt(index: number, record: PasteDataRecord): boolean + +Replaces the data record with a specified index in this pasteboard. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | index | number | Yes | Specified index. | + | record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. | + +- Return values + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + var isReplace = pasteData.replaceRecordAt(0, record); + ``` + + +## pasteboard.getSystemPasteboard + +getSystemPasteboard(): SystemPasteboard + +Obtains the system pasteboard. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | [SystemPasteboard](#systempasteboard) | System pasteboard. | + +- Example + + ``` + var systemPasteboard = pasteboard.getSystemPasteboard(); + ``` + + +## SystemPasteboard + + Before calling any **SystemPasteboard** method, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard). + +``` +var systemPasteboard = pasteboard.getSystemPasteboard(); +``` + + +### setPasteData + +setPasteData(data:PasteData, callback:AsyncCallback<void>): void + +Writes data to a pasteboard. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | data | [PasteData](#pastedata) | Yes | **PasteData** object. | + | callback | AsyncCallback<void> | Yes | Callback used to return the data write result. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("content"); + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.setPasteData(pasteData, (error, data) => { + if (error) { + console.error('Failed to setPasteData. Cause: ' + error.message); + return; + } + console.info('setPasteData successfully.'); + }); + ``` + + +### setPasteData + +setPasteData(data:PasteData): Promise<void> + +Writes data to a pasteboard. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Description | + | -------- | -------- | -------- | + | data | [PasteData](#pastedata) | **PasteData** object. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the data write result. | + +- Example + + ``` + var pasteData = pasteboard.createPlainTextData("content"); + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.setPasteData(pasteData).then((data) => { + console.info('setPasteData success.'); + }).catch((error) => { + console.error('Failed to setPasteData. Cause: ' + error.message); + }); + ``` + + +### getPasteData + +getPasteData( callback:AsyncCallback<PasteData>): void + +Reads the system pasteboard content. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[PasteData](#pastedata)> | Yes | Callback used to return the system pasteboard data. | + +- Example + + ``` + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.getPasteData((error, pasteData) => { + if (error) { + console.error('Failed to getPasteData. Cause: ' + error.message); + return; + } + var text = pasteData.getPrimaryText(); + }); + ``` + + +### getPasteData + +getPasteData(): Promise<PasteData> + +Reads the system pasteboard content. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<[PasteData](#pastedata)> | Promise used to return the system pasteboard data. | + +- Example + + ``` + var systemPasteboard = pasteboard.getSystemPasteboard(); + systemPasteboard.getPasteData().then((pasteData) => { + var text = pasteData.getPrimaryText(); + }).catch((error) => { + console.error('Failed to getPasteData. Cause: ' + error.message); + }) + ``` + + +### on('update')7+ + +on(type: 'update', callback: () =>void ): void + +Subscribes to the content change event of the system pasteboard. If the pasteboard content changes, the callback is triggered. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | + | callback | function | Yes | Callback invoked when the pasteboard content changes. | + +- Example + + ``` + var systemPasteboard = pasteboard.getSystemPasteboard(); + var listener = ()=>{ + console.info('The system pasteboard has changed'); + }; + systemPasteboard.on('update', listener); + ``` + + +### off('update')7+ + +off(type: 'update', callback? : () =>void ): void + +Unsubscribes from the system pasteboard content change event. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. | + | callback | function | No | Callback invoked when the pasteboard content changes. | + +- Example + + ``` + systemPasteboard.off('update', listener); + ``` + + +### hasPasteData7+ + +hasPasteData(callback: AsyncCallback<boolean>): void + +Checks whether the system pasteboard contains content. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. | + +- Example + + ``` + systemPasteboard.hasPasteData((err, data) => { + if (err) { + console.error('failed to hasPasteData because ' + JSON.stringify(err)); + return; + } + console.info('success hasPasteData : ' + JSON.stringify(data)); + }); + ``` + + +### hasPasteData7+ + +hasPasteData(): Promise<boolean> + +Checks whether the system pasteboard contains content. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Returns **true** if the pasteboard contains content; returns **false** otherwise. | + +- Example + + ``` + systemPasteboard.hasPasteData().then((data) => { + console.info('Operation succeeded. ' + JSON.stringify(data)); + }).catch((error) => { + console.error('failed to hasPasteData because ' + JSON.stringify(error)); + }); + ``` + + +### clear7+ + +clear(callback: AsyncCallback<void>): void + +Clears the system pasteboard content. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +- Example + + ``` + systemPasteboard.clear((err, data) => { + if (err) { + console.error('failed to clear because ' + JSON.stringify(err)); + return; + } + console.info('success clear'); + }); + ``` + + +### clear7+ + +clear(): Promise<void> + +Clears the system pasteboard content. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.Pasteboard + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. | + +- Example + + ``` + systemPasteboard.clear().then((data) => { + console.info('success clear'); + }).catch((error) => { + console.error('failed to clear because ' + JSON.stringify(error)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md new file mode 100644 index 0000000000000000000000000000000000000000..0a8f08d0210217fcf972ce30e1bdabdcc8e1ac10 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-request.md @@ -0,0 +1,971 @@ +# Upload and Download + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + + +``` +import request from '@ohos.request'; +``` + + +## Constraints + +- HTTPS is supported by default. To support HTTP, you need to add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**. + + ``` + "deviceConfig": { + "default": { + "network": { + "cleartextTraffic": true + } + ... + } + } + ``` + + +## Constants + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. | +| NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. | +| ERROR_CANNOT_RESUME7+ | number | Yes | No | Failure to resume the download due to an error. | +| ERROR_DEVICE_NOT_FOUND7+ | number | Yes | No | Failure to find a storage device such as an SD card. | +| ERROR_FILE_ALREADY_EXISTS7+ | number | Yes | No | Failure to download the file because it already exists. | +| ERROR_FILE_ERROR7+ | number | Yes | No | File operation failure. | +| ERROR_HTTP_DATA_ERROR7+ | number | Yes | No | HTTP transmission failure. | +| ERROR_INSUFFICIENT_SPACE7+ | number | Yes | No | Insufficient storage space. | +| ERROR_TOO_MANY_REDIRECTS7+ | number | Yes | No | Error caused by too many network redirections. | +| ERROR_UNHANDLED_HTTP_CODE7+ | number | Yes | No | Unidentified HTTP code. | +| ERROR_UNKNOWN7+ | number | Yes | No | Unknown error. | +| PAUSED_QUEUED_FOR_WIFI7+ | number | Yes | No | Download paused and queuing for WLAN connection, because the file size exceeds the maximum value allowed by a cellular network session. | +| PAUSED_UNKNOWN7+ | number | Yes | No | Download paused due to unknown reasons. | +| PAUSED_WAITING_FOR_NETWORK7+ | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. | +| PAUSED_WAITING_TO_RETRY7+ | number | Yes | No | Download paused and then retried. | +| SESSION_FAILED7+ | number | Yes | No | Download failure without retry. | +| SESSION_PAUSED7+ | number | Yes | No | Download paused. | +| SESSION_PENDING7+ | number | Yes | No | Download pending. | +| SESSION_RUNNING7+ | number | Yes | No | Download in progress. | +| SESSION_SUCCESSFUL7+ | number | Yes | No | Successful download. | + + +## request.upload + +upload(config: UploadConfig): Promise<UploadTask> + +Uploads files. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object. | + +- Example + + ``` + request.upload({ url: 'https://patch' }).then((data) => { + uploadTask = data; + }).catch((err) => { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + }) + ``` + + +## request.upload + +upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void + +Uploads files. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. | + | callback | AsyncCallback<[UploadTask](#uploadtask)> | No | Callback used to return the **UploadTask** object. | + +- Example + + ``` + request.upload({ url: 'https://patch' }, (err, data) => { + if (err) { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + return; + } + uploadTask = data; + }); + ``` + + +## UploadTask + +Implements file uploads. Before using a method of this class, you must obtain an **UploadTask** object. + + +### on('progress') + +on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => void): void + +Subscribes to the upload progress event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to subscribe to. The value is **progress** (upload progress). | + | callback | function | Yes | Callback for the upload progress event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uploadedSize | number | Yes | Size of the uploaded files, in KB. | + | totalSize | number | Yes | Total size of the files to upload, in KB. | + +- Example + + ``` + uploadTask.on('progress', function callback(uploadedSize, totalSize) { + console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); + } + ); + ``` + + +### on('headerReceive')7+ + +on(type: 'headerReceive', callback: (header: object) => void): void + +Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to subscribe to. The value is **headerReceive** (response header). | + | callback | function | Yes | Callback for the HTTP Response Header event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | header | object | Yes | HTTP Response Header. | + +- Example + + ``` + uploadTask.on('headerReceive', function callback(headers){ + console.info("upOnHeader headers:" + JSON.stringify(headers)); + } + ); + ``` + + +### off('progress') + +off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void + +Unsubscribes from the upload progress event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (upload progress). | + | callback | function | No | Callback for the upload progress event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | uploadedSize | number | Yes | Size of the uploaded files, in KB. | + | totalSize | number | Yes | Total size of the files to upload, in KB. | + +- Example + + ``` + uploadTask.off('progress', function callback(uploadedSize, totalSize) { + console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); + } + ); + ``` + + +### off('headerReceive')7+ + +off(type: 'headerReceive', callback?: (header: object) => void): void + +Unsubscribes from the **headerReceive** event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to unsubscribe from. The value is **headerReceive** (response header). | + | callback | function | No | Callback for the HTTP Response Header event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | header | object | Yes | HTTP Response Header. | + +- Example + + ``` + uploadTask.off('headerReceive', function callback(headers) { + console.info("upOnHeader headers:" + JSON.stringify(headers)); + } + ); + ``` + + +### remove + +remove(): Promise<boolean> + +Removes this upload task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result. If **true** is returned, the task is removed. If **false** is returned, the task fails to be removed. | + +- Example + + ``` + uploadTask.remove().then((result) => { + if (result) { + console.info('Upload task removed successfully. '); + } else { + console.error('Failed to remove the upload task. '); + } + }).catch((err) => { + console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); + }); + ``` + + +### remove + +remove(callback: AsyncCallback<boolean>): void + +Removes this upload task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Upload + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | + +- Example + + ``` + uploadTask.remove((err, result) => { + if (err) { + console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); + return; + } + if (result) { + console.info('Upload task removed successfully.'); + } else { + console.error('Failed to remove the upload task.'); + } + }); + ``` + + +## UploadConfig + +**System capability**: SystemCapability.MiscServices.Upload + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| url | string | Yes | Resource URL. | +| header | object | No | HTTP or HTTPS header added to an upload request. | +| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. | +| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. | +| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. | + + +## File + +**System capability**: SystemCapability.MiscServices.Upload + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| filename | string | No | File name in the header when **multipart** is used. | +| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. | +| uri | string | Yes | Local path for storing files.
The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example:
dataability:///com.domainname.dataability.persondata/person/10/file.txt
internal://cache/path/to/file.txt | +| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. | + + +## RequestData + +**System capability**: SystemCapability.MiscServices.Upload + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Name of a form element. | +| value | string | Yes | Value of a form element. | + + +## request.download + +download(config: DownloadConfig): Promise<DownloadTask> + +Downloads files. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<[DownloadTask](#downloadtask)> | Promise used to return the result. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { + downloadTask = data; + }).catch((err) => { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + }) + ``` + + +## request.download + +download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void + +Downloads files. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. | + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | No | Callback used to return the result. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxxx.hap', + filePath: 'xxx/xxxxx.hap'}, (err, data) => { + if (err) { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + return; + } + downloadTask = data; + }); + ``` + + +## DownloadTask + +Implements file downloads. + + +### on('progress') + +on(type: 'progress', callback:(receivedSize: number, totalSize: number) => void): void + +Subscribes to the download progress event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to subscribe to. The value is **progress** (download progress). | + | callback | function | Yes | Callback for the download progress event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | receivedSize | number | Yes | Size of the downloaded files, in KB. | + | totalSize | number | Yes | Total size of the files to download, in KB. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask.on('progress', function download_callback(receivedSize, totalSize) { + console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); + } + ); + }); + ``` + + +### off('progress') + +off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void + +Unsubscribes from the download progress event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (download progress). | + | callback | function | No | Callback for the download progress event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | receivedSize | number | Yes | Size of the downloaded files, in KB. | + | totalSize | number | Yes | Total size of the files to download, in KB. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask .off('progress', function download_callback(receivedSize, totalSize) { + console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); + } + ); + }); + ``` + + +### on('complete'|'pause'|'remove')7+ + +on(type: 'complete'|'pause'|'remove', callback:() => void): void + +Subscribes to a download event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | + | callback | function | Yes | Callback used to return the result. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask= data; + downloadTask.on('complete', function callback() { + console.info('Download task completed.'); + } + ); + }); + ``` + + +### off('complete'|'pause'|'remove')7+ + +off(type: 'complete'|'pause'|'remove', callback?:() => void): void + +Unsubscribes from the download event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Event type.
- **complete**: download task completion event.
- **pause**: download task pause event.
- **remove**: download task removal event. | + | callback | function | No | Callback used to return the result. | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + JSON.stringify(err)); + return; + } + downloadTask = data; + downloadTask.off('complete', function callback() { + console.info('Download task completed.'); + } + ); + }); + ``` + + +### on('fail')7+ + +on(type: 'fail', callback: (err: number) => void): void + +Subscribes to the download task failure event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the subscribed event. The value is **fail** (download failure). | + | callback | function | Yes | Callback for the download task failure event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask.on('fail', function callBack(err) { + console.info('Download task failed. Cause:' + err); + } + ); + }); + ``` + + +### off('fail')7+ + +off(type: 'fail', callback?: (err: number) => void): void + +Unsubscribes from the download task failure event. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to unsubscribe from. The value is **fail** (download failure). | + | callback | function | No | Callback for the download task failure event. | + + Parameters of the callback function + + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). | + +- Example + + ``` + request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { + if (err) { + console.error('Failed to request download. Cause:' + err); + return; + } + downloadTask = data; + downloadTask.off('fail', function callBack(err) { + console.info('Download task failed. Cause:' + err); + } + ); + }); + ``` + + +### remove + +remove(): Promise<boolean> + +Removes this download task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result. | + +- Example + + ``` + downloadTask.remove().then((result) => { + if (result) { + console.info('Download task removed.'); + } else { + console.error('Failed to remove the download task.'); + } + }).catch ((err) => { + console.error('Failed to remove the download task.'); + }); + ``` + + +### remove + +remove(callback: AsyncCallback<boolean>): void + +Removes this download task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the task removal result. | + +- Example + + ``` + downloadTask.remove((err, result)=>{ + if(err) { + console.error('Failed to remove the download task.'); + return; + } + if (result) { + console.info('Download task removed.'); + } else { + console.error('Failed to remove the download task.'); + } + }); + ``` + + +### query7+ + +query(): Promise<DownloadInfo> + +Queries this download task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Type | Description | + | -------- | -------- | + | Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information. | + +- Example + + ``` + downloadTask.query().then((downloadInfo) => { + console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) + }) .catch((err) => { + console.error('Failed to query the download task. Cause:' + err) + }); + ``` + + +### query7+ + +query(callback: AsyncCallback<DownloadInfo>): void + +Queries this download task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes | Callback used to return the download task information. | + +- Example + + ``` + downloadTask.query((err, downloadInfo)=>{ + if(err) { + console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); + } else { + console.info('download query success. data:'+ JSON.stringify(downloadInfo)); + } + }); + ``` + + +### queryMimeType7+ + +queryMimeType(): Promise<string> + +Queries **MimeType** of this download task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<string> | Promise used to return **MimeType** of the download task. | + +- Example + + ``` + downloadTask.queryMimeType().then((data) => { + console.info('Download task queried. Data:' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err)) + }); + ``` + + +### queryMimeType7+ + +queryMimeType(callback: AsyncCallback<string>): void; + +Queries **MimeType** of this download task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes | Callback used to return **MimeType** of the download task. | + +- Example + + ``` + downloadTask.queryMimeType((err, data)=>{ + if(err) { + console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); + } else { + console.info('Download task queried. data:' + JSON.stringify(data)); + } + }); + ``` + + +### pause7+ + +pause(): Promise<void> + +Pauses this download task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the download task pause result. | + +- Example + + ``` + downloadTask.pause().then((result) => { + if (result) { + console.info('Download task paused. '); + } else { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); + } + }).catch((err) => { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); + }); + ``` + + +### pause7+ + +pause(callback: AsyncCallback<void>): void + +Pauses this download task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +- Example + + ``` + downloadTask.pause((err, result)=>{ + if(err) { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); + return; + } + if (result) { + console.info('Download task paused. '); + } else { + console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); + } + }); + ``` + + +### resume7+ + +resume(): Promise<void> + +Resumes this download task. This method uses a promise to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. | + +- Example + + ``` + downloadTask.resume().then((result) => { + if (result) { + console.info('Download task resumed.') + } else { + console.error('Failed to resume the download task. '); + } + console.info('Download task resumed.') + }).catch((err) => { + console.error('Failed to resume the download task. Cause:' + err); + }); + ``` + + +### resume7+ + +resume(callback: AsyncCallback<void>): void + +Resumes this download task. This method uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.INTERNET + +**System capability**: SystemCapability.MiscServices.Download + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +- Example + + ``` + downloadTask.resume((err, result)=>{ + if (err) { + console.error('Failed to resume the download task. Cause:' + err); + return; + } + if (result) { + console.info('Download task resumed.'); + } else { + console.error('Failed to resume the download task.'); + } + }); + ``` + + +## DownloadConfig + +**System capability**: SystemCapability.MiscServices.Download + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| url | string | Yes | Resource URL. | +| header | object | No | HTTP or HTTPS header added to a download request. | +| enableMetered | boolean | No | Download allowed in metered connections. | +| enableRoaming | boolean | No | Download allowed on a roaming network. | +| description | string | No | Description of the download session. | +| filePath7+ | string | No | Download path. (The default path is [ERROR:Invalid link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).
- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.
- filePath:'test.txt': Files are stored in the default path.
- filePath:'workspace/': The **workspace** directory is created in the default path to store files. | +| networkType | number | No | Network type allowed for download. | +| title | string | No | Title of the download session. | + + +## DownloadInfo7+ + +**System capability**: SystemCapability.MiscServices.Download + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| downloadId | number | Yes | ID of the downloaded file. | +| failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). | +| fileName | string | Yes | Name of the downloaded file. | +| filePath | string | Yes | URI of the saved file. | +| pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). | +| status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). | +| targetURI | string | Yes | URI of the downloaded file. | +| downloadTitle | string | Yes | Title of the downloaded file. | +| downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). | +| description | string | Yes | Description of the file to download. | +| downloadedBytes | number | Yes | Size of the files downloaded (int bytes). | diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index 7af90e99d9b1b57f167acb10de07c8bffbc5875c..e5e05092630126119a870b5e8e430d62abaac43b 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,4 +1,4 @@ -Resource Management +# Resource Management > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -19,9 +19,9 @@ Obtains the **ResourceManager** object of this application. This method uses a c **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----------------------------- | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained. | **Example** ``` @@ -50,10 +50,10 @@ Obtains the **ResourceManager** object of an application. This method uses an as **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ---------------------------------------- | ---- | ----------------------------- | -| bundleName | string | Yes | Bundle name of the target application. | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| +| Name | Type | Mandatory | Description | +| ---------- | ---------------------------------------- | --------- | ---------------------------------------- | +| bundleName | string | Yes | Bundle name of the target application. | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained. | **Example** ``` @@ -71,9 +71,9 @@ Obtains the **ResourceManager** object of this application. This method uses a p **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ----------------- | -| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained. | **Example** ``` @@ -100,14 +100,14 @@ Obtains the **ResourceManager** object of an application. This method uses a pro **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | ------------- | -| bundleName | string | Yes | Bundle name of the target application.| +| Name | Type | Mandatory | Description | +| ---------- | ------ | --------- | -------------------------------------- | +| bundleName | string | Yes | Bundle name of the target application. | **Return value** -| Type | Description | -| ---------------------------------------- | ------------------ | -| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained. | **Example** ``` @@ -125,10 +125,10 @@ Enumerates the screen directions. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------------- | ---- | ---- | -| DIRECTION_VERTICAL | 0 | Portrait | -| DIRECTION_HORIZONTAL | 1 | Landscape | +| Name | Default Value | Description | +| -------------------- | ------------- | ----------- | +| DIRECTION_VERTICAL | 0 | Portrait | +| DIRECTION_HORIZONTAL | 1 | Landscape | ## DeviceType @@ -137,14 +137,14 @@ Enumerates the device types. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------------- | ---- | ---- | -| DEVICE_TYPE_PHONE | 0x00 | Mobile phone. | -| DEVICE_TYPE_TABLET | 0x01 | Tablet. | -| DEVICE_TYPE_CAR | 0x02 | Automobile. | -| DEVICE_TYPE_PC | 0x03 | Computer. | -| DEVICE_TYPE_TV | 0x04 | TV. | -| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | +| Name | Default Value | Description | +| -------------------- | ------------- | ------------- | +| DEVICE_TYPE_PHONE | 0x00 | Mobile phone. | +| DEVICE_TYPE_TABLET | 0x01 | Tablet. | +| DEVICE_TYPE_CAR | 0x02 | Automobile. | +| DEVICE_TYPE_PC | 0x03 | Computer. | +| DEVICE_TYPE_TV | 0x04 | TV. | +| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | ## ScreenDensity @@ -153,14 +153,14 @@ Enumerates the screen density types. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------- | ---- | ---------- | -| SCREEN_SDPI | 120 | Screen density with small-scale dots per inch (SDPI). | -| SCREEN_MDPI | 160 | Screen density with medium-scale dots per inch (MDPI). | -| SCREEN_LDPI | 240 | Screen density with large-scale dots per inch (LDPI). | -| SCREEN_XLDPI | 320 | Screen density with extra-large-scale dots per inch (XLDPI). | -| SCREEN_XXLDPI | 480 | Screen density with extra-extra-large-scale dots per inch (XXLDPI). | -| SCREEN_XXXLDPI | 640 | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI).| +| Name | Default Value | Description | +| -------------- | ------------- | ---------------------------------------- | +| SCREEN_SDPI | 120 | Screen density with small-scale dots per inch (SDPI). | +| SCREEN_MDPI | 160 | Screen density with medium-scale dots per inch (MDPI). | +| SCREEN_LDPI | 240 | Screen density with large-scale dots per inch (LDPI). | +| SCREEN_XLDPI | 320 | Screen density with extra-large-scale dots per inch (XLDPI). | +| SCREEN_XXLDPI | 480 | Screen density with extra-extra-large-scale dots per inch (XXLDPI). | +| SCREEN_XXXLDPI | 640 | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). | ## Configuration @@ -170,10 +170,10 @@ Defines the device configuration. **System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Readable | Writable | Description | -| --------- | ----------------------- | ---- | ---- | -------- | -| direction | [Direction](#direction) | Yes | No | Screen direction of the device.| -| locale | string | Yes | No | Current system language. | +| Name | Type | Readable | Writable | Description | +| --------- | ----------------------- | -------- | -------- | ------------------------------- | +| direction | [Direction](#direction) | Yes | No | Screen direction of the device. | +| locale | string | Yes | No | Current system language. | ## DeviceCapability @@ -183,10 +183,10 @@ Defines the device capability. **System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Readable | Writable | Description | -| ------------- | ------------------------------- | ---- | ---- | -------- | -| screenDensity | [ScreenDensity](#screendensity) | Yes | No | Screen density of the device.| -| deviceType | [DeviceType](#devicetype) | Yes | No | Type of the device. | +| Name | Type | Readable | Writable | Description | +| ------------- | ------------------------------- | -------- | -------- | ----------------------------- | +| screenDensity | [ScreenDensity](#screendensity) | Yes | No | Screen density of the device. | +| deviceType | [DeviceType](#devicetype) | Yes | No | Type of the device. | ## RawFileDescriptor8+ @@ -194,11 +194,11 @@ Defines the device capability. Defines the descriptor information of the raw file.
**System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Description | -| ------ | ------ | ------------------ | -| fd | number | Descriptor of a raw file.| -| offset | number | Offset to the start position of the raw file. | -| length | number | Length of the raw file. | +| Name | Type | Description | +| ------ | ------ | ---------------------------------------- | +| fd | number | Descriptor of a raw file. | +| offset | number | Offset to the start position of the raw file. | +| length | number | Length of the raw file. | ## ResourceManager @@ -220,10 +220,10 @@ Obtains the string corresponding to the specified resource ID. This method uses **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | --------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the string obtained.| +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<string> | Yes | Callback used to return the string obtained. | **Example** ``` @@ -248,14 +248,14 @@ Obtains the string corresponding to the specified resource ID. This method uses **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| resId | number | Yes | Resource ID.| +| Name | Type | Mandatory | Description | +| ----- | ------ | --------- | ------------ | +| resId | number | Yes | Resource ID. | **Return value** -| Type | Description | -| --------------------- | ----------- | -| Promise<string> | Promise used to return the string obtained.| +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<string> | Promise used to return the string obtained. | **Example** ``` @@ -278,10 +278,10 @@ Obtains the array of strings corresponding to the specified resource ID. This me **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the obtained array of strings.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the obtained array of strings. | **Example** ``` @@ -306,14 +306,14 @@ Obtains the array of strings corresponding to the specified resource ID. This me **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| resId | number | Yes | Resource ID.| +| Name | Type | Mandatory | Description | +| ----- | ------ | --------- | ------------ | +| resId | number | Yes | Resource ID. | **Return value** -| Type | Description | -| ---------------------------------- | ------------- | -| Promise<Array<string>> | Promise used to return the array of strings obtained.| +| Type | Description | +| ---------------------------------- | ---------------------------------------- | +| Promise<Array<string>> | Promise used to return the array of strings obtained. | **Example** ``` @@ -336,10 +336,10 @@ Obtains the content of the media file corresponding to the specified resource ID **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ------------------ | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the content of the media file obtained.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the content of the media file obtained. | **Example** ``` @@ -364,14 +364,14 @@ Obtains the content of the media file corresponding to the specified resource ID **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| resId | number | Yes | Resource ID.| +| Name | Type | Mandatory | Description | +| ----- | ------ | --------- | ------------ | +| resId | number | Yes | Resource ID. | **Return value** -| Type | Description | -| ------------------------- | -------------- | -| Promise<Uint8Array> | Promise used to return the content of the media file obtained.| +| Type | Description | +| ------------------------- | ---------------------------------------- | +| Promise<Uint8Array> | Promise used to return the content of the media file obtained. | **Example** ``` @@ -394,10 +394,10 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ------------------------ | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the Base64 code of the image obtained.| +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<string> | Yes | Callback used to return the Base64 code of the image obtained. | **Example** ``` @@ -422,14 +422,14 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| resId | number | Yes | Resource ID.| +| Name | Type | Mandatory | Description | +| ----- | ------ | --------- | ------------ | +| resId | number | Yes | Resource ID. | **Return value** -| Type | Description | -| --------------------- | -------------------- | -| Promise<string> | Promise used to return the Base64 code of the image obtained.| +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<string> | Promise used to return the Base64 code of the image obtained. | **Example** ``` @@ -452,9 +452,9 @@ Obtains the device configuration. This method uses an asynchronous callback to r **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------------- | -| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the obtained device configuration.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the obtained device configuration. | **Example** ``` @@ -479,9 +479,9 @@ Obtains the device configuration. This method uses a promise to return the resul **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ---------------- | -| Promise<[Configuration](#configuration)> | Promise used to return the device configuration.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[Configuration](#configuration)> | Promise used to return the device configuration. | **Example** ``` @@ -504,9 +504,9 @@ Obtains the device capability. This method uses an asynchronous callback to retu **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the obtained device capability.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the obtained device capability. | **Example** ``` @@ -531,9 +531,9 @@ Obtains the device capability. This method uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ------------------- | -| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability. | **Example** ``` @@ -556,11 +556,11 @@ Obtains the specified number of singular-plural strings corresponding to the spe **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ------------------------------- | -| resId | number | Yes | Resource ID. | -| num | number | Yes | Number that determines the plural or singular form. | -| callback | AsyncCallback<string> | Yes | Callback used to return the singular-plural string obtained.| +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| num | number | Yes | Number that determines the plural or singular form. | +| callback | AsyncCallback<string> | Yes | Callback used to return the singular-plural string obtained. | **Example** ``` @@ -585,15 +585,15 @@ Obtains the specified number of singular-plural strings corresponding to the spe **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | ---- | ----- | -| resId | number | Yes | Resource ID.| -| num | number | Yes | Number that determines the plural or singular form. | +| Name | Type | Mandatory | Description | +| ----- | ------ | --------- | ---------------------------------------- | +| resId | number | Yes | Resource ID. | +| num | number | Yes | Number that determines the plural or singular form. | **Return value** -| Type | Description | -| --------------------- | ------------------------- | -| Promise<string> | Promise used to return the singular-plural string obtained.| +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<string> | Promise used to return the singular-plural string obtained. | **Example** ``` @@ -615,10 +615,10 @@ Obtains the content of the raw file in the specified path. This method uses an a **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ----------------------- | -| path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the raw file content, in byte arrays.| +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | --------- | ---------------------------------------- | +| path | string | Yes | Path of the raw file. | +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the raw file content, in byte arrays. | **Example** ``` @@ -642,14 +642,14 @@ Obtains the content of the raw file in the specified path. This method uses a pr **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ----------- | -| path | string | Yes | Path of the raw file.| +| Name | Type | Mandatory | Description | +| ---- | ------ | --------- | --------------------- | +| path | string | Yes | Path of the raw file. | **Return value** -| Type | Description | -| ------------------------- | ----------- | -| Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays.| +| Type | Description | +| ------------------------- | ---------------------------------------- | +| Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays. | **Example** ``` @@ -671,10 +671,10 @@ Obtains the descriptor of the raw file in the specified path. This method uses a **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | -------------------------------- | -| path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8+ ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + + +``` +import screenlock from '@ohos.screenLock'; +``` + + +## screenlock.isScreenLocked + +isScreenLocked(callback: AsyncCallback<boolean>): void + +Checks whether the screen is locked. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If **true** is returned, the screen is locked. If **false** is returned, the screen is not locked. | + +- Example + + ``` + screenlock.isScreenLocked((err, data)=>{ + if (err) { + console.error('isScreenLocked callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('isScreenLocked callback success data -> ${JSON.stringify(data)}'); + }); + ``` + + +## screenlock.isScreenLocked + +isScreenLocked(): Promise<boolean> + +Checks whether the screen is locked. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +- Return Values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return the result. | + +- Example + + ``` + screenlock.isScreenLocked().then((data) => { + console.log('isScreenLocked success: data -> ${JSON.stringify(data)}'); + }).catch((err) => { + console.error('isScreenLocked fail, promise: err -> ${JSON.stringify(err)}'); + }); + ``` + + +## screenlock.isSecureMode + +isSecureMode(callback: AsyncCallback<boolean>): void + + +Checks whether a device is in secure mode. This method uses an asynchronous callback to return the result. + + +**System capability**: SystemCapability.MiscServices.ScreenLock + + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If **true** is returned, the device is in secure mode. If **false** is returned, the device is not in secure mode. | + +- Example + + ``` + screenlock.isSecureMode((err, data)=>{ + if (err) { + console.error('isSecureMode callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('isSecureMode callback success data -> ${JSON.stringify(err)}'); + }); + ``` + + +## screenlock.isSecureMode + +isSecureMode(): Promise<boolean> + +Checks whether a device is in secure mode. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +- Return Values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return the result. | + +- Example + + ``` + screenlock.isSecureMode().then((data) => { + console.log('isSecureMode success: data->${JSON.stringify(data)}'); + }).catch((err) => { + console.error('isSecureMode fail, promise: err->${JSON.stringify(err)}'); + }); + ``` + + +## screenlock.unlockScreen + +unlockScreen(callback: AsyncCallback<void>): void + + +Unlocks the screen. This method uses an asynchronous callback to return the result. + + +**System capability**: SystemCapability.MiscServices.ScreenLock + + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | Callback function. If the callback fails, an error message is returned. | + +- Example + + ``` + screenlock.unlockScreen((err)=>{ + if (err) { + console.error('unlockScreen callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('unlockScreen callback success'); + }); + ``` + + +## screenlock.unlockScreen + +unlockScreen(): Promise<void> + +Unlocks the screen. This method uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +- Return Values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. | + +- Example + + ``` + screenlock.unlockScreen().then(() => { + console.log('unlockScreen success'); + }).catch((err) => { + console.error('unlockScreen fail, promise: err->${JSON.stringify(err)}'); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 82e50e09cfa95f0610c99d44fa4af11375a575a1..2c8e375b6123ec8d0938c1fca2823360cee823b3 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -18,8 +18,8 @@ Describes screenshot options. | Name | Type | Mandatory| Description | | ---------- | ------------- | ---- | ------------------------------------------------------------ | -| screenRect | [Rect](#Rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.| -| imageSize | [Size](#Size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.| +| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.| +| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.| | rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**.| @@ -62,7 +62,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#ScreenshotOptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| + | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | - Example @@ -102,7 +102,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro | Name | Type | Mandatory| Description | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#ScreenshotOptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| + | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| - Return value diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md index cf3f8347a415bde8aa969e6d9585d8d3f69dd643..66b51201e3e42e7c852b7f372c4d392ed543ea29 100644 --- a/en/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -126,70 +126,3 @@ Asynchronously obtains the available space of the specified volume. This method }); ``` -## storagestatistics.getBundleStats - -getBundleStats(packageName: string): Promise<BundleStats> - -Obtains the bundle status. This method uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - -- Parameters - - | Name | Type | Mandatory| Description | - | ----------- | ------ | ---- | -------- | - | packageName | string | Yes | Bundle name of the app.| - -- Return value - - | Type | Description | - | ------------------------------------------ | -------------------------- | - | Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.| - -- Example - - ```js - let packageName = ""; - storagestatistics.getBundleStats(packageName).then(function(BundleStats){ - console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); - }).catch(function(err){ - console.info("getBundleStats failed with error:"+ err); - }); - ``` - -## storagestatistics.getBundleStats - -getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void - -Obtains the bundle status. This method uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | packageName | string | Yes | Bundle name of the app.| - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the bundle status on the volume.| - -- Example - - ```js - let packageName = ""; - storagestatistics.getBundleStats(packageName, function(error, BundleStats){ - // Do something - console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); - }); - ``` - -## BundleStats9+ - -**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - -### Attributes - -| Name | Type | Description | -| --------- | ------ | -------------- | -| appSize9+ | number | Size of the app. | -| cacheSize9+ | number | Size of the cached data. | -| dataSize9+ | number | Total data size of the app.| diff --git a/en/application-dev/reference/apis/js-apis-system-sensor.md b/en/application-dev/reference/apis/js-apis-system-sensor.md index 9ed5217402da967c4557d220c14e3c2bfc0c7076..e8c267f0b0b0d584013882632f71f7faa88ed4b7 100644 --- a/en/application-dev/reference/apis/js-apis-system-sensor.md +++ b/en/application-dev/reference/apis/js-apis-system-sensor.md @@ -17,9 +17,9 @@ import sensor from '@system.sensor'; ## Error Codes - | Error Code| Description| -| -------- | -------- | -| 900 | The current device does not support the corresponding sensor.| +| Error Code | Description | +| ---------- | ---------------------------------------- | +| 900 | The current device does not support the corresponding sensor. | ## sensor.subscribeAccelerometer @@ -33,19 +33,19 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| interval | string | Yes| Execution frequency of the callback for returning the acceleration sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes| Called when the acceleration sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Execution frequency of the callback for returning the acceleration sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the acceleration sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| x | number | Acceleration on the x-axis.| -| y | number | Acceleration on the y-axis.| -| z | number | Acceleration on the z-axis.| +| Name | Type | Description | +| ---- | ------ | --------------------------- | +| x | number | Acceleration on the x-axis. | +| y | number | Acceleration on the y-axis. | +| z | number | Acceleration on the z-axis. | **Example** @@ -92,16 +92,16 @@ Subscribes to data changes of the compass sensor. If this API is called multiple **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the compass sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the compass sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| direction | number | Direction of the device, in degrees.| +| Name | Type | Description | +| --------- | ------ | ------------------------------------ | +| direction | number | Direction of the device, in degrees. | **Example** @@ -143,16 +143,16 @@ Subscribes to data changes of the proximity sensor. If this API is called multip **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the proximity sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the proximity sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| distance | number | Distance between a visible object and the device screen.| +| Name | Type | Description | +| -------- | ------ | ---------------------------------------- | +| distance | number | Distance between a visible object and the device screen. | **Example** @@ -194,16 +194,16 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the ambient light sensor data changes| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the ambient light sensor data changes | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| intensity | number | Light intensity, in lux.| +| Name | Type | Description | +| --------- | ------ | ------------------------ | +| intensity | number | Light intensity, in lux. | **Example** @@ -247,16 +247,16 @@ Subscribes to data changes of the step counter sensor. If this API is called mul **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the step counter sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the step counter sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| steps | number | Number of counted steps after the sensor is restarted.
| +| Name | Type | Description | +| ----- | ------ | ---------------------------------------- | +| steps | number | Number of counted steps after the sensor is restarted.
| **Example** @@ -301,16 +301,16 @@ Subscribes to data changes of the barometer sensor. If this API is called multip **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the barometer sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the barometer sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| pressure | number | Pressure, in pascal.| +| Name | Type | Description | +| -------- | ------ | -------------------- | +| pressure | number | Pressure, in pascal. | **Example** @@ -356,16 +356,16 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the heart rate sensor data changes. This callback is invoked every five seconds.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| heartRate | number | Heart rate.| +| Name | Type | Description | +| --------- | ------ | ----------- | +| heartRate | number | Heart rate. | **Example** @@ -410,16 +410,16 @@ Subscribes to changes of the wearing state of a wearable device. If this API is **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | Yes| Called when the wearing state changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | -------------------------------------- | +| success | Function | Yes | Called when the wearing state changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| value | boolean | Whether the wearable device is worn.| +| Name | Type | Description | +| ----- | ------- | ------------------------------------ | +| value | boolean | Whether the wearable device is worn. | **Example** @@ -461,17 +461,17 @@ Obtains the wearing state of a wearable device. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| success | Function | No| Callback upon success.| -| fail | Function | No| Callback upon failure.| -| complete | Function | No| Called when the execution is complete.| +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | -------------------------------------- | +| success | Function | No | Callback upon success. | +| fail | Function | No | Callback upon failure. | +| complete | Function | No | Called when the execution is complete. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| value | boolean | Whether the wearable device is worn.| +| Name | Type | Description | +| ----- | ------- | ------------------------------------ | +| value | boolean | Whether the wearable device is worn. | **Example** @@ -498,18 +498,18 @@ If this API is called multiple times for the same application, the last call tak **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| interval | string | Yes| Interval at which the callback is invoked to return the device orientation sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes| Called when the device orientation sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Interval at which the callback is invoked to return the device orientation sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the device orientation sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| alpha | number | Rotation angle around the Z axis when the X/Y axis of the mobile phone coincides with the X/Y axis of the earth.| -| beta | number | Rotation angle around the X axis when the Y/Z axis of the mobile phone coincides with the Y/Z axis of the earth.| -| gamma | number | Rotation angle around the Y axis when the X/Z axis of the mobile phone coincides with the X/Z axis of the earth.| +| Name | Type | Description | +| ----- | ------ | ---------------------------------------- | +| alpha | number | Rotation angle around the Z axis when the X/Y axis of the mobile device coincides with the X/Y axis of the earth. | +| beta | number | Rotation angle around the X axis when the Y/Z axis of the mobile device coincides with the Y/Z axis of the earth. | +| gamma | number | Rotation angle around the Y axis when the X/Z axis of the mobile device coincides with the X/Z axis of the earth. | **Example** @@ -558,19 +558,19 @@ If this API is called multiple times for the same application, the last call tak **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| interval | string | Yes| Interval at which the callback is invoked to return the gyroscope sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes| Called when the gyroscope sensor data changes.| -| fail | Function | No| Callback upon failure.| +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the gyroscope sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback - | Name| Type| Description| -| -------- | -------- | -------- | -| x | number | Rotation angular velocity of the X axis.| -| y | number | Rotation angular velocity of the Y axis.| -| z | number | Rotation angular velocity of the Z axis.| +| Name | Type | Description | +| ---- | ------ | ---------------------------------------- | +| x | number | Rotation angular velocity of the X axis. | +| y | number | Rotation angular velocity of the Y axis. | +| z | number | Rotation angular velocity of the Z axis. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-basic-features-timer.md b/en/application-dev/reference/apis/js-apis-timer.md similarity index 100% rename from en/application-dev/reference/apis/js-apis-basic-features-timer.md rename to en/application-dev/reference/apis/js-apis-timer.md diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index a9a417c88513e0d39dd5f6fa68892574b7a62d0b..d84b4bdcd5acbe6169c8172961f935f254f5a7d2 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -1,6 +1,6 @@ # Update -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. @@ -8,7 +8,7 @@ The Update module applies to updates throughout the entire system, including bui There are two types of updates: SD card update and over the air (OTA) update. - The SD card update depends on the update packages and SD cards. -- The OTA update depends on the server deployed by the phone manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the phone manufacturer. +- The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer. ## Modules to Import @@ -30,16 +30,16 @@ Obtains the **Updater** object for local update. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | -------- | -| upgradeFile | string | Yes | Update file.| -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.| +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | --------- | ------------ | +| upgradeFile | string | Yes | Update file. | +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | -**Return Value** +**Return value** -| Type | Description | -| ------------------- | -------- | -| [Updater](#updater) | **Updater** object.| +| Type | Description | +| ------------------- | ------------------- | +| [Updater](#updater) | **Updater** object. | **Example** @@ -61,17 +61,17 @@ Obtains the **Updater** object for the device to be updated. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | Yes | Update file. | -| device | string | Yes | Device to be updated.| -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | --------- | --------------------- | +| upgradeFile | string | Yes | Update file. | +| device | string | Yes | Device to be updated. | +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | -**Return Value** +**Return value** -| Type | Description | -| ------------------- | -------- | -| [Updater](#updater) | **Updater** object.| +| Type | Description | +| ------------------- | ------------------- | +| [Updater](#updater) | **Updater** object. | **Example** @@ -93,17 +93,17 @@ Obtains the **Updater** object from another device for the device to be updated. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | Yes | Update file. | -| device | string | Yes | Device to be updated.| -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | --------- | --------------------- | +| upgradeFile | string | Yes | Update file. | +| device | string | Yes | Device to be updated. | +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | -**Return Value** +**Return value** -| Type | Description | -| ------------------- | -------- | -| [Updater](#updater) | **Updater** object.| +| Type | Description | +| ------------------- | ------------------- | +| [Updater](#updater) | **Updater** object. | **Example** @@ -121,15 +121,15 @@ try { getNewVersionInfo(callback: AsyncCallback\): void -Obtains the new version information. This API uses an asynchronous callback to return the result. +Obtains the new version information. This function uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | ------------------ | -| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | **Example** @@ -146,15 +146,15 @@ update.getNewVersionInfo(info => { getNewVersionInfo(): Promise\ -Obtains the new version information. This API uses a promise to return the result. +Obtains the new version information. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -**Return Value** +**Return value** -| Type | Description | -| ------------------------------------------- | ------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | **Example** @@ -172,15 +172,15 @@ updater.getNewVersionInfo().then(value => { checkNewVersion(callback: AsyncCallback\): void -Checks whether the current version is the latest. This API uses an asynchronous callback to return the result. +Checks whether the current version is the latest. This function uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | **Example** @@ -197,15 +197,15 @@ update.checkNewVersion(info => { checkNewVersion(): Promise\ -Checks whether the current version is the latest. This API uses a promise to return the result. +Checks whether the current version is the latest. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -**Return Value** +**Return value** -| Type | Description | -| ------------------------------------------- | ------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| +| Type | Description | +| ---------------------------------------- | ---------------------------------------- | +| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | **Example** @@ -229,10 +229,10 @@ Verifies whether the update package is valid. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | ------ | ---- | ------------------ | -| upgradeFile | string | Yes | Path of the update package to be verified.| -| certsFile | string | Yes | Certificate path. | +| Name | Type | Mandatory | Description | +| ----------- | ------ | --------- | ---------------------------------------- | +| upgradeFile | string | Yes | Path of the update package to be verified. | +| certsFile | string | Yes | Certificate path. | **Example** @@ -247,15 +247,15 @@ update.verifyUpdatePackage("XXX", "XXX"); rebootAndCleanUserData(): Promise\ -Reboots the device and clears the user partition data. This API uses a promise to return the result. +Reboots the device and clears the user partition data. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -**Return Value** +**Return value** -| Type | Description | -| ---------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ---------------- | ---------------------------------------- | +| Promise\ | Promise used to return the execution result. | **Example** @@ -271,15 +271,15 @@ update.rebootAndCleanUserData().then(result => { rebootAndCleanUserData(callback: AsyncCallback\): void -Reboots the device and clears the user partition data. This API uses an asynchronous callback to return the result. +Reboots the device and clears the user partition data. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------- | ---- | ---------------------- | -| callback | AsyncCallback\| Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the execution result. | **Example** @@ -293,15 +293,15 @@ update.rebootAndCleanUserData(result => { applyNewVersion(): Promise\ -Installs the update package. This API uses a promise to return the result. +Installs the update package. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -**Return Value** +**Return value** -| Type | Description | -| ---------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ---------------- | ---------------------------------------- | +| Promise\ | Promise used to return the execution result. | **Example** @@ -317,15 +317,15 @@ update.applyNewVersion().then(result => { applyNewVersion(callback: AsyncCallback\): void -Installs the update package. This API uses an asynchronous callback to return the result. +Installs the update package. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------- | ---- | ---------------------- | -| callback | AsyncCallback\| Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the execution result. | **Example** @@ -356,7 +356,7 @@ updater.download(); ### upgrade -updater.upgrade():void +upgrade():void Starts an update. @@ -377,16 +377,16 @@ updater.upgrade(); setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void -Sets the update policy. This API uses an asynchronous callback to return the result. +Sets the update policy. This function uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | +| callback | Callback used to return the execution result. | Yes | Callback used to return the execution result. | **Example** @@ -408,21 +408,21 @@ update.setUpdatePolicy(policy, result => { setUpdatePolicy(policy: UpdatePolicy): Promise\ -Sets the update policy. This API uses a promise to return the result. +Sets the update policy. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| +| Name | Type | Mandatory | Description | +| ------ | ----------------------------- | --------- | --------------------- | +| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | -**Return Value** +**Return value** -| Type | Description | -| ---------------- | ----------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ---------------- | ---------------------------------------- | +| Promise\ | Promise used to return the execution result. | **Example** @@ -445,15 +445,15 @@ update.setUpdatePolicy(policy).then(result => getUpdatePolicy(callback: AsyncCallback\): void -Obtains the update policy. This API uses an asynchronous callback to return the result. +Obtains the update policy. This function uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy. | **Example** @@ -470,15 +470,15 @@ update.getUpdatePolicy(policy => { getUpdatePolicy(): Promise\ -Obtains the update policy. This API uses a promise to return the result. +Obtains the update policy. This function uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -**Return Value** +**Return value** -| Type | Description | -| --------------------------------------- | --------------------------- | -| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the result.| +| Type | Description | +| --------------------------------------- | ---------------------------------------- | +| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy. | **Example** @@ -498,10 +498,10 @@ Enumerates update types. **System capability**: SystemCapability.Update.UpdateService -| Name| Description | -| ------ | -------- | -| OTA | OTA update. | -| patch | Patch update.| +| Name | Description | +| ----- | ------------- | +| OTA | OTA update. | +| patch | Patch update. | ## PackageTypes @@ -509,15 +509,15 @@ Enumerates update package types. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value| Description | -| -------------------- | ------ | -------------- | -| PACKAGE_TYPE_NORMAL | 1 | Common update package. | -| PACKAGE_TYPE_BASE | 2 | Basic update package. | -| PACKAGE_TYPE_CUST | 3 | Custom update package. | -| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | -| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.| -| PACKAGE_TYPE_VERSION | 6 | Version update package. | -| PACKAGE_TYPE_PATCH | 7 | Patch packages | +| Name | Default Value | Description | +| -------------------- | ------------- | --------------------------------------- | +| PACKAGE_TYPE_NORMAL | 1 | Common update package. | +| PACKAGE_TYPE_BASE | 2 | Basic update package. | +| PACKAGE_TYPE_CUST | 3 | Custom update package. | +| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | +| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package. | +| PACKAGE_TYPE_VERSION | 6 | Version update package. | +| PACKAGE_TYPE_PATCH | 7 | Patch package. | ## InstallMode @@ -525,11 +525,11 @@ Enumerates update modes. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value| Description | -| ------------------- | ------ | -------- | -| INSTALL_MODE_NORMAL | 0 | Normal update.| -| INSTALL_MODE_NIGHT | 1 | Update at night.| -| INSTALL_MODE_AUTO | 2 | Automatic update.| +| Name | Default Value | Description | +| ------------------- | ------------- | ----------------- | +| INSTALL_MODE_NORMAL | 0 | Normal update. | +| INSTALL_MODE_NIGHT | 1 | Update at night. | +| INSTALL_MODE_AUTO | 2 | Automatic update. | ## NewVersionStatus @@ -537,12 +537,12 @@ Enumerates new version check results. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value| Description | -| ------------------- | ------ | ---------------- | -| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | -| VERSION_STATUS_NEW | 0 | New version detected. | -| VERSION_STATUS_NONE | 1 | No new version detected.| -| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. | +| Name | Default Value | Description | +| ------------------- | ------------- | ---------------------------------------- | +| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | +| VERSION_STATUS_NEW | 0 | New version detected. | +| VERSION_STATUS_NONE | 1 | No new version detected. | +| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. | ## UpdatePolicy @@ -550,11 +550,11 @@ Defines the update policy. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory| Description | -| ------------------- | --------------------------- | ---- | -------------- | -| autoDownload | bool | Yes | Automatic update switch. | -| installMode | [InstallMode](#installmode) | Yes | Installation mode. | -| autoUpgradeInterval | Array\ | Yes | Period of time for automatic update.| +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | --------- | ------------------------------------ | +| autoDownload | bool | Yes | Automatic update switch. | +| installMode | [InstallMode](#installmode) | Yes | Update mode. | +| autoUpgradeInterval | Array\ | Yes | Period of time for automatic update. | ## NewVersionInfo @@ -562,12 +562,12 @@ Defines the new version information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory| Description | -| --------------- | ------------------------------------------- | ---- | -------- | -| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.| -| errMsg | string | Yes | Error message.| -| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.| -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.| +| Name | Type | Mandatory | Description | +| --------------- | ---------------------------------------- | --------- | -------------------------------- | +| status | [NewVersionStatus](#newversionstatus) | Yes | Update status. | +| errMsg | string | Yes | Error message. | +| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result. | +| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information. | ## CheckResult @@ -575,14 +575,14 @@ Defines the version check result. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory| Description | -| ------------- | ----------------------------- | ---- | ------------ | -| versionName | string | Yes | Version name. | -| versionCode | number | Yes | Version code. | -| size | number | Yes | Version size. | -| verifyInfo | string | Yes | Version verification information.| -| packageType | [PackageTypes](#packagetypes) | Yes | Version type. | -| descriptionId | string | Yes | Version description information.| +| Name | Type | Mandatory | Description | +| ------------- | ----------------------------- | --------- | --------------------------------- | +| versionName | string | Yes | Version name. | +| versionCode | number | Yes | Version code. | +| size | number | Yes | Version size. | +| verifyInfo | string | Yes | Version verification information. | +| packageType | [PackageTypes](#packagetypes) | Yes | Version type. | +| descriptionId | string | Yes | Version description information. | ## DescriptionInfo @@ -590,7 +590,7 @@ Defines the version description information. **System capability**: SystemCapability.Update.UpdateService -| Name | Type| Mandatory| Description | -| ------------- | -------- | ---- | ----------------- | -| descriptionId | string | Yes | Version ID information.| -| content | string | Yes | Version changelog information.| +| Name | Type | Mandatory | Description | +| ------------- | ------ | --------- | ------------------------------ | +| descriptionId | string | Yes | Version ID information. | +| content | string | Yes | Version changelog information. | diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md deleted file mode 100644 index 0b5491d66aad03a77512c492f96b31f264b05da5..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-volumemanager.md +++ /dev/null @@ -1,179 +0,0 @@ -# Volume Management - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> -> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> - This is a system API and cannot be called by third-party applications. - -## Modules to Import - -```js -import volumemanager from "@ohos.volumeManager"; -``` - -## volumemanager.getAllVolumes9+ - -getAllVolumes(): Promise<Array<Volume>> - -Asynchronously obtains information about all available volumes. This method uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Return value - - | Type | Description | - | ---------------------------------- | -------------------------- | - | Promise<[Volume](#volume)[]> | Promise used to return the execution result.| - -- Example - - ```js - volumemanager.getAllVolumes().then(function(volumes){ - // do something - }); - ``` - -## volumemanager.getAllVolumes9+ - -getAllVolumes(callback: AsyncCallback<Array<Volume>>): void - -Asynchronously obtains information about all available volumes. This method uses a callback to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return the volume information obtained.| - -- Example - - ```js - let uuid = ""; - volumemanager.getAllVolumes(uuid, function(error, volumes){ - // do something - }); - ``` - - -## volumemanager.mount9+ - -mount(volumeId: string): Promise<boolean> - -Asynchronously mounts a volume. This method uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Parameters - - | Name | Type | Mandatory| Description| - | -------- | ------ | ---- | ---- | - | volumeId | string | Yes | Volume ID.| - -- Return value - - | Type | Description | - | ---------------------- | ---------- | - | Promise<boolean> | Promise used to return the execution result.| - -- Example - - ```js - let volumeId = ""; - volumemanager.mount(volumeId).then(function(flag){ - // do something - }); - ``` - -## volumemanager.mount9+ - -mount(volumeId: string, callback:AsyncCallback<boolean>):void - -Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | Yes | Volume ID. | - | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| - -- Example - - ```js - let volumeId = ""; - volumemanager.mount(volumeId, function(error, flag){ - // do something - }); - ``` - -## volumemanager.unmount9+ - -unmount(volumeId: string): Promise<boolean> - -Asynchronously unmounts a volume. This method uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Parameters - - | Name | Type | Mandatory| Description| - | -------- | ------ | ---- | ---- | - | volumeId | string | Yes | Volume ID.| - -- Return value - - | Type | Description | - | ---------------------- | ---------- | - | Promise<boolean> | Promise used to return the execution result.| - -- Example - - ```js - let volumeId = ""; - volumemanager.unmount(volumeId).then(function(flag){ - // do something - }); - ``` - -## volumemanager.unmount9+ - -unmount(volumeId: string, callback:AsyncCallback<boolean>):void - -Asynchronously unmounts a volume. This method uses a callback to return the result. - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -- Parameters - - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | Yes | Volume ID. | - | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| - -- Example - - ```js - let volumeId = ""; - volumemanager.unmount(volumeId, function(error, flag){ - // do something - }); - ``` - -## Volume9+ - -**System capability**: SystemCapability.FileManagement.StorageService.Volume - -### Attributes - -| Name | Type | Description | -| ----------- | ------- | -------------------- | -| id9+ | number | Volume ID. | -| uuid9+ | string | Universally unique identifier (UUID) of the volume. | -| description9+ | string | Description of the volume. | -| removable9+ | boolean | Whether the volume is a removable storage device.| -| state9+ | int | Current volume status. | -| path9+ | string | Mount address of the volume. | diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md new file mode 100644 index 0000000000000000000000000000000000000000..8f0d4aaae67090bf9335b223e6882852397a4a23 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-wallpaper.md @@ -0,0 +1,628 @@ +# Wallpaper + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + + +``` +import wallpaper from '@ohos.wallpaper'; +``` + + +## WallpaperType + +Defines the wallpaper type. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +| Name | Description | +| -------- | -------- | +| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. | +| WALLPAPER_SYSTEM | Home screen wallpaper. | + + +## wallpaper.getColors + +getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void + +Obtains the main color information of the wallpaper of a specified type. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. | + +- Example + + ``` + wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getColors because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getColors.`); + }); + ``` + + +## wallpaper.getColors + +getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> + +Obtains the main color information of the wallpaper of a specified type. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<Array<[RgbaColor](#rgbacolor)>> | Promise used to return the main color information of the wallpaper. | + +- Example + + ``` + wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getColors.`); + }).catch((error) => { + console.error(`failed to getColors because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.getId + +getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void + +Obtains the ID of the wallpaper of the specified type. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<number> | Yes | Callback used to return the wallpaper ID. If the wallpaper of the specified type is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | + +- Example + + ``` + wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getId because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getId: ` + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getId + +getId(wallpaperType: WallpaperType): Promise<number> + +Obtains the ID of the wallpaper of the specified type. + +**System capability**: SystemCapability.MiscServices.Wallpaper + + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<number> | Promise used to return the wallpaper ID. If this type of wallpaper is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. | + +- Example + + ``` + wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getId: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getId because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.getMinHeight + +getMinHeight(callback: AsyncCallback<number>): void + +Obtains the minimum height of the wallpaper. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | + +- Example + + ``` + wallpaper.getMinHeight((error, data) => { + if (error) { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinHeight: ` + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getMinHeight + +getMinHeight(): Promise<number> + +Obtains the minimum height of the wallpaper. + +**System capability**: SystemCapability.MiscServices.Wallpaper + + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<number> | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. | + +- Example + + ``` + wallpaper.getMinHeight().then((data) => { + console.log(`success to getMinHeight: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.getMinWidth + +getMinWidth(callback: AsyncCallback<number>): void + +Obtains the minimum width of the wallpaper. + +**System capability**: SystemCapability.MiscServices.Wallpaper + + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | + +- Example + + ``` + wallpaper.getMinWidth((error, data) => { + if (error) { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getMinWidth: ` + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getMinWidth + +getMinWidth(): Promise<number> + +Obtains the minimum width of the wallpaper. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<number> | Promised used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. | + +- Example + + ``` + wallpaper.getMinWidth().then((data) => { + console.log(`success to getMinWidth: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.isChangePermitted + +isChangePermitted(callback: AsyncCallback<boolean>): void + +Checks whether to allow the application to change the wallpaper for the current user. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | + +- Example + + ``` + wallpaper.isChangePermitted((error, data) => { + if (error) { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); + }); + ``` + + +## wallpaper.isChangePermitted + +isChangePermitted(): Promise<boolean> + +Checks whether to allow the application to change the wallpaper for the current user. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. | + +- Example + + ``` + wallpaper.isChangePermitted().then((data) => { + console.log(`success to isChangePermitted: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.isOperationAllowed + +isOperationAllowed(callback: AsyncCallback<boolean>): void + +Checks whether the user is allowed to set wallpapers. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | + +- Example + + ``` + wallpaper.isOperationAllowed((error, data) => { + if (error) { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); + return; + } + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); + }); + ``` + + +## wallpaper.isOperationAllowed + +isOperationAllowed(): Promise<boolean> + +Checks whether the user is allowed to set wallpapers. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | + +- Example + + ``` + wallpaper.isOperationAllowed().then((data) => { + console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.reset + +reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void + +Removes a wallpaper of the specified type and restores the default one. + +**Required permission**: ohos.permission.SET_WALLPAPER + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | + +- Example + + ``` + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to reset because: ` + JSON.stringify(error)); + return; + } + console.log(`success to reset.`); + }); + ``` + + +## wallpaper.reset + +reset(wallpaperType: WallpaperType): Promise<void> + +Removes a wallpaper of the specified type and restores the default one. + +**Required permission**: ohos.permission.SET_WALLPAPER + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | + +- Example + + ``` + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to reset.`); + }).catch((error) => { + console.error(`failed to reset because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.setWallpaper + +setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void + +Sets a specified source as the wallpaper of a specified type. + +**Required permission**: ohos.permission.SET_WALLPAPER + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | + +- Example + + ``` + //The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); + }); + + //The source type is image.PixelMap. + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + return; + } + console.log(`success to setWallpaper.`); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.setWallpaper + +setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> + +Sets a specified source as the wallpaper of a specified type. + +**Required permission**: ohos.permission.SET_WALLPAPER + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | + +- Example + + ``` + //The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); + }).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + }); + + //The source type is image.PixelMap. + import image from '@ohos.multimedia.image'; + let imageSource = image.createImageSource("file://" + wallpaperPath); + let opts = { + "desiredSize": { + "height": 3648, + "width": 2736 + } + }; + imageSource.createPixelMap(opts).then((pixelMap) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to setWallpaper.`); + }).catch((error) => { + console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); + }); + }).catch((error) => { + console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); + }); + ``` + +## wallpaper.getFile8+ + +getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void + +Obtains the wallpaper of the specified type. + +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + | callback | AsyncCallback<number> | Yes | Callback used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | + +- Example + + ``` + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getFile: ` + JSON.stringify(data)); + }); + ``` + +## wallpaper.getFile8+ + +getFile(wallpaperType: WallpaperType): Promise<number> + +Obtains the wallpaper of the specified type. + +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | + +- Return values + | Type | Description | + | -------- | -------- | + | Promise<number> | Promise used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. | + +- Example + + ``` + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getFile: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + }); + ``` + + +## wallpaper.on('colorChange') + +on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void + +Subscribes to the wallpaper color change event. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. | + | callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.
- colors
  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
  Wallpaper type. | + +- Example + + ``` + let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); + }; + wallpaper.on('colorChange', listener); + ``` + + +## wallpaper.off('colorChange') + +off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void + +Unsubscribes from the wallpaper color change event. + +**System capability**: SystemCapability.MiscServices.Wallpaper + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. | + | callback | function | No |   Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.
- colors
  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).
- wallpaperType
  Wallpaper type. | + +- Example + + ``` + let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); + }; + wallpaper.on('colorChange', listener); + // Unsubscribe from the listener. + wallpaper.off('colorChange', listener); + //Unsubscribe from all subscriptions of the colorChange type. + wallpaper.off('colorChange'); + ``` + + +## RgbaColor + +**System capability**: SystemCapability.MiscServices.Wallpaper + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. | +| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. | +| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. | +| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. | diff --git a/en/application-dev/reference/apis/js-apis-workScheduler.md b/en/application-dev/reference/apis/js-apis-workScheduler.md deleted file mode 100644 index 770f833363445e40fa738a4347ff68444125b3f6..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-workScheduler.md +++ /dev/null @@ -1,340 +0,0 @@ -# Work Scheduler - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - - -## Modules to Import - -``` -import workScheduler from '@ohos.workScheduler' -``` - -## workScheduler.startWork -startWork(work: WorkInfo): boolean - -Instructs the **WorkSchedulerService** to add the specified task to the execution queue. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---- | --------------------- | ---- | -------------- | -| work | [WorkInfo](#workinfo) | Yes | Task to be added to the execution queue.| - -**Return value** - -| Type | Description | -| ------- | -------------------------------- | -| boolean | Returns **true** if the task is added to the execution queue; returns **false** otherwise.| - -**Example** - -``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.startWork(workInfo); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.stopWork -stopWork(work: WorkInfo, needCancel?: boolean): boolean - -Instructs the **WorkSchedulerService** to stop the specified task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------- | --------------------- | ---- | ---------- | -| work | [WorkInfo](#workinfo) | Yes | Task to stop. | -| needCancel | boolean | Yes | Whether to cancel the task.| - -**Return value** - -| Type | Description | -| ------- | ----------------------- | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| - -**Example** - -``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.stopWork(workInfo, false); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.getWorkStatus -getWorkStatus(workId: number, callback : AsyncCallback\): void - -Obtains the latest task status. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | ---------------------------------------- | -| workId | number | Yes | Task ID. | -| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| - -**Example** - -``` - workScheduler.getWorkStatus(50, (err, res) => { - if (err) { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - } else { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } - } - }); -``` - -## workScheduler.getWorkStatus -getWorkStatus(workId: number): Promise\ - -Obtains the latest task status. This API uses a promise to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | -------- | -| workId | number | Yes | Task ID.| - -**Return value** - -| Type | Description | -| ------------------------------- | ---------------------------------------- | -| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| - -**Example** - -``` - workScheduler.getWorkStatus(50).then((res) => { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } - }).catch((err) => { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - }) -``` - -## workScheduler.obtainAllWorks -obtainAllWorks(callback : AsyncCallback\): Array\ - -Obtains all tasks associated with this application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | -------------------- | ---- | ------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return all tasks associated with the current application.| - -**Return value** - -| Type | Description | -| ----------------------------- | --------------- | -| Array\<[WorkInfo](#workinfo)> | All tasks associated with the current application.| - -**Example** - -``` - workScheduler.obtainAllWorks((err, res) =>{ - if (err) { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - } else { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - } - }); -``` - -## workScheduler.obtainAllWorks -obtainAllWorks(): Promise> - -Obtains all tasks associated with this application. This API uses a promise to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Return value** - -| Type | Description | -| -------------------------------------- | ------------------------------ | -| Promise> | Promise used to return all tasks associated with the current application.| - -**Example** - -``` - workScheduler.obtainAllWorks().then((res) => { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - }).catch((err) => { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - }) -``` - -## workScheduler.stopAndClearWorks -stopAndClearWorks(): boolean - -Stops and cancels all tasks associated with the current application. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Example** - -``` - let res = workScheduler.stopAndClearWorks(); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.isLastWorkTimeOut -isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean - -Checks whether the last execution of the specified task timed out. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | -------------------- | ---- | ---------------------------------------- | -| workId | number | Yes | Task ID. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Return value** - -| Type | Description | -| ------- | ---------------------------------------- | -| boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| - -**Example** - -``` - workScheduler.isLastWorkTimeOut(500, (err, res) =>{ - if (err) { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - } else { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - } - }); -``` - -## workScheduler.isLastWorkTimeOut -isLastWorkTimeOut(workId: number): Promise\ - -Checks whether the last execution of the specified task timed out. This API uses a promise to return the result. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -**Parameters** - -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | -------- | -| workId | number | Yes | Task ID.| - -**Return value** - -| Type | Description | -| ----------------- | ---------------------------------------- | -| Promise\ | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| - -**Example** - -``` - workScheduler.isLastWorkTimeOut(500) - .then(res => { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - }) - .catch(err => { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - }); -``` - -## WorkInfo -Provides detailed information about the task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -| Name | Type | Mandatory | Description | -| --------------- | --------------------------------- | ---- | ---------------- | -| workId | number | Yes | Task ID. | -| bundleName | string | Yes | Name of the Work Scheduler task bundle. | -| abilityName | string | Yes | Name of the component to be notified by a Work Scheduler callback.| -| networkType | [NetworkType](#networktype) | No | Network type. | -| isCharging | boolean | No | Whether the device is charging. | -| chargerType | [ChargingType](#chargingtype) | No | Charging type. | -| batteryLevel | number | No | Battery level. | -| batteryStatus | [BatteryStatus](#batterystatus) | No | Battery status. | -| storageRequest | [StorageRequest](#storagerequest) | No | Storage status. | -| isRepeat | boolean | No | Whether the task is repeated. | -| repeatCycleTime | number | No | Repeat interval. | -| repeatCount | number | No | Number of repeat times. | - -## NetworkType -Enumerates the network types that can trigger the task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -| Name | Default Value | Description | -| ---------------------- | ---- | ----------------------- | -| NETWORK_TYPE_ANY | 0 | Any network type. | -| NETWORK_TYPE_MOBILE | 1 | Mobile network. | -| NETWORK_TYPE_WIFI | 2 | Wi-Fi network. | -| NETWORK_TYPE_BLUETOOTH | 3 | Bluetooth network.| -| NETWORK_TYPE_WIFI_P2P | 4 | Wi-Fi P2P network. | -| NETWORK_TYPE_ETHERNET | 5 | Ethernet. | - -## ChargingType -Enumerates the charging types that can trigger the task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -| Name | Default Value | Description | -| ------------------------- | ---- | -------------------- | -| CHARGING_PLUGGED_ANY | 0 | Any charging type.| -| CHARGING_PLUGGED_AC | 1 | DC charging. | -| CHARGING_PLUGGED_USB | 2 | USB charging. | -| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. | - -## BatteryStatus -Enumerates the battery status that can trigger the task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - -| Name | Default Value | Description | -| -------------------------- | ---- | -------------------------- | -| BATTERY_STATUS_LOW | 0 | A low battery alert is displayed. | -| BATTERY_STATUS_OKAY | 1 | The battery level is restored from low to normal. | -| BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.| - -## StorageRequest -Enumerates the storage status that can trigger the task. - -**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - - |Name |Default Value |Description| - | -------- | -------- | -------- | - |STORAGE_LEVEL_LOW |0 |The storage space is insufficient. - |STORAGE_LEVEL_OKAY |1 |The storage space is restored from insufficient to normal. - |STORAGE_LEVEL_LOW_OR_OKAY |2 |The storage space is restored from insufficient to normal, or the storage space is insufficient. diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index 8c0dd7f96ee0f57ad2e542760f552313e3fca391..f0b0e7b6c9d76f3380dd78f21c92108c969f9e77 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -1,7 +1,7 @@ -# TypeScript-based Declarative Development Paradigm +# JavaScript-based Web-like Development Paradigm -- [Components](js-components.md) - - [Common](js-components-common.md) +- Components + - Common - [Universal Attributes](js-components-common-attributes.md) - [Universal Styles](js-components-common-styles.md) - [Universal Events](js-components-common-events.md) @@ -13,7 +13,7 @@ - [Custom Font Styles](js-components-common-customizing-font.md) - [Atomic Layout](js-components-common-atomic-layout.md) - - [Container Component](js-components-container.md) + - Container Component - [badge](js-components-container-badge.md) - [dialog](js-components-container-dialog.md) - [div](js-components-container-div.md) @@ -32,7 +32,7 @@ - [tab-bar](js-components-container-tab-bar.md) - [tab-content](js-components-container-tab-content.md) - - [Basic Components](js-components-basic.md) + - Basic Components - [button](js-components-basic-button.md) - [chart](js-components-basic-chart.md) - [divider](js-components-basic-divider.md) @@ -60,11 +60,12 @@ - [toolbar](js-components-basic-toolbar.md) - [toolbar-item](js-components-basic-toolbar-item.md) - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) - - [Media Components](js-components-media.md) + - Media Components - [video](js-components-media-video.md) - - [Canvas Components](js-components-canvas.md) + - Canvas Components - [canvas](js-components-canvas-canvas.md) - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) - [Image](js-components-canvas-image.md) @@ -75,13 +76,13 @@ - [OffscreenCanvas](js-components-canvas-offscreencanvas.md) - [OffscreenCanvasRenderingContext2D](js-offscreencanvasrenderingcontext2d.md) - - [Grid](js-components-grid.md) + - Grid - [Basic Concepts](js-components-grid-basic-concepts.md) - [grid-container](js-components-grid-container.md) - [grid-row](js-components-grid-row.md) - [grid-col](js-components-grid-col.md) - - [SVG Components](js-svg.md) + - SVG Components - [Universal Attributes](js-components-svg-common-attributes.md) - [svg](js-components-svg.md) - [rect](js-components-svg-rect.md) @@ -98,14 +99,12 @@ - [animateMotion](js-components-svg-animatemotion.md) - [animateTransform](js-components-svg-animatetransform.md) -- [Custom Components](js-components-custom.md) +- Custom Components - [Basic Usage](js-components-custom-basic-usage.md) - [Custom Events](js-components-custom-events.md) - [props](js-components-custom-props.md) - [Event Parameter](js-components-custom-event-parameter.md) - [slot](js-components-custom-slot.md) - [Lifecycle Definition](js-components-custom-lifecycle.md) - -- [Appendix](js-appendix.md) - - [Type Attributes](js-appendix-types.md) +- [Type Attributes](js-appendix-types.md) diff --git a/en/application-dev/reference/arkui-js/figures/1-9.png b/en/application-dev/reference/arkui-js/figures/1-9.png index 5e7bc3dec11daa00059d3ec93d77ac15ce357a14..3d74a346c8d9d41efbef3f0f2feb12b19fc90a94 100644 Binary files a/en/application-dev/reference/arkui-js/figures/1-9.png and b/en/application-dev/reference/arkui-js/figures/1-9.png differ diff --git a/en/application-dev/reference/arkui-js/figures/3.png b/en/application-dev/reference/arkui-js/figures/3.png index b370937f36a472829e7a08a4439b4025721b0437..495f967777f91ce6e654c278683807ef6560809c 100644 Binary files a/en/application-dev/reference/arkui-js/figures/3.png and b/en/application-dev/reference/arkui-js/figures/3.png differ diff --git a/en/application-dev/reference/arkui-js/figures/c3.png b/en/application-dev/reference/arkui-js/figures/c3.png deleted file mode 100644 index dca96aeb057ba12dc63365e613007e54dd268a40..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/c3.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png b/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png deleted file mode 100644 index 70aa78c1973add7bf07ec822d905c1bc98cb47f9..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/example.gif b/en/application-dev/reference/arkui-js/figures/example.gif new file mode 100644 index 0000000000000000000000000000000000000000..00f9ce6746501edad918bda726b3e143991189fc Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/example.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/gif.gif b/en/application-dev/reference/arkui-js/figures/gif.gif deleted file mode 100644 index 98bf461673a8f11366755e99b8f59baf7cc282e8..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/gif.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/js-appendix.md b/en/application-dev/reference/arkui-js/js-appendix.md deleted file mode 100644 index 6d1c2b0cd7139cbca7d215f877151c782a75327a..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-js/js-appendix.md +++ /dev/null @@ -1,5 +0,0 @@ -# Appendix - -- **[Type Attributes](js-appendix-types.md)** - - diff --git a/en/application-dev/reference/arkui-js/js-components-basic-button.md b/en/application-dev/reference/arkui-js/js-components-basic-button.md index 0e3cd7fe5e0f3ff9f43ebb0c45dad2676de730d4..771a5a55404f5bccfab8350837e74dc049bdc298 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-button.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-button.md @@ -32,7 +32,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

No

Dynamic modification is not supported. If this attribute is not set, capsule-like buttons are displayed. Different from the capsule button, the four rounded corners of a capsule-like button can be configured using border-radius. Available button types are as follows:

-
  • capsule: a capsule button with fillets, background color, and text
  • circle: a circle button which can be used to place icons
  • text: a text button which displays the text only
  • arc: an arc button. This value is applicable to wearables only.
  • download: a download button. The download progress bar is added. This value is applicable to smart TVs and smartphones.
+
  • capsule: a capsule button with fillets, background color, and text
  • circle: a circle button which can be used to place icons
  • text: a text button which displays the text only
  • arc: an arc button. This value is applicable to wearables only.
  • download: a download button. The download progress bar is added.

value

diff --git a/en/application-dev/reference/arkui-js/js-components-basic-chart.md b/en/application-dev/reference/arkui-js/js-components-basic-chart.md index cfb8ae34e6ea898ca580e58a0ac7ebcd7a16569c..c635eb624433b2333a8a912a531cf457912c8f9e 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-chart.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-chart.md @@ -72,7 +72,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

Data structures used by progress, loading, and rainbow charts.

DataSegment is available for progress and loading charts.

Array<DataSegment> is available for rainbow charts. A maximum of nine DataSegment are supported in the array.

-
NOTE:

This attribute is only supported on phones and tablets.

+

@@ -85,7 +85,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

No

Whether to enable the effects for progress and rainbow charts.

-
NOTE:

This attribute is only supported on phones and tablets.

+

@@ -98,7 +98,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

No

Animation duration for expanding a rainbow chart, in milliseconds.

-
NOTE:

This attribute is only supported on phones and tablets.

+

diff --git a/en/application-dev/reference/arkui-js/js-components-basic-image.md b/en/application-dev/reference/arkui-js/js-components-basic-image.md index a2b12f6effff89978040365e49b0ee16c8084433..2afd0a80fce71b2d7cbc3b8f756e57e3eb8ce303 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-image.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-image.md @@ -202,7 +202,7 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported. ```
- + - - - - - -
-
- ``` - - ``` - // xxx.js - export default { - data: { - count: 0 - }, - increase() { - this.count++; - }, - decrease() { - this.count--; - }, - multiply(multiplier) { - this.count = multiplier * this.count; - } - }; - ``` - - ``` - /* xxx.css */ - .container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 454px; - height: 454px; - } - .title { - font-size: 30px; - text-align: center; - width: 200px; - height: 100px; - } - .box { - width: 454px; - height: 200px; - justify-content: center; - align-items: center; - flex-wrap: wrap; - } - .btn { - width: 200px; - border-radius: 0; - margin-top: 10px; - margin-left: 10px; +- funcName: name of the event callback, which is implemented by defining the corresponding function in the .js file. + +- funcName(a,b): function parameters, such as a and b, which can be constants, or variables defined in data in the .js file. Do not add the prefix this. to variables. + +- Example + + ``` + +
+ {{count}} +
+ + + + + + +
+
+ ``` + + + ``` + // xxx.js + export default { + data: { + count: 0 + }, + increase() { + this.count++; + }, + decrease() { + this.count--; + }, + multiply(multiplier) { + this.count = multiplier * this.count; } - ``` + }; + ``` + + + ``` + /* xxx.css */ + .container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; + } + .title { + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; + } + .box { + width: 454px; + height: 200px; + justify-content: center; + align-items: center; + flex-wrap: wrap; + } + .btn { + width: 200px; + border-radius: 0; + margin-top: 10px; + margin-left: 10px; + } + ``` -## Bubbling Event Binding5+ +## Bubbling Event Binding5+ Bubbling event binding covers the following: -- Bind an event callback for event bubbling: **on:\{event\}.bubble**. **on:\{event\}** is equivalent to **on:\{event\}.bubble**. -- Bind an event callback, but stop the event from bubbling upwards: **grab:\{event\}.bubble**. **grab:\{event\}** is equivalent to **grab:\{event\}.bubble**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details about bubbling events, see [Universal Events](../reference/arkui-js/js-components-common-events.md). - - -- Example - - ``` - -
- -
-
- -
-
- -
-
- -
-
-
- ``` - - ``` - // xxx.js - export default { - clickfunc: function(e) { - console.log(e); - }, - touchstartfuc: function(e) { - console.log(e); - }, - } - ``` +- Bind an event callback for event bubbling: on:{event}.bubble. on:{event} is equivalent to on:{event}.bubble. + +- Bind an event callback, but stop the event from bubbling upwards: grab:{event}.bubble. grab:{event} is equivalent to grab:{event}.bubble. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: + > For details about bubbling events, see [Universal Events](../reference/arkui-js/js-components-common-events.md) + +- Example + + ``` + +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Events bound using a traditional statement \(such as **onclick**\) will bubble only when the API version in use is 6 or later. + ``` + // xxx.js + export default { + clickfunc: function(e) { + console.log(e); + }, + touchstartfuc: function(e) { + console.log(e); + }, + } + ``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> Events bound using a traditional statement (such as onclick) will bubble only when the API version in use is 6 or later. -## Capturing Event Binding5+ +## Capturing Event Binding5+ Touch events can be captured. In the capture phase, which precedes the bubbling phase, an event starts from the parent component to the child component. Event capturing binding includes: -- Bind an event callback for event capturing: **on:\{event\}.capture**. -- Bind an event callback, but stop the event from being captured during downward transfer: **grab:\{event\}.capture**. - -- Example - - ``` - -
- -
- -
-
- ``` - - ``` - // xxx.js - export default { - touchstartfuc: function(e) { - console.log(e); - }, - } - ``` +- Bind an event callback for event capturing: on:{event}.capture. +- Bind an event callback, but stop the event from being captured during downward transfer: grab:{event}.capture. + +- Example + + ``` + +
+
+ +
+
+ ``` + + + ``` + // xxx.js + export default { + touchstartfuc: function(e) { + console.log(e); + }, + } + ``` + + +## Loop Rendering -## Loop Rendering ``` @@ -216,6 +228,7 @@ Event capturing binding includes:
``` + ``` // xxx.js export default { @@ -235,36 +248,43 @@ export default { } ``` -The **tid** attribute accelerates the **for** loop and improves the re-rendering efficiency when data in a loop changes. +The tid attribute accelerates the for loop and improves the re-rendering efficiency when data in a loop changes. + +The tid attribute specifies the unique ID of each element in the array. If it is not specified, the index of each element in the array is used as the ID. For example, tid="id" indicates that the id attribute of each element is its unique ID. -The **tid** attribute specifies the unique ID of each element in the array. If it is not specified, the index of each element in the array is used as the ID. For example, **tid="id"** indicates that the **id** attribute of each element is its unique ID. +The for loop supports the following statements: -The **for** loop supports the following statements: +- for="array": array is an array object, whose element variable is $item by default. -- for="array": **array** is an array object, whose element variable is **$item** by default. -- for="v in array": **v** is a custom element variable, whose index is **$idx** by default. -- for="\(i, v\) in array": **i** indicates the element index, and **v** indicates the element variable. All elements of the array object will be looped through. +- for="v in array": v is a custom element variable, whose index is $idx by default. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- Each element in the array must have the data attribute specified by **tid**. Otherwise, an exception may occur. ->- The attribute specified by **tid** in the array must be unique. Otherwise, performance loss occurs. In the above example, only **id** and **name** can be used as **tid** because they are unique fields. ->- The **tid** field does not support expressions. +- for="(i, v) in array": i indicates the element index, and v indicates the element variable. All elements of the array object will be looped through. -## Conditional Rendering +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - Each element in the array must have the data attribute specified by tid. Otherwise, an exception may occur. +> +> - The attribute specified by tid in the array must be unique. Otherwise, performance loss occurs. In the above example, only id and name can be used as tid because they are unique fields. +> +> - The tid field does not support expressions. + + +## Conditional Rendering + +There are two ways to implement conditional rendering: if-elif-else or show. In if-elif-else, when the if statement evaluates to false, the component is not built in the VDOM and is not rendered. For show, when show is false, the component is not rendered but is built in the VDOM. In addition, the if-elif-else statements must be used in sibling nodes. Otherwise, the compilation fails. The following example uses both ways to implement conditional rendering: -There are two ways to implement conditional rendering: **if-elif-else** or **show**. In **if-elif-else**, when the **if** statement evaluates to **false**, the component is not built in the VDOM and is not rendered. For **show**, when show is **false**, the component is not rendered but is built in the VDOM. In addition, the **if-elif-else** statements must be used in sibling nodes. Otherwise, the compilation fails. The following example uses both ways to implement conditional rendering: ```
- Hello-TV - Hello-Wearable + Hello-World1 + Hello-World2 Hello-World
``` + ``` /* xxx.css */ .container{ @@ -278,6 +298,7 @@ There are two ways to implement conditional rendering: **if-elif-else** or ** } ``` + ``` // xxx.js export default { @@ -294,7 +315,8 @@ export default { } ``` -In the optimized rendering \(**show**\), if **show** is **true**, the node is rendered properly; if it is **false**, the display style will be **none**. +In the optimized rendering (show), if show is true, the node is rendered properly; if it is false, the display style will be none. + ``` @@ -304,6 +326,7 @@ In the optimized rendering \(**show**\), if **show** is **true**, the node is
``` + ``` /* xxx.css */ .container{ @@ -317,6 +340,7 @@ In the optimized rendering \(**show**\), if **show** is **true**, the node is } ``` + ``` // xxx.js export default { @@ -329,12 +353,13 @@ export default { } ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Do not use **for** and **if** attributes at the same time in an element. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> Do not use for and if attributes at the same time in an element. + +## Logic Control Block -## Logic Control Block + makes loop rendering and conditional rendering more flexible. A will not be compiled as a real component. **NOTE** that the tag supports only the for and if attributes. -**** makes loop rendering and conditional rendering more flexible. A **** will not be compiled as a real component. Note that the **** tag supports only the **for** and **if** attributes. ``` @@ -352,6 +377,7 @@ export default { ``` + ``` // xxx.js export default { @@ -364,9 +390,10 @@ export default { } ``` -## Template Reference +## Template Reference + +HML supports using elements to reference template files. For details, see Custom Components. -HML supports using elements to reference template files. For details, see [Custom Components](../reference/arkui-js/js-components-custom.md). ``` @@ -376,6 +403,7 @@ HML supports using elements to reference template files. For details, see [Cust
``` + ``` @@ -383,4 +411,3 @@ HML supports using elements to reference template files. For details, see [Cust
``` - diff --git a/en/application-dev/ui/js-framework-syntax-js.md b/en/application-dev/ui/js-framework-syntax-js.md index 9742330e0e9f05f1e15d6f901edceb2937e91cf5..6651a84e33a77efe6020a087a830150b3d71f783 100644 --- a/en/application-dev/ui/js-framework-syntax-js.md +++ b/en/application-dev/ui/js-framework-syntax-js.md @@ -1,449 +1,234 @@ -# JavaScript +# JavaScript -You can use a **.js** file to define the service logic of an HML page. The JS UI framework supports the JavaScript language that conforms to the ECMAScript specification. With dynamic typing, JavaScript can make your application more expressive with a flexible design. The following describes the JavaScript compilation and running. -## Syntax +You can use a .js file in the ECMAScript compliant JavaScript language to define the service logic of an HML page. With dynamic typing, JavaScript can make your application more expressive with a flexible design. The following describes the JavaScript compilation and running. -The ES6 syntax is supported. -- **Module declaration** +## Syntax - Import functionality modules. +The ES6 syntax is supported. - ``` - import router from '@system.router'; - ``` +- Module declaration + Import functionality modules. -- **Code reference** + + ``` + import router from '@system.router'; + ``` - Import JavaScript code. +- Code reference + Import JavaScript code. - ``` - import utils from '../../common/utils.js'; - ``` + + ``` + import utils from '../../common/utils.js'; + ``` -## Objects +## Objects -- **Application Object** +- Application Object + | Attribute | Type | Description | + | -------- | -------- | -------- | + | $def | Object | Object that is exposed in the app.js file and obtained by this.$app.$def.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> Application objects do not support data binding. Data update should be triggered on the UI. | - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

$def

-

Object

-

Object that is exposed in the app.js file and obtained by this.$app.$def.

-
NOTE:

Application objects do not support data binding. Data update should be triggered on the UI.

-
-
+ Example Code - Example Code - - ``` - // app.js - export default { - onCreate() { - console.info('Application onCreate'); - }, - onDestroy() { - console.info('Application onDestroy'); - }, - globalData: { - appData: 'appData', - appVersion: '2.0', - }, - globalMethod() { - console.info('This is a global method!'); - this.globalData.appVersion = '3.0'; - } - }; - ``` - - ``` - // index.js - export default { - data: { - appData: 'localData', - appVersion:'1.0', - }, - onInit() { - this.appData = this.$app.$def.globalData.appData; - this.appVersion = this.$app.$def.globalData.appVersion; - }, - invokeGlobalMethod() { - this.$app.$def.globalMethod(); - }, - getAppVersion() { - this.appVersion = this.$app.$def.globalData.appVersion; - } + + ``` + // app.js + export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, + globalData: { + appData: 'appData', + appVersion: '2.0', + }, + globalMethod() { + console.info('This is a global method!'); + this.globalData.appVersion = '3.0'; } - ``` - -- **Page objects** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

data

-

Object/Function

-

Data model of the page. If the attribute is of the function type, the return value must be of the object type. The attribute name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid).

-

Do not use this attribute and private or public at the same time.

-

$refs

-

Object

-

DOM elements or child component instances that have registered the ref attribute. For example code, see Obtaining a DOM element.

-

private

-

Object

-

Data model of the page. Private data attribute can be modified only on the current page.

-

public

-

Object

-

Data model of the page. Behaviors of public data attributes are the same as those of the data attribute.

-

props

-

Array/Object

-

Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions. For details, see Custom Components.

-

computed

-

Object

-

Used for pre-processing an object for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words. For details, see Custom Components.

-
- - -## Functions - -- **Data functions** - - - - - - - - - - - - - - - - -

Function

-

Parameter

-

Description

-

$set

-

key: string, value: any

-

Adds an attribute or modifies an existing attribute.

-

Usage:

-

this.$set('key',value): Add an attribute.

-

$delete

-

key: string

-

Deletes an attribute.

-

Usage:

-

this.$delete('key'): Delete an attribute.

-
- - Example Code - - ``` - export default { - data: { - keyMap: { - OS: 'OpenHarmony', - Version: '2.0', - }, - }, - getAppVersion() { - this.$set('keyMap.Version', '3.0'); - console.info("keyMap.Version = " + this.keyMap.Version); // keyMap.Version = 3.0 - - this.$delete('keyMap'); - console.info("keyMap.Version = " + this.keyMap); // log print: keyMap.Version = undefined - } + }; + ``` + + + ``` + // index.js + export default { + data: { + appData: 'localData', + appVersion:'1.0', + }, + onInit() { + this.appData = this.$app.$def.globalData.appData; + this.appVersion = this.$app.$def.globalData.appVersion; + }, + invokeGlobalMethod() { + this.$app.$def.globalMethod(); + }, + getAppVersion() { + this.appVersion = this.$app.$def.globalData.appVersion; } - ``` - -- **Public functions** - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function

-

Parameter

-

Description

-

$element

-

id: string

-

Obtains the component with a specified ID. If no ID is specified, the root component is returned. For example code, see Obtaining a DOM element.

-

Usage:

-

<div id='xxx'></div>

-
  • this.$element('xxx'): Obtain the component whose ID is xxx.
  • this.$element(): Obtain the root component.
-

$rootElement

-

None

-

Obtains the root element.

-

Usage: this.$rootElement().scrollTo({ duration: 500, position: 300 }), which scrolls the page by 300 px within 500 ms.

-

$root

-

N/A

-

Obtains the root ViewModel instance. For example code, see Obtaining the ViewModel.

-

$parent

-

N/A

-

Obtains the parent ViewModel instance. For example code, see Obtaining the ViewModel.

-

$child

-

id: string

-

Obtains the ViewModel instance of a custom child component with a specified ID. For example code, see Obtaining the ViewModel.

-

Usage:

-

this.$child('xxx'): Obtain the ViewModel instance of a custom child component whose ID is xxx.

-
- -- **Event function** - - - - - - - - - - - - -

Function

-

Parameter

-

Description

-

$watch

-

data: string, callback: string | Function

-

Listens for attribute changes. If the value of the data attribute changes, the bound event is triggered. For details, see Custom Components.

-

Usage:

-

this.$watch('key', callback)

-
- -- **Page function** - - - - - - - - - - - - -

Function

-

Parameter

-

Description

-

scrollTo6+

-

scrollPageParam: ScrollPageParam

-

Scrolls the page to the target position. You can specify the position using the ID selector or scrolling distance.

-
- - **Table 1** ScrollPageParam6+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

position

-

number

-

-

-

Position to scroll to.

-

id

-

string

-

-

-

ID of the element to be scrolled to.

-

duration

-

number

-

300

-

Scrolling duration, in milliseconds.

-

timingFunction

-

string

-

ease

-

Animation curve for scrolling. Available option:

-

animation-timing-function

-

complete

-

() => void

-

-

-

Callback to be invoked when the scrolling is complete.

-
- - Example: - - ``` - this.$rootElement.scrollTo({position: 0}) - this.$rootElement.scrollTo({id: 'id', duration: 200, timingFunction: 'ease-in', complete: ()=>void}) - ``` - - -## Obtaining a DOM Element - -1. Use **$refs** to obtain a DOM element. - - ``` - -
- -
- ``` - - ``` - // index.js - export default { - data: { - images: [ - { src: '/common/frame1.png' }, - { src: '/common/frame2.png' }, - { src: '/common/frame3.png' }, - ], - }, - handleClick() { - const animator = this.$refs.animator; // Obtain the DOM element whose $refs attribute is animator. - const state = animator.getState(); - if (state === 'paused') { - animator.resume(); - } else if (state === 'stopped') { - animator.start(); - } else { - animator.pause(); - } - }, - }; - ``` - -2. Call **$element** to obtain a DOM element. - - ``` - -
- -
- ``` - - ``` - // index.js - export default { - data: { - images: [ - { src: '/common/frame1.png' }, - { src: '/common/frame2.png' }, - { src: '/common/frame3.png' }, - ], - }, - handleClick() { - const animator = this.$element('animator'); // Obtain the DOM element whose ID is animator. - const state = animator.getState(); - if (state === 'paused') { - animator.resume(); - } else if (state === 'stopped') { - animator.start(); - } else { - animator.pause(); - } + } + ``` + +- Page objects + | Attribute | Type | Description | + | -------- | -------- | -------- | + | data | Object/Function | Data model of the page. If the attribute is of the function type, the return value must be of the object type. The attribute name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid).
Do not use this attribute and private or public at the same time. | + | $refs | Object | DOM elements or child component instances that have registered the ref attribute. For example code, see [Obtaining a DOM element](#obtaining-a-dom-element). | + | private | Object | Data model of the page. Private data attribute can be modified only on the current page. | + | public | Object | Data model of the page. Behaviors of public data attributes are the same as those of the data attribute. | + | props | Array/Object | Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions. For details, see [Custom Component](../reference/arkui-js/js-components-custom-props.md). | + | computed | Object | Used for pre-processing an object for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words. For details, see [Custom Component](../reference/arkui-js/js-components-custom-props.md). | + +## Functions + +- Data functions + | Function | Parameter | Description | + | -------- | -------- | -------- | + | $set | key: string, value: any | Adds an attribute or modifies an existing attribute.
Usage:
this.$set('_key_',_value_): Add an attribute. | + | $delete | key: string | Deletes an attribute.
Usage:
this.$delete('_key_'): Delete an attribute. | + + Example Code + + + ``` + // index.js + export default { + data: { + keyMap: { + OS: 'OpenHarmony', + Version: '2.0', }, - }; - ``` - - -## Obtaining the ViewModel + }, + getAppVersion() { + this.$set('keyMap.Version', '3.0'); + console.info("keyMap.Version = " + this.keyMap.Version); // keyMap.Version = 3.0 + + this.$delete('keyMap'); + console.info("keyMap.Version = " + this.keyMap); // log print: keyMap.Version = undefined + } + } + ``` + +- Public functions + | Function | Parameter | Description | + | -------- | -------- | -------- | + | $element | id: string | Obtains the component with a specified ID. If no ID is specified, the root component is returned. For example code, see [Obtaining a DOM element](#obtaining-a-dom-element).
Usage:
```
```
- this.$element('_xxx_'): Obtain the component whose ID is _xxx_.
- this.$element(): Obtain the root component. | + | $rootElement | None | Obtains the root element.
Usage: this.$rootElement().scrollTo({ duration: 500, position: 300 }), which scrolls the page by 300 px within 500 ms. | + | $root | N/A | Obtains the root ViewModel instance. For example code, see [Obtaining the ViewModel](#obtaining-the-viewmodel). | + | $parent | N/A | Obtains the parent ViewModel instance. For example code, see [Obtaining the ViewModel](#obtaining-the-viewmodel). | + | $child | id: string | Obtains the ViewModel instance of a custom child component with a specified ID. For example code, see [Obtaining the ViewModel](#obtaining-the-viewmodel).
Usage:
this.$child('_xxx_'): Obtain the ViewModel instance of a custom child component whose ID is _xxx_. | + +- Event function + | Function | Parameter | Description | + | -------- | -------- | -------- | + | $watch | data: string, callback: string \| Function | Listens for attribute changes. If the value of the data attribute changes, the bound event is triggered. For details, see [Custom Component](../reference/arkui-js/js-components-custom-props.md)
Usage:
this.$watch('_key_',_callback_) | + +- Page function + | Function | Parameter | Description | + | -------- | -------- | -------- | + | scrollTo6+ | scrollPageParam: ScrollPageParam | Scrolls the page to the target position. You can specify the position using the ID selector or scrolling distance. | + + Table1 ScrollPageParam6+ + + | Name | Type | Default Value | Description | + | -------- | -------- | -------- | -------- | + | position | number | - | Position to scroll to. | + | id | string | - | ID of the element to be scrolled to. | + | duration | number | 300 | Scrolling duration, in milliseconds. | + | timingFunction | string | ease | Animation curve for scrolling. Available option:
[Animation Styles](../reference/arkui-js/js-components-common-animation.md) | + | complete | () => void | - | Callback to be invoked when the scrolling is complete. | + + Example: + + + ``` + this.$rootElement.scrollTo({position: 0}) + this.$rootElement.scrollTo({id: 'id', duration: 200, timingFunction: 'ease-in', complete: ()=>void}) + ``` + + +## Obtaining a DOM Element + +1. Use $refs to obtain a DOM element. + + ``` + +
+ +
+ ``` + + + ``` + // index.js + export default { + data: { + images: [ + { src: '/common/frame1.png' }, + { src: '/common/frame2.png' }, + { src: '/common/frame3.png' }, + ], + }, + handleClick() { + const animator = this.$refs.animator; // Obtain the DOM element whose $refs attribute is animator. + const state = animator.getState(); + if (state === 'paused') { + animator.resume(); + } else if (state === 'stopped') { + animator.start(); + } else { + animator.pause(); + } + }, + }; + ``` + +2. Call $element to obtain a DOM element. + + ``` + +
+ +
+ ``` + + + ``` + // index.js + export default { + data: { + images: [ + { src: '/common/frame1.png' }, + { src: '/common/frame2.png' }, + { src: '/common/frame3.png' }, + ], + }, + handleClick() { + const animator = this.$element('animator'); // Obtain the DOM element whose ID is animator. + const state = animator.getState(); + if (state === 'paused') { + animator.resume(); + } else if (state === 'stopped') { + animator.start(); + } else { + animator.pause(); + } + }, + }; + ``` + +## Obtaining the ViewModel The following shows files of the root page: + ``` @@ -455,6 +240,7 @@ The following shows files of the root page:
``` + ``` // root.js export default { @@ -466,6 +252,7 @@ export default { Customize the parent component. + ``` @@ -476,6 +263,7 @@ Customize the parent component. ``` + ``` // parent.js export default { @@ -495,6 +283,7 @@ export default { Customize the child component. + ```
@@ -503,6 +292,7 @@ Customize the child component.
``` + ``` // child.js export default { @@ -519,4 +309,3 @@ export default { }, } ``` - diff --git a/en/application-dev/ui/js-framework-syntax.md b/en/application-dev/ui/js-framework-syntax.md deleted file mode 100644 index 9ba136648a707eb0b4970f2e0d9a9b7b55bc2794..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/js-framework-syntax.md +++ /dev/null @@ -1,9 +0,0 @@ -# Syntax - -- **[HML](js-framework-syntax-hml.md)** - -- **[CSS](js-framework-syntax-css.md)** - -- **[JavaScript](js-framework-syntax-js.md)** - - diff --git a/en/application-dev/ui/js-framework.md b/en/application-dev/ui/js-framework.md deleted file mode 100644 index 9747766bd040881d19b537c7eb77159e4f1be265..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/js-framework.md +++ /dev/null @@ -1,17 +0,0 @@ -# Framework - -- **[File Organization](js-framework-file.md)** - -- **["js" Tag](js-framework-js-tag.md)** - -- **[app.js](js-framework-js-file.md)** - -- **[Syntax](js-framework-syntax.md)** - -- **[Lifecycle](js-framework-lifecycle.md)** - -- **[Resource Limitations and Access](js-framework-resource-restriction.md)** - -- **[Multi-Language Capability](js-framework-multiple-languages.md)** - - diff --git a/en/application-dev/ui/ts-a-deep-dive-into-component.md b/en/application-dev/ui/ts-a-deep-dive-into-component.md deleted file mode 100644 index cc95c1bae6dbfe8e1078c086953e39f85ada01bb..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-a-deep-dive-into-component.md +++ /dev/null @@ -1,11 +0,0 @@ -# About @Component - -- **[build Function](ts-function-build.md)** - -- **[Custom Component Initialization](ts-custom-component-initialization.md)** - -- **[Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md)** - -- **[Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md)** - - diff --git a/en/application-dev/ui/ts-application-resource-access.md b/en/application-dev/ui/ts-application-resource-access.md index 1dbba18d4a78462127eb07f69c3306dd02d4d946..33dee0468c7905ea10d202e347dbb937a2ad2137 100644 --- a/en/application-dev/ui/ts-application-resource-access.md +++ b/en/application-dev/ui/ts-application-resource-access.md @@ -3,35 +3,35 @@ ## Resource Definition -Application resources are defined by in the project's **resources** directory, which is organized as follows: +Application resources are defined by in the project's resources directory, which is organized as follows: -- Level-1: **base** sub-directory, qualifiers sub-directories, and **rawfile** sub-directory - - 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. +- Level-1: base sub-directory, qualifiers sub-directories, and rawfile sub-directory + - 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. - You need to create qualifiers sub-directories on your own. 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, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-). - - When the resources in the **rawfile** sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the **rawfile** sub-directory. + - When the resources in the rawfile sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the rawfile sub-directory. - Level-2: resource sub-directories - Resource sub-directories store basic elements such as character strings, colors, and floating point numbers, and resource files such as media files. - Supported files and resource types are listed in the table below: - | File Name | Resource Type | + | File Name | Resource Type | | -------- | -------- | - | color.json | Color resource. | - | float.json | Resources such as spacing, rounded corners, and fonts. | - | string.json | String resource. | - | plural.json | String resource. | - | media directory | Image resource. | + | color.json | Color resource. | + | float.json | Resources such as spacing, rounded corners, and fonts. | + | string.json | String resource. | + | plural.json | String resource. | + | media directory | Image resource. | ## Referencing 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. +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. Currently, **$rawfile** allows only the **<Image>** component to reference image resources. In the format, **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash (/). +When referencing resources in the rawfile sub-directory, use the "$rawfile('filename')" format. Currently, $rawfile allows only the component to reference image resources. In the format, filename indicates the relative path of a file in the rawfile directory, and the file name must contain the file name extension. **NOTE** that the relative path cannot start with a slash (/). ## Example -Some custom resources in the **base** sub-directory are as follows: +Some custom resources in the base sub-directory are as follows: ``` @@ -49,7 +49,7 @@ Some custom resources in the **base** sub-directory are as follows: └─ newTest.png ``` -The content of the **color.json** file is as follows: +The content of the color.json file is as follows: ``` @@ -67,7 +67,7 @@ The content of the **color.json** file is as follows: } ``` -The content of the **float.json** file is as follows: +The content of the float.json file is as follows: ``` @@ -85,7 +85,7 @@ The content of the **float.json** file is as follows: } ``` -The content of the **string.json** file is as follows: +The content of the string.json file is as follows: ``` @@ -107,7 +107,7 @@ The content of the **string.json** file is as follows: } ``` -The content of the **plural.json** file is as follows: +The content of the plural.json file is as follows: ``` @@ -130,7 +130,7 @@ The content of the **plural.json** file is as follows: } ``` - In the **ets** file, you can use the resources defined in the **resources** directory. + In the ets file, you can use the resources defined in the resources directory. ``` Text($r('app.string.string_hello')) diff --git a/en/application-dev/ui/ts-application-states-apis-environment.md b/en/application-dev/ui/ts-application-states-apis-environment.md index 69e62557dfa01f19e884799ddfb9d66b39d39ddc..112e98bf561287ca283406e1bfad3c964cadb809 100644 --- a/en/application-dev/ui/ts-application-states-apis-environment.md +++ b/en/application-dev/ui/ts-application-states-apis-environment.md @@ -1,118 +1,35 @@ -# Environment +# Environment + + +Environment is a singleton object created by the framework when the application is started. It provides the AppStorage with a series of environment state attributes required by the application. These attributes describe the device environment where the application runs. Environment and its attributes are immutable, and all attribute values are of the simple type. The following example shows how to obtain the semantic environment from Environment: -**Environment** is a singleton object created by the framework when the application is started. It provides the **AppStorage** with a series of environment state attributes required by the application. These attributes describe the device environment where the application runs. **Environment** and its attributes are immutable, and all attribute values are of the simple type. -The following example shows how to obtain the voice environment from **Environment**: ``` Environment.EnvProp("accessibilityEnabled", "default"); -var enable = AppStorageGet("accessibilityEnabled"); +var enable = AppStorage.Get("accessibilityEnabled"); ``` -**accessibilityEnabled** is the default system variable identifier provided by **Environment**. You need to bind the corresponding system attribute to the **AppStorage**. Then, you can use the methods or decorators in the **AppStorage** to access the corresponding system attribute data. -## Environment APIs +accessibilityEnabled is the default system variable identifier provided by Environment. You need to bind the corresponding system attribute to the AppStorage. Then, you can use the methods or decorators in the AppStorage to access the corresponding system attribute data. + + +## Environment APIs - - - - - - - - - - - - - - - - - - - - - - - -

key

-

Parameter

-

Return Value

-

Description

-

EnvProp

-

key : string

-

defaultValue: any

-

boolean

-

Associates this system variable to the Appstorage. You are advised to use this API during application startup. If the attribute already exists in the Appstorage, false is returned. Do not use the variables in the AppStorage. Instead, call this method to bind environment variables.

-

EnvProps

-

keys: {

-

key: string,

-

defaultValue: any

-

}[]

-

void

-

Associates this system item array with the Appstorage.

-

Keys

-

Array<string>

-

number

-

Returns the associated system item array.

-
+| key | Parameter | Return Value | Description | +| -------- | -------- | -------- | -------- | +| EnvProp | key: string,
defaultValue: any | boolean | Binds this system attribute to the AppStorage. You are advised to use this API during application startup. If the attribute already exists in the AppStorage, false is returned. Do not use the variables in the AppStorage. Instead, call this method to bind environment variables. | +| EnvProps | keys: {
key: string,
defaultValue: any
}[] | void | Associates this system item array with the AppStorage. | +| Keys | Array<string> | number | Returns the associated system item array. | -## Built-in Environment Variables - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

key

-

Type

-

Description

-

accessibilityEnabled

-

boolean

-

Whether to enable accessibility.

-

colorMode

-

ColorMode

-

Color mode. The options are as follows:

-
  • ColorMode.LIGHT: light mode.
  • ColorMode.DARK: dark mode.
-

fontScale

-

number

-

Font scale. The value range is [0.85, 1.45].

-

fontWeightScale

-

number

-

Font weight scale. The value range is [0.6, 1.6].

-

layoutDirection

-

LayoutDirection

-

Layout direction. The options are as follows:

-
  • LayoutDirection.LTR: The direction is from left to right.
  • LayoutDirection.RTL: The direction is from right to left.
-

languageCode

-

string

-

Current system language. The value is in lowercase, for example, zh.

-
+## Built-in Environment Variables + | key | Type | Description | +| -------- | -------- | -------- | +| accessibilityEnabled | boolean | Whether to enable accessibility. | +| colorMode | ColorMode | Color mode. The options are as follows:
- ColorMode.LIGHT: light mode.
- ColorMode.DARK: dark mode. | +| fontScale | number | Font scale. The value range is [0.85, 1.45]. | +| fontWeightScale | number | Font weight scale. The value range is [0.6, 1.6]. | +| layoutDirection | LayoutDirection | Layout direction. The options are as follows:
- LayoutDirection.LTR: The direction is from left to right.
- LayoutDirection.RTL: The direction is from right to left. | +| languageCode | string | Current system language. The value is in lowercase, for example, zh. | diff --git a/en/application-dev/ui/ts-application-states-apis-persistentstorage.md b/en/application-dev/ui/ts-application-states-apis-persistentstorage.md index 0d4215b5f06b1e85a4e5c4437d15e9167627f2e1..c776ed015e030c72c0f7be251e7c95d224810872 100644 --- a/en/application-dev/ui/ts-application-states-apis-persistentstorage.md +++ b/en/application-dev/ui/ts-application-states-apis-persistentstorage.md @@ -1,69 +1,23 @@ -# PersistentStorage +# PersistentStorage -**PersistentStorage** is used to manage persistent data of applications. This object can link the persistent data of a specific flag to the **AppStorage** and access the persistent data through the **AppStorage** APIs or access the variable of the corresponding key through the **@StorageLink** decorator. -## PersistentStorage APIs +ArkUI provides some static methods in the PersistentStorage class for managing persistent data of applications. Persistent data with specific tags can be linked to the AppStorage, and then the persistent data can be accessed through the AppStorage APIs. Alternatively, the @StorageLink decorator can be used to access the variable of the specific key. + + +| Name | Type | Return Value | Definition | +| -------- | -------- | -------- | -------- | +| PersistProp | key : string
defaultValue: T | void | Changes the associated named attribute to persistent data in the AppStorage. The value overwriting sequence is as follows:
- If the attribute exists in the AppStorage, use it to overwrite the value in Persistent.
- If Persistent contains the specified attribute, use the attribute value in Persistent.
- If the preceding conditions are not met, use defaultValue. The values null and undefined are not supported. | +| DeleteProp | key: string | void | Cancels two-way binding. The value of this attribute will be deleted from the persistent storage. | +| PersistProps | keys: {
key: string,
defaultValue: any
}[] | void | Associates multiple named attribute bindings. | +| Keys | void | Array <string> | Returns the flags of all persistent attributes. | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - When using PersistProp, ensure that the input key exists in the AppStorage. +> +> - DeleteProp takes effect only for the data that has been linked during the current startup. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Return Value

-

Definition

-

PersistProp

-

key : string

-

defaultValue: T

-

void

-

Changes associated named attribute to persistent data in the AppStorage. Value overwriting sequence:

-

If the attribute exists in the AppStorage, overwrite its value with the attribute value in Persistent.

-

If Persistent contains the specified attribute, use the attribute value in Persistent.

-

If the preceding conditions are not met, use defaultValue. The null and undefined values are not supported.

-

DeleteProp

-

key: string

-

void

-

Cancels two-way binding. The value of this attribute will be deleted from the persistent storage.

-

PersistProps

-

keys: {

-

key: string,

-

defaultValue: any

-

}[]

-

void

-

Associates multiple named attribute bindings.

-

Keys

-

void

-

Array<string>

-

Returns the flags of all persistent attributes.

-
->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When using **PersistProp**, ensure that the input key exists in the **Appstorage**. ->- **DeleteProp** takes effect only for the data that has been linked during the current startup. ``` PersistentStorage.PersistProp("highScore", "0"); @@ -91,4 +45,3 @@ struct PersistentComponent { } } ``` - diff --git a/en/application-dev/ui/ts-application-states-appstorage.md b/en/application-dev/ui/ts-application-states-appstorage.md index 9dfac0e2e52fcf1df995cb7e8cb0875d4065d9cb..1f5f3b09bfa92962cb764bce02a6ad7768aab2cb 100644 --- a/en/application-dev/ui/ts-application-states-appstorage.md +++ b/en/application-dev/ui/ts-application-states-appstorage.md @@ -1,153 +1,93 @@ -# AppStorage - -**AppStorage** is a singleton object in an application and is created by the UI framework when the application is started. It is designed to provide central storage for changing application state attributes. **AppStorage** contains all the state attributes that need to be accessed throughout the application. The **AppStorage** retains all attributes and their values as long as the application remains running, and the attribute values can be accessed through unique key values. - -The UI component can synchronize the application state data with the **AppStorage** through the decorators. The application service logic can also be implemented by accessing the **AppStorage** through APIs. - -The selection state attribute of the **AppStorage** can be synchronized with different data sources or data sinks. These data sources and data sinks can be local or remote devices and provide different functions, such as data persistence. Such data sources and data sinks can be implemented independently of the UI in the service logic. - -By default, the attributes in the **AppStorage** are changeable. If needed, **AppStorage** can also use immutable \(read-only\) attributes. - -## AppStorage APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Return Value

-

Definition

-

Link

-

key: string

-

@Link

-

Returns the two-way binding to this attribute if there is data with a given key. This means that changes made to the data by a variable or component will be synchronized to the AppStorage, and changes made to the data by the AppStorage will be synchronized to the variable or component. If the attribute with this key does not exist or is read-only, undefined is returned.

-

SetAndLink

-

key : String

-

defaultValue: T

-

@Link

-

Works in a way similar to the Link API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Link instance corresponding to the default value is created and returned.

-

Prop

-

key: string

-

@Prop

-

Returns one-way binding to an attribute with a given key if the attribute exists. This one-way binding means that changes to the attribute can only be synchronized to variables or components through AppStorage. The variable returned by this method is an immutable one, which is applicable both to the variable and immutable state attributes. If the attribute with this key does not exist, undefined is returned.

-
NOTE:

The attribute value type used in the prop method must be of a simple type.

-
-

SetAndProp

-

key : string

-

defaultValue: S

-

@Prop

-

Works in a way similar to the Prop API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Prop instance corresponding to the default value is created and returned.

-

Has

-

key: string

-

boolean

-

Checks whether the attribute corresponding to the key value exists.

-

Keys

-

void

-

array<string>

-

Returns an array of strings containing all keys.

-

Get

-

string

-

T or undefined

-

Obtains the value of the key.

-

Set

-

string, newValue : T

-

void

-

Replaces the value of a saved key.

-

SetOrCreate

-

string, newValue : T

-

boolean

-

Returns true if an attribute with the same name exists and the attribute can be modified; returns false otherwise.

-

If the attribute with the same name does not exist: the first attribute whose value is the defaultValue is created and returned. The null and undefined values are not supported.

-

Delete

-

key : string

-

boolean

-

Deletes an attribute. If the attribute exists, true is returned. Otherwise, false is returned.

-

Clear

-

none

-

boolean

-

Deletes all attributes. If any of the attributes is being referenced by a state variable, false is returned.

-

IsMutable

-

key: string

-
  

Specifies whether the attribute exists and can be changed.

-
- ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Currently, the API can process only basic data and cannot modify a value in an object. - -## Example +# AppStorage + + +AppStorage is a singleton object in an application, which is created by the UI framework when the application is started and destroyed when the application exits. It is used to provide central storage for changing state attributes of an application. AppStorage contains all the state attributes that need to be accessed throughout the application. The AppStorage retains all attributes and their values as long as the application remains running, and the attribute values can be accessed through unique key values. + + +The UI component can synchronize the application state data with the AppStorage through the decorators. The application service logic can also be implemented by accessing the AppStorage through APIs. + + +The selection state attribute of the AppStorage can be synchronized with different data sources or data sinks. These data sources and data sinks can be local or remote devices and provide different functions, such as data persistence. Such data sources and data sinks can be implemented independently of the UI in the service logic. + + +By default, the attributes in the AppStorage are changeable. If needed, AppStorage can also use immutable (read-only) attributes. + + +## AppStorage APIs + +| Name | Type | Return Value | Definition | +| -------- | -------- | -------- | -------- | +| SetAndLink | key: string,
defaultValue: T | @Link | Works in a way similar to the Link API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Link instance corresponding to the default value is created and returned. | +| Set | key: string,
newValue: T | void | Replaces the value of a saved key. | +| Link | key: string | @Link | Returns two-way binding to this attribute if there is data with a given key. This means that attribute changes made by a variable or component will be synchronized to the AppStorage, and attribute changes made through the AppStorage will be synchronized to the variable or component. If the attribute with this key does not exist or is read-only, undefined is returned. | +| SetAndProp | propName: string,
defaultValue: S | @Prop | Works in a way similar to the Prop API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Prop instance corresponding to the default value is created and returned. | +| Prop | key: string | @Prop | Returns one-way binding to an attribute with a given key if the attribute exists. This means that attribute changes made through the AppStorage will be synchronized to the variable or component, but attribute changes made by the variable or component will be synchronized to the AppStorage. The variable returned by this method is an immutable one, which is applicable both to the variable and immutable state attributes. If the attribute with the specified key does not exist, undefined is returned.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> The attribute value used in the prop method must be of a simple type. | +| SetOrCreate | key: string,
newValue: T | boolean | If an attribute that has the same name as the specified key exists: replaces the value of the attribute and returns true when the attribute can be modified; retains the original value of the attribute and returns false otherwise.
If an attribute that has the same name as the specified key does not exist: creates an attribute whose key is key and value is newValue. The values null and undefined are not supported. | +| Get | key: string | T or undefined | Obtains the value of the specified key. | +| Has | propName: string | boolean | Checks whether the attribute corresponding to the specified key value exists. | +| Keys | void | array<string> | Returns an array of strings containing all keys. | +| Delete | key: string | boolean | Deletes the key-value pair for the specified key. Returns true if the key-value pair exists and is successfully deleted; returns false otherwise. | +| Clear | void | boolean | Deletes all attributes. If any of the attributes is being referenced by a state variable, false is returned. | +| IsMutable | key: string | boolean | Specifies whether the attribute exists and can be changed. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> Currently, the API can process only basic data and cannot modify a value in an object. + + +## Synchronization Between AppStorage and Components + +In [Managing Component States](ts-component-states-state.md), we have defined how to synchronize the state variables of child components with the @State decorated variables in the parent component or ancestor component, including @Prop, @Link, and @Consume. + +In this section, we'll describe how to synchronize component variables with the AppStorage through the @StorageLink and @StorageProp decorators. + + +### @StorageLink Decorator + +Two-way data binding can be established between components and the AppStorage through state variables decorated by @StorageLink(_key_). Wherein, key is the attribute key value in the AppStorage. When a component containing the @StorageLink decorated variable is created, the variable is initialized using the value in the AppStorage. Changes made to this variable in the component will be first synchronized to the AppStorage, and then to other bound instances, such as PersistentStorage or other bound UI components. + + +### @StorageProp Decorator + +One-way data binding can be established between components and the AppStorage through state variables decorated by @StorageProp(_key_). Wherein, key is the attribute key value in the AppStorage. When a component containing the @StorageProp decorated variable is created, the variable is initialized using the value in the AppStorage. Changes made to the value in the AppStorage will cause the bound UI component to update the state. + + +## Example + ``` -let link1 = AppStorage.Link('PropA') -let link2 = AppStorage.Link('PropA') -let prop = AppStorage.Prop('PropA') +let varA = AppStorage.Link('varA') +let envLang = AppStorage.Prop('languageCode') + +@Entry +@Component +struct ComponentA { + @StorageLink('varA') varA: number = 2 + @StorageProp('languageCode') lang: string = 'en' + private label: string = 'count' + + private aboutToAppear() { + this.label = (this.lang === 'en') ? 'Number' : 'Count' + } + + build() { + Row({ space: 20 }) { -link1 = 47 // causes link1 == link2 == prop == 47 -link2 = link1 + prop // causes link1 == link2 == prop == 94 -prop = 1 // error, prop is immutable + Button(`${this.label}: ${this.varA}`) + .onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1) + }) + Button(`lang: ${this.lang}`) + .onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en') + } else { + AppStorage.Set('languageCode', 'en') + } + this.label = (this.lang === 'en') ? 'Number' : 'Count' + }) + } + } +} ``` +Each time the user clicks the Count button, the value of this.varA will increase by 1. This variable is synchronized with varA in the AppStorage. Each time the user clicks the language icon, the value of languageCode in the AppStorage will be changed, and the change will be synchronized to the this.lang variable. diff --git a/en/application-dev/ui/ts-attribution-configuration.md b/en/application-dev/ui/ts-attribution-configuration.md index f1ff930d90b2cd8574526fad963ab8085e4e02a7..d1d00d17eb3b607f830959df35d37c12ad6ee040 100644 --- a/en/application-dev/ui/ts-attribution-configuration.md +++ b/en/application-dev/ui/ts-attribution-configuration.md @@ -1,46 +1,41 @@ -# Attribution Configuration +# Attribute Configuration -Use attribute methods to configure component attributes. An attribute method follows the corresponding component and is bound to the component using the "**.**" operator. -The following is an example of configuring the **fontsize** attribute of the **** component: +Use attribute methods to configure component attributes. An attribute method follows the corresponding component and is bound to the component using the "." operator. -``` -Text('123') - .fontSize(12) -``` -You can also use the "**.**" operation to implement chain call to configure multiple attributes at the same time. +- The following is an example of configuring the font size attribute of the Text component: + + ``` + Text('123') + .fontSize(12) + ``` -Below is the sample code for configuring the **width** and **height** attributes of the **** component at the same time: -``` -Image('a.jpg') - .alt('error.jpg') - .width(100) - .height(100) -``` +- Use the "." operator to implement chain call to configure multiple attributes at the same time, as shown below: + + ``` + Image('a.jpg') + .alt('error.jpg') .width(100) .height(100) + ``` -In addition to constants, you can also pass variables or expressions, as shown below: -``` -// Size, count, and offset are private variables defined in the component. -Text('hello') - .fontSize(this.size) -Image('a.jpg') - .width(this.count % 2 === 0 ? 100 : 200) - .height(this.offset + 100) -``` +- In addition to constants, you can also pass variables or expressions, as shown below: + + ``` + // Size, count, and offset are private variables defined in the component. + Text('hello') + .fontSize(this.size) + Image('a.jpg') + .width(this.count % 2 === 0 ? 100 : 200) .height(this.offset + 100) + ``` -For attributes of preset components, the framework also provides some predefined enumeration types, which you can pass as parameters to methods. - -Enumeration types must meet the parameter type requirements on the enumeration type definitions for specific attributes. - -You can configure the font color and weight attributes of the **** component as follows: - -``` -Text('hello') - .fontSize(20) - .fontColor(Color.Red) - .fontWeight(FontWeight.Bold) -``` +- For attributes of preset components, the framework also provides some predefined enumeration types, which you can pass as parameters to methods. Enumeration types must meet the parameter type requirements on the enumeration type definitions for specific attributes. You can configure the font color and weight attributes of the Text component as follows: + + ``` + Text('hello') + .fontSize(20) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bold) + ``` diff --git a/en/application-dev/ui/ts-child-component-configuration.md b/en/application-dev/ui/ts-child-component-configuration.md index 4d8d82427410ae6c037445446eecdbff94cc9d47..61fb05beeaab30c6a2828bd318b034db58197025 100644 --- a/en/application-dev/ui/ts-child-component-configuration.md +++ b/en/application-dev/ui/ts-child-component-configuration.md @@ -1,47 +1,49 @@ -# Child Component Configuration +# Child Component Configuration -For a component that supports child components, for example, a container component, add the UI descriptions of the child components inside "**\{ ... \}**". The ****, ****, ****, ****, ****, and **** components are container components. -The following is a simple example of the **** component: +For a component that supports child components, for example, a container component, add the UI descriptions of the child components inside "{ ... }". The <Column>, <Row>, <Stack>, <Button>, <Grid>, and <List> components are container components. -``` -Column() { - Text('Hello') - .fontSize(100) - Divider() - Text(this.myText) - .fontSize(100) - .fontColor(Color.Red) -} -``` -Multiple child components can be nested in the **** component, as shown below: +- The following is a simple example of the <Column> component: + + ``` + Column() { + Text('Hello') + .fontSize(100) + Divider() + Text(this.myText) + .fontSize(100) + .fontColor(Color.Red) + } + ``` -``` -Column() { - Column() { - Button() { - Text('+ 1') - }.type(ButtonType.Capsule) - .onClick(() => console.log ('+1 clicked!')) - Image('1.jpg') - } - Divider() - Column() { - Button() { - Text('+ 2') - }.type(ButtonType.Capsule) - .onClick(() => console.log ('+2 clicked!')) - Image('2.jpg') - } - Divider() - Column() { - Button() { - Text('+ 3') - }.type(ButtonType.Capsule) - .onClick(() => console.log('+3 clicked!')) - Image('3.jpg') - } -}.alignItems(HorizontalAlign.Center) // center align components inside Column -``` +- Multiple child components can be nested in the <Column> component, as shown below: + + ``` + Column() { + Column() { + Button() { + Text('+ 1') + }.type(ButtonType.Capsule) + .onClick(() => console.log ('+1 clicked!')) + Image('1.jpg') + } + Divider() + Column() { + Button() { + Text('+ 2') + }.type(ButtonType.Capsule) + .onClick(() => console.log ('+2 clicked!')) + Image('2.jpg') + } + Divider() + Column() { + Button() { + Text('+ 3') + }.type(ButtonType.Capsule) + .onClick(() => console.log('+3 clicked!')) + Image('3.jpg') + } + }.alignItems(HorizontalAlign.Center) // center align components inside Column + ``` diff --git a/en/application-dev/ui/ts-component-based-builder.md b/en/application-dev/ui/ts-component-based-builder.md index ca33d875afd237420c4856665c2bcd4736828f4d..94e75620e5a4d9c1f24cb7c0325d6f852017f797 100644 --- a/en/application-dev/ui/ts-component-based-builder.md +++ b/en/application-dev/ui/ts-component-based-builder.md @@ -1,8 +1,9 @@ -# @Builder +# @Builder + + +The @Builder decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the @Builder decorator are the same as those of the [build Function](ts-function-build.md). -The **@Builder** decorator defines a method for rendering custom components It allows a method to work in the same way as the [build](ts-function-build.md) function. The syntax of methods decorated by **@Builder** is the same as that of the **build** function. -You can use the **@Builder** decorator to quickly generate multiple layouts within a custom component. ``` @Entry @@ -42,3 +43,99 @@ struct CompA { } ``` +## @BuilderParam8+ + +The @BuilderParam decorator is used to modify the function type attributes (for example, @BuilderParam content: () => any) in a custom component. When the custom component is initialized, the attributes modified by the @BuilderParam decorator must be assigned values. + +### Background + +In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component can add the function to all places where the component is initialized. This is where the @BuilderParam decorator come into the picture. When initializing a custom component, you can assign a @Builder decorated method to the @BuilderParam decorated attribute, thereby adding the specific function to the custom component. + +### Component Initialization Through Parameters + +When initializing a custom component through parameters, assign a @Builder decorated method to the @BuilderParam decorated attribute —content, and call the value of content in the custom component. + +``` +@Component +struct CustomContainer { + header: string = ""; + @BuilderParam content: () => any; + footer: string = ""; + build() { + Column() { + Text(this.header) + .fontSize(50) + this.content() + Text(this.footer) + .fontSize(50) + } + } +} + +@Entry +@Component +struct CustomContainerUser { + @Builder specificParam(label: string) { + Column() { + Text(label).fontSize(50) + } + } + + build() { + Column() { + CustomContainer({ + header: "Header", + content: this.specificParam("111") + footer: "Footer", + }) + } + } +} +``` + +### Component Initialization Through Trailing Closure + +In a custom component, use the @BuilderParam decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (CustomComponent(){}). You can consider a trailing closure as a container and add content to it. For example, you can add a component ({Column(){Text("content")}) to the closure. The syntax of the closure is the same as that of [build](ts-function-build.md). In this scenario, the custom component has one and only one @BuilderParam decorated attribute. + +Example: Add a <Column> component and a click event to the closure, and call the specificParam method decorated by @Builder in the new <Column> component. After the <Column> component is clicked, the value of the component's header attribute will be changed to changeHeader. In addition, when the component is initialized, the content of the trailing closure will be assigned to the closer attribute decorated by @BuilderParam. + +``` +@Component +struct CustomContainer { + header: string = ""; + @BuilderParam closer: () => any; + 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/en/application-dev/ui/ts-component-based-component.md b/en/application-dev/ui/ts-component-based-component.md index 49854681fd5fa42f8975aa1ab684b738ea4810f7..f247caa2887a59cdbb96e33ba23f22f7ed3137de 100644 --- a/en/application-dev/ui/ts-component-based-component.md +++ b/en/application-dev/ui/ts-component-based-component.md @@ -1,31 +1,28 @@ -# @Component +# @Component -A struct decorated by **@Component** has the component-based capability and can serve as an independent component. This type of component is also called a custom component. -This component can be combined with other components. It describes the UI structure by implementing the **build** method, which must comply with the **Builder** API constraints. The API definition is as follows: +A struct decorated by @Component has the componentization capability and can serve as an independent component. This type of component is also called a custom component, and its UI structure is described in the build method. Custom components have the following features: -``` -interface Builder { - build: () => void -} -``` -Custom components have the following features: +- Composability: Custom components can be used with preset or other components, as well as common attributes and methods. + +- Reusable: Custom components can be reused by other components and used as different instances in different parent components or containers. + +- Lifecycle: Custom components provide callbacks for service logic processing throughout the lifecycle. + +- Data-driven update: The UI of custom components can be automatically updated based on the data of state variables. -- **Composability:** Custom components can be used with preset or other components, as well as common attributes and methods. -- **Reusable:** Custom components can be reused by other components and used as different instances in different parent components or containers. -- **Lifecycle:** Custom components provide callbacks for service logic processing throughout the lifecycle. -- **Data-driven update:** The UI of custom components can be automatically updated based on the status data. -The component lifecycle mainly involves two callbacks, **aboutToAppear** and **aboutToDisappear** . For details, see [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md). +For details about componentization, see [About @Component](ts-function-build.md). ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- Components must comply with the preceding **Builder** API constraints. Other components are combined in declarative mode in the internal **build** method. The **build** method is called when a component is created or updated for the first time. ->- Custom constructors are prohibited for components. -## Example +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - The build method must be defined for a custom component. +> +> - Custom constructors are prohibited for custom components. -The following code illustrates how to create a custom component named **MyComponent**: + +The following code illustrates how to create a custom component named MyComponent: ``` @Component @@ -39,9 +36,11 @@ struct MyComponent { } ``` -The **build** method of **MyComponent** is executed during initial rendering. When the component status changes, the **build** method will be executed again. -The following code illustrates how to use **MyComponent**: +The build method of MyComponent is executed during initial rendering. When the component status changes, the build method will be executed again. + + +The following code illustrates how to use MyComponent: ``` @Component @@ -56,7 +55,8 @@ struct ParentComponent { } ``` -**MyComponent** can be embedded multiple times and can be nested in different components, as shown in the code below: + +MyComponent can be applied multiple times and reused in different components, as shown in the code below: ``` @Component @@ -85,4 +85,3 @@ struct ParentComponent { } } ``` - diff --git a/en/application-dev/ui/ts-component-based-customdialog.md b/en/application-dev/ui/ts-component-based-customdialog.md index c03cdc1d402974df3287caa93be16e6a1db7711f..efcc465830ffbd4805ce9097d846d389473f4b03 100644 --- a/en/application-dev/ui/ts-component-based-customdialog.md +++ b/en/application-dev/ui/ts-component-based-customdialog.md @@ -1,7 +1,10 @@ -# @CustomDialog +# @CustomDialog -The **@CustomDialog** decorator is used to decorate custom pop-up dialog boxes. +The @CustomDialog decorator is used to decorate custom pop-up dialog boxes. + + + ``` // custom-dialog-demo.ets @CustomDialog @@ -46,4 +49,3 @@ struct CustomDialogUser { } } ``` - diff --git a/en/application-dev/ui/ts-component-based-entry.md b/en/application-dev/ui/ts-component-based-entry.md index a058f034fdb32a4658bf3de8336850f2893f149c..0973548901962c27b4cd15e30d7f115e51d9acc1 100644 --- a/en/application-dev/ui/ts-component-based-entry.md +++ b/en/application-dev/ui/ts-component-based-entry.md @@ -1,13 +1,14 @@ -# @Entry +# @Entry -The custom component decorated by **@Entry** functions as the default entry component of the respective page. When the page is loaded, the custom component decorated by **@Entry** is created and displayed first. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->A source file can contain at most one custom component decorated by **@Entry**. +The custom component decorated by @Entry functions as the default entry component of the respective page. When the page is loaded, the custom component decorated by @Entry is created and displayed first. -## Example -Example of using **@Entry**: +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> A source file can contain at most one custom component decorated by @Entry. + + +Example of using @Entry: ``` // Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed. @@ -32,4 +33,3 @@ struct HideComponent { } } ``` - diff --git a/en/application-dev/ui/ts-component-based-extend.md b/en/application-dev/ui/ts-component-based-extend.md index 729893c2ee6368fdba48ead9635bd540351da1d7..6280fa1b5fc2460ba34e542a8bb22382258ed77f 100644 --- a/en/application-dev/ui/ts-component-based-extend.md +++ b/en/application-dev/ui/ts-component-based-extend.md @@ -1,6 +1,6 @@ -# @Extend +# @Extend -The **@Extend** decorator adds new attribute functions to preset components, such as ****, ****, and ****. You can use the **@Extend** decorator to quickly define and reuse the custom styles of a component. +The @Extend decorator adds new attribute functions to preset components, such as <Text>, <Column>, and <Button>. You can use the @Extend decorator to quickly define and reuse the custom styles of a component. ``` @Extend(Text) function fancy(fontSize: number) { @@ -23,6 +23,4 @@ struct FancyUse { } ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The **@Extend** decorator cannot be used in the struct definition of a custom component. - +> ![img](public_sys-resources/icon-note.gif) **NOTE**: The @Extend decorator cannot be used in the struct definition of a custom component. \ No newline at end of file diff --git a/en/application-dev/ui/ts-component-based-preview.md b/en/application-dev/ui/ts-component-based-preview.md index c58898c2e41841f5b93b50ed7c0ab79b98e73324..703e4d41a434d66d32a25ab941c1a98da977a7e0 100644 --- a/en/application-dev/ui/ts-component-based-preview.md +++ b/en/application-dev/ui/ts-component-based-preview.md @@ -1,16 +1,17 @@ -# @Preview +# @Preview -Custom components decorated by **@Preview** can be previewed in the Previewer of DevEco Studio. When the page is loaded, the custom components decorated by **@Preview** are created and displayed. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->In a source file, at most one custom component can be decorated by **@Preview**. +Custom components decorated by @Preview can be previewed in the Previewer of DevEco Studio. When the page is loaded, the custom components decorated by @Preview are created and displayed. -## Example -Example of using **@Preview**: +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> In a source file, at most one custom component can be decorated by @Preview. + + +Example of using @Preview: ``` -// Display only Hello Component1 on the PC preview. The content under MyComponent is displayed on the real device. +// Display only Hello Component1 on the preview. The content under MyComponent is displayed on the real device. @Entry @Component struct MyComponent { @@ -57,4 +58,3 @@ struct Component2 { } } ``` - diff --git a/en/application-dev/ui/ts-component-based-styles.md b/en/application-dev/ui/ts-component-based-styles.md new file mode 100644 index 0000000000000000000000000000000000000000..33ed37a07a5bb089bcff39f38d4456f6149b646f --- /dev/null +++ b/en/application-dev/ui/ts-component-based-styles.md @@ -0,0 +1,76 @@ +# @Styles + + +The @Styles decorator adds new attribute functions to basic components, such as <Text>, <Column>, and <Button>. Currently, @Styles supports only universal attributes. You can use the @Styles decorator to quickly define and reuse the custom styles of a component. + + +@Styles can be defined inside or outside a component. When it is defined outside a component, the keyword function must be included. + + + +``` +@Styles function globalFancy() { + .backgroundColor(Color.Red) +} + +@Entry +@Component +struct FancyUse { + @Styles componentFancy() { + .backgroundColor(Color.Blue) + } + build() { + Column({ space: 10 }) { + Text("Fancy") + .globalFancy() + .width(100) + .height(100) + .fontSize(30) + Text("Fancy") + .componentFancy() + .width(100) + .height(100) + .fontSize(30) + } + } +} +``` + + +@Styles can also be used inside the StateStyles attribute to assign state-specific attributes to components. + + +In StateStyles, styles defined outside the component can be directly called. However, the keyword this must be used to call styles defined in the component. + + + +``` +@Styles function globalFancy() { + .width(100) + .height(100) +} + +@Entry +@Component +struct FancyUse { + @Styles function componentFancy() { + .width(50) + .height(50) + } + build() { + Row({ space: 10 }) { + Button() { + Text("Fancy") + } + .stateStyles({ + normal: { + .width(80) + .height(80) + }, + disabled: this.componentFancy, + pressed: globalFancy + }) + } + } +} +``` diff --git a/en/application-dev/ui/ts-component-based.md b/en/application-dev/ui/ts-component-based.md deleted file mode 100644 index 2ebfc47886dd60ed5586c20d718e6904a4a46cee..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-component-based.md +++ /dev/null @@ -1,15 +0,0 @@ -# Componentization - -- **[@Component](ts-component-based-component.md)** - -- **[@Entry](ts-component-based-entry.md)** - -- **[@Preview](ts-component-based-preview.md)** - -- **[@Builder](ts-component-based-builder.md)** - -- **[@Extend](ts-component-based-extend.md)** - -- **[@CustomDialog](ts-component-based-customdialog.md)** - - diff --git a/en/application-dev/ui/ts-component-creation-re-initialization.md b/en/application-dev/ui/ts-component-creation-re-initialization.md index ad98aedda691eeed622fe2cf5c7e70afc3a099a5..8be07a11249b0e7cadef3df26d33aea054791fea 100644 --- a/en/application-dev/ui/ts-component-creation-re-initialization.md +++ b/en/application-dev/ui/ts-component-creation-re-initialization.md @@ -1,4 +1,52 @@ -# Example: Component Creation and Re-Initialization +# Component Creation and Re-initialization + + +## Initial Creation and Rendering + +1. Create the parent component ParentComp. + +2. Locally initialize the state variable isCountDown of ParentComp. + +3. Execute the build function of ParentComp. + +4. Create a preset <Column> component. + 1. Create a preset <Text> component, set the text content to be displayed, and add the <Text> component instance to the <Column> component. + 2. Create the component on the true branch based on the if condition. + 1. Create a preset <Image> component and set the image source address. + 2. Create a TimerComponent using the given constructor. + 1. Create a TimerComponent object. + 2. Initialize the values of member variables locally. + 3. Use the parameters provided by the TimerComponent constructor to update the values of member variables. + 4. Execute the aboutToAppear function of TimerComponent. + 5. Execute the build function of TimerComponent to create the corresponding UI description structure. + 3. Create a preset <Button> component and set the corresponding content. + + +## Status Update + +When a user clicks a button: + +1. The value of the isCountDown state variable of ParentComp is changed to false. + +2. The build function of ParentComp is executed. + +3. The preset <Column> component is reused by the framework and reinitialized. + +4. The child components of <Column> reuse and reinitialize the objects in the memory. + 1. Reuse the preset <Text> component after re-initializing the component using new text content. + 2. Reuse the component on the false branch based on the if condition. + 1. Destroy the components on the original true branch as these components are no longer used. + 1. Destroy the created preset <image> component instance. + 2. Destroy the TimerComponent component instance, and call the aboutToDisappear function. + 2. Create components on the false branch. + 1. Create a preset <Image> component and set the image source address. + 2. Create a TimerComponent again using the given constructor. + 3. Initialize the newly created TimerComponent and call the aboutToAppear and build functions. + 3. Reuse the preset <Button> component, with the new image source address. + + +## Example + ``` @Entry @@ -16,7 +64,7 @@ struct ParentComp { TimerComponent({counter: 0, changePerSec: +1, showInColor: Color.Black }) } Button(this.isCountDown ? 'Swtich to Stopwatch' : 'Switch to Count Down') - .onClick(() => {this.isCountDown = !this.isCountDown}) + .onClick(() => {this.isCountDown = !this.isCountDown}) } } } @@ -35,56 +83,14 @@ struct TimerComponent { } aboutToAppear() { - this.timerId = setInterval(() => {this.counter += this.changePerSec}, 1000) + this.timerId = setInterval(() => {this.counter += this.changePerSec}, 1000) } aboutToDisappear() { - if (this.timerId > 0) { + if (this.timerId > 0) { clearTimeout(this.timerId) this.timerId = -1 } } } ``` - -## Initial Creation and Rendering - -1. Create the parent component **ParentComp**. -2. Locally initialize the state variable **isCountDown** of **ParentComp**. -3. Execute the **build** function of **ParentComp**. -4. Create a preset **** component. - 1. Create a preset **** component, set the text content to be displayed, and add the **** component instance to the **** component. - 2. Create the component on the **true** branch based on the **if** condition. - 1. Create a preset **** component and set the image source address. - 2. Create a **TimerComponent** using the given constructor. - 1. Create a **TimerComponent** object. - 2. Initialize the values of member variables locally. - 3. Use the parameters provided by the **TimerComponent** constructor to update the values of member variables. - 4. Execute the **aboutToAppear** function of **TimerComponent**. - 5. Execute the **build** function of **TimerComponent** to create the corresponding UI description structure. - - 3. Create a preset **** component and set the corresponding content. - - -## Status Update - -When a user clicks a button: - -1. The value of the **isCountDown** state variable of **ParentComp** is changed to **false**. -2. The **build** function of **ParentComp** is executed. -3. The preset **** component is reused by the framework and reinitialized. -4. The child components of **** reuse and reinitialize the objects in the memory. - 1. Reuse the preset **** component after re-initializing the component using new text content. - 2. Reuse the component on the **false** branch based on the **if** condition. - 1. Destroy the components on the original **true** branch as these components are no longer used. - 1. Destroy the created preset **** component instance. - 2. Destroy the **TimerComponent** component instance, and call the **aboutToDisappear** function. - - 2. Create components on the **false** branch. - 1. Create a preset **** component and set the image source address. - 2. Create a **TimerComponent** again using the given constructor. - 3. Initialize the newly created **TimerComponent** and call the **aboutToAppear** and **build** functions. - - 3. Reuse the preset **** component, with the new image source address. - - diff --git a/en/application-dev/ui/ts-component-states-link.md b/en/application-dev/ui/ts-component-states-link.md index 16ffb392a2baeab7b77fc6f0aa7b01577724ff52..0112e9cc38582ee6e5da1666fe16c54a5956e9eb 100644 --- a/en/application-dev/ui/ts-component-states-link.md +++ b/en/application-dev/ui/ts-component-states-link.md @@ -1,17 +1,26 @@ -# @Link +# @Link -Two-way binding can be established between the **@Link** decorated variable and the **@State** decorated variable of the parent component. The **@Link** data has the following features: -- **Support for multiple types**: The value of the **@Link** decorated variable can be of the same type as the **@State** decorated variable; that is, the value can be of the following types: **class**, **number**, **string**, **boolean**, or arrays of these types. -- **Private**: Data is accessed only within the component. -- **Single data source**: The variable of the parent component for initializing the **@Link** decorated variable must be the **@State** decorated variable. -- **Two-way binding**: When a child component changes the **@Link** decorated variable, the **@State** decorated variable of its parent component is also changed. -- **Support for initialization with the variable reference passed to the @Link decorated variable**: When creating a new instance of the component, you must use the naming parameter to initialize all **@Link** decorated variables. The **@Link** decorated variable can be initialized by using the reference of the **@State** or **@Link** decorated variable. Wherein, the **@State** decorated variable can be referenced using the '**$**' operator. +Two-way binding can be established between the @Link decorated variable and the @State decorated variable of the parent component. The @Link data has the following features: ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The **@Link** decorated variable cannot be initialized within the component. -## Simple Type Example +- Support for multiple types: The value of the @Link decorated variable can be of the same type as the @State decorated variable; that is, the value can be of the following types: class, number, string, boolean, or arrays of these types. + +- Private: Data is accessed only within the component. + +- Single data source: The variable of the parent component for initializing the @Link decorated variable must be the @State decorated variable. + +- Two-way binding: When a child component changes the @Link decorated variable, the @State decorated variable of its parent component is also changed. + +- Support for initialization with the variable reference passed to the @Link decorated variable: When creating a new instance of the component, you must use the naming parameter to initialize all @Link decorated variables. The @Link decorated variable can be initialized by using the reference of the @State or @Link decorated variable. Wherein, the @State decorated variable can be referenced using the '$' operator. + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> The @Link decorated variable cannot be initialized within the component. + + +## Simple Type Example + ``` @Entry @@ -41,9 +50,11 @@ struct PlayButton { } ``` -The **@Link** semantics are derived from the '**$**' operator. In other words, **$isPlaying** is the two-way binding of the internal state **this.isPlaying**. When you click **PlayButton**, the **** and **** components of **PlayButton** are refreshed at the same time. +The @Link semantics are derived from the '$' operator. In other words, $isPlaying is the two-way binding of the internal state this.isPlaying. When you click PlayButton, the <Image> and <Text> components of PlayButton are refreshed at the same time. + + +## Complex Type Example -## Complex Type Example ``` @Entry @@ -80,9 +91,11 @@ struct Child { } ``` -In the example above, click **Button1** and **Button2** to change the list of text items displayed in the parent component. +In the example above, click Button1 and Button2 to change the list of text items displayed in the parent component. + + +## Example of Using @Link, @State, and @Prop Together -## Example of Using @Link, @State, and @Prop Together ``` @Entry @@ -118,8 +131,8 @@ struct ChildB { } ``` -In the preceding example, **ParentView** contains two child components: **ChildA** and **ChildB**. They are initialized by the state variable **counter** of **ParentView**. +In the preceding example, ParentView contains two child components: ChildA and ChildB. They are initialized by the state variable counter of ParentView. -- **ChildB** uses **@Link** to establish two-way state binding. When the value of the **counterRef** state variable is changed in **ChildB**, the change is synchronized to **ParentView** and **ChildA**. -- **ChildA** uses **@Prop** to establish one-way state binding from **ParentView** to itself. When **ChildA** changes the state, it is re-rendered, but the change is not updated to **ParentView** or **ChildB**. +- ChildB uses @Link to establish two-way state binding. When the value of the counterRef state variable is changed in ChildB, the change is synchronized to ParentView and ChildA. +- ChildA uses @Prop to establish one-way state binding from ParentView to itself. When ChildA changes the state, it is re-rendered, but the change is not updated to ParentView or ChildB. diff --git a/en/application-dev/ui/ts-component-states-prop.md b/en/application-dev/ui/ts-component-states-prop.md index 06e195c25108ec681807542b30511c40a19b1f66..c70de8031c26bb06c845d4d1e214dc9e1b9fe57a 100644 --- a/en/application-dev/ui/ts-component-states-prop.md +++ b/en/application-dev/ui/ts-component-states-prop.md @@ -1,16 +1,24 @@ -# @Prop +# @Prop -**@Prop** and **@State** have the same semantics but different initialization modes. Variables decorated by **@Prop** must be initialized using the **@State** decorated variable provided by their parent components. The **@Prop** decorated variable can be modified in the component, but the modification is not updated to the parent component; that is, **@Prop** uses unidirectional data binding. -The **@Prop** state data has the following features: +@Prop and @State have the same semantics but different initialization modes. Variables decorated by @Prop must be initialized using the @State decorated variable provided by their parent components. The @Prop decorated variable can be modified in the component, but the modification is not updated to the parent component; that is, @Prop uses one-way data binding. -- **Support for simple types**: Only the following simple types are supported: **number**, **string**, and **boolean**. -- **Private**: Data is accessed only within the component. -- **Support for multiple instances**: A component can have multiple attributes decorated by **@Prop**. -- **Support for initialization with a value passed to the @Prop decorated variable**: When a new instance of the component is created, all **@Prop** decorated variables must be initialized. Initialization inside the component is not supported. -## Example +The @Prop state data has the following features: + +- Support for simple types: The number, string, and boolean types are supported. + +- Private: Data is accessed only within the component. + +- Support for multiple instances: A component can have multiple attributes decorated by @Prop. + +- Support for initialization with a value passed to the @Prop decorated variable: When a new instance of the component is created, all @Prop decorated variables must be initialized. Initialization inside the component is not supported. + + +## Example + + ``` @Entry @Component @@ -29,10 +37,7 @@ struct ParentComponent { }.onClick(() => { this.countDownStartValue -= 1 }) - - // when creatng ChildComponent, the initial value of its @Prop variable must be supplied - // in a named constructor parameter - // also regular costOfOneAttempt (non-Prop) variable is initialied + // When creating a child component, you must provide the initial value of its @Prop decorated variable in the constructor parameter and initialize the regular variable CostOfOneAttump (not Prop). CountDownComponent({ count: this.countDownStartValue, costOfOneAttempt: 2}) } } @@ -61,8 +66,7 @@ struct CountDownComponent { } ``` -In the preceding example, when you press **+1** or **-1**, the status of the parent component changes and the **build** method is executed again. In this case, a new **CountDownComponent** is created. The **countDownStartValue** property of the parent component is used to initialize the **@Prop** decorated variable of the child component. When you touch the **Try again** button of the child component, the value of the **count** variable decorated by **@Prop** is changed. As a result, the **CountDownComponent** is rendered again. However, the change of the **count** value does not affect the **countDownStartValue** value of the parent component. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->When a new component instance is created, all its **@Prop** decorated variables must be initialized. +In the preceding example, when you press +1 or -1, the status of the parent component changes and the build method is executed again. In this case, a new CountDownComponent is created. The countDownStartValue property of the parent component is used to initialize the @Prop decorated variable of the child component. When you tap the Try again button of the child component, the value of the @Prop decorated variable count is changed. As a result, the CountDownComponent is rendered again. However, the change of the count value does not affect the countDownStartValue value of the parent component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> When a new component instance is created, all its @Prop decorated variables must be initialized. diff --git a/en/application-dev/ui/ts-component-states-state.md b/en/application-dev/ui/ts-component-states-state.md index fa1704e770f7c06b1cb112ed040f97a0313ea1f7..143929758de06064f922e5fc82fa71db3ef0b67b 100644 --- a/en/application-dev/ui/ts-component-states-state.md +++ b/en/application-dev/ui/ts-component-states-state.md @@ -1,16 +1,25 @@ -# @State +# @State -The **@State** decorated variable is the internal state data of the component. When the state data is modified, the** build** method of the component is called to refresh the UI. -The **@State** data has the following features: +The @State decorated variable is the internal state data of the component. When the state data is modified, the build method of the component is called to refresh the UI. -- **Support for multiple types**: The following types are supported: strong types by value and by reference, including **class**, **number**, **boolean**, **string**, as well as arrays of these types, that is, **Array**, **Array**, **Array**, and **Array**. **object** and **any** are not allowed. -- **Support for multiple instances**: Multiple instances can coexist in a component. The internal state data of different instances is independent. -- **Internal private**: An attribute marked with **@State** cannot be directly modified outside the component. Its lifecycle depends on the component where it is located. -- **Local initialization required**: Initial values must be allocated to all **@State** decorated variables through the initialization process. Otherwise, they may become undefined in the framework. -- **Support for setting of initial attribute values based on the state variable name**: When creating a component instance, you can explicitly specify the initial value of the **@State** decorated attribute based on the variable name. -## Simple Example of @State Decorated Attribute +The @State data has the following features: + + +- Support for multiple types: The following types are supported: strong types by value and by reference, including class, number, boolean, string, as well as arrays of these types, that is, Array<class>, Array<string>, Array<boolean>, and Array<number>. object and any are not allowed. + +- Support for multiple instances: Multiple instances can coexist in a component. The internal state data of different instances is independent. + +- Private: An attribute marked with @State can only be accessed within the component. + +- Local initialization required: Initial values must be allocated to all @State decorated variables through the initialization process. Otherwise, they may become undefined in the framework. + +- Support for setting of initial attribute values based on the state variable name: When creating a component instance, you can explicitly specify the initial value of the @State decorated attribute based on the variable name. + + +## Simple Example of @State Decorated Attribute + ``` @Entry @@ -33,7 +42,9 @@ struct MyComponent { } ``` -## Complex Example of @State Decorated Variable + +## Complex Example of @State Decorated Variable + ``` // Customize the status data class. @@ -49,7 +60,7 @@ class Model { struct EntryComponent { build() { Column() { - MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document + MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document MyComponent({title: {value: 'Hello, World 2'}, count: 7}) //MyComponent2 in this document } } @@ -81,14 +92,16 @@ struct MyComponent { } ``` + In the preceding example: -- Two **@State** decorated variables, **count** and **title**, have been defined for **MyComponent**. If the value of **count** or **title** changes, the **build** method of **MyComponent** needs to be called to render the component again. -- The **EntryComponent** has multiple **MyComponent** instances. The internal status change of the first **MyComponent** does not affect the second **MyComponent**. -- When creating a **MyComponent** instance, initialize the variables in the component based on the variable name. For example: - ``` - MyComponent({title: {value: 'Hello, World 2'}, count: 7}) - ``` +- Two @State decorated variables, count and title, have been defined for MyComponent. If the value of count or title changes, the build method of MyComponent needs to be called to render the component again. +- The EntryComponent has multiple MyComponent instances. The internal status change of the first MyComponent does not affect the second MyComponent. +- When creating a MyComponent instance, initialize the variables in the component based on the variable name. For example: + + ``` + MyComponent({title: {value: 'Hello, World 2'}, count: 7}) + ``` diff --git a/en/application-dev/ui/ts-configuration-with-mandatory-parameters.md b/en/application-dev/ui/ts-configuration-with-mandatory-parameters.md index da3e114f5cdbe795914f5b96b169d10ca3d352bc..7060f4ca5d3069bad685c429b4b9bc7f11fa2aac 100644 --- a/en/application-dev/ui/ts-configuration-with-mandatory-parameters.md +++ b/en/application-dev/ui/ts-configuration-with-mandatory-parameters.md @@ -1,24 +1,27 @@ -# Configuration with Mandatory Parameters +# Configuration with Mandatory Parameters + + +If the API definition of a component contains any mandatory parameter, set the parameters in the parentheses next to the component. Use constants to assign values to the parameters. -If the API definition of a component contains mandatory construction parameters, the parameters must be configured in the brackets **\(\)** next to the component. You can use constants to assign values to parameters. Examples: -Set the mandatory parameter **src** of the **** component as follows: -``` -Image('http://xyz/a.jpg') -``` +- Set the mandatory parameter src of the <Image> component as follows: + + ``` + Image('http://xyz/a.jpg') + ``` -Set the mandatory parameter **content** of the **** component as follows: -``` -Text('123') -``` +- Set the mandatory parameter content of the <Text> component as follows: + + ``` + Text('123') + ``` -You can also use variables or expressions to assign values to parameters. The result type returned by an expression must meet the parameter type requirements. -To pass a variable or expression to construct the **Image** and **Text** components: +You can also use variables or expressions to assign values to parameters. The result type returned by an expression must meet the parameter type requirements. For example, to pass a variable or expression to construct the Image and Text components: ``` // imagePath, where imageUrl is a private data variable defined in the component. @@ -29,4 +32,3 @@ Image('http://' + this.imageUrl) // features of the corresponding language. This specification is not limited. Text(`count: ${this.count}`) ``` - diff --git a/en/application-dev/ui/ts-custom-component-initialization.md b/en/application-dev/ui/ts-custom-component-initialization.md index 42d04f5580804797cbb3ad84eaf1cb20e9abdd4c..15008a60b98bf273a408e4e86386e2487e443513 100644 --- a/en/application-dev/ui/ts-custom-component-initialization.md +++ b/en/application-dev/ui/ts-custom-component-initialization.md @@ -1,199 +1,78 @@ -# Custom Component Initialization +# Initialization of Custom Components' Member Variables -This section describes the rules for initializing component state variables. The member variables of a component can be initialized in either of the following ways: -- Local initialization. For example: - ``` - @State counter: Counter = new Counter() - ``` +- Local initialization. For example: + + ``` + @State counter: Counter = new Counter() + ``` -- Initialization using constructor parameters. For example: - - ``` - MyComponent(counter: $myCounter) - ``` +- Initialization using constructor parameters. For example: + + ``` + MyComponent(counter: $myCounter) + ``` The allowed method depends on the decorator of the state variable, as shown in the following table. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Decorator Type

-

Local Initialization

-

Initialization Using Constructor Parameters

-

@State

-

Mandatory

-

Optional

-

@Prop

-

Forbidden

-

Mandatory

-

@Link

-

Forbidden

-

Mandatory

-

@StorageLink

-

Mandatory

-

Forbidden

-

@StorageProp

-

Mandatory

-

Forbidden

-

@Provide

-

Mandatory

-

Optional

-

@Consume

-

Forbidden

-

Forbidden

-

@ObjectLink

-

Forbidden

-

Mandatory

-

Normal member variable

-

Recommended

-

Optional

-
+ + | Decorator Type | Local Initialization | Initialization Using Constructor Parameters | +| -------- | -------- | -------- | +| @State | Mandatory | Optional | +| @Prop | Forbidden | Mandatory | +| @Link | Forbidden | Mandatory | +| @StorageLink | Mandatory | Forbidden | +| @StorageProp | Mandatory | Forbidden | +| @Provide | Mandatory | Optional | +| @Consume | Forbidden | Forbidden | +| @ObjectLink | Forbidden | Mandatory | +| Normal member variable | Recommended | Optional | + As indicated by the preceding table: -- The **@State** decorated variable needs to be initialized locally. The initial value can be overwritten by the constructor parameter. -- The **@Prop** and **@Link** decorated variables must be initialized only by constructor parameters. + +- The @State decorated variables need to be initialized locally. The initial value can be overwritten by the constructor parameter. + +- The @Prop and @Link decorated variables must be initialized only by constructor parameters. + Comply with the following rules when using constructors to initialize member variables: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

From the Variable in the Parent Component (Below) to the Variable in the Child Component (Right)

-

@State

-

@Link

-

@Prop

-

Normal Variable

-

@State

-

Not allowed

-

Allowed

-

Allowed

-

Allowed

-

@Link

-

Not allowed

-

Allowed

-

Not recommended

-

Allowed

-

@Prop

-

Not allowed

-

Not allowed

-

Allowed

-

Allowed

-

@StorageLink

-

Not allowed

-

Allowed

-

Not allowed

-

Allowed

-

@StorageProp

-

Not allowed

-

Not allowed

-

Not allowed

-

Allowed

-

Normal variable

-

Allowed

-

Not allowed

-

Not allowed

-

Allowed

-
+ + | From the Variable in the Parent Component (Below) to the Variable in the Child Component (Right) | @State | @Link | @Prop | Normal Variable | +| -------- | -------- | -------- | -------- | -------- | +| @State | Not allowed | Allowed | Allowed | Allowed | +| @Link | Not allowed | Allowed | Not recommended | Allowed | +| @Prop | Not allowed | Not allowed | Allowed | Allowed | +| @StorageLink | Not allowed | Allowed | Not allowed | Allowed | +| @StorageProp | Not allowed | Not allowed | Not allowed | Allowed | +| Normal variable | Allowed | Not allowed | Not allowed | Allowed | + As indicated by the preceding table: -- The normal variable of the parent component can be used to initialize the **@State** decorated variable of the child component, but not the **@Link** or **@Prop** decorated variable. -- The **@State** decorated variable of the parent component can be used to initialize the **@Prop**, **@Link** \(using **$**\), or normal variables of the child component, but cannot initialize the **@State** decorated variable of the child component. -- The **@Link** decorated variable of the parent component can initialize the **@Link** decorated or normal variables of the child component. However, initializing the **@State** decorated member of the child component can result in a syntax error. In addition, initializing the **@Prop** decorated variable is not recommended. -- The **@Prop** decorated variable of the parent component can be used to initialize the normal variables or **@Prop** decorated variables of the child component, but not the **@State** or **@Link** decorated variables. -- Passing **@StorageLink** and **@StorageProp** from the parent component to the child component is prohibited. -- In addition to the preceding rules, the TypeScript strong type rules need to be followed. -## Example +- The normal variables of the parent component can be used to initialize the @State decorated variables of the child component, but not the @Link or @Prop decorated variables. +- The @State decorated variable of the parent component can be used to initialize the @Prop, @Link (using $), or normal variables of the child component, but not the @State decorated variables of the child component. + +- The @Link decorated variables of the parent component can be used to initialize the @Link decorated or normal variables of the child component. However, initializing the @State decorated members of the child component can result in a syntax error. In addition, initializing the @Prop decorated variables is not recommended. + +- The @Prop decorated variables of the parent component can be used to initialize the normal variables or @Prop decorated variables of the child component, but not the @State or @Link decorated variables. + +- Passing @StorageLink and @StorageProp from the parent component to the child component is prohibited. + +- In addition to the preceding rules, the TypeScript strong type rules need to be followed. + + +## Example + + ``` @Entry @Component @@ -218,7 +97,7 @@ struct CompA { Row() { CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, bProp: this.aState}) // valid init a @Prop with value of a @State - CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean + CompB({aLink: $aState, // invalid: type missmatch expected ref to ClassA, provided reference to boolean bProp: false}) // valid init a @Prop by constants value } } @@ -234,4 +113,3 @@ struct CompB { } } ``` - diff --git a/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 3fbf56db7d03632f4aff64f276234d24ebba8f3f..874d01b5dde8f80947cfc8626f71b1c55db44258 100644 --- a/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -1,49 +1,23 @@ -# Custom Component Lifecycle Callbacks +# Custom Component Lifecycle Callbacks + The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time at runtime. They cannot be manually invoked from applications. -## Lifecycle Callback Definition - - - - - - - - - - - - - - - - - - - - - -

Function

-

Description

-

aboutToAppear

-

Invoked after a new instance of the custom component is created and before its build function is executed.

-

You can change state variables in the aboutToAppear function. The change will take effect when you execute the build function next time.

-

aboutToDisappear

-

Invoked before the destructor of the custom component is consumed.

-

Do not change state variables in the aboutToDisappear function as doing this can cause unexpected errors. For example, the modification of the @Link decorated variable may cause unstable application running.

-

onPageShow

-

Invoked when a page is displayed. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

-

onPageHide

-

Invoked when a page is hidden. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

-

onBackPress

-

Invoked when a user clicks the back button. Only the custom components decorated by @Entry take effect.

-
  • The value true is returned if the page processes the return logic instead of performing page routing.
  • The value false is returned if the default return logic is used.
  • If no value is returned, the default return logic is used.
-
+## Lifecycle Callback Definition + + | Function | Description | +| -------- | -------- | +| aboutToAppear | Invoked after a new instance of the custom component is created and before its build function is executed. You can change state variables in the aboutToAppear function. The change will take effect when you execute the build function next time. | +| aboutToDisappear | Invoked before the destructor of the custom component is consumed. Do not change state variables in the aboutToDisappear function as doing this can cause unexpected errors. For example, the modification of the @Link decorated variable may cause unstable application running. | +| onPageShow | Invoked when a page is displayed. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect. | +| onPageHide | Invoked when a page is hidden. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect. | +| onBackPress | Invoked when a user clicks the back button. Only the custom components decorated by @Entry take effect.
- The value true is returned if the page processes the return logic instead of performing page routing.
- The value false is returned if the default return logic is used.
- If no value is returned, the default return logic is used. | + -## Example +## Example + ``` @Component struct CountDownTimerComponent { @@ -72,9 +46,10 @@ struct CountDownTimerComponent { } ``` -The example above shows that lifecycle functions are critical for **CountDownTimerComponent** to manage its timer resources. Similar functions include loading resources asynchronously from the network. +The example above shows that lifecycle functions are critical for CountDownTimerComponent to manage its timer resources. Similar functions include loading resources asynchronously from the network. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters. ->- Do not use **async await** in lifecycle functions. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters. +> +> - Do not use async await in lifecycle functions. diff --git a/en/application-dev/ui/ts-declarative-syntax.md b/en/application-dev/ui/ts-declarative-syntax.md deleted file mode 100644 index 806cf1f72eabbe021f18487f711384494c801503..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-declarative-syntax.md +++ /dev/null @@ -1,15 +0,0 @@ -# Declarative Syntax - -- **[Overview](ts-syntax-intro.md)** - -- **[General UI Description Specifications](ts-general-ui-description-specifications.md)** - -- **[About UI State Management](ts-ui-state-management.md)** - -- **[About Rendering Control Syntax](ts-rending-control-syntax.md)** - -- **[About @Component](ts-a-deep-dive-into-component.md)** - -- **[About Syntactic Sugar](ts-syntactic-sugar.md)** - - diff --git a/en/application-dev/ui/ts-declarative-ui-description-specifications.md b/en/application-dev/ui/ts-declarative-ui-description-specifications.md deleted file mode 100644 index 20de125b2f7d3847e8332ef13b50dfad43e90eb9..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-declarative-ui-description-specifications.md +++ /dev/null @@ -1,13 +0,0 @@ -# Declarative UI Description Specifications - -- **[Parameterless Configuration](ts-parameterless-configuration.md)** - -- **[Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md)** - -- **[Attribution Configuration](ts-attribution-configuration.md)** - -- **[Event Configuration](ts-event-configuration.md)** - -- **[Child Component Configuration](ts-child-component-configuration.md)** - - diff --git a/en/application-dev/ui/ts-event-configuration.md b/en/application-dev/ui/ts-event-configuration.md index fbaaca289df7e1b8d49101eb10e4ac172c1b5d4a..9f216ead2a25bce5fc16b8bcf1a02420e7fea019 100644 --- a/en/application-dev/ui/ts-event-configuration.md +++ b/en/application-dev/ui/ts-event-configuration.md @@ -1,42 +1,40 @@ -# Event Configuration +# Event Configuration -You can use event methods to configure events supported by components. - -- Example of using a lambda expression to configure the event of a component: - - ``` - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(() => { - this.counter += 2 - }) - ``` - - -- Example of using an anonymous function expression to configure the event of a component: - In this case, **bind** must be used to ensure that the contained components are referenced by **this** in the function body. +You can use event methods to configure events supported by components. - ``` - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(function () { - this.counter += 2 - }.bind(this)) - ``` +- Example of using a lambda expression to configure the event of a component: + + ``` + // Counter is a private data variable defined in the component. + Button('add counter') + .onClick(() => { + this.counter += 2 + }) + ``` -- Example of using a component's member function to configure the event of the component: - ``` - myClickHandler(): void { - // do something - } +- When using an anonymous function expression to configure the event of a component, bind must be used to ensure that the contained components are referenced by this in the function body. - ... - - Button('add counter') - .onClick(this.myClickHandler) - ``` + ``` + // Counter is a private data variable defined in the component. + Button('add counter') + .onClick(function () { + this.counter += 2 + }.bind(this)) + ``` +- Example of using a component's member function to configure the event of the component: + + ``` + myClickHandler(): void { + // do something + } + + ... + + Button('add counter') + .onClick(this.myClickHandler) + ``` diff --git a/en/application-dev/ui/ts-framework-directory.md b/en/application-dev/ui/ts-framework-directory.md index 75bf3b9fea9cf4341d98b9c423bbc8cea9427955..ce9ac122086ec353c29c44cc9796a19ed3f1deb5 100644 --- a/en/application-dev/ui/ts-framework-directory.md +++ b/en/application-dev/ui/ts-framework-directory.md @@ -1,19 +1,28 @@ -# Directory Structure +# Directory Structure -The following figure shows the typical directory structure of the **eTS** module \(**entry/src/main**\) for an application with feature abilities \(FAs\). -![](figures/en-us_image_0000001251421931.png) +The following figure shows the typical directory structure of the eTS module (entry/src/main) for an application with feature abilities (FAs). + + +![en-us_image_0000001222967752](figures/en-us_image_0000001222967752.png) + Functions of the files are as follows: -- The Extended TypeScript \(eTS\) files that end with the **.ets** extension describe the UI layouts, styles, event interactions, and page logics. + +- The Extended TypeScript (eTS) files that end with the .ets extension describe the UI layouts, styles, event interactions, and page logics. + Functions of the folders and files are as follows: -- The **app.ets** file manages global application logics and lifecycles. -- The **pages** directory stores all component pages. -- The **common** directory stores common code files, such as custom components and public methods. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- TypeScript and JavaScript files can be imported as page files. +- The app.ets file manages global application logics and lifecycles. + +- The pages directory stores all component pages. + +- The common directory stores common code files, such as custom components and public methods. + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> +> TypeScript and JavaScript files can be imported as page files. diff --git a/en/application-dev/ui/ts-framework-file-access-rules.md b/en/application-dev/ui/ts-framework-file-access-rules.md index 73e828a9ef8f7aad23b421e220f9b0e7174f6feb..15be5a8bc0e02e7b23f2f5badb582bedfc192414 100644 --- a/en/application-dev/ui/ts-framework-file-access-rules.md +++ b/en/application-dev/ui/ts-framework-file-access-rules.md @@ -1,13 +1,19 @@ -# Rules for Accessing Application Code Files +# Rules for Accessing Application Code Files + The application code files can be accessed in the following ways: -- Use a relative path to reference the code file. For example, if the upper-level directory is **../common/utils/utils.ets**, use **./common/utils/utils.ets** for the current directory. -- Use the root path of the current module to reference the code file, for example, **common/utils/utils.ets**. -- Store common code files in the **common** directory. -## Example +- Use a relative path to reference the code file. For example, if the upper-level directory is ../common/utils/utils.ets, use ./common/utils/utils.ets for the current directory. + +- Use the root path of the current module to reference the code file, for example, common/utils/utils.ets. + +- Store common code files in the common directory. + +## Example + + ``` import { FoodData, FoodList } from "../common/utils/utils.ets"; @@ -29,6 +35,7 @@ struct FoodCategoryList { Example for importing a code file: + ``` //common/utils/utils.ets @@ -64,4 +71,3 @@ export struct FoodList { } } ``` - diff --git a/en/application-dev/ui/ts-framework-file.md b/en/application-dev/ui/ts-framework-file.md deleted file mode 100644 index 2a48d61106d7a0f1d50389bea75e8e2db437db5a..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-framework-file.md +++ /dev/null @@ -1,7 +0,0 @@ -# File Organization - -- **[Directory Structure](ts-framework-directory.md)** - -- **[Rules for Accessing Application Code Files](ts-framework-file-access-rules.md)** - - diff --git a/en/application-dev/ui/ts-framework-js-tag.md b/en/application-dev/ui/ts-framework-js-tag.md index 5f7e115ad2d69803312591f23b2f28f7aee593c5..553e3328fd5580db16fa80f90b13819de111f5f2 100644 --- a/en/application-dev/ui/ts-framework-js-tag.md +++ b/en/application-dev/ui/ts-framework-js-tag.md @@ -1,70 +1,21 @@ -# "js" Tag - -Configure the **"js"** tag in the [config.json](https://developer.harmonyos.com/en/docs/documentation/doc-guides/basic-config-file-overview-0000000000011951) file of your application. The **"js"** tag contains the instance name, page route, and window configuration information. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Tag

-

Type

-

Default Value

-

Mandatory

-

Description

-

name

-

string

-

default

-

Yes

-

Name of the eTS instance.

-

pages

-

Array

-

-

-

Yes

-

Page route information. For details, see "pages".

-

window

-

Object

-

-

-

No

-

Window configuration information. For details, see "window".

-

mode

-

Object

-

-

-

No

-

Running type and syntax style of the JS component. For details, see "mode".

-
- -## pages - -The **"pages"** defines the route information of each page's entry component. Each page consists of the page path and page name. The following is an example: +# "js" Tag + + +Configure the "js" tag in the config.json file of your application. The "js" tag contains the instance name, page route, and window configuration information. + + + | Tag | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| name | string | default | Yes | Name of the eTS instance. | +| pages | Array | - | Yes | Page route information. For details, see ["pages"](#pages). | +| window | Object | - | No | Window configuration information. For details, see ["window"](#window). | +| mode | Object | - | No | Running type and syntax style of the JS component. For details, see ["mode"](#mode). | + + +## pages + +The "pages" defines the route information of each page's entry component. Each page consists of the page path and page name. The following is an example: + ``` { @@ -75,33 +26,22 @@ The **"pages"** defines the route information of each page's entry component. } ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- The first page in the **"pages"** list is the home page of the application. ->- The page name must not be a component name, for example, **Text.ets** or **Button.ets**. ->- Each page file must contain the [page entry component](ts-component-based-entry.md) \(with the @Entry decoration\). - -## window - -The **"window"** configures the view window. The following attributes can be configured: - - - - - - - - - - - - -

Type

-

Default Value

-

Description

-

designWidth

-

-

-

Logical width of the view. The default value is 720. (The default value is 454 for wearables.) The logical width of the view determines the unit size of lpx. For example, if designWidth is 720 and the view width is 1440 physical pixels, 1 lpx is 2 physical pixels. For details, see lpx.

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - The first page in the "pages" list is the home page of the application. +> +> - The page name must not be a component name, for example, Text.ets or Button.ets. +> +> - Each page file must contain the [page entry component](ts-component-based-entry.md) (with the @Entry decoration). + + +## window + +The "window" configures the view window. The following attributes can be configured: + + | Type | Default Value | Description | +| -------- | -------- | -------- | +| designWidth | - | Logical width of the view. The default value is 720. (The default value is 454 for wearables.) The logical width of the view determines the unit size of lpx. For example, if designWidth is 720 and the view width is 1440 physical pixels, 1 lpx is 2 physical pixels. For details, see [lpx](ts-pixel-units.md). | + ``` { @@ -113,45 +53,25 @@ The **"window"** configures the view window. The following attributes can be c } ``` -## mode - -The **"mode"** configures the running type and syntax style of a JS component. The following attributes are supported: - - - - - - - - - - - - - - - - -

Type

-

Default Value

-

Description

-

type

-

-

-

Running type of the JS component. The options are as follows:

-
  • pageAbility: Run the JS component in ability mode.
  • form: Run the JS component as a service widget.
-

syntax

-

-

-

Syntax type of the JS component. The options are as follows:

-
  • hml: compiled in the .hml, .css, or .js style.
  • ets: compiled in the declarative syntax style.
-
- ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->If **type** is set to **form**, **syntax** cannot be **ets**. - -## Example + +## mode + +The "mode" configures the running type and syntax style of a JS component. The following attributes are supported: + + | Type | Default Value | Description | +| -------- | -------- | -------- | +| type | - | Running type of the JS component. The options are as follows:
- pageAbility: Run the JS component in ability mode.
- form: Run the JS component as a service widget. | +| syntax | - | Syntax type of the JS component. The options are as follows:
- hml: compiled in the .hml, .css, or .js style.
- ets: compiled in the declarative syntax style. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> If type is set to form, syntax cannot be ets. + + +## Example config.json: + ``` { "app": { @@ -163,19 +83,19 @@ config.json: "vendor": "example" }, "module": { - "js": [{ - "name": "default", - "pages": [ - "pages/index", - "pages/detail" - ], - "window": { - "designWidth": 720 - }, - "mode": { - "type": "pageAbility", - "syntax": "ets" - }, + "js": [{ + "name": "default", + "pages": [ + "pages/index", + "pages/detail" + ], + "window": { + "designWidth": 720 + }, + "mode": { + "type": "pageAbility", + "syntax": "ets" + }, }], "abilities": [{ ... @@ -183,4 +103,3 @@ config.json: } } ``` - diff --git a/en/application-dev/ui/ts-framework.md b/en/application-dev/ui/ts-framework.md deleted file mode 100644 index ee1e6d359efd49ade99c82e33289ee7fac21ff35..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-framework.md +++ /dev/null @@ -1,13 +0,0 @@ -# Framework Overview - -- **[File Organization](ts-framework-file.md)** - -- **["js" Tag](ts-framework-js-tag.md)** - -- **[Resource Access](ts-resource-access.md)** - -- **[Pixel Units](ts-pixel-units.md)** - -- **[Types](ts-types.md)** - - diff --git a/en/application-dev/ui/ts-function-build.md b/en/application-dev/ui/ts-function-build.md index 5415112733ba0a915822ddc2f94073cca2ada01e..26578d47e765f40f7d4fa0c454f4e0fe2692feb8 100644 --- a/en/application-dev/ui/ts-function-build.md +++ b/en/application-dev/ui/ts-function-build.md @@ -1,10 +1,16 @@ -# build Function +# build Function -The **build** function meets the definition of the **Builder** API and is used to define the declarative UI description of components. +The build function meets the definition of the Builder API and is used to define the declarative UI description of components. Components must comply with the preceding Builder API constraints. Custom or preset components are combined in declarative mode in the build method. The build method is called when a component is created or updated. + + + ``` interface Builder { build: () => void } ``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> The build method supports only composite components and uses the rendering control syntax. diff --git a/en/application-dev/ui/ts-general-ui-concepts.md b/en/application-dev/ui/ts-general-ui-concepts.md index fd834881baf8524e1f8c7834031c98dcc4f19a38..db5bd3b1e5e3b476ff8faae504616b099a0cbd31 100644 --- a/en/application-dev/ui/ts-general-ui-concepts.md +++ b/en/application-dev/ui/ts-general-ui-concepts.md @@ -1,8 +1,11 @@ -# Basic Concepts +# Basic Concepts + The TypeScript-based declarative development paradigm provides a wide array of basic components, which can be combined and extended in a declarative manner to describe the UI of an application. It also provides basic data binding and event processing mechanisms to help you implement the application interaction logic. -## HelloWorld Example + +## HelloWorld Example + ``` // An example of displaying Hello World. After you click the button, Hello UI is displayed. @@ -20,7 +23,7 @@ struct Hello { Button() { Text('Click me') .fontColor(Color.Red) - }.onClick(() => { + }.onClick(() => { this.myText = 'UI' }) .width(500) @@ -30,14 +33,19 @@ struct Hello { } ``` -## Basic Concepts + +## Basic Concepts The preceding sample code shows the structure of a simple page. It involves the following basic concepts: -- **Decorator**: a special kind of declaration that can be applied to classes, structures, methods, and variables, and assigns special meanings to them. In the sample code, **@Entry**, **@Component**, and **@State** are decorators. -- **Custom component**: a reusable UI unit, which can be combined with other components. In the sample code, **struct Hello** decorated by **@Component** is a custom component. -- **UI description**: declaratively describes the UI structure. In the sample code, the block of code in the **build\(\)** method provides the UI description. -- **Built-in component**: the default basic or layout component preset in the framework. You can directly invoke these components, such as ****, ****, ****, and **** components in the sample code. -- **Attribute method**: a method used to configure component attributes, such as **fontSize\(\)**, **width\(\)**, **height\(\)**, and **color\(\)**. -- **Event method**: a method used to add the component response logic to an event. The logic is set through an event method, such as **onClick\(\)** for a button. +- Decorator: a special kind of declaration that can be applied to classes, structures, methods, and variables. In the sample code, @Entry, @Component, and @State are decorators. + +- Custom component: a reusable UI unit, which can be combined with other components. In the sample code, struct Hello decorated by @Component is a custom component. + +- UI description: declaratively describes the UI structure. In the sample code, the block of code in the build() method provides the UI description. + +- Built-in component: the default basic or layout component preset in the framework. You can directly invoke these components, such as <Column>, <Text>, <Divider>, and <Button> components in the sample code. + +- Attribute method: a method used to configure component attributes, such as fontSize(), width(), height(), and color(). +- Event method: a method used to add the component response logic to an event. In the sample code, the onClick method is added for the Button component for defining the click response logic. diff --git a/en/application-dev/ui/ts-general-ui-description-specifications.md b/en/application-dev/ui/ts-general-ui-description-specifications.md deleted file mode 100644 index 209c5856b1e8cddf865efe8a72d59b7272ed6af3..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-general-ui-description-specifications.md +++ /dev/null @@ -1,9 +0,0 @@ -# General UI Description Specifications - -- **[Basic Concepts](ts-general-ui-concepts.md)** - -- **[Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md)** - -- **[Componentization](ts-component-based.md)** - - diff --git a/en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md b/en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md deleted file mode 100644 index d4510ca475164a5806c958570e86f28a64351bed..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md +++ /dev/null @@ -1,23 +0,0 @@ -# Instantiating a struct Without the new Keyword - -You can omit the **new** keyword when instantiating a **struct**. - -``` -// Definition -@Component -struct MyComponent { - build() { - } -} - -// Use -Column() { - MyComponent() -} - -// Equivalent to -new Column() { - new MyComponent() -} -``` - diff --git a/en/application-dev/ui/ts-managing-application-states-apis.md b/en/application-dev/ui/ts-managing-application-states-apis.md deleted file mode 100644 index 3ce3654cbab58c6402a650c0e24194fdac8ab3f4..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-managing-application-states-apis.md +++ /dev/null @@ -1,9 +0,0 @@ -# APIs - -- **[AppStorage](ts-application-states-appstorage.md)** - -- **[PersistentStorage](ts-application-states-apis-persistentstorage.md)** - -- **[Environment](ts-application-states-apis-environment.md)** - - diff --git a/en/application-dev/ui/ts-managing-application-states.md b/en/application-dev/ui/ts-managing-application-states.md deleted file mode 100644 index be78ab93baf2033ec54d9101b0ef31db93d14ddb..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-managing-application-states.md +++ /dev/null @@ -1,7 +0,0 @@ -# Managing Application States - -- **[APIs](ts-managing-application-states-apis.md)** - -- **[Synchronization Between AppStorage and Components](ts-application-states-storagelink-storageprop.md)** - - diff --git a/en/application-dev/ui/ts-managing-component-states.md b/en/application-dev/ui/ts-managing-component-states.md deleted file mode 100644 index b862e704f6dd254dc39134ceb66bbbe7403e7901..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-managing-component-states.md +++ /dev/null @@ -1,9 +0,0 @@ -# Managing Component States - -- **[@State](ts-component-states-state.md)** - -- **[@Prop](ts-component-states-prop.md)** - -- **[@Link](ts-component-states-link.md)** - - diff --git a/en/application-dev/ui/ts-managing-other-states.md b/en/application-dev/ui/ts-managing-other-states.md deleted file mode 100644 index 07380c64163f2a0b6ce57a80bc243510a7278113..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-managing-other-states.md +++ /dev/null @@ -1,9 +0,0 @@ -# Managing Other States - -- **[@observed and @objectLink](ts-other-states-observed-objectlink.md)** - -- **[@Consume and @Provide](ts-other-states-consume-provide.md)** - -- **[@Watch](ts-other-states-watch.md)** - - diff --git a/en/application-dev/ui/ts-media-resource-type.md b/en/application-dev/ui/ts-media-resource-type.md index 402f387f880e132e046e8c58a0c225b0cf88e628..9143da0dc1cf6d62dfb7ccf402d8c50adf7eec58 100644 --- a/en/application-dev/ui/ts-media-resource-type.md +++ b/en/application-dev/ui/ts-media-resource-type.md @@ -1,45 +1,12 @@ -# Media Resource Types - -- The following table describes the image resource types supported by the development framework. - - - - - - - - - - - - - - - - - - - - - - - - - -

Image Format

-

File Name Extension

-

JPEG

-

.jpg

-

PNG

-

.png

-

GIF

-

.gif

-

SVG

-

.svg

-

WEBP

-

.webp

-

BMP

-

.bmp

-
- - +# Media Resource Types + + +- The following table describes the image resource types supported by the development framework. + | Image Format | File Name Extension | + | -------- | -------- | + | JPEG | .jpg | + | PNG | .png | + | GIF | .gif | + | SVG | .svg | + | WEBP | .webp | + | BMP | .bmp | diff --git a/en/application-dev/ui/ts-other-states-consume-provide.md b/en/application-dev/ui/ts-other-states-consume-provide.md index 51a3624a69b9349b10a0294ccc0cb056cc2834c4..4c4e61f92b05e9008d201a7b0b2a2899825ad179 100644 --- a/en/application-dev/ui/ts-other-states-consume-provide.md +++ b/en/application-dev/ui/ts-other-states-consume-provide.md @@ -1,63 +1,34 @@ -# @Consume and @Provide - -As the data provider, **Provide** can update the data of child nodes and trigger page rendering. After **Consume** detects that the **Provide** data is updated, it will initiate re-rendering of the current view. - -**Table 1** @Provide - - - - - - - - - - - - - - - - - - - -

Type

-

Description

-

Decorator parameters

-

Alias: a constant of the string type. If an alias is specified, implement the data update for this alias. If there is no alias, use the variable name as the alias. @Provide("alias") is recommended.

-

Synchronization mechanism

-

The @Provide decorated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume decorated variable to modify the @State decorated variable reversely.

-

Initial value

-

The initial value must be set.

-

Page re-rendering scenarios

-

1. Primitive types: boolean, string, and number

-

2. @observed: used to modify the attributes of the @observed decorated class.

-

3. Array: Add, delete, or update elements in an array.

-
- -**Table 2** @Consume - - - - - - - - - - -

Type

-

Description

-

Initial value

-

No default value can be set.

-
- ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->To avoid infinite loops caused by circular reference, exercise caution when using **@Provide** and **@Consume**. - -The description of other attributes is the same as that of **@Provide**. +# @Consume and @Provide + +As the data provider, @Provide can update the data of child nodes and trigger page rendering. After @Consume detects that the @Provide data is updated, it will initiate re-rendering of the current view. + + + Table1 @Provide + +| Name | Description | +| -------- | -------- | +| Decorator parameter | A constant of the string type, which is used to set an alias for a decorated variable. If an alias is specified, implement the data update for this alias. If there is no alias, use the variable name as the alias. @Provide("_alias_") is recommended. | +| Synchronization mechanism | The @Provide decorated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume decorated variable to modify the @State decorated variable reversely. | +| Initial value | The initial value must be set. | +| Page re-rendering scenarios | The following will trigger page re-rendering:
- Changes of variables in primitive types (boolean, string, and number)
- Changes of the @Observed decorated classes or their attributes
- Adding, deleting, or updatingelements in an array | + + + Table2 @Consume + +| Type | Description | +| -------- | -------- | +| Initial value | No default value can be set. | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> To avoid infinite loops caused by circular reference, exercise caution when using @Provide and @Consume. + + +The description of other attributes is the same as that of @Provide. + + + ``` @Entry @Component @@ -103,4 +74,3 @@ struct CompC { } } ``` - diff --git a/en/application-dev/ui/ts-other-states-observed-objectlink.md b/en/application-dev/ui/ts-other-states-observed-objectlink.md index b62e6a13e4a7b5dac72ae829bb400cfdca13b9ca..7b68a0ab326f728f511329dc3c4d47971fa244f2 100644 --- a/en/application-dev/ui/ts-other-states-observed-objectlink.md +++ b/en/application-dev/ui/ts-other-states-observed-objectlink.md @@ -1,71 +1,181 @@ -# @observed and @objectLink +# @Observed and @ObjectLink -**@observed** is a decorator used for classes, indicating that the data changes in the object will be managed by the UI page. **@objectLink** is used to decorate the variables that are decorated by **@observed**. +This section introduces to you two new decorators: @Observed and @ObjectLink. + + +- @Observed applies to a class, indicating that the data changes in the class are managed by the UI page, for example, @Observed class ClassA {}. + +- @ObjectLink applies to an object decorated by @Observed, for example, @ObjectLink a: ClassA. + + +## Background + +When you need to set bidirectional synchronization in a child component for a variable (parent_a) of its parent component, you can use @State to decorate the variable (parent_a) in the parent component and use @Link to decorate the corresponding variable (child_a) in the child component. In this way, data can be synchronized between the parent component and the specific child component, and between the parent component and its other child components. As shown below, bidirectional synchronization is configured for variables of ClassA in the parent and child components. If attribute c of the variable in child component 1 has its value changed, the parent component will be notified to synchronize the change. If attribute c in the parent component has its value changed, all child components will be notified to synchronize the change. + +![en-us_image_0000001267647861](figures/en-us_image_0000001267647861.png) + +In the preceding example, full synchronization is performed for a data object. If you want to synchronize partial information of a data object in a parent component, and if the information is a class object, use @ObjectLink and @Observed instead, as shown below. + +![en-us_image_0000001267607881](figures/en-us_image_0000001267607881.png) + + +## Configuration Requirement + +- @Observed applies to classes, and @ObjectLink applies to variables. + +- The variables decorated by @ObjectLink must be of the class type. + - The classes must be decorated by @Observed. + - Parameters of the primitive types are not supported. You can use @Prop to perform unidirectional synchronization. + +- @ObjectLink decorated variables are immutable. + - Attribute changes are allowed. If an object is referenced by multiple @ObjectLink decorated variables, all custom components that have these variables will be notified for re-rendering. + +- Default values cannot be set for @ObjectLink decorated variables. + - The parent component must be initialized with a TypeScript expression that involves variables decorated by @State, @Link, @StorageLink, @Provide, or @Consume. + +- @ObjectLink decorated variables are private variables and can be accessed only within the component. + + +## Examples + + +### Example 1 + + ``` -// Object to be observed -@Observed class ClassA { - static nextID : number = 0; - public id : number; - public c: number; - - constructor(c: number) { - this.id = ClassA.nextID++; - this.c = c; +@Observed +class ClassA { + public name : string; + public c: number; + constructor(c: number, name: string = 'OK') { + this.name = name; + this.c = c; + } +} + +class ClassB { + public a: ClassA; + constructor(a: ClassA) { + this.a = a; + } +} + +@Component +struct ViewA { + label : string = "ep1"; + @ObjectLink a : ClassA; + build() { + Column() { + Text(`ViewA [${this.label}]: a.c=${this.a.c}`) + .fontSize(20) + Button(`+1`) + .width(100) + .margin(2) + .onClick(() => { + this.a.c += 1; + }) + Button(`reset`) + .width(100) + .margin(2) + .onClick(() => { + this.a = new ClassA(0); // ERROR, this.a is immutable + }) } + } } -@Observed class ClassB { - public a: ClassA; +@Entry +@Component +struct ViewB { + @State b : ClassB = new ClassB(new ClassA(10)); + build() { + Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center}) { + ViewA({label: "ViewA #1", a: this.b.a}) + ViewA({label: "ViewA #2", a: this.b.a}) - constructor(a: ClassA) { - this.a = a; + Button(`ViewB: this.b.a.c += 1` ) + .width(320) + .margin(4) + .onClick(() => { + this.b.a.c += 1; + }) + Button(`ViewB: this.b.a = new ClassA(0)`) + .width(240) + .margin(4) + .onClick(() => { + this.b.a = new ClassA(0); + }) + Button(`ViewB: this.b = new ClassB(ClassA(0))`) + .width(240) + .margin(4) + .onClick(() => { + this.b = new ClassB(new ClassA(0)); + }) } + } } ``` + +### Example 2 + + ``` +var nextID: number = 0; +@Observed +class ClassA { + public name : string; + public c: number; + public id : number; + constructor(c: number, name: string = 'OK') { + this.name = name; + this.c = c; + this.id = nextID++; + } +} + @Component struct ViewA { - @ObjectLink a : ClassA; label : string = "ViewA1"; + @ObjectLink a: ClassA; build() { - Row() { - Button(`ViewA [${this.label}] this.a.c=${this.a.c} +1`) + Row() { + Button(`ViewA [${this.label}] this.a.c= ${this.a.c} +1`) .onClick(() => { - this.a.c += 1; + this.a.c += 1; }) - Button(`ViewA [${this.label}] reset this.a =new ClassA(0)`) - .onClick(() => { - this.a = new ClassA(0); // ERROR, this.a is immutable - }) - } + } } } @Entry -@Component +@Component struct ViewB { - @State b : ClassB = new ClassB(new ClassA(0)); - + @State arrA : ClassA[] = [ new ClassA(0), new ClassA(0) ]; build() { - Column() { - ViewA({label: "ViewA #1", a: this.b.a}) - ViewA({label: "ViewA #2", a: this.b.a}) + Column() { + ForEach (this.arrA, (item) => { + ViewA({label: `#${item.id}`, a: item}) + }, + (item) => item.id.toString() + ) + ViewA({label: `ViewA this.arrA[first]`, a: this.arrA[0]}) + ViewA({label: `ViewA this.arrA[last]`, a: this.arrA[this.arrA.length-1]}) - Button(`ViewB: this.b.a = new ClassA(0)`) + Button(`ViewB: reset array`) + .onClick(() => { + this.arrA = [ new ClassA(0), new ClassA(0) ]; + }) + Button(`ViewB: push`) .onClick(() => { - this.b.a = new ClassA(0); - }) - Button(`ViewB: this.b = new ClassB(ClassA(0))`) + this.arrA.push(new ClassA(0)) + }) + Button(`ViewB: shift`) .onClick(() => { - this.b = new ClassB(new ClassA(0)); - }) + this.arrA.shift() + }) } - } + } } ``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->**@ObjectLink** is used to decorate variables and cannot be initialized. **@Observed** is used to decorate a class. - diff --git a/en/application-dev/ui/ts-other-states-watch.md b/en/application-dev/ui/ts-other-states-watch.md index 5e5c10722f6079f2b4e4d313eadadd1bf3485845..3be75d6ee904334e1a5615cb6eb4d4cc6ff6bf26 100644 --- a/en/application-dev/ui/ts-other-states-watch.md +++ b/en/application-dev/ui/ts-other-states-watch.md @@ -1,7 +1,22 @@ -# @Watch +# @Watch -The application can register a callback through **@Watch**. This callback is triggered when a variable decorated by any of the following decorators changes: **@State**, **@Prop**, **@Link**, **@ObjectLink**, **@Provide**, **@Consume**, **@StorageProp**, and **@StorageLink**. The variables in **@Watch** must be enclosed in **""**. +@Watch is used to listen for changes of state variables. The syntax structure is as follows: + + + +``` +@State @Watch("onChanged") count : number = 0 +``` + + +As shown above, add an @Watch decorator to the target state variable to register an onChanged callback. When the state variable count is changed, the onChanged callback will be triggered. + + +@Watch can be used to listen for changes of variables decorated by @State, @Prop, @Link, @ObjectLink, @Provide, @Consume, @StorageProp, or @StorageLink. + + + ``` @Entry @Component @@ -12,7 +27,7 @@ struct CompA { updateTotal() : number { let sum = 0; this.shopBasket.forEach((i) => { sum += i; }); - // calculate new total shop basket value and apply discount if over 100RMB + // Calculate the total amount of items in the shopping basket. If the amount exceeds CNY100, the specified discount will be applied. this.totalPurchase = (sum < 100) ? sum : 0.9 * sum; return this.totalPurchase; } @@ -31,4 +46,3 @@ struct CompA { } } ``` - diff --git a/en/application-dev/ui/ts-parameterless-configuration.md b/en/application-dev/ui/ts-parameterless-configuration.md index bb08205d3361fc55936efb7b04e3a17f64d5dde3..c8a0939c904c5194dad069887ca7d236a800dd76 100644 --- a/en/application-dev/ui/ts-parameterless-configuration.md +++ b/en/application-dev/ui/ts-parameterless-configuration.md @@ -1,8 +1,7 @@ -# Parameterless Configuration +# Configuration Without Parameters -If the API definition of a component does not contain mandatory parameters, you do not need to configure any content in the parentheses next to the component. -For example, the following **Divider** component does not contain parameters: +If the API definition of a component does not contain mandatory parameters, you do not need to configure any content in the parentheses next to the component. For example, the Divider component does not contain parameters: ``` Column() { @@ -11,4 +10,3 @@ Column() { Text('item 2') } ``` - diff --git a/en/application-dev/ui/ts-pixel-units.md b/en/application-dev/ui/ts-pixel-units.md index 30c64a9b078610a68bea9e2f9ff8d20360fabd74..0a5011500f3bc8a928885035faaf4471fb442b61 100644 --- a/en/application-dev/ui/ts-pixel-units.md +++ b/en/application-dev/ui/ts-pixel-units.md @@ -1,83 +1,34 @@ -# Pixel Units +# Pixel Units + The framework provides four pixel units, with vp as the reference data unit. - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

px

-

Physical pixel unit of the screen.

-

vp

-

Pixels specific to the screen density, which are converted into physical pixels of the screen based on the screen pixel density.

-

fp

-

Font pixel, which is similar to vp and varies according to the system font size.

-

lpx

-

Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by designWidth). For example, if designWidth is set to 720, then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels.

-
-## Pixel Unit Conversion + | Name | Description | +| -------- | -------- | +| px | Physical pixel unit of the screen. | +| vp | Pixels specific to the screen density, which are converted into physical pixels of the screen based on the screen pixel density. | +| fp | Font pixel, which is similar to vp and varies according to the system font size. | +| lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by [designWidth](ts-framework-js-tag.md)). For example, if designWidth is set to 720, then 1lpx is equal to 2px for a screen with an actual width of 1440 physical pixels. | + + +## Pixel Unit Conversion Conversion from other pixel units to px is supported. - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

vp2px(value : number) : number

-

Converts a value in units of vp to a value in units of px.

-

px2vp(value : number) : number

-

Converts a value in units of px to a value in units of vp.

-

fp2px(value : number) : number

-

Converts a value in units of fp to a value in units of px.

-

px2fp(value : number) : number

-

Converts a value in units of px to a value in units of fp.

-

lpx2px(value : number) : number

-

Converts a value in units of lpx to a value in units of px.

-

px2lpx(value : number) : number

-

Converts a value in units of px to a value in units of lpx.

-
+ | API | Description | +| -------- | -------- | +| vp2px(value : number) : number | Converts a value in units of vp to a value in units of px. | +| px2vp(value : number) : number | Converts a value in units of px to a value in units of vp. | +| fp2px(value : number) : number | Converts a value in units of fp to a value in units of px. | +| px2fp(value : number) : number | Converts a value in units of px to a value in units of fp. | +| lpx2px(value : number) : number | Converts a value in units of lpx to a value in units of px. | +| px2lpx(value : number) : number | Converts a value in units of px to a value in units of lpx. | -## Example +## Example + + ``` @Entry @Component @@ -121,5 +72,4 @@ struct Example { } ``` -![](figures/pixel-unit.gif) - +![en-us_image_0000001267607893](figures/en-us_image_0000001267607893.gif) diff --git a/en/application-dev/ui/ts-rending-control-syntax-foreach.md b/en/application-dev/ui/ts-rending-control-syntax-foreach.md index 58714c0b13c4291c47b2ba80136161406650a5e3..7896c60288171b4a19481b0686b1c761f50be0a6 100644 --- a/en/application-dev/ui/ts-rending-control-syntax-foreach.md +++ b/en/application-dev/ui/ts-rending-control-syntax-foreach.md @@ -1,7 +1,10 @@ -# ForEach +# ForEach -The development framework provides **ForEach** to iterate arrays and create components for each array item. **ForEach** is defined as follows: +The development framework provides ForEach to iterate arrays and create components for each array item. ForEach is defined as follows: + + + ``` ForEach( arr: any[], // Array to be iterated @@ -10,28 +13,48 @@ ForEach( ) ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- Loop rendering uses **ForEach** to automatically generate child components from the provided array. ->- **ForEach** must be used in container components. ->- The first parameter must be an array. An empty array is allowed. If an array is empty, no child component is created. You can set the functions whose return values are of the array type, for example, **arr.slice \(1, 3\)**. The set functions cannot change any state variables including the array itself, such as **Array.splice**, **Array.sort**, and **Array.reverse**. ->- The second parameter is used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in the braces \(\{...\}\). ->- The third parameter is optional and used as an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that the generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in **ForEach** will be rebuilt. ->- The generated child components must be allowed in the parent container component of **ForEach**. The child component generator function can contain the **if/else** conditional statement. In addition, **ForEach** can be contained in the **if/else** conditional statement. ->- The calling sequence of subitem generator functions may be different from that of the data items in the array. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: -> ``` -> ForEach(anArray, item => {Text(`${++counter}. item.label`)}) -> ``` -> Below is an example of correct usage: -> ``` -> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), -> item => Text(`${item.i}. item.data.label`), -> item => item.data.id.toString()) -> ``` - -## Example + +## ForEach + + +ForEach(arr: any[],itemGenerator: (item: any, index?: number) => void, keyGenerator?: (item: any, index?: number) => string):void + + + Table1 Parameters + +| Name | Type | Mandatory | Default Value | Description | +| -------- | -------- | -------- | -------- | -------- | +| arr | any[] | Yes | - | Must be an array. An empty array is allowed. If an array is empty, no child component is created. You can set the functions whose return values are of the array type, for example, arr.slice (1, 3). The set functions cannot change any state variables including the array itself, such as Array.splice, Array.sort, and Array.reverse. | +| itemGenerator | (item: any, index?: number) => void | Yes | - | Used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in braces ({...}) | +| keyGenerator | (item: any, index?: number) => string | No | - | Used as an anonymous parameter for generating a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from that of the new item. This key-value generator is optional. However, for performance reasons, it is strongly recommended that the key-value generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in ForEach will be rebuilt. | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - ForEach must be used in container components. +> +> - The generated child components are allowed in the parent container component of ForEach. The child component generator function can contain the if/else conditional statement, and the if/else conditional statement can contain ForEach. +> +> - The calling sequence of subitem generator functions may be different from that of the data items in the array. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: +> +> ``` +> ForEach(anArray, item => {Text(`${++counter}. item.label`)}) +> ``` +> +> Below is an example of correct usage: +> +> +> ``` +> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), +> item => Text(`${item.i}. item.data.label`), +> item => item.data.id.toString()) +> ``` + + +## Example The following is an example of a simple-type array: + ``` @Entry @Component @@ -57,8 +80,8 @@ struct MyComponent { } ``` -The following is an example of a complex-type array: - + The following is an example of a complex-type array: + ``` class Month { year: number @@ -121,4 +144,3 @@ struct Calendar1 { } } ``` - diff --git a/en/application-dev/ui/ts-rending-control-syntax-if-else.md b/en/application-dev/ui/ts-rending-control-syntax-if-else.md index 22af60153a56496b6f5cfd3dc9b7fd72ef0208d2..6dd0f40247033f4c9fb0756bceaf88d375307ac2 100644 --- a/en/application-dev/ui/ts-rending-control-syntax-if-else.md +++ b/en/application-dev/ui/ts-rending-control-syntax-if-else.md @@ -1,16 +1,23 @@ -# if/else +# if/else -Use **if/else** for conditional rendering. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- State variables can be used in the **if** conditional statement. ->- You can use the **if** conditional statement to implement rendering of child components. ->- The **if** conditional statement must be used in container components. ->- Some container components limit the type or number of child components. When **if** is placed in these components, the limitation applies to components created in **if** and **else** statements. For example, when **if** is used in the **** component, only the **** component can be used in the **if** conditional statement, and only the **** component can be used in the **** component. +Use if/else for conditional rendering. -## Example -Example of using the **if** conditional statement: +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - State variables can be used in the if conditional statement. +> +> - You can use the if conditional statement to implement rendering of child components. +> +> - The if conditional statement must be used in container components. +> +> - Some container components limit the type or number of child components. When if is placed in these components, the limitation applies to components created in if and else statements. For example, when if is used in the <Grid> component, whose child components can only be <GridItem>, only the <GridItem> component can be used in the if conditional statement. + + +## Example + +Example of using the if conditional statement: + ``` Column() { @@ -20,7 +27,10 @@ Column() { } ``` -Example of using the **if**, **else if**, and **else** conditional statements: + +Example of using the if, else if, and else conditional statements: + + ``` Column() { @@ -35,4 +45,3 @@ Column() { } } ``` - diff --git a/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md b/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md index 095ff605e8f14fe9fba9d0d09d585d9c55afa127..86743ca4f46230dce98eddbf0c6c54f6eda71516 100644 --- a/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md +++ b/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md @@ -1,8 +1,24 @@ -# LazyForEach +# LazyForEach + + +The development framework provides LazyForEach to iterate data from provided data sources and create corresponding components during each iteration. LazyForEach is defined as follows: + -The development framework provides the **LazyForEach** component to iterate data as required and create corresponding components during each iteration. **LazyForEach** is defined as follows: ``` +LazyForEach( + dataSource: IDataSource, // Data source to be iterated + itemGenerator: (item: any) => void, // child component generator + keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. +): void + +interface IDataSource { + totalCount(): number; // Get total count of data + getData(index: number): any; // Get single data by index + registerDataChangeListener(listener: DataChangeListener): void; // Register listener to listening data changes + unregisterDataChangeListener(listener: DataChangeListener): void; // Unregister listener +} + interface DataChangeListener { onDataReloaded(): void; // Called while data reloaded onDataAdded(index: number): void; // Called while single data added @@ -10,42 +26,75 @@ interface DataChangeListener { onDataDeleted(index: number): void; // Called while single data deleted onDataChanged(index: number): void; // Called while single data changed } -interface IDataSource { - totalCount(): number; // Get total count of data - getData(index: number): any; // Get single data by index - registerDataChangeListener(listener: DataChangeListener): void; // Register listener to listening data changes - unregisterDataChangeListener(listener: DataChangeListener): void; // Unregister listener -} -LazyForEach( - dataSource: IDataSource, // Data source to be iterated - itemGenerator: (item: any) => void, // child component generator - keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. -): void ``` ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When data is updated through **onDataChanged** of **LazyForEach**, if **itemGenerator** contains a fully static view \(that is, the view does not contain state variables\), the view will not be updated. ->- **LazyForEach** is used to automatically generate child components from the provided data source. ->- **LazyForEach** must be used in the container component. Only the ****, ****, and **** components support on-demand data loading \(that is, only the visible part and a small amount of data before and after the visible part are loaded for caching\). For other components, all data is loaded at a time. ->- The first parameter must be an object inherited from **IDataSource**. You need to implement related APIs. ->- The second parameter is used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in the braces \(\{...\}\). ->- The third parameter is optional and used as an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that the generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in **ForEach** will be rebuilt. ->- The generated child component must be allowed in the parent container component of **LazyForEach**, so that **LazyForEach** can be included in the **if/else** conditional statement. ->- **LazyForEach** must create one and only one child component in each iteration. ->- **ForEach** cannot be used as a child component of **LazyForEach**, and **LazyForEach** does not support nesting. ->- The **if/else** conditional statement is not allowed in **LazyForEach**. ->- The calling sequence of the subitem generator function may be different from that of the data items in the data source. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: -> ``` -> ForEach(dataSource, item => {Text(`${++counter}. item.label`)}) -> ``` -> Below is an example of correct usage: -> ``` -> ForEach(dataSource, -> item => Text(`${item.i}. item.data.label`)), -> item => item.data.id.toString()) -> ``` - -## Example + +## APIs + + +### LazyForEach + +LazyForEach(dataSource: IDataSource, itemGenerator: (item: any) => void, keyGenerator?: (item: any) => string):void + + Table1 Parameters + +| Name | Type | Mandatory | Default Value | Description | +| -------- | -------- | -------- | -------- | -------- | +| dataSource | IDataSource | Yes | - | Object used to implement the IDataSource API. You need to implement related APIs. | +| itemGenerator | (item: any) => void | Yes | - | Used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in the braces ({...}) | +| keyGenerator | (item: any) => string | No | - | Used as an anonymous parameter for generating a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from that of the new item. This key-value generator is optional. However, for performance reasons, it is strongly recommended that the key-value generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in LazyForEach will be rebuilt. | + + + Table2 Description of IDataSource + +| Name | Description | +| -------- | -------- | +| totalCount(): number | Obtains the total number of data records. | +| getData(index: number): any | Obtains the data corresponding to the specified index. | +| registerDataChangeListener(listener: DataChangeListener): void | Registers the data change listener. | +| unregisterDataChangeListener(listener: DataChangeListener): void | Unregisters the data change listener. | + + + Table3 Description of DataChangeListener + +| Name | Description | +| -------- | -------- | +| onDataReloaded(): void | Reloads all data. | +| onDataAdded(index: number): void | Notifies the component that data is added to the position indicated by the specified index. | +| onDataMoved(from: number, to: number): void | Notifies the component that data is moved from the from position to the to position. | +| onDataDeleted(index: number): void | Notifies the component that data is deleted from the position indicated by the specified index. | +| onDataChanged(index: number): void | Notifies the component that data in the position indicated by the specified index is changed. | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - LazyForEach must be used in the container component. Only the <List>, <Grid>, and <Swiper> components support LazyForEach (that is, only the visible part and a small amount of data before and after the visible part are loaded for caching). For other components, all data is loaded at a time. +> +> - LazyForEach must create one and only one child component in each iteration. +> +> - The generated child component must be in the parent container component of LazyForEach. +> +> - LazyForEach can be included in an if/else conditional statement, but cannot contain an if/else conditional statement. +> +> - For the purpose of high-performance rendering, when the onDataChanged method of the DataChangeListener object is used to update the UI, the component update is triggered only when the state variable is used in the component specified in the UI description of itemGenerator. +> +> - The calling sequence of the subitem generator function may be different from that of the data items in the data source. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: +> +> ``` +> LazyForEach(dataSource, item => {Text(`${++counter}. item.label`)}) +> ``` +> +> Below is an example of correct usage: +> +> +> ``` +> LazyForEach(dataSource, +> item => Text(`${item.i}. item.data.label`)), +> item => item.data.id.toString()) +> ``` + + +## Example + ``` // Basic implementation of IDataSource to handle data listener @@ -141,4 +190,3 @@ struct MyComponent { } } ``` - diff --git a/en/application-dev/ui/ts-rending-control-syntax.md b/en/application-dev/ui/ts-rending-control-syntax.md deleted file mode 100644 index e8626c1a4acc4e4881c7648e973fb9555164f4af..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-rending-control-syntax.md +++ /dev/null @@ -1,9 +0,0 @@ -# About Rendering Control Syntax - -- **[if/else](ts-rending-control-syntax-if-else.md)** - -- **[ForEach](ts-rending-control-syntax-foreach.md)** - -- **[LazyForEach](ts-rending-control-syntax-lazyforeach.md)** - - diff --git a/en/application-dev/ui/ts-resource-access.md b/en/application-dev/ui/ts-resource-access.md deleted file mode 100644 index 3294e7f68de3f762505efa0d18117ae6a35e9e1b..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-resource-access.md +++ /dev/null @@ -1,7 +0,0 @@ -# Resource Access - -- **[Accessing Application Resources](ts-application-resource-access.md)** - -- **[Media Resource Types](ts-media-resource-type.md)** - - diff --git a/en/application-dev/ui/ts-restrictions-for-generators.md b/en/application-dev/ui/ts-restrictions-for-generators.md deleted file mode 100644 index 03e708ccc7e83178c1c39b1f55b49c279b36eb2f..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-restrictions-for-generators.md +++ /dev/null @@ -1,26 +0,0 @@ -# Restrictions on Using TypeScript for Generators - -TypeScript has the following restrictions on generators: - -- Expressions can be used only in character strings \($\{expression\}\), **if** conditions, **ForEach** parameters, and component parameters. -- No expressions should cause any application state variables \(**@State**, **@Link**, and **@Prop**\) to change. Otherwise, undefined and potentially unstable framework behavior may occur. -- You can use **console.log** in the first line of the generator function body so that you can track component re-rendering more easily. Expressions in the log character strings also comply with the preceding restrictions. -- The generator function cannot contain local variables. - -None of the above restrictions apply to anonymous function implementations of event-handling functions \(such as **onClick**\) and to the rest of the UI component description. - -Incorrect: - -``` -build() { - let a: number = 1 // invalid: variable declaration not allowed - console.log(`a: ${a}`) // invalid: console.log only allowed in first line of build - Column() { - Text('Hello ${this.myName.toUpperCase()}') // ok. - ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place - } - buildSpecial() // invalid: no function calls - Text(this.calcTextValue()) // this function call is ok. -} -``` - diff --git a/en/application-dev/ui/ts-syntactic-sugar-chaining.md b/en/application-dev/ui/ts-syntactic-sugar-chaining.md deleted file mode 100644 index 6cccebeeead49fad7eba642fd668b7b902c7f2e4..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-syntactic-sugar-chaining.md +++ /dev/null @@ -1,13 +0,0 @@ -# Chain Call - -You can configure the UI structure and its attributes and events and separate them with a dot\(.\) to implement chain call. - -``` -Column() { - Image('1.jpg') - .alt('error.jpg') - .width(100) - .height(100) -}.padding(10) -``` - diff --git a/en/application-dev/ui/ts-syntactic-sugar-decorator.md b/en/application-dev/ui/ts-syntactic-sugar-decorator.md deleted file mode 100644 index d2bc0707dcab41db9ba908d8c69905e0d15e85b8..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-syntactic-sugar-decorator.md +++ /dev/null @@ -1,80 +0,0 @@ -# @Decorator - -**@Decorator** can be applied to variable declarations, class definitions, structure definitions, or method definitions. - -Multiple decorator implementations can be superimposed on the target element and written on the same line or multiple lines. It is recommended that the implementation be written on multiple lines. - -In the example below, the elements decorated by **@Component** take on the form of a component, and the variables decorated by **@State** have the meaning of state data. - -``` -@Component -struct MyComponent { - @State count: number = 0 -} -``` - -Multiple decorator implementations can be written on the same line. - -``` -@Entry @Component struct MyComponent { -} -``` - -However, you are advised to write the decorator implementations on multiple lines. - -``` -@Entry -@Component -struct MyComponent { -} -``` - -## Supported Decorators - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Decorator

-

Decorates...

-

Description

-

@Component

-

struct

-

The decorated structure has the component-based capability. The build method must be implemented to update the UI.

-

@Entry

-

struct

-

The decorated component is used as the entry of a page. The component is rendered and displayed when the page is loaded.

-

@State

-

Primitive types, classes, and arrays

-

If the decorated state data is modified, the build method of the component will be called to update the UI.

-

@Prop

-

Primitive types

-

The modified state data is used to establish a unidirectional data dependency between the parent component and the child component. When the data associated with the parent component is modified, the UI of the current component is updated.

-

@Link

-

Primitive types, classes, and arrays

-

This decorator is used for two-way binding between the parent component and the child component. The internal state data of the parent component is used as the data source. Any changes made to one component will be reflected to the other.

-
- diff --git a/en/application-dev/ui/ts-syntactic-sugar-struct.md b/en/application-dev/ui/ts-syntactic-sugar-struct.md deleted file mode 100644 index 3755803f5de09fc94442c2597531366c5d70e964..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-syntactic-sugar-struct.md +++ /dev/null @@ -1,14 +0,0 @@ -# struct - -Components can be implemented based on **struct**s. Components cannot inherit from each other. The **struct**s implemented components can be created and destroyed more quickly than **class** implemented components. - -``` -@Component -struct MyComponent { - @State data: string = '' - - build() { - } -} -``` - diff --git a/en/application-dev/ui/ts-syntactic-sugar.md b/en/application-dev/ui/ts-syntactic-sugar.md index 088e9598c05662fe8f3331c94a4b1980377f432f..4f367db9ee810ccd016780c68e37078b82d8d522 100644 --- a/en/application-dev/ui/ts-syntactic-sugar.md +++ b/en/application-dev/ui/ts-syntactic-sugar.md @@ -1,15 +1,168 @@ -# About Syntactic Sugar +# About Syntactic Sugar -- **[@Decorator](ts-syntactic-sugar-decorator.md)** -- **[Chain Call](ts-syntactic-sugar-chaining.md)** +## Decorators -- **[struct](ts-syntactic-sugar-struct.md)** +A decorator @Decorator can decorate a class, structure, or class attribute. Multiple decorators can be applied to the same target element and defined on a single line or multiple lines. It is recommended that the decorators be defined on multiple lines. -- **[Instantiating a struct Without the new Keyword](ts-instantiating-a-struct-without-new-keyword.md)** +In the example below, the elements decorated by @Component take on the form of a component, and the variables decorated by @State can be used to represent states. -- **[Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md)** -- **[Restrictions on Using TypeScript for Generators](ts-restrictions-for-generators.md)** +``` +@Component +struct MyComponent { + @State count: number = 0 +} +``` +Multiple decorators can be defined on a single line, as shown below: + + +``` +@Entry @Component struct MyComponent { +} +``` + +However, you are advised to define the decorators on multiple lines, as shown below: + + +``` +@Entry +@Component +struct MyComponent { +} +``` + + +### Supported Decorators + + | Decorator | Decorates... | Description | +| -------- | -------- | -------- | +| @Component | struct | The decorated structure has the component-based capability. The build method must be implemented to update the UI. | +| @Entry | struct | The decorated component is used as the entry of a page. The component is rendered and displayed when the page is loaded. | +| @Preview | struct | Custom components decorated by @Preview can be previewed in the Previewer of DevEco Studio. When the page is loaded, the custom components decorated by @Preview are created and displayed. | +| @Builder | Methods | In the decorated method, you can use the declarative UI description to quickly generate multiple layouts in a custom component. | +| @Extend | Methods | This decorator adds new attribute functions to a preset component, allowing you to quickly define and reuse the custom style of the component. | +| @CustomDialog | struct | This decorator is used to decorate custom pop-up dialog boxes. | +| @State | Primitive data types, classes, and arrays | If the decorated state data is modified, the build method of the component will be called to update the UI. | +| @Prop | Primitive data types | This decorator is used to establish one-way data binding between the parent and child components. When the data associated with the parent component is modified, the UI of the current component is updated. | +| @Link | Primitive data types, classes, and arrays | This decorator is used to establish two-way data binding between the parent and child components. The internal state data of the parent component is used as the data source. Any changes made to one component will be reflected to the other. | +| @Observed | Classes | This decorator is used to indicate that the data changes in the class will be managed by the UI page. | +| @ObjectLink | Objects of @Observed decorated classes | When the decorated state variable is modified, the parent and sibling components that have the state variable will be notified for UI re-rendering. | +| @Consume | Primitive data types, classes, and arrays | When the @Consume decorated variable detects the update of the @Provide decorated variable, the re-rendering of the current custom component is triggered. | +| @Provide | Primitive data types, classes, and arrays | As the data provider, @Provide can update the data of child nodes and trigger page rendering. | +| @Watch | Variables decorated by @State, @Prop, @Link, @ObjectLink, @Provide, @Consume, @StorageProp, or @StorageLink | This decorator is used to listen for the changes of the state variables. The application can register a callback method through @Watch. | + + +## Chain Call + +You can configure the UI structure and its attributes and events and separate them with a dot(.) to implement chain call. + + +``` +Column() { + Image('1.jpg') + .alt('error.jpg') + .width(100) + .height(100) +}.padding(10) +``` + + +## struct + +Components can be implemented based on structs. Components cannot inherit from each other. The structs implemented components can be created and destroyed more quickly than class implemented components. + + +``` +@Component +struct MyComponent { + @State data: string = '' + + build() { + } +} +``` + + +## Instantiating a struct Without the new Keyword + +You can omit the new keyword when instantiating a struct. + + +``` +// Definition +@Component +struct MyComponent { + build() { + } +} + +// Use +Column() { + MyComponent() +} + +// Equivalent to +new Column() { + new MyComponent() +} +``` + + +## Restrictions on Using TypeScript in Generators + +TypeScript has the following restrictions on generators: + +- Expressions can be used only in character strings (${expression}), if conditions, ForEach parameters, and component parameters. + +- No expressions should cause any application state variables (@State, @Link, and @Prop) to change. Otherwise, undefined and potentially unstable framework behavior may occur. + +- The generator function cannot contain local variables. + +None of the above restrictions apply to anonymous function implementations of event-handling functions (such as onClick) + +Incorrect: + + +``` +build() { + let a: number = 1 // invalid: variable declaration not allowed + Column() { + Text('Hello ${this.myName.toUpperCase()}') // ok. + ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place + } + buildSpecial() // invalid: no function calls + Text(this.calcTextValue()) // this function call is ok. +} +``` + +## $$ + +$$ supports two-way binding for simple variables and @State, @Link, and @Prop decorated variables. + +Currently, $$ supports only the rendering between the show parameter of the bindPopup attribute and the @State decorated variable, and the checked attribute of the component. + +``` +@Entry +@Component +struct bindPopup { + @State customPopup: boolean = false + build() { + Column() { + Button(){ + Text('Popup') + } + .onClick(()=>{ + this.customPopup = !this.customPopup + }) + .bindPopup( + $$this.customPopup, { + message: "showPopup" + } + ) + } + } +} +``` diff --git a/en/application-dev/ui/ts-syntax-intro.md b/en/application-dev/ui/ts-syntax-intro.md index 87fdf54d31c403eda07675cb8a6d11924a857b94..a1ac7a1d8a25bcc25e0b85ade30d278b1ca91e1c 100644 --- a/en/application-dev/ui/ts-syntax-intro.md +++ b/en/application-dev/ui/ts-syntax-intro.md @@ -1,11 +1,16 @@ -# Overview +# Overview + This section defines the core mechanism and functions of the TypeScript-based declarative development paradigm. It acquaints you with the declarative UI descriptions, componentization mechanisms, UI state management, rendering control syntax, and syntactic sugar. -Follow the provided guidelines for UI development. For details about the components, see [Components](../reference/arkui-js/js-components.md). ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- All examples use the TypeScript \(TS\) language. If you are using another language, comply with the syntax requirements for that language. ->- The components used in the examples are preset in the UI framework and are used only to explain the UI description specifications. ->- Universal attribute and event methods generally apply to all components, and the attribute and event methods within a component apply only to this component. +Follow the provided guidelines for UI development. For details about the components, see components. + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - All examples use the TypeScript (TS) language. If you are using another language, comply with the syntax requirements for that language. +> +> - The components used in the examples are preset in the UI framework and are used only to explain the UI description specifications. +> +> - Universal attribute and event methods generally apply to all components, and the attribute and event methods within a component apply only to this component. diff --git a/en/application-dev/ui/ts-system-resource-access.md b/en/application-dev/ui/ts-system-resource-access.md index fbdeaceeb58762693645cb6e3b4e214516bce045..e3879354d0998ff54cf5d78547dd0d94280e721d 100644 --- a/en/application-dev/ui/ts-system-resource-access.md +++ b/en/application-dev/ui/ts-system-resource-access.md @@ -4,7 +4,7 @@ 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, which is determined when the system resource is provided. For details about available system resource IDs. +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, which is determined when the system resource is provided. For details about available system resource IDs. ``` Text('Hello') diff --git a/en/application-dev/ui/ts-types.md b/en/application-dev/ui/ts-types.md index 5f6c16c2bbf307b021260a431ef12cea46e6fed2..7a6838d2453d1bcf681e6ae397481653b5074e5e 100644 --- a/en/application-dev/ui/ts-types.md +++ b/en/application-dev/ui/ts-types.md @@ -4,33 +4,33 @@ | Name| Type| Description| | -------- | -------- | -------- | -| Length | string \| number | Length unit. If the input is a number, use **vp**. If the input is a string, explicitly specify the unit, for example, **'10px'**, or specify the length in percentage, for example, **'100%'**.| +| Length | string \| number | Length unit. If the input is a number, use vp. If the input is a string, explicitly specify the unit, for example, '10px', or specify the length in percentage, for example, '100%'.| ## Angle Type | Name| Type| Description| | -------- | -------- | -------- | -| Angle | string \| number | Angle unit. If the input is a number, use **deg**. If the input is a string, explicitly specify the unit, which can be either of the following:
- deg, as in **'100deg'**
- rad, as in **'3.14rad'** | +| Angle | string \| number | Angle unit. If the input is a number, use deg. If the input is a string, use either of the following angle units:
- deg: for example, '100deg'
- rad: for example, '3.14rad' | ## Point Type | Name| Type| Description| | -------- | -------- | -------- | -| Point | [Length, Length] | Coordinates of a point. The first value is the x-axis coordinate, and the second value is the y-axis coordinate.| +| Point | [Length, Length] | Coordinates of a point. The first value is the x-axis coordinate, and the second value is the y-axis coordinate.| ## Color Type -The **Color** used by the component attribute method is described as follows: +The Color type used by component attribute methods is described as follows: | Name| Type| Description| | -------- | -------- | -------- | -| Color | string \| number \| Color | Color information. If the input is a string, use **rgb** or **rgba** to specify the color. If the input is a number, use Hex format to specify the color. If the input is a **Color" enum, use a color value to specify the color.
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- Hex format: 0xrrggbb, 0xaarrggbb, '\#FFFFFF'
- Enum: Color.Black, Color.White| +| Color | string \| number \| Color | Color information. If the input is a string, use rgb or rgba to specify the color. If the input is a number, use Hex format to specify the color. If the input is a Color enum, use a color value to specify the color.
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- Hex format: 0xrrggbb, 0xaarrggbb, '\#FFFFFF'
- Enum: Color.Black, Color.White | -The supported **Color** enums are described as follows: +The supported Color enums are described as follows: | Color| Value| Illustration| @@ -49,55 +49,60 @@ The supported **Color** enums are described as follows: ## ColorStop Type -**ColorStop** is used to describe the progressive color stop. +ColorStop is used to describe the progressive color stop. | Name| Type| Description| | -------- | -------- | -------- | -| ColorStop | [Color, number] | Type of the progressive color stop. The first parameter specifies the color value, and the second parameter specifies the ratio of 0 to 1.| +| ColorStop | [Color, number] | Type of the progressive color stop. The first parameter specifies the color value, and the second parameter specifies the ratio of 0 to 1.| ## Resource Type -Resource reference type, which is used to set the value of a component attribute. +The Resource type is used to reference resources for setting the value of a component attribute. -You can use **$r** or **$rawfile** to create a **Resource** object. For details, see [Resource Access](ts-media-resource-type.md). +You can use $r or $rawfile to create a Resource object. For details, see [Resource Access](ts-application-resource-access.md). - $r('belonging.type.name') - **belonging**: system or application resource. The value can be **'sys'** or **'app'**. + belonging: system or application resource. The value can be 'sys' or 'app'. - **type**: resource type, which can be **'color'**, **'float'**, **'string'**, or **'media'**. + type: resource type, which can be 'color', 'float', 'string', or 'media'. - **name**: resource name, which is determined during resource definition. + name: resource name, which is determined during resource definition. - $rawfile('filename') - **filename**: name of the file in **resources/rawfile** of the project. + filename: name of the file in resources/rawfile of the project. | Name| Type| Description| | -------- | -------- | -------- | -| Resource | {
readonly id: [number];
readonly type: [number];
readonly params?: any[];
} | **id**: resource ID.
**type**: resource type (enumerated value).
**params**: optional parameters.
After a **Resource** object is created using **$r** or **$rawfile**, modifying attribute values of the object is prohibited.| +| Resource | {
readonly id: [number];
readonly type: [number];
readonly params?: any[];
} | id: resource ID.
type: resource type (enumerated value).
params: optional parameters.
After a Resource object is created using $r or $rawfile, modifying attribute values of the object is prohibited.| -## ResourceStr8+ +## ResourceStr Type8+ | Name| Type| Description| | -------- | -------- | -------- | -| ResourceStr | string \| [Resource](#resourcetype) | Resource string.| +| ResourceStr | string \| Resource| Resource string.| -## Resource Color8+ +## ResourceColor Type8+ | Name| Type| Description| | -------- | -------- | -------- | -| ResourceColor | Color \| number \| string \| [Resource](#resourcetype) | Resource color.| +| ResourceColor | Color \| number \| string \| Resource | Resource color.| +## Font Type8+ -## Custom Builder8+ +| Name| Type| Description| +| -------- | -------- | -------- | +| Font | {
size?: Length;
weight?: FontWeight \| number \| string;
family?: string \| Resource;
style?: FontStyle;
} | Text style.
size: font size. For the number type, use the unit fp.
weight: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is 400. A larger value indicates a larger font weight.
family: font family. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is 'Arial, sans-serif'.
style: font style.| + +## CustomBuilder Type8+ -You can use **CustomBuilder** to define custom UI descriptions in component attribute methods. +You can use CustomBuilder to define custom UI descriptions in component attribute methods. | Name| Type| Description| | -------- | -------- | -------- | -| CustomBuilder | () => any | Builder of component attribute methods for defining custom UI descriptions. This type of method must be decorated by **@Builder**. For details, see [@Builder](ts-component-based-builder.md).| +| CustomBuilder | () => any | Builder of component attribute methods for defining custom UI descriptions. This type of method must be decorated by @Builder. For details, see [@Builder](ts-component-based-builder.md).| ## Example diff --git a/en/application-dev/ui/ts-ui-state-management.md b/en/application-dev/ui/ts-ui-state-management.md deleted file mode 100644 index fd37d287c456038cc1a9709048a71255d8ab6722..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-ui-state-management.md +++ /dev/null @@ -1,11 +0,0 @@ -# About UI State Management - -- **[Basic Concepts](ts-ui-state-mgmt-concepts.md)** - -- **[Managing Component States](ts-managing-component-states.md)** - -- **[Managing Application States](ts-managing-application-states.md)** - -- **[Managing Other States](ts-managing-other-states.md)** - - diff --git a/en/application-dev/ui/ts-ui-state-mgmt-concepts.md b/en/application-dev/ui/ts-ui-state-mgmt-concepts.md index ec3fbe4640e2bbe9c66ca2d4171beb3767fcd5a0..a25d43a5767e9f25f73f7a1bb46903a279451cf3 100644 --- a/en/application-dev/ui/ts-ui-state-mgmt-concepts.md +++ b/en/application-dev/ui/ts-ui-state-mgmt-concepts.md @@ -1,27 +1,27 @@ -# Basic Concepts +# Basic Concepts -In the declarative UI programming paradigm, the UI is a function in the specific application state, and you update a UI by modifying the current application state. -The development framework provides comprehensive application state management capabilities, as shown in the figure below. +In the declarative UI programming paradigm, the UI is a function in the specific application state, and you update a UI by modifying the current application state. The development framework provides comprehensive application state management capabilities, as shown in the figure below. -![](figures/corespec_figures_state-mgmt-overview.png) -## State Variable Decorators +![en-us_image_0000001222967768](figures/en-us_image_0000001222967768.png) -- **@State**: grants a component the state attribute. Each time the **@State** decorated variable changes, the component re-renders and updates the UI. -- **@Link**: allows a component to depend on some state attributes of its parent component. Each time the data in one component is updated, the state of the other component is updated, and the parent and child components are rendered again. +## State Variable Decorators -- **@Prop**: works in a way similar to that of **@Link**. The only difference is that the changes made by a child component are not synchronized to the parent component. +- @State: state attribute of the component. Each time the @State decorated variable changes, the component re-renders and updates the UI. - > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** - > The state variable name cannot be **id**, for example, **@Prop id:number**. +- @Link: allows a component to depend on some state attributes of its parent component. Each time the data in one component is updated, the state of the other component is updated, and the parent and child components are rendered again. -## Application State Data +- @Prop: works in a way similar to that of @Link. The difference is that the changes made by a child component are not synchronized to the parent component. -**AppStorage** is the central store of the application states used in the entire UI. The UI framework creates a singleton **AppStorage** object for the application and provides the corresponding decorators and APIs for the application. -- **@StorageLink**: works in a way similar to that of **@Consume**. The difference is that the link object with the specified name is obtained from the **AppStorage**. It establishes two-way binding between the UI component and **AppStorage** to synchronize data. -- **@StorageProp**: synchronizes UI component attributes with the **AppStorage** unidirectionally. The value change in the **AppStorage** will trigger an update of the attribute value in the UI component, but the attribute value of the UI component will not cause an update of the attribute value in the **AppStorage**. -- Service logic implementation API: adds, reads, modifies, or deletes the state attributes of applications. The changes made by this API will be synchronized to the UI component for UI update. +## Application State Data +AppStorage is the central store of the application states in the entire UI. The UI framework creates a singleton AppStorage object for the application and provides the corresponding decorators and APIs for the application. + +- @StorageLink: works in a way similar to that of @Consume. The difference is that the link object with the specified name is obtained from the AppStorage. It establishes two-way binding between the UI component and AppStorage to synchronize data. + +- @StorageProp: synchronizes UI component attributes with the AppStorage unidirectionally. That is, the value change in the AppStorage will trigger an update of the corresponding UI component, but the change of the UI component will not cause an update of the attribute value in the AppStorage. + +- Service logic implementation API: adds, reads, modifies, or deletes the state attributes of applications. The changes made by this API will be synchronized to the UI component for UI update. diff --git a/en/application-dev/ui/ts-using-a-separate-line-for-new-component.md b/en/application-dev/ui/ts-using-a-separate-line-for-new-component.md deleted file mode 100644 index 9a220f54a95d24d195d3ab1dad5004f12223feb6..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-using-a-separate-line-for-new-component.md +++ /dev/null @@ -1,50 +0,0 @@ -# Using a Separate Line for New Component - -**Semicolons \(;\) can be omitted at the end of each line of code.** - -``` -Column() { - Image('icon.png') - Text('text') -} -``` - -It is equivalent to: - -``` -Column() { - Image('icon.png'); - Text('text'); -} -``` - -**Only one component can be created in a line. An if, else, else if, or ForEach statement must also be in a separate line.** - -Incorrect: - -``` -Column() { - Image('icon.png') Text('text') // invalid, creation of two components in same line -} - -if (this.condi) {Image('icon.png')} // invalid, if and creation a components in same line -``` - -**Built-in container components, if, and ForEach item generator functions must use closed parentheses \(\{\}\) in the case of a single subitem.** - -Incorrect: - -``` -if (this.condi) -Image('icon.png'), // invalid, missing {} -else - Text('text'); -``` - -``` -ForEach(this.arr, - (item) => Image('icon.png'), // invalid, missing {} - (item) => item.id.toString() -} -``` - diff --git a/en/application-dev/ui/ui-arkui-js.md b/en/application-dev/ui/ui-arkui-js.md deleted file mode 100644 index f43f305fc3ddc40343a1d3f7d685a7bf394c04aa..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-arkui-js.md +++ /dev/null @@ -1,15 +0,0 @@ -# JavaScript-based Web-Like Development Paradigm - -- **[Overview](ui-js-overview.md)** - -- **[Framework](js-framework.md)** - -- **[Building the UI](ui-js-building-ui.md)** - -- **[Common Component Development Guidelines](ui-js-common-components.md)** - -- **[Animation Development Guidelines](ui-js-animate.md)** - -- **[Custom Components](ui-js-custom-components.md)** - - diff --git a/en/application-dev/ui/ui-arkui-ts.md b/en/application-dev/ui/ui-arkui-ts.md deleted file mode 100644 index e22bf628a98afc6c86be83f65da7c83492d45e51..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-arkui-ts.md +++ /dev/null @@ -1,13 +0,0 @@ -# TypeScript-based Declarative Development Paradigm - -- **[Overview](ui-ts-overview.md)** - -- **[Framework Overview](ts-framework.md)** - -- **[Declarative Syntax](ts-declarative-syntax.md)** - -- **[Experiencing the Declarative UI](ui-ts-experiencing-declarative-ui.md)** - -- **[Defining Page Layout and Connection](ui-ts-page-layout-connections.md)** - - diff --git a/en/application-dev/ui/ui-arkui.md b/en/application-dev/ui/ui-arkui.md deleted file mode 100644 index 669dfd6203114becefec73cfbb2914c182036c4c..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-arkui.md +++ /dev/null @@ -1,7 +0,0 @@ -# ArkUI - -- **[JavaScript-based Web-Like Development Paradigm](ui-arkui-js.md)** - -- **[TypeScript-based Declarative Development Paradigm](ui-arkui-ts.md)** - - diff --git a/en/application-dev/ui/ui-js-animate-attribute-style.md b/en/application-dev/ui/ui-js-animate-attribute-style.md index 7060d95c005843a954ad0850ac8acf4258743cc3..17e860ab2ee639d02a7e61556715051577f131d3 100644 --- a/en/application-dev/ui/ui-js-animate-attribute-style.md +++ b/en/application-dev/ui/ui-js-animate-attribute-style.md @@ -1,6 +1,7 @@ -# Defining Attribute Style Animations +# Defining Attribute Style Animations -Keyframes is used to scale a component by dynamically setting the width and height of its parent component. Set the **scale** attribute for child components to scale the child and parent components at the same time. Then, set the **opacity** attribute to display or hide the child and parent components. + +Keyframes is used to scale a component by dynamically setting the width and height of its parent component. Set the scale attribute for child components to scale the child and parent components at the same time. Then, set the opacity attribute to display or hide the child and parent components. ``` @@ -78,9 +79,11 @@ text{ } ``` -![](figures/d1.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->1. The values of **animation** attributes are not sequenced. However, the values of **duration** and **delay** are parsed based on the sequence in which they are displayed. ->2. The **animation-duration** attribute must be set. Otherwise, the duration is 0, which means there is no animation effect. When **animation-fill-mode** is set to **forwards**, the component directly displays the style of the last frame. +![en-us_image_0000001267647889](figures/en-us_image_0000001267647889.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> 1. The values of animation attributes are not sequenced. However, the values of duration and delay are parsed based on the sequence in which they are displayed. +> +> 2. The animation-duration attribute must be set. Otherwise, the duration is 0, which means there is no animation effect. When animation-fill-mode is set to forwards, the component directly displays the style of the last frame. diff --git a/en/application-dev/ui/ui-js-animate-background-position-style.md b/en/application-dev/ui/ui-js-animate-background-position-style.md index a0be0d599a8020166cd7dc3fc294ad7781e1608f..567468ef9817e7bb83d0d6650f32a7711fb8cb15 100644 --- a/en/application-dev/ui/ui-js-animate-background-position-style.md +++ b/en/application-dev/ui/ui-js-animate-background-position-style.md @@ -1,6 +1,7 @@ -# Defining Animations with the background-position Attribute +# Defining Animations with the background-position Attribute -By changing the **background-position** attribute \(where the first value is the position on the x-axis and the second value is the position on the y-axis\), you move a background image. If the background image goes beyond the respective component boundaries, the excess parts will not be displayed. + +By changing the background-position attribute (where the first value is the position on the x-axis and the second value is the position on the y-axis), you move a background image. If the background image goes beyond the respective component boundaries, the excess parts will not be displayed. ``` @@ -74,8 +75,6 @@ By changing the **background-position** attribute \(where the first value is t } ``` -![](figures/q8.gif) - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The **background-position** attribute can only be used to move background images, but not the background color \(**background-color**\). +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> The background-position attribute can only be used to move background images, but not the background color (background-color). diff --git a/en/application-dev/ui/ui-js-animate-component.md b/en/application-dev/ui/ui-js-animate-component.md index a81efad3851a78467643141a164977281577df5a..25ce93282ae143540e272f274d938998e9c7c8d6 100644 --- a/en/application-dev/ui/ui-js-animate-component.md +++ b/en/application-dev/ui/ui-js-animate-component.md @@ -1,10 +1,13 @@ -# Component Animation +# Component Animation -Create and run an animation shortcut on the component. For details, see [Universal Methods](../reference/arkui-js/js-components-common-methods.md). -## Obtaining an Animation Object +Create and run an animation shortcut on the component. For details, see [Universal Methods](../reference/arkui-js/js-components-common-methods.md). + + +## Obtaining an Animation Object + +Call the animate method to obtain an animation object, which supports animation attributes, methods, and events. -Call the **animate** method to obtain an **animation** object, which supports animation attributes, methods, and events. ``` @@ -13,6 +16,7 @@ Call the **animate** method to obtain an **animation** object, which support ``` + ``` /* xxx.css */ .container { @@ -29,6 +33,7 @@ Call the **animate** method to obtain an **animation** object, which support } ``` + ``` /* xxx.js */ export default { @@ -57,15 +62,17 @@ export default { } ``` -![](figures/1-14.gif) +![en-us_image_0000001222807812](figures/en-us_image_0000001222807812.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - When using the animate method, you must pass the keyframes and options parameters. +> - If animate is called multiple times and the replace policy is used, parameters passed to the last call will take effect. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When using the **animate** method, you must pass the keyframes and options parameters. ->- If **animate** is called multiple times and the **replace** policy is used, parameters passed to the last call will take effect. -## Setting Animation Parameters +## Setting Animation Parameters + +After obtaining an animation object, you can set its style working on the component by using the keyframes parameter. -After obtaining an **animation** object, you can set its style working on the component by using the keyframes parameter. ``` @@ -74,6 +81,7 @@ After obtaining an **animation** object, you can set its style working on the ``` + ``` /* xxx.css */ .container { @@ -90,6 +98,7 @@ After obtaining an **animation** object, you can set its style working on the } ``` + ``` /* xxx.js */ export default { @@ -134,14 +143,16 @@ export default { } ``` -![](figures/1-15.gif) +![en-us_image_0000001267647897](figures/en-us_image_0000001267647897.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- The sequence of **translate**, **scale**, and **rotate** affects the animation effect. ->- **transformOrigin** works only for **scale** and **rotate**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - The sequence of translate, scale, and rotate affects the animation effect. +> +> - transformOrigin works only for scale and rotate. Set the animation attributes by using the options parameter. + ```
@@ -149,6 +160,7 @@ Set the animation attributes by using the options parameter.
``` + ``` /* xxx.css */ .container { @@ -165,6 +177,7 @@ Set the animation attributes by using the options parameter. } ``` + ``` /* xxx.js */ export default { @@ -174,13 +187,7 @@ export default { onInit() { }, onShow() { - var options = { - duration: 1500, - easing: 'ease-in', - delay: 5, - iterations: 2, - direction: 'normal', - }; + var options = { duration: 1500, easing: 'ease-in', delay: 5, iterations: 2, direction: 'normal', }; var frames = [ { transform: { @@ -201,18 +208,24 @@ export default { } ``` -![](figures/3-16.gif) +![en-us_image_0000001222967796](figures/en-us_image_0000001222967796.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->**direction**: mode of playing the animation. ->**normal**: plays the animation in forward loop mode. ->**reverse**: plays the animation in reverse loop mode. ->**alternate**: plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in reverse direction. ->**alternate-reverse**: plays the animation in reverse alternating loop mode. When the animation is played for an odd number of times, the playback is in reverse direction. When the animation is played for an even number of times, the playback is in forward direction. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> direction: mode of playing the animation. +> +> normal: plays the animation in forward loop mode. +> +> reverse: plays the animation in reverse loop mode. +> +> alternate: plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in reverse direction. +> +> alternate-reverse: plays the animation in reverse alternating loop mode. When the animation is played for an odd number of times, the playback is in reverse direction. When the animation is played for an even number of times, the playback is in forward direction. -## Adding an Event and Calling a Method -Animation objects support animation events and methods. You can achieve the intended animation by adding **start** and **cancel** events and calling the **play**, **pause**, **rewind**, and **stop** methods. +## Adding an Event and Calling a Method + +Animation objects support animation events and methods. You can achieve the intended animation by adding start and cancel events and calling the play, pause, rewind, and stop methods. + ``` @@ -230,6 +243,7 @@ Animation objects support animation events and methods. You can achieve the inte ``` + ``` /* xxx.css */ .container { @@ -262,6 +276,7 @@ button{ } ``` + ``` /* xxx.js */ import prompt from '@system.prompt'; @@ -336,9 +351,10 @@ export default { } ``` -![](figures/111-17.gif) +![en-us_image_0000001223127752](figures/en-us_image_0000001223127752.gif) + +Change the animation status by changing the playStat attribute. -Change the animation status by changing the **playStat** attribute. ``` @@ -354,6 +370,7 @@ Change the animation status by changing the **playStat** attribute. ``` + ``` /* xxx.css */ .container { @@ -386,6 +403,7 @@ button{ } ``` + ``` /* xxx.js */ import prompt from '@system.prompt'; @@ -463,5 +481,4 @@ export default { } ``` -![](figures/1111.gif) - +![en-us_image_0000001267607921](figures/en-us_image_0000001267607921.gif) diff --git a/en/application-dev/ui/ui-js-animate-css.md b/en/application-dev/ui/ui-js-animate-css.md deleted file mode 100644 index c5103fa5fe9b0a6f7535fa815be625dd1b6b0af5..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-animate-css.md +++ /dev/null @@ -1,9 +0,0 @@ -# CSS Animation - -- **[Defining Attribute Style Animations](ui-js-animate-attribute-style.md)** - -- **[Defining Animations with the transform Attribute](ui-js-animate-transform.md)** - -- **[Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md)** - - diff --git a/en/application-dev/ui/ui-js-animate-dynamic-effects.md b/en/application-dev/ui/ui-js-animate-dynamic-effects.md index d566b7bee31f6c3a57953b38589861d42e876515..bbd5aae520e9c5e767b132b929f11cb006670f5b 100644 --- a/en/application-dev/ui/ui-js-animate-dynamic-effects.md +++ b/en/application-dev/ui/ui-js-animate-dynamic-effects.md @@ -1,13 +1,17 @@ -# Animation Effect +# Animation Effect -You can set the interpolator to implement the animation effect. For details, see [Animation](../reference/apis/js-apis-basic-features-animator.md). ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->This feature is supported since API version 6. +You can set the interpolator to implement the animation effect. For details, see [Animation](../reference/apis/js-apis-basic-features-animator.md). -## Creating an Animation Object -Use **createAnimator** to create an **animation** object and set the **animation** attributes by using the options parameter. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> This feature is supported since API version 6. + + +## Creating an Animation Object + +Use createAnimator to create an animation object and set the animation attributes by using the options parameter. + ``` @@ -20,6 +24,7 @@ Use **createAnimator** to create an **animation** object and set the **anim ``` + ``` /* xxx.css */ .container { @@ -40,6 +45,7 @@ button{ } ``` + ``` /* xxx.js */ import animator from '@ohos.animator'; @@ -72,16 +78,20 @@ export default { } ``` -![](figures/22.gif) +![en-us_image_0000001267887885](figures/en-us_image_0000001267887885.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When you use **createAnimator** to create an animation object, you must pass the **options** parameter. ->- **begin** indicates the start point of the animation interpolation. If it is not set, the default value **0** is used. ->- **end** indicates the end point of the animation interpolation. If it is not set, the default value **1** is used. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - When you use createAnimator to create an animation object, you must pass the options parameter. +> +> - begin indicates the start point of the animation interpolation. If it is not set, the default value 0 is used. +> +> - end indicates the end point of the animation interpolation. If it is not set, the default value 1 is used. -## Adding Animation Events and Calling Methods -The **animator** supports events and methods, which you can use to customize the animation effect. Events include **frame**, **cancel**, **repeat**, and **finish**. Methods include **update**, **play**, **pause**, **cancel**, **reverse**, and **finish**. For details about the supported events and methods, see [animator supported events and animator supported APIs](../reference/apis/js-apis-basic-features-animator.md). +## Adding Animation Events and Calling Methods + +The animator supports events and methods, which you can use to customize the animation effect. Events include frame, cancel, repeat, and finish. Methods include update, play, pause, cancel, reverse, and finish. For details about the supported events and methods, see [animator supported events and animator supported APIs](../reference/apis/js-apis-basic-features-animator.md). + ``` @@ -106,6 +116,7 @@ The **animator** supports events and methods, which you can use to customize t ``` + ``` /* xxx.css */ .container { @@ -148,6 +159,7 @@ button{ } ``` + ``` /* xxx.js */ import animator from '@ohos.animator'; @@ -230,8 +242,7 @@ export default { } ``` -![](figures/1-18.gif) - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->When calling the **update** method, you can use it to update the animation parameters. The input parameters are the same as those of **createAnimator**. +![en-us_image_0000001223287724](figures/en-us_image_0000001223287724.gif) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> When calling the update method, you can use it to update the animation parameters. The input parameters are the same as those of createAnimator. diff --git a/en/application-dev/ui/ui-js-animate-frame.md b/en/application-dev/ui/ui-js-animate-frame.md index 355cc098f746d1271ab6823578ce30f16a1c9b55..f1cb12abb0f69ce1c76868b4f162621290eeb012 100644 --- a/en/application-dev/ui/ui-js-animate-frame.md +++ b/en/application-dev/ui/ui-js-animate-frame.md @@ -1,11 +1,13 @@ -# Animation Frame +# Animation Frame -## Requesting an Animation Frame -Use the **requestAnimationFrame** method to request frames on a one-by-one basis. This method accepts a callback as an argument. +## Requesting an Animation Frame -When **runframe** calls **requestAnimationFrame**, the **step** callback with the **timestamp** parameter is passed, and this **timestamp** iss assigned to **startTime**. When the difference between the **timestamp** and **startTime** is less than the specified value, **requestAnimationFrame** is called again, and the animation stops. +Use the requestAnimationFrame method to request frames on a one-by-one basis. This method accepts a callback as an argument. +When runframe calls requestAnimationFrame, the step callback with the timestamp parameter is passed, and this timestamp iss assigned to startTime. When the difference between the timestamp and startTime is less than the specified value, requestAnimationFrame is called again, and the animation stops. + + ```
@@ -25,6 +27,7 @@ When **runframe** calls **requestAnimationFrame**, the **step** callback wi
``` + ``` /* xxx.css */ .container { @@ -39,6 +42,7 @@ button{ } ``` + ``` /* xxx.js */ export default { @@ -93,15 +97,17 @@ export default { } ``` -![](figures/3333.gif) +![en-us_image_0000001267767877](figures/en-us_image_0000001267767877.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> When invoking the callback, the requestAnimationFrame method passes the timestamp as the first parameter, which indicates the time when requestAnimationFrame starts to execute the callback. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->When invoking the callback, the **requestAnimationFrame** method passes the timestamp as the first parameter, which indicates the time when **requestAnimationFrame** starts to execute the callback. -## Canceling an Animation Frame +## Canceling an Animation Frame -Use the **cancelAnimationFrame** method to cancel frames on a one-by-one basis. When this method is called, the animation frame request sent through **requestAnimationFrame** will be canceled. +Use the cancelAnimationFrame method to cancel frames on a one-by-one basis. When this method is called, the animation frame request sent through requestAnimationFrame will be canceled. + ```
@@ -121,6 +127,7 @@ Use the **cancelAnimationFrame** method to cancel frames on a one-by-one basis
``` + ``` /* xxx.css */ .container { @@ -135,6 +142,7 @@ button{ } ``` + ``` /* xxx.js */ export default { @@ -181,8 +189,7 @@ export default { } ``` -![](figures/4444.gif) - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->When **cancelAnimationFrame** is called, a parameter that indicates an ID must be passed. +![en-us_image_0000001223127740](figures/en-us_image_0000001223127740.gif) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> When cancelAnimationFrame is called, a parameter that indicates an ID must be passed. diff --git a/en/application-dev/ui/ui-js-animate-interpolator.md b/en/application-dev/ui/ui-js-animate-interpolator.md deleted file mode 100644 index a3e45d4b072f61ebcdc03ab1a2abe68b043f039b..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-animate-interpolator.md +++ /dev/null @@ -1,7 +0,0 @@ -# Interpolator Animation - -- **[Animation Effect](ui-js-animate-dynamic-effects.md)** - -- **[Animation Frame](ui-js-animate-frame.md)** - - diff --git a/en/application-dev/ui/ui-js-animate-javascript.md b/en/application-dev/ui/ui-js-animate-javascript.md deleted file mode 100644 index f14e27fb8805e9f56e3e27e677d3f87744e2383f..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-animate-javascript.md +++ /dev/null @@ -1,7 +0,0 @@ -# JS Animation - -- **[Component Animation](ui-js-animate-component.md)** - -- **[Interpolator Animation](ui-js-animate-interpolator.md)** - - diff --git a/en/application-dev/ui/ui-js-animate-svg.md b/en/application-dev/ui/ui-js-animate-svg.md new file mode 100644 index 0000000000000000000000000000000000000000..7a9cb5ea1147020cec5599008db06d1518eacd4a --- /dev/null +++ b/en/application-dev/ui/ui-js-animate-svg.md @@ -0,0 +1,100 @@ +# Defining Animations for SVG Components + +You can use child components in the <svg> component to animate attributes over time. + +#### Attribute Style Animation + +In the [animate](../reference/arkui-js/js-components-svg-animate.md) child component of the <svg> component, set attributeName to the attribute you want to animate, set from to the animation start value, and set to to the animation end value. + +``` + +
+ + + Hello + + + + + + + + + World + + + + + + + + +
+``` + +![en-us_image_0000001183871404.gif](figures/en-us_image_0000001183871404.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) NOTE: +> When values is also set, the from and to settings do not take effect. + +#### Motion Path Animation + +In the [animateMotion](../reference/arkui-js/js-components-svg-animatemotion.md) child component of the <svg> component, set path to define a shape for the animation. + +``` + +
+ + + + + + + + +
+``` + +![en-us_image_0000001229510983.gif](figures/en-us_image_0000001229510983.gif) + +#### animateTransform Animation + +In the [animateTransform](../reference/arkui-js/js-components-svg-animatetransform.md) child component of the <svg> component, set attributeName to bind the corresponding attribute to the transform attribute, and set type to the animation type, from to the start value, and to to the end value. + +``` + +
+ + + + + + + + + + + + + + + + + + +
+``` + +``` +/* xxx.css */ +.container { + flex-direction: column; + align-items: center; + width: 100%; + height: 100%; + background-color: #F1F3F5; +} +``` + +![en-us_image_0000001182832088.gif](figures/en-us_image_0000001182832088.gif) \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-animate-transform.md b/en/application-dev/ui/ui-js-animate-transform.md index 9ac89180bae2aec0dededa5c0c962fcf0fd8179d..c8d5c6b233b5b263e6614fa836386441486eb870 100644 --- a/en/application-dev/ui/ui-js-animate-transform.md +++ b/en/application-dev/ui/ui-js-animate-transform.md @@ -1,11 +1,14 @@ -# Defining Animations with the transform Attribute +# Defining Animations with the transform Attribute -Set the **transform** attribute for component rotation, scaling, translation, and skewing. -## Designing Static Animation +Set the transform attribute for component rotation, scaling, translation, and skewing. -Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle to form a roof. Set the **translate** attribute of the rectangle to the coordinate \(150px, -150px\) to form a door, use the **position** attribute to translate the horizontal and vertical axes to the specified coordinates of the parent component \(square\), set the **scale** attribute to scale up the parent and child components together to determine the window size, and use the **skewX** attribute to skew the component and set the coordinate **translate\(200px,-830px\)** to form a chimney. +## Designing Static Animation + +Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle to form a roof. Set the translate attribute of the rectangle to the coordinate (150px, -150px) to form a door, use the position attribute to translate the horizontal and vertical axes to the specified coordinates of the parent component (square), set the scale attribute to scale up the parent and child components together to determine the window size, and use the skewX attribute to skew the component and set the coordinate translate(200px,-830px) to form a chimney. + + ```
@@ -21,6 +24,7 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p
``` + ``` /* xxx.css */ .container { @@ -86,12 +90,14 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p } ``` -![](figures/111-13.png) +![en-us_image_0000001267887841](figures/en-us_image_0000001267887841.png) + -## Designing Translation Animation +## Designing Translation Animation Decrease the y-coordinate over a time frame to make the ball bounce back. Gradually decrease the bounce height until it drops to 0. An animation where the ball falls is hereby created. + ```
@@ -100,6 +106,7 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua
``` + ``` /* xxx.css */ .container { @@ -162,12 +169,14 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua } ``` -![](figures/q2.gif) +![en-us_image_0000001222967760](figures/en-us_image_0000001222967760.gif) -## Designing Rotation Animation -Set the rotation center around an element in different **transform-origin** positions. Of the **rotate3d** values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed counterclockwise. +## Designing Rotation Animation +Set the rotation center around an element in different transform-origin positions. Of the rotate3d values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed counterclockwise. + + ```
@@ -187,6 +196,7 @@ Set the rotation center around an element in different **transform-origin** po
``` + ``` /* xxx.css */ .container { @@ -292,17 +302,19 @@ Set the rotation center around an element in different **transform-origin** po } ``` -![](figures/d2.gif) +![en-us_image_0000001222807776](figures/en-us_image_0000001222807776.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> transform-origin specifies the origin of an element's transformation. If only one value is set, the other value is 50%. If both values are set, the first value indicates the position on the x-axis, and the second value indicates the position on the y-axis. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->**transform-origin** specifies the origin of an element's transformation. If only one value is set, the other value is **50%**. If both values are set, the first value indicates the position on the x-axis, and the second value indicates the position on the y-axis. -## Designing Scaling Animation +## Designing Scaling Animation -This example implements a ripple animation with the **scale** attribute. Here is the overall procedure: First, use the positioning function to determine the coordinates of the element's position. Then, create multiple components to achieve the overlapping effect. After that, set the **opacity** attribute to hide or display the components. To scale and hide/display a component at the same time, set both the **scale** and **opacity** attributes. Finally, set different animation durations for different components to achieve the diffusion effect. +This example implements a ripple animation with the scale attribute. Here is the overall procedure: First, use the positioning function to determine the coordinates of the element's position. Then, create multiple components to achieve the overlapping effect. After that, set the opacity attribute to hide or display the components. To scale and hide/display a component at the same time, set both the scale and opacity attributes. Finally, set different animation durations for different components to achieve the diffusion effect. -Set the scaling values for the x-axis, y-axis, and z-axis in **scale3d** to implement the animation. +Set the scaling values for the x-axis, y-axis, and z-axis in scale3d to implement the animation. + ```
@@ -318,6 +330,7 @@ Set the scaling values for the x-axis, y-axis, and z-axis in **scale3d** to im
``` + ``` /* xxx.css */ .container { @@ -333,14 +346,12 @@ Set the scaling values for the x-axis, y-axis, and z-axis in **scale3d** to im height: 100px; border-radius: 50px; background:linear-gradient(#dcaec1, #d3a8e3); - z-index: 1; - position: absolute; + z-index: 1; position: absolute; } .ripple{ margin-top: 400px; margin-left: 40%; - position: absolute; - z-index: 0; + position: absolute; z-index: 0; width: 100px; height: 100px; border-radius: 50px; @@ -406,15 +417,17 @@ text{ } ``` -![](figures/d3.gif) +![en-us_image_0000001267887837](figures/en-us_image_0000001267887837.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> After the transform attributes are set, the child element changes with the parent element. Value changing of other attributes (such as height and width) of the parent element will not affect the child element. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->After the **transform** attributes are set, the child element changes with the parent element. Value changing of other attributes \(such as **height** and **width**\) of the parent element will not affect the child element. -## Setting matrix +## Setting matrix -The **matrix** attribute defines a transformation matrix with six input parameters: **scaleX**, **skewY**, **skewX**, **scaleY**, **translateX**, and **translateY**. In the following example, **matrix** is set to **matrix\(1,0,0,1,0,200\)** to skew and translate the component. +The matrix attribute defines a transformation matrix with six input parameters: scaleX, skewY, skewX, scaleY, translateX, and translateY. In the following example, matrix is set to matrix(1,0,0,1,0,200) to skew and translate the component. + ```
@@ -422,6 +435,7 @@ The **matrix** attribute defines a transformation matrix with six input parame
``` + ``` /* xxx.css */ .container{ @@ -451,12 +465,14 @@ The **matrix** attribute defines a transformation matrix with six input parame } ``` -![](figures/q3.gif) +![en-us_image_0000001267767853](figures/en-us_image_0000001267767853.gif) -## Integrating transform Attributes -You can set multiple **transform** attributes at the same time to apply different transformations to a component. The following example applies the **scale**, **translate**, and **rotate** attributes simultaneously. +## Integrating transform Attributes +You can set multiple transform attributes at the same time to apply different transformations to a component. The following example applies the scale, translate, and rotate attributes simultaneously. + + ```
@@ -468,6 +484,7 @@ You can set multiple **transform** attributes at the same time to apply differ
``` + ``` /* xxx.css */ .container{ @@ -514,8 +531,7 @@ You can set multiple **transform** attributes at the same time to apply differ /* Use change1 and change2 for comparison. */ @keyframes change1{ 0%{ - transform: translate(0,0); - transform: rotate(0deg) + transform: translate(0,0); transform: rotate(0deg) } 100%{ transform: translate(0,500px); @@ -559,10 +575,11 @@ You can set multiple **transform** attributes at the same time to apply differ } ``` -![](figures/d4.gif) - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->1. When multiple **transform** attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one **transform**, for example, **transform: scale\(1\) rotate\(0\) translate\(0,0\)**. ->2. When using the shorthand notion, note that the animation effect varies according to the sequence of the style values. ->3. The style values in the **transform** attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. +![en-us_image_0000001223127712](figures/en-us_image_0000001223127712.gif) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> 1. When multiple transform attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one transform, for example, transform: scale(1) rotate(0) translate(0,0). +> +> 2. When using the shorthand notion, **NOTE** that the animation effect varies according to the sequence of the style values. +> +> 3. The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. diff --git a/en/application-dev/ui/ui-js-animate.md b/en/application-dev/ui/ui-js-animate.md deleted file mode 100644 index 0da19180580713ad664d48637de5853d79892002..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-animate.md +++ /dev/null @@ -1,7 +0,0 @@ -# Animation Development Guidelines - -- **[CSS Animation](ui-js-animate-css.md)** - -- **[JS Animation](ui-js-animate-javascript.md)** - - diff --git a/en/application-dev/ui/ui-js-building-ui-animation.md b/en/application-dev/ui/ui-js-building-ui-animation.md index b9c7f025bfb1d4a75ad1aa04c65cd43fd5abaaf9..c6f7c0cdf8a1903ff8d66a18a0f2ae91e60451b0 100644 --- a/en/application-dev/ui/ui-js-building-ui-animation.md +++ b/en/application-dev/ui/ui-js-building-ui-animation.md @@ -1,16 +1,21 @@ -# Developing Animations +# Developing Animations -Animations are classified into [Static Animation](#section456613911492) and [Continuous Animation](#section17836125204914). -## Static Animation +Animations are classified into [Static Animation](#static-animation) and [Continuous Animation](#continuous-animation). + + +## Static Animation The transform attributes are the core of the static animation. A static animation can transform in the following three ways and only once in each way at a time: -- **translate**: Moves a specified component horizontally or vertically. -- **scale**: Scales a specified component horizontally or vertically to the required scale. -- **rotate**: Rotates a specified component by a specified angle along the horizontal axis, vertical axis, or center point. +- translate: Moves a specified component horizontally or vertically. + +- scale: Scales a specified component horizontally or vertically to the required scale. + +- rotate: Rotates a specified component by a specified angle along the horizontal axis, vertical axis, or center point. + +For more information, see [Component Methods](../reference/arkui-js/js-components-common-methods.md). The following is an example: -For more information, see [Component Methods](../reference/arkui-js/js-components-common-methods.md). The following is an example: ``` @@ -21,6 +26,7 @@ For more information, see [Component Methods](../reference/arkui-js/js-componen ``` + ``` /* xxx.css */ .container { @@ -51,22 +57,30 @@ For more information, see [Component Methods](../reference/arkui-js/js-componen } ``` -**Figure 1** Static animation -![](figures/static-animation.png "static-animation") -## Continuous Animation + figure1 Static animation + + ![en-us_image_0000001223127724](figures/en-us_image_0000001223127724.png) + + +## Continuous Animation The static animation has only the start and end states. To set the transition state and conversion effect, use continuous animations. The core of a continuous animation is animation attributes, which define the start and end states of the animation and the curve of time and speed. Animation attributes can implement the following effects: -- **animation-name**: Background color, opacity, width, height, and transformation type applied to the element after the animation is executed -- **animation-delay** and **animation-duration**: Element delay and duration after the animation is executed -- **animation-timing-function**: Speed curve of an animation, which makes the animation more fluent -- **animation-iteration-count**: Number of animation playback times -- **animation-fill-mode**: Whether to restore the initial state after the animation is executed +- animation-name: Background color, opacity, width, height, and transformation type applied to the element after the animation is executed + +- animation-delay and animation-duration: Element delay and duration after the animation is executed + +- animation-timing-function: Speed curve of an animation, which makes the animation more fluent + +- animation-iteration-count: Number of animation playback times + +- animation-fill-mode: Whether to restore the initial state after the animation is executed + +To use the animation attributes, you need to define a @keyframes rule in the .css file, set the animation transition effect in @keyframes, and invoke the effect through a style class in the .hml file. The following is an example for animation-name: -To use the animation attributes, you need to define a @keyframes rule in the **.css** file, set the animation transition effect in @keyframes, and invoke the effect through a style class in the **.hml** file. The following is an example for **animation-name**: ``` @@ -82,6 +96,7 @@ To use the animation attributes, you need to define a @keyframes rule in the ** ``` + ``` /* xxx.css */ .item-container { @@ -131,6 +146,7 @@ To use the animation attributes, you need to define a @keyframes rule in the ** } ``` + ``` // xxx.js export default { @@ -147,6 +163,6 @@ export default { } ``` -**Figure 2** Continuous animation effect -![](figures/continuous-animation-effect.gif "continuous-animation-effect") - + figure2 Continuous animation effect + + ![en-us_image_0000001223287696](figures/en-us_image_0000001223287696.gif) diff --git a/en/application-dev/ui/ui-js-building-ui-component.md b/en/application-dev/ui/ui-js-building-ui-component.md index bb5970bd4af8f46805433d2af2626efc8d1a5123..50b3fccf7a613a43117c879be4005c98ba822c92 100644 --- a/en/application-dev/ui/ui-js-building-ui-component.md +++ b/en/application-dev/ui/ui-js-building-ui-component.md @@ -1,50 +1,21 @@ -# Component Overview +# Component Overview -Components are the core of a UI page. Each component can provide visible and interactive functional units that are independent from each other. This is achieved by data and method encapsulation. You can use and reuse any component anywhere as needed. For details about how to use the components, see [Components](../reference/arkui-js/js-components-common-attributes.md). -You can also customize a new component through proper combination of components to make the development simple and easy. For details about how to customize components, see [Custom Components](ui-js-custom-components.md). +Components are the core of a UI page. Each component can provide visible and interactive functional units that are independent from each other. This is achieved by data and method encapsulation. You can use and reuse any component anywhere as needed. For details about how to use the components, see [Universal Attributes](../reference/arkui-js/js-components-common-attributes.md). -## Classification -Components can be classified into the following types based on their functions. +You can also customize a new component through proper combination of components to make the development simple and easy. For details about how to customize components, see [Custom Components](ui-js-custom-components.md). + - - - - - - - - - - - - - - - - - - - - - - - - -

Type

-

Components

-

Container

-

badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content

-

Basic

-

button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle

-

Media

-

video

-

Canvas

-

canvas

-

Grid

-

grid-container, grid-row, grid-col

-

SVG

-

svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform

-
+## Classification + +Components can be classified into the following types based on their functions. + | Type | Components | +| -------- | -------- | +| Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content | +| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle | +| Media | video | +| Canvas | canvas | +| Grid | grid-container, grid-row, grid-col | +| SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform | diff --git a/en/application-dev/ui/ui-js-building-ui-event.md b/en/application-dev/ui/ui-js-building-ui-event.md index e5d66d95647911209d229a3811cdc249c7ddeea7..02b1d1a13b6358ce5cef34373bdbe971b345a3fb 100644 --- a/en/application-dev/ui/ui-js-building-ui-event.md +++ b/en/application-dev/ui/ui-js-building-ui-event.md @@ -1,28 +1,33 @@ -# Defining Events +# Defining Events + Events mainly include gesture events for touchscreen devices. -## Gesture Events -A gesture represents a semantic action \(for example, tap, drag, or longpress\) that can trigger one or more events. A gesture lifecycle may consist of multiple events from the start to the end of the gesture. Supported events: +## Gesture Events + +A gesture represents a semantic action (for example, tap, drag, or longpress) that can trigger one or more events. A gesture lifecycle may consist of multiple events from the start to the end of the gesture. Supported events: + + Touch +- touchstart: Triggered when the touch starts + +- touchmove: Triggered when the touch moves -**Touch** +- touchcancel: Triggered when the touch is interrupted, for example, by an incoming call notification or pop-up message -- **touchstart**: Triggered when the touch starts -- **touchmove**: Triggered when the touch moves -- **touchcancel**: Triggered when the touch is interrupted, for example, by an incoming call notification or pop-up message -- **touchend**: Triggered when the touch ends +- touchend: Triggered when the touch ends -**Click** +Click -**click**: Triggered when a user taps the screen quickly. +click: Triggered when a user taps the screen quickly. -**Longpress** +Longpress -**longpress**: Triggered when a user keeps tapping the screen at the same position for a while. +longpress: Triggered when a user keeps tapping the screen at the same position for a while. The following is an example: + ```
@@ -47,6 +52,7 @@ The following is an example:
``` + ``` /* xxx.css */ .container { @@ -70,6 +76,7 @@ The following is an example: } ``` + ``` // xxx.js export default { @@ -101,4 +108,3 @@ export default { }, } ``` - diff --git a/en/application-dev/ui/ui-js-building-ui-interactions.md b/en/application-dev/ui/ui-js-building-ui-interactions.md index 87cd80eb5a7fbba63ddf2675bbcf4b99f6ce11e4..564e4ca6ab305962d19967d28a0ef9725e7e6dca 100644 --- a/en/application-dev/ui/ui-js-building-ui-interactions.md +++ b/en/application-dev/ui/ui-js-building-ui-interactions.md @@ -1,18 +1,20 @@ -# Adding Interactions +# Adding Interactions -You can make the UI interactive by binding events to components. This section describes how to bind ****, ****, and **** components to click events to build a thumb up button, as shown in the following figure. + You can make the UI interactive by binding events to components. This section describes how to bind <div>, <text>, and <image> components to click events to build a thumb up button, as shown in the following figure. + figure1 Thumb up button effect -**Figure 1** Thumb up button effect +![en-us_image_0000001267647901](figures/en-us_image_0000001267647901.gif) -![](figures/zan.gif) +The thumb up button is implemented by binding a click event to a <div> component. The <div> component contains an <image> component and a <text> component. -The thumb up button is implemented by binding a click event to a **** component. The **** component contains an **** component and a **** component. -- The **** component is used to display unselected and selected \(highlighted\) thumbs up images. The click event function alternately updates the paths of the images that are liked and not liked. -- The **** component is used to display the number of thumbs up. The number is updated in the function of the click event. +- The <image> component is used to display unselected and selected (highlighted) thumbs up images. The click event function alternately updates the paths of the images that are liked and not liked. -The click event calls the **likeClick\(\)** function defined in the **.js** file. You can change the value of **isPressed** to update the image component. If the value of **isPressed** is **true**, the number of thumbs up is incremented by 1. The **likeClick\(\)** function takes effect on the **** component in the **.hml** file. The style of each child component for the thumbs up button is set in the **.css** file. The following is an example: +- The <text> component is used to display the number of thumbs up. The number is updated in the function of the click event. + + +The click event calls the likeClick() function defined in the .js file. You can change the value of isPressed to update the image component. If the value of isPressed is true, the number of thumbs up is incremented by 1. The likeClick() function takes effect on the <div> component in the .hml file. The style of each child component for the thumbs up button is set in the .css file. The following is an example: ``` @@ -71,5 +73,5 @@ export default { } ``` - ArkUI also provides many form components, such as switches, tags, and pickers, for you to flexibly lay out pages and improve their interactions with users. For details, see [Container Components](../reference/arkui-js/js-components-container.md). +ArkUI also provides many form components, such as switches, tags, and pickers, for you to flexibly lay out pages and improve their interactions with users. For details, see Container Components. diff --git a/en/application-dev/ui/ui-js-building-ui-layout-comment.md b/en/application-dev/ui/ui-js-building-ui-layout-comment.md index e11cabf09e0a19428dfba30e8d196aed318537df..f23830faca115ffaaae5e9d60520c7d0d435e19d 100755 --- a/en/application-dev/ui/ui-js-building-ui-layout-comment.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-comment.md @@ -1,8 +1,10 @@ -# Adding a Comment +# Adding a Comment + After a user enters a comment and clicks the submit button, the content is displayed in the comment area. The user can click the delete button to delete the current comment and enter another comment again. -To set such a comment area on a page, you need to associate a click event with ****, ****, and ****. You can use the **** component to obtain the comment entered by a user, use the **** component to display the comment, and use **commentText** to mark the **** component \(controlled by the **if** attribute\). Associate the click event with the **** component that contains **Done** and **Delete** to update the **commentText** and **inputValue**. The following is an example: + +To set such a comment area on a page, you need to associate a click event with <div>, <text>, and <input>. You can use the <input> component to obtain the comment entered by a user, use the <text> component to display the comment, and use commentText to mark the <text> component (controlled by the if attribute). Associate the click event with the <text> component that contains Done and Delete to update the commentText and inputValue. The following is an example: ``` @@ -19,6 +21,8 @@ To set such a comment area on a page, you need to associate a click event with ``` + + ``` /* xxx.css */ .container { @@ -60,6 +64,8 @@ To set such a comment area on a page, you need to associate a click event with } ``` + + ``` // xxx.js export default { @@ -75,4 +81,3 @@ export default { }, } ``` - diff --git a/en/application-dev/ui/ui-js-building-ui-layout-external-container.md b/en/application-dev/ui/ui-js-building-ui-layout-external-container.md index 2c6b781adbe2d144c5bfb576575cefa1927dafc9..4bd2fd37d55bd30e68aab90acc68b0d82756a403 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-external-container.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-external-container.md @@ -1,10 +1,13 @@ -# Adding a Container +# Adding a Container -To assemble the basic elements of a page, you need a container component. The ****, ****, and **** components are commonly used for laying out page elements. You can use **** as the container in a page with simple layout. **** supports a variety of child components required to build the page. -## +To assemble the basic elements of a page, you need a container component. The <div>, <list>, and <tabs> components are commonly used for laying out page elements. You can use <div> as the container in a page with simple layout. <div> supports a variety of child components required to build the page. + + +## <List> + +If you use <div> repeatedly to render a complex page, frame freezing may occur. In this case, use the <list> component instead of <div> to lay out list items, which provides a smooth list scrolling. **NOTE** that <list> supports only <list-item> as it child components. The following is an example: -If you use **** repeatedly to render a complex page, frame freezing may occur. In this case, use the **** component instead of **** to lay out list items, which provides a smooth list scrolling. Note that **** supports only **** as it child components. The following is an example: ``` @@ -15,6 +18,7 @@ If you use **** repeatedly to render a complex page, frame freezing may ``` + ``` /* xxx.css */ .desc-text { @@ -23,6 +27,7 @@ If you use **** repeatedly to render a complex page, frame freezing may } ``` + ``` // xxx.js export default { @@ -32,11 +37,13 @@ export default { } ``` -To shorten the sample code, the list contains only one **** component that holds only one **** component. In practice, a **** has multiple **** components, and a **** has multiple child components. +To shorten the sample code, the list contains only one <list-item> component that holds only one <text> component. In practice, a <list> has multiple <list-item> components, and a <list-item> has multiple child components. -## -If your page needs to be dynamically loaded, use the **** component. This component supports the change event, which is triggered after tab switching. A **** component can hold only one **** and one ****. The following is an example: +## <Tabs> + +If your page needs to be dynamically loaded, use the <tabs> component. This component supports the change event, which is triggered after tab switching. A <tabs> component can hold only one <tab-bar> and one <tab-content>. The following is an example: + ``` @@ -54,6 +61,7 @@ If your page needs to be dynamically loaded, use the **** component. Th ``` + ``` // xxx.js export default { @@ -65,5 +73,4 @@ export default { } ``` -The **** component is used to display the tab content, which vertically fills the remaining space of the **** component by default. - +The <tab-content> component is used to display the tab content, which vertically fills the remaining space of the <tabs> component by default. diff --git a/en/application-dev/ui/ui-js-building-ui-layout-image.md b/en/application-dev/ui/ui-js-building-ui-layout-image.md index 8c9026d467b0dc746ff6fd51c7b62cf5a0caccee..63e8f07dff27f8f33106c0db6c817d7e38276c3f 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-image.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-image.md @@ -1,8 +1,10 @@ -# Adding an Image +# Adding an Image -Generally, the [****](../reference/arkui-js/js-components-basic-image.md) component is used to add images on a page. The method of using this component is similar to that of using the **** component. -To reference images via the **** component, you must create the **common** directory under **js** \> **default**, and then store the image files in the **common** directory. For details about the directory structure, see [Directory Structure](js-framework-file.md). The following sample code shows you how to add an image and set its style. +Generally, the [<image>](../reference/arkui-js/js-components-basic-image.md)component is used to add images on a page. The method of using this component is similar to that of using the <text> component. + + +To reference images via the <image> component, you must create the common directory under jsdefault, and then store the image files in the common directory. For details about the directory structure, see [Directory Structure](js-framework-file.md). The following sample code shows you how to add an image and set its style. ``` @@ -26,4 +28,3 @@ export default { }, } ``` - diff --git a/en/application-dev/ui/ui-js-building-ui-layout-intro.md b/en/application-dev/ui/ui-js-building-ui-layout-intro.md index 7ee7f04d95087af0266e0d896ed0c2e9698b0c30..14c6e5f3a16ba09a07c5948c717d8c89828b97f2 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-intro.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-intro.md @@ -1,26 +1,32 @@ -# Layout Description +# Layout Description + The baseline width for page design is 720 logical pixels. The display width of a page element depends on the ratio of the screen width to the baseline width. + For example, when the width of a component is 100 px, its display width is converted as follows: + On a screen with the width of 720 physical pixels, the display width is 100 physical pixels. On a screen with the width of 1440 physical pixels, the display width is 200 physical pixels. Basic page elements include title, text, and image areas. Each basic element may contain multiple sub-elements. You can add components, such as buttons, switches, and progress bars, to these elements and sub-elements as required. When setting the layout, you need to consider the following for each basic element: -- Size and arrangement -- Overlapping with other elements -- Alignment, padding, and margin -- Sub-elements and their positions -- Container components and their types -You can disassemble elements on the page first and then implement them in sequence. This reduces visual confusion and logical conflicts caused by element nesting and improves code readability for easier modification. For example, as shown below, you disassemble the page elements and elements in the comment area. +- Size and arrangement + +- Overlapping with other elements + +- Alignment, padding, and margin + +- Sub-elements and their positions -**Figure 1** Page layout -![](figures/page-layout.png "page-layout") +- Container components and their types -**Figure 2** Layout of the comment area + You can disassemble elements on the page first and then implement them in sequence. This reduces visual confusion and logical conflicts caused by element nesting and improves code readability for easier modification. For example, as shown below, you disassemble the page elements and elements in the comment area. + figure1 Page layout + ![en-us_image_0000001222967792](figures/en-us_image_0000001222967792.png) -![](figures/figures3.png) + figure2 Layout of the comment area +![en-us_image_0000001267767889](figures/en-us_image_0000001267767889.png) diff --git a/en/application-dev/ui/ui-js-building-ui-layout-text.md b/en/application-dev/ui/ui-js-building-ui-layout-text.md index 141eb9f25b8a6c65c83c0fd288099d1bd4f0b3cb..f01820f6f73fc45cc660813f108aa352209d0bdb 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-text.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-text.md @@ -1,6 +1,9 @@ -# Adding Title and Paragraph Text +# Adding Title and Paragraph Text + + +The <text> component is most commonly used to display text in title and paragraph areas. You can set attributes and styles for a <text> component and add the text to be displayed between the <text> and </text> tags. For details about the attributes and styles, see [text](../reference/arkui-js/js-components-basic-text.md). The following is an example of adding title and paragraph text on a page: + -The **** component is most commonly used to display text in title and paragraph areas. You can set attributes and styles for a **** component and add the text to be displayed between the **** and **** tags. For details about the attributes and styles, see [text](../reference/arkui-js/js-components-basic-text.md). The following is an example of adding title and paragraph text on a page: ``` @@ -11,6 +14,8 @@ The **** component is most commonly used to display text in title and p ``` + + ``` /* xxx.css */ .container { @@ -31,6 +36,8 @@ The **** component is most commonly used to display text in title and p } ``` + + ``` // xxx.js export default { @@ -41,4 +48,3 @@ export default { }, } ``` - diff --git a/en/application-dev/ui/ui-js-building-ui-layout.md b/en/application-dev/ui/ui-js-building-ui-layout.md deleted file mode 100644 index 154a22bb6af4f3b7060f169d46b11135a54fbb88..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-building-ui-layout.md +++ /dev/null @@ -1,13 +0,0 @@ -# Building the Layout - -- **[Layout Description](ui-js-building-ui-layout-intro.md)** - -- **[Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md)** - -- **[Adding an Image](ui-js-building-ui-layout-image.md)** - -- **[Adding a Comment](ui-js-building-ui-layout-comment.md)** - -- **[Adding a Container](ui-js-building-ui-layout-external-container.md)** - - diff --git a/en/application-dev/ui/ui-js-building-ui-routes.md b/en/application-dev/ui/ui-js-building-ui-routes.md index e5eaa8dfb6679f50140551eb1437c1bc9df84261..4fcdb531fd87488f639df54d3d8aef5a016d799c 100644 --- a/en/application-dev/ui/ui-js-building-ui-routes.md +++ b/en/application-dev/ui/ui-js-building-ui-routes.md @@ -1,16 +1,23 @@ -# Defining Page Routes +# Defining Page Routes -Many applications consist of more than one page. For example, in a music application, a user taps a song on a music list page, and then needs to jump to the playback page of the song. You need to link these pages through page routing to implement redirection as required. -The page router finds the target page based on the page URI. The following describes how to switch between two pages: +An application generally consist of more than one page. For example, in a music application, a user taps a song on a music list page to jump to the playback page of the song. You need to link these pages through the page router to implement redirection as required. -1. In the **Project** window of DevEco Studio, choose **entry \> src \> main** \> **js** \> **default**. Right-click the **pages** folder and choose **New****JS Page** from the shortcut menu to create the **detail** page. -2. Call **router.push\(\)** to navigate users to the **detail** page. -3. Call **router.back\(\)** to navigate users to the **index** page. -## Building the Page Layout +The page router finds the target page based on the page URI. The following describes how to implement redirection between two pages: + + +1. In the “Project“ window of DevEco Studio, choose entry > src > mainjsdefault. Right-click the pages folder and choose NewJS Page from the shortcut menu to create the detail page. + +2. Call router.push() to navigate users to the detail page. + +3. Call router.back() to navigate users to the index page. + + +## Building the Page Layout + +The index and detail pages each contains a <text> component that specifies the current page, and a <button> component that implements the switching between two pages. Example code in .hml files is as follows: -The **index** and **detail** pages each contains a **** component that specifies the current page, and a **** component that implements the switching between two pages. Example code in **.hml** files is as follows: ``` @@ -20,6 +27,7 @@ The **index** and **detail** pages each contains a **** component t ``` + ```
@@ -28,9 +36,11 @@ The **index** and **detail** pages each contains a **** component t
``` -## Setting Page Styles -Set styles for the **index** and **detail** pages. Centers the **** and **** components and spaces the two components with 50 pixels. The CSS code for the two pages is as follows: +## Setting Page Styles + +Set styles for the index and detail pages. Center the <text> and <button> components and space the two components with 50 pixels. The CSS code for the two pages is as follows: + ``` /* index.css */ @@ -47,9 +57,11 @@ Set styles for the **index** and **detail** pages. Centers the **** } ``` -## Setting the Switch -To make the **launch** method of the **** component take effect, the redirection logic needs to be implemented in the **.js** file of the page. Call **router.push\(\)** to add the page URI to the route stack, that is, to jump to the page specified by the URI. You need to import the router module before calling the router method. The sample code is as follows: +## Implementing Redirection + +To make the launch method of the <button> component take effect, the redirection logic needs to be implemented in the .js file of the page. Call router.push() to add the page URI to the route stack, that is, to jump to the page specified by the URI. You need to import the router module before calling the router method. The sample code is as follows: + ``` // index.js @@ -63,6 +75,7 @@ export default { } ``` + ``` // detail.js import router from '@system.router'; @@ -73,8 +86,8 @@ export default { } ``` -The following figure shows the effect. +The figure below shows the effect. -**Figure 1** Page routing -![](figures/page-routing.png "page-routing") + figure1 Page routing + ![en-us_image_0000001222967784](figures/en-us_image_0000001222967784.png) diff --git a/en/application-dev/ui/ui-js-building-ui.md b/en/application-dev/ui/ui-js-building-ui.md deleted file mode 100644 index e689826b459549da5facd7ac28402c502d0479ee..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-building-ui.md +++ /dev/null @@ -1,15 +0,0 @@ -# Building the UI - -- **[Component Overview](ui-js-building-ui-component.md)** - -- **[Building the Layout](ui-js-building-ui-layout.md)** - -- **[Adding Interactions](ui-js-building-ui-interactions.md)** - -- **[Developing Animations](ui-js-building-ui-animation.md)** - -- **[Defining Events](ui-js-building-ui-event.md)** - -- **[Defining Page Routes](ui-js-building-ui-routes.md)** - - diff --git a/en/application-dev/ui/ui-js-common-components.md b/en/application-dev/ui/ui-js-common-components.md deleted file mode 100644 index 14a90b7ded028c890c3e3ec9ca359898e75667a5..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-js-common-components.md +++ /dev/null @@ -1,26 +0,0 @@ -# Common Component Development Guidelines - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The sample code provided in this document is applicable to the 720 px screen width on the phones. - -- **[Text](ui-js-components-text.md)** - -- **[Input](ui-js-components-input.md)** - -- **[Button](ui-js-components-button.md)** - -- **[List](ui-js-components-list.md)** - -- **[Picker](ui-js-components-picker.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)** - -- **[Image](ui-js-components-images.md)** - - diff --git a/en/application-dev/ui/ui-js-component-tabs.md b/en/application-dev/ui/ui-js-component-tabs.md index d29186ddca5ea240ad27dd237e0cc7c605324894..0e20aaea35129a98b219d5eaac252dfda7e420d4 100644 --- a/en/application-dev/ui/ui-js-component-tabs.md +++ b/en/application-dev/ui/ui-js-component-tabs.md @@ -1,16 +1,19 @@ -# Tabs +# <tabs> Development -The **** component is a common UI component for navigation. It allows quick access to different functions of an app. For details, see [tabs](../reference/arkui-js/js-components-container-tabs.md). -## Creating Tabs +The <tabs> component is a common UI component for navigation. It allows quick access to different functions of an app. For details, see [tabs](../reference/arkui-js/js-components-container-tabs.md). + + +## Creating Tabs + +Create a <tabs> component in the .hml file under pages/index. -Create a **** component in the **.hml** file under **pages/index**. ```
- + item1 item2 @@ -26,6 +29,7 @@ Create a **** component in the **.hml** file under **pages/index**.
``` + ``` /* xxx.css */ .container { @@ -42,11 +46,13 @@ Create a **** component in the **.hml** file under **pages/index**. } ``` -![](figures/3-9.gif) +![en-us_image_0000001223287676](figures/en-us_image_0000001223287676.gif) + -## Setting the Tabs Orientation +## Setting the Tabs Orientation + +By default, the active tab of a <tabs> component is the one with the specified index. To show the <tabs> vertically, set the vertical attribute to true. -By default, the active tab of a **** component is the one with the specified **index**. To show the **** vertically, set the **vertical** attribute to **true**. ``` @@ -68,9 +74,10 @@ By default, the active tab of a **** component is the one with the spec ``` -![](figures/29.gif) +![en-us_image_0000001222967756](figures/en-us_image_0000001222967756.gif) + +Set the mode attribute to enable the child components of the to be evenly distributed. Set the scrollable attribute to disable scrolling of the . -Set the **mode** attribute to enable the child components of the **** to be evenly distributed. Set the **scrollable** attribute to disable scrolling of the ****. ``` @@ -92,11 +99,12 @@ Set the **mode** attribute to enable the child components of the ** ``` -![](figures/30.gif) +![en-us_image_0000001267647857](figures/en-us_image_0000001267647857.gif) + -## Setting the Style +## Setting the Style -Set the background color, border, and tab-content layout of the **** component. + Set the background color, border, and tab-content layout of the <tabs> component. ``` @@ -118,17 +126,18 @@ Set the background color, border, and tab-content layout of the **** co ``` + ``` /* xxx.css */ .container { flex-direction: column; justify-content: flex-start; align-items: center; - background-color:#F1F3F5; + background-color:#F1F3F5; } .tabs{ margin-top: 20px; - border: 1px solid #2262ef; + border: 1px solid #2262ef; width: 99%; padding: 10px; } @@ -141,16 +150,17 @@ Set the background color, border, and tab-content layout of the **** co margin-top: 10px; height: 300px; color: blue; - justify-content: center; - align-items: center; + justify-content: center; align-items: center; } ``` -![](figures/31.gif) +![en-us_image_0000001267767857](figures/en-us_image_0000001267767857.gif) + + +## Displaying the Tab Index -## Displaying the Tab Index +Add the change event for the <tabs> component to display the index of the current tab after tab switching. -Add the **change** event for the **** component to display the index of the current tab after tab switching. ``` @@ -172,6 +182,7 @@ Add the **change** event for the **** component to display the index ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -184,17 +195,19 @@ export default { } ``` -![](figures/32.gif) +![en-us_image_0000001222807772](figures/en-us_image_0000001222807772.gif) + ->![](../public_sys-resources/icon-note.gif) **NOTE:** -> ->- A **** can wrap at most one [****](../reference/arkui-js/js-components-container-tab-bar.md) and at most one [****](../reference/arkui-js/js-components-container-tab-content.md). +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - A <tabs> can wrap at most one [](../reference/arkui-js/js-components-container-tab-bar.md) and at most one [](../reference/arkui-js/js-components-container-tab-content.md). -## Example Scenario + +## Example Scenario In this example, you can switch between tabs and the active tab has the title text in red with an underline below. -Use the ****, ****, and **** components to implement tab switching. Then define the arrays and attributes. Add the **change** event to change the attribute values in the arrays so that the active tab has a different font color and an underline. +Use the <tabs>, , and components to implement tab switching. Then define the arrays and attributes. Add the change event to change the attribute values in the arrays so that the active tab has a different font color and an underline. + ``` @@ -224,10 +237,11 @@ Use the ****, ****, and **** components to im ``` + ``` /* xxx.css */ .container{ - background-color:#F1F3F5; +background-color:#F1F3F5; } .tab_bar { width: 100%; @@ -256,6 +270,7 @@ Use the ****, ****, and **** components to im } ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -299,5 +314,4 @@ export default { } ``` -![](figures/33.gif) - +![en-us_image_0000001267607885](figures/en-us_image_0000001267607885.gif) diff --git a/en/application-dev/ui/ui-js-components-button.md b/en/application-dev/ui/ui-js-components-button.md index 7910632641df5d614ea8409a818507b72ece5eca..1507ce9c9843bb535efbb8cbd8ebafde66bd93e5 100644 --- a/en/application-dev/ui/ui-js-components-button.md +++ b/en/application-dev/ui/ui-js-components-button.md @@ -1,10 +1,13 @@ -# Button +# <button> Development -The **** component can be used to set a capsule, circle, text, arc, or download button. For details, see [button](../reference/arkui-js/js-components-basic-button.md). -## Creating a Component +The<button>component can be used to set a capsule, circle, text, arc, or download button. For details, see [button](../reference/arkui-js/js-components-basic-button.md). + + +## Creating a <button> Component + +Create a <button> component in the .hml file under pages/index. -Create a **** component in the **.hml** file under **pages/index**. ``` @@ -13,6 +16,7 @@ Create a **** component in the **.hml** file under **pages/index** ``` + ``` /* xxx.css */ .container { @@ -23,11 +27,12 @@ Create a **** component in the **.hml** file under **pages/index** } ``` -![](figures/3-2.png) +![en-us_image_0000001267887821](figures/en-us_image_0000001267887821.png) -## Setting the Button Type -Set the **type** attribute of the **** component to **button**, **date**, or any of the supported values. +## Setting the Button Type + +Set the type attribute of the <input> component to button, date, or any of the supported values. ``` @@ -61,15 +66,21 @@ Set the **type** attribute of the **** component to **button**, ** } ``` -![](figures/05-3.png) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- For capsule buttons, border-related styles are not supported. ->- For circle buttons, text-related styles are not supported. ->- For text buttons, the text size is adaptive, and **radius**, **width**, and **height** cannot be set. The **background-color** style is not supported when the background is completely transparent. ->- If the icon used by the **** component is from the cloud, you must declare the **ohos.permission.INTERNET** permission in the **config.json** file under the **resources** folder. +![en-us_image_0000001222967744](figures/en-us_image_0000001222967744.png) + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - For capsule buttons, border-related styles are not supported. +> +> - For circle buttons, text-related styles are not supported. +> +> - For text buttons, the text size is adaptive, and radius, width, and height cannot be set. The background-color style is not supported when the background is completely transparent. +> +> - If the icon used by the<button>component is from the cloud, you must declare the ohos.permission.INTERNET permission in the config.json file under the resources folder. -Sample code for declaring the **ohos.permission.INTERNET** permission in the **config.json** file under the **resources** folder: + +Sample code for declaring the ohos.permission.INTERNET permission in the config.json file under the resources folder: ``` @@ -80,9 +91,11 @@ Sample code for declaring the **ohos.permission.INTERNET** permission in the } ``` -## Showing the Download Progress -Add the **progress** method to the **** component to display the download progress in real time. +## Showing the Download Progress + +Add the progress method to the<button>component to display the download progress in real time. + ``` @@ -91,6 +104,7 @@ Add the **progress** method to the **** component to display the do ``` + ``` /* xxx.css */ .container { @@ -106,6 +120,7 @@ Add the **progress** method to the **** component to display the do } ``` + ``` // xxx.js import prompt from '@system.prompt'; @@ -136,7 +151,7 @@ export default { clearInterval(this.intervalId); this.intervalId = null; }, - setProgress(e) { + setProgress(e) { if(this.isPaused){ prompt.showToast({ message: "Download started" @@ -154,13 +169,14 @@ export default { } ``` -![](figures/34.gif) +![en-us_image_0000001223287652](figures/en-us_image_0000001223287652.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: > ->- The **setProgress** method supports only buttons of the download type. +> The setProgress method supports only buttons of the download type. + -## Example Scenario +## Example Scenario Switch between the button types for different types of text. @@ -262,5 +278,5 @@ export default { } ``` -![](figures/21.gif) +![en-us_image_0000001222967740](figures/en-us_image_0000001222967740.gif) diff --git a/en/application-dev/ui/ui-js-components-dialog.md b/en/application-dev/ui/ui-js-components-dialog.md index eecd6e02fa0141e82aedbee04009a15181aae0d8..0c5c1303dbaa51e7c2d3987788cded4d51be8906 100644 --- a/en/application-dev/ui/ui-js-components-dialog.md +++ b/en/application-dev/ui/ui-js-components-dialog.md @@ -1,16 +1,17 @@ -# Dialog +# <dialog> Development -The **** component is custom pop-up container for showing critical information or calling for an action. For details, see [dialog](../reference/arkui-js/js-components-container-dialog.md). -## Creating a Component +The <dialog> component is custom pop-up container for showing critical information or calling for an action. For details, see [dialog](../reference/arkui-js/js-components-container-dialog.md). -Create a **** component in the **.hml** file under **pages/index** and add **** components to trigger the ****. The **** component supports only the **width**, **height**, **margin**, **margin-\[left|top|right|bottom\]**, and **margin-\[start|end\]** styles. + +## Creating a <dialog> Component + + Create a <dialog> component in the .hml file under pages/index and add <button> components to trigger the <dialog>. The <dialog> component supports only the width, height, margin, margin-[left|top|right|bottom], and margin-[start|end] styles. ```
- -
+
this is a dialog
@@ -18,6 +19,7 @@ Create a **** component in the **.hml** file under **pages/index**
``` + ``` /* xxx.css */ .doc-page { @@ -49,6 +51,7 @@ button{ } ``` + ``` /* xxx.js */ export default { @@ -59,11 +62,12 @@ export default { } ``` -![](figures/5-5.gif) +![en-us_image_0000001267767893](figures/en-us_image_0000001267767893.gif) -## Setting Dialog Box Response -Add a **cancel** event that is triggered when a user touches a non-dialog area to cancel the pop-up dialog box. Add the **show** and **close** methods to display and close the dialog box, respectively. +## Setting Dialog Box Response + +Add a cancel event that is triggered when a user touches a non-dialog area to cancel the pop-up dialog box. Add the show and close methods to display and close the dialog box, respectively. ``` @@ -125,16 +129,22 @@ export default { } ``` -![](figures/38.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- This component supports only one child component. ->- Attributes and styles of a **** component cannot be dynamically updated. ->- The **** component does not support the **focusable** and **click-effect** attributes. +![en-us_image_0000001223287720](figures/en-us_image_0000001223287720.gif) + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - This component supports only one child component. +> +> - Attributes and styles of a <dialog> component cannot be dynamically updated. +> +> - The <dialog> component does not support the focusable and click-effect attributes. + + +## Example Scenario -## Example Scenario -Use the **** component to implement a schedule. When the dialog box is open, use the [****](../reference/arkui-js/js-components-basic-textarea.md) component to add an event and touch the OK button to obtain the current time and save the input text. The events in the calendar are displayed in a list. +Use the <dialog> component to implement a schedule. When the dialog box is open, use the [<textarea>](../reference/arkui-js/js-components-basic-textarea.md) component to add an event and touch the OK button to obtain the current time and save the input text. The events in the calendar are displayed in a list. ``` @@ -292,5 +302,5 @@ export default { } ``` -![](figures/6.gif) +![en-us_image_0000001223127756](figures/en-us_image_0000001223127756.gif) diff --git a/en/application-dev/ui/ui-js-components-form.md b/en/application-dev/ui/ui-js-components-form.md index 19c05e7189c0c438173966e138b541694da3fff3..734d3dc510a597d08c5dda4d31e8c6d2b18436be 100644 --- a/en/application-dev/ui/ui-js-components-form.md +++ b/en/application-dev/ui/ui-js-components-form.md @@ -1,23 +1,26 @@ -# Form +# <form> Development -The **** component allows the content in [****](../reference/arkui-js/js-components-basic-input.md) components to be submitted and reset. For details, see [form](../reference/arkui-js/js-components-container-form.md). ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 6. +The <form> component allows the content in [<input>](../reference/arkui-js/js-components-basic-input.md)components to be submitted and reset. For details, see [form](../reference/arkui-js/js-components-container-form.md). -## Creating a Component -Create a **** component in the **.hml** file under **pages/index**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> This component is supported since API version 6. + + +## Creating a <form> Component + + Create a <form> component in the .hml file under pages/index. ```
-
- +
``` + ``` /* xxx.css */ .container { @@ -28,11 +31,12 @@ Create a **** component in the **.hml** file under **pages/index**. } ``` -![](figures/11.png) +![en-us_image_0000001267887873](figures/en-us_image_0000001267887873.png) -## Zooming In or Out on a Form -To implement the zoom effect after a form is clicked, add the **click-effect** attribute to the **** component. For values of **click-effect**, see [Universal Attributes](../reference/arkui-js/js-components-common-attributes.md). +## Zooming In or Out on a Form + + To implement the zoom effect after a form is clicked, add the click-effect attribute to the <form> component. For values of click-effect, see [Universal Attributes](../reference/arkui-js/js-components-common-attributes.md). ``` @@ -43,9 +47,11 @@ To implement the zoom effect after a form is clicked, add the **click-effect**
``` -## Setting the Form Style -Add the **background-color** and **border** attributes. +## Setting the Form Style + + +Add the background-color and border attributes. ``` /* xxx.css */ @@ -62,11 +68,13 @@ Add the **background-color** and **border** attributes. } ``` -![](figures/7.gif) -## Adding Response Events +![en-us_image_0000001267607913](figures/en-us_image_0000001267607913.gif) + -To submit or reset a form, add the **submit** and **reset** events. +## Adding Response Events + + To submit or reset a form, add the submit and reset events. ``` @@ -88,6 +96,7 @@ To submit or reset a form, add the **submit** and **reset** events. ``` + ``` /* xxx.js */ import prompt from '@system.prompt'; @@ -105,13 +114,16 @@ export default{ } ``` -![](figures/8-6.gif) -## Example Scenario +![en-us_image_0000001267767885](figures/en-us_image_0000001267767885.gif) + + +## Example Scenario Select an option and submit or reset the form data. -Create [****](../reference/arkui-js/js-components-basic-input.md) components, set their **type** attribute to **checkbox** and **radio**, and use the **onsubmit** and **onreset** events of the **** component to submit and reset the form data. +Create [<input>](../reference/arkui-js/js-components-basic-input.md) (en-us_topic_0000001173324647.xml) components, set their type attribute to checkbox and radio, and use the onsubmit and onreset events of the <form> component to submit and reset the form data. + ``` @@ -148,6 +160,7 @@ Create [****](../reference/arkui-js/js-components-basic-input.md) comp ``` + ``` /* index.css */ .container { @@ -165,6 +178,7 @@ label{ } ``` + ``` /* xxx.js */ import prompt from '@system.prompt'; @@ -182,5 +196,4 @@ export default { } ``` -![](figures/9.gif) - +![en-us_image_0000001222967788](figures/en-us_image_0000001222967788.gif) diff --git a/en/application-dev/ui/ui-js-components-images.md b/en/application-dev/ui/ui-js-components-images.md index a74db3749a3673fd691a013822ff71096792c1e6..2efab79c2b112824278d8e2fda72fbbf5a847d85 100644 --- a/en/application-dev/ui/ui-js-components-images.md +++ b/en/application-dev/ui/ui-js-components-images.md @@ -1,10 +1,12 @@ -# Image +# <image> Development -The **** component is used to render and display images. For details, see [image](../reference/arkui-js/js-components-basic-image.md). -## Creating an Component +The <image> component is used to render and display images. For details, see [image](../reference/arkui-js/js-components-basic-image.md). -Create an **** component in the **.hml** file under **pages/index**. + +## Creating an <image> Component + + Create an <image> component in the .hml file under pages/index. ``` @@ -13,6 +15,7 @@ Create an **** component in the **.hml** file under **pages/index** ``` + ``` /* xxx.css */ .container { @@ -23,11 +26,12 @@ Create an **** component in the **.hml** file under **pages/index** } ``` -![](figures/10-10.png) +![en-us_image_0000001223127736](figures/en-us_image_0000001223127736.png) + -## Setting the Image Style +## Setting the Image Style -Set the **width**, **height**, and **object-fit** attributes to define the width, height, and scale type of an image. +Set the width, height, and object-fit attributes to define the width, height, and scale type of an image. ``` @@ -42,11 +46,10 @@ Set the **width**, **height**, and **object-fit** attributes to define the w flex-direction: column; align-items: center; justify-content: center; - background-color:#F1F3F5; +background-color:#F1F3F5; } image{ - width: 80%; - height: 500px; + width: 80%; height: 500px; border: 5px solid saddlebrown; border-radius: 20px; object-fit: contain; @@ -55,85 +58,14 @@ image{ } ``` -![](figures/7-11.png) - -## Display Multiple Images -Define a **for** loop to display multiple images cyclically. Set **option** to specify the image scale style. For details about the scale styles, see the description of object-fit. - -``` - -
- - - -
- image{{$idx}} - content -
-
-
-
- -
-
-``` - -``` -/* xxx.css */ -.page-container { - flex-direction:column; - background-color:#F1F3F5; -} -.text-container { - width: 300px; - flex-direction: column; - justify-content: center; -} -.item-container { - flex-direction: row; - align-items: center; - justify-content:center; - margin-top:200px; -} -.testimage { - width: 175px; - height: 220px; - border: 5px solid #add8e6; - padding: 5px 5px 5px 5px; - margin: 5px 5px 5px 5px; -} -.testicon { - width: 50px; - height: 50px; - margin-left: 150px; - border-radius: 25px; - background-color: orange; -} -``` +![en-us_image_0000001222807796](figures/en-us_image_0000001222807796.png) -``` -/* index.js */ -export default { - data: { - url:['common/images/bg-tv.jpg','common/images/img2.jpg'], - list:[0,1], - fit:'cover', - fit_list:['cover','contain','fill','none','scale-down'] - }, - setfit(e) { - this.fit = e.newValue - } -} -``` -![](figures/34-12.gif) +## Loading Images -## Loading Images +When an image is successfully loaded, the complete event is triggered, and the loaded image is returned. If an exception occurs during image loading, the error event is triggered, and the image loading failure is printed. -When an image is successfully loaded, the **complete** event is triggered, and the loaded image is returned. If an exception occurs during image loading, the **error** event is triggered, and the image loading failure is printed. ``` @@ -147,6 +79,7 @@ When an image is successfully loaded, the **complete** event is triggered, and ``` + ``` /* xxx.css */ .container{ @@ -163,6 +96,7 @@ When an image is successfully loaded, the **complete** event is triggered, and } ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -184,11 +118,12 @@ export default { } ``` -![](figures/111.gif) +![en-us_image_0000001267887865](figures/en-us_image_0000001267887865.gif) + -## Example Scenario +## Example Scenario -In this example you touch and hold an image to gradually hide it. After the image is completely hidden, it will show in its original setting. Set a **setInterval** timer to change the image opacity at a specified interval so that it is hidden gradually. When the opacity changes to **0**, the timer is cleared and the opacity is set to **1**. + In this example you touch and hold an image to gradually hide it. After the image is completely hidden, it will show in its original setting. Set a setInterval timer to change the image opacity at a specified interval so that it is hidden gradually. When the opacity changes to 0, the timer is cleared and the opacity is set to 1. ``` @@ -204,6 +139,7 @@ In this example you touch and hold an image to gradually hide it. After the imag ``` + ``` /* xxx.css */ .page-container { @@ -211,6 +147,7 @@ In this example you touch and hold an image to gradually hide it. After the imag align-self: center; justify-content: center; background-color:#F1F3F5; + background-color: #F1F3F5; } .content{ flex-direction:column; @@ -229,13 +166,10 @@ In this example you touch and hold an image to gradually hide it. After the imag justify-content: space-between; } .testimage { - width: 100%; - height: 400px; - object-fit: scale-down; - border-radius: 20px; -} + width: 100%; height: 400px; object-fit: scale-down; border-radius: 20px;} ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -263,5 +197,4 @@ export default { } ``` -![](figures/17.gif) - +![en-us_image_0000001267607905](figures/en-us_image_0000001267607905.gif) diff --git a/en/application-dev/ui/ui-js-components-input.md b/en/application-dev/ui/ui-js-components-input.md index f98b669ebe7560b969e287548b9567451ef25985..559cca5401092490afd8ea1e841ae6d3b8809bba 100644 --- a/en/application-dev/ui/ui-js-components-input.md +++ b/en/application-dev/ui/ui-js-components-input.md @@ -1,20 +1,22 @@ -# Input +# Development -The **** component provides an interactive way to receive user input of various types, including **date**, **checkbox**, and **button**. For details, see [input](../reference/arkui-js/js-components-basic-input.md). -## Creating an Component +The component provides an interactive way to receive user input of various types, including date, checkbox, and button. For details, see [input](../reference/arkui-js/js-components-basic-input.md). + + +## Creating an Component + +Create an component in the .hml file under pages/index. -Create an **** component in the **.hml** file under **pages/index**. ```
- - Please enter the content - + Please enter the content
``` + ``` /* xxx.css */ .container { @@ -25,11 +27,13 @@ Create an **** component in the **.hml** file under **pages/index** } ``` -![](figures/2.png) +![en-us_image_0000001222807768](figures/en-us_image_0000001222807768.png) + + +## Setting the Input Type -## Setting the Input Type +Set the type attribute of the component to button, date, or any of the supported values. -Set the **type** attribute of the **** component to **button**, **date**, or any of the supported values. ``` @@ -51,6 +55,7 @@ Set the **type** attribute of the **** component to **button**, ** ``` + ``` /* xxx.css */ .container { @@ -83,6 +88,7 @@ Set the **type** attribute of the **** component to **button**, ** } ``` + ``` // xxx.js export default { @@ -92,15 +98,19 @@ export default { } ``` -![](figures/18.gif) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- For wearables, the input type can only be **button**, **radio**, or **checkbox**. ->- The settings of **checked** take effect only when the input type is set to **checkbox** or **radio**. The default value of **checked** is **false**. +![en-us_image_0000001223287672](figures/en-us_image_0000001223287672.gif) + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - For wearables, the input type can only be button, radio, or checkbox. +> +> - The settings of checked take effect only when the input type is set to checkbox or radio. The default value of checked is false. -## Event Binding -Add the **search** and **translate** events to the **** component. +## Event Binding + + Add the search and translate events to the component. ``` @@ -113,6 +123,7 @@ Add the **search** and **translate** events to the **** component. ``` + ``` /* xxx.css */ .content { @@ -134,6 +145,7 @@ text{ } ``` + ``` // xxx.js import prompt from '@system.prompt' @@ -153,11 +165,13 @@ export default { } ``` -![](figures/36.gif) +![en-us_image_0000001267647853](figures/en-us_image_0000001267647853.gif) -## Setting the Input Error Message -Add the **showError** method to the **** component to display an error message in the event of incorrect input. +## Setting the Input Error Message + +Add the showError method to the component to display an error message in the event of incorrect input. + ``` @@ -168,6 +182,7 @@ Add the **showError** method to the **** component to display an err ``` + ``` /* xxx.css */ .content { @@ -187,6 +202,7 @@ Add the **showError** method to the **** component to display an err } ``` + ``` // xxx.js import prompt from '@system.prompt' @@ -203,13 +219,9 @@ import prompt from '@system.prompt' }, buttonClick(e){ if(this.value.length > 6){ - this.$element("input").showError({ - error: 'Up to 6 characters are allowed.' - }); + this.$element("input").showError({ error: 'Up to 6 characters are allowed.' }); }else if(this.value.length == 0){ - this.$element("input").showError({ - error:this.value + 'This field cannot be left empty.' - }); + this.$element("input").showError({ error:this.value + 'This field cannot be left empty.' }); }else{ prompt.showToast({ message: "success " @@ -219,15 +231,18 @@ import prompt from '@system.prompt' } ``` -![](figures/19.gif) +![en-us_image_0000001223127708](figures/en-us_image_0000001223127708.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - This method is available when the input type is set to text, email, date, time, number, or password. ->![](../public_sys-resources/icon-note.gif) **NOTE:** -> ->- This method is available when the input type is set to **text**, **email**, **date**, **time**, **number**, or **password**. -## Example Scenario +## Example Scenario + + +Enter information by using the component of the type that suits your needs. + -Enter information by using the **** component of the type that suits your needs. ``` @@ -257,6 +272,8 @@ Enter information by using the **** component of the type that suits y ``` + + ``` /* xxx.css */ .container { @@ -285,6 +302,8 @@ label { } ``` + + ``` // xxx.js import prompt from '@system.prompt'; @@ -301,5 +320,5 @@ export default { } ``` -![](figures/4.gif) +![en-us_image_0000001222807760](figures/en-us_image_0000001222807760.gif) diff --git a/en/application-dev/ui/ui-js-components-list.md b/en/application-dev/ui/ui-js-components-list.md index 6e45758d530697b6793bfbfe18c9fe5dde6a2120..c2a3150d366260d91dac7997690474f37cf3955e 100644 --- a/en/application-dev/ui/ui-js-components-list.md +++ b/en/application-dev/ui/ui-js-components-list.md @@ -1,16 +1,18 @@ -# List +# <list> Development -The **** component provides a list container that presents a series of list items arranged in a column with the same width. Lists can be used for presenting the same type of data in a multiple and coherent row style. For details, see [list](../reference/arkui-js/js-components-container-list.md). -## Creating a Component +The <list> component provides a list container that presents a series of list items arranged in a column with the same width. Lists can be used for presenting the same type of data in a multiple and coherent row style. For details, see [list](../reference/arkui-js/js-components-container-list.md). + + +## Creating a <list> Component + +Create a <list> component in the .hml file under pages/index. -Create a **** component in the **.hml** file under **pages/index**. ```
- - + @@ -18,6 +20,7 @@ Create a **** component in the **.hml** file under **pages/index**.
``` + ``` /* xxx.css */ .container { @@ -32,15 +35,18 @@ Create a **** component in the **.hml** file under **pages/index**. } ``` -![](figures/5.png) +![en-us_image_0000001223287680](figures/en-us_image_0000001223287680.png) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - <list-item-group> is a child component of the <list> component and is used to group items in a list. It can have a <list-item> nested inside, but not <list>. +> +> - <list-item> is a child component of the <list> component and is used to display items in a list. + ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- **** is a child component of the **** component and is used to group items in a list. It can have a **** nested inside, but not ****. ->- **** is a child component of the **** component and is used to display items in a list. +## Adding a Scrollbar -## Adding a Scrollbar +To display a scrollbar on the right side of the screen, set scrollbar to on. The side scrollbar can be used to scroll a long list or the screen up or down. -To display a scrollbar on the right side of the screen, set **scrollbar** to **on**. The side scrollbar can be used to scroll a long list or the screen up or down. ``` @@ -56,6 +62,7 @@ To display a scrollbar on the right side of the screen, set **scrollbar** to ``` + ``` /* index.css */ .container { @@ -74,11 +81,13 @@ To display a scrollbar on the right side of the screen, set **scrollbar** to } ``` -![](figures/24.gif) +![en-us_image_0000001223287684](figures/en-us_image_0000001223287684.gif) -## Adding a Side Index Bar -Set a custom **indexer** component to add an index bar at the right boundary of a list. By default, an alphabetical indexer is used. +## Adding a Side Index Bar + +Set a custom indexer component to add an index bar at the right boundary of a list. By default, an alphabetical indexer is used. + ``` @@ -89,9 +98,10 @@ Set a custom **indexer** component to add an index bar at the right boundary o ``` + ``` /* index.css */ -.container { +.container{ flex-direction: column; background-color: #F1F3F5; } @@ -102,15 +112,18 @@ Set a custom **indexer** component to add an index bar at the right boundary o } ``` -![](figures/00.png) +![en-us_image_0000001223127716](figures/en-us_image_0000001223127716.png) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - This indexer attribute is valid only when flex-direction is set to column and columns is set to 1. +> +> - You must include "\#" when using a customized indexer. + ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- This **indexer** attribute is valid only when **flex-direction** is set to **column** and **columns** is set to **1**. ->- You must include **"\#"** when using a customized indexer. +## Collapsing or Expanding a List -## Collapsing or Expanding a List +To allow a <list> component to collapse and expand, add groupcollapse and groupexpand events. -To allow a **** component to collapse and expand, add **groupcollapse** and **groupexpand** events. ``` @@ -132,6 +145,7 @@ To allow a **** component to collapse and expand, add **groupcollapse* ``` + ``` /* index.css */ .doc-page { @@ -152,6 +166,7 @@ margin-top:30px; } ``` + ``` // xxx.js import prompt from '@system.prompt'; @@ -183,21 +198,18 @@ export default { } ``` -![](figures/8-4.gif) +![en-us_image_0000001267887845](figures/en-us_image_0000001267887845.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - The groupcollapse and groupexpand events can be used only by the list-item-group component. ->![](../public_sys-resources/icon-note.gif) **NOTE:** -> ->- The **groupcollapse** and **groupexpand** events can be used only by the **list-item-group** component. -## Example Scenario +## Example Scenario Search for contacts by using an alphabetical indexer. ``` -``` - -```
Contacts @@ -207,7 +219,7 @@ Search for contacts by using an alphabetical indexer.
{{$item.name}} - 18888888888 + 18888888888
@@ -239,7 +251,7 @@ Search for contacts by using an alphabetical indexer. color: #000000; font-size: 39px; } -.phone { +.number { color: black; font-size: 25px; } @@ -294,5 +306,5 @@ export default { } ``` -![](figures/27.gif) +![en-us_image_0000001267767861](figures/en-us_image_0000001267767861.gif) diff --git a/en/application-dev/ui/ui-js-components-picker.md b/en/application-dev/ui/ui-js-components-picker.md index 6d4f4131e62832db16054273b3d7052ada0ad5be..a2e5ff4c52c17ce2d17b4638eebcebd68f9418bf 100644 --- a/en/application-dev/ui/ui-js-components-picker.md +++ b/en/application-dev/ui/ui-js-components-picker.md @@ -1,20 +1,22 @@ -# Picker +# <picker> Development -The **** component supports common, date, time, data and time, and multi-column text selectors. For details, see [picker](../reference/arkui-js/js-components-basic-picker.md). -## Creating a Component +The <picker> component supports common, date, time, data and time, and multi-column text selectors. For details, see [picker](../reference/arkui-js/js-components-basic-picker.md). + + +## Creating a <picker> Component + +Create a <picker> component in the .hml file under pages/index. -Create a **** component in the **.hml** file under **pages/index**. ```
- - picker - + picker
``` + ``` /* index.css */ .container { @@ -25,11 +27,13 @@ Create a **** component in the **.hml** file under **pages/index** } ``` -![](figures/20211008-184455(welinkpc).gif) +![en-us_image_0000001223287716](figures/en-us_image_0000001223287716.gif) + -## Setting the Picker Type +## Setting the Picker Type + +Set the type attribute of the <picker> component. For example, set it to date. -Set the **type** attribute of the **** component. For example, set it to **date**. ``` @@ -39,6 +43,7 @@ Set the **type** attribute of the **** component. For example, set
``` + ``` /* index.css */ .container { @@ -52,6 +57,7 @@ Set the **type** attribute of the **** component. For example, set } ``` + ``` // xxx.js export default { @@ -63,15 +69,17 @@ export default { } ``` -![](figures/20211217-130837(welinkpc).gif) +![en-us_image_0000001267647893](figures/en-us_image_0000001267647893.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> +> When setting the value range of a common selector, you must use the data binding mode. ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When setting the value range of a common selector, you must use the data binding mode. ->- The **lunarswitch** attribute of the date selector is only supported on phones and tablets. -## Setting the Time Format +## Setting the Time Format + +Set the hours attribute to specify the time format used by the time selector. Available values include 12 and 24, indicating the 12-hour format and 24-hour format, respectively. -Set the **hours** attribute to specify the time format used by the time selector. Available values include **12** and **24**, indicating the 12-hour format and 24-hour format, respectively. ``` @@ -81,6 +89,7 @@ Set the **hours** attribute to specify the time format used by the time select
``` + ``` /* index.css */ .container { @@ -96,15 +105,18 @@ Set the **hours** attribute to specify the time format used by the time select } ``` -![](figures/25.gif) +![en-us_image_0000001222807808](figures/en-us_image_0000001222807808.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - When hours is set to 12, the time is displayed in 12-hour format and distinguished by a.m. and p.m. +> +> - When hours is set to 24, the time is displayed in 24-hour format. + ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When **hours** is set to **12**, the time is displayed in 12-hour format and distinguished by a.m. and p.m. ->- When **hours** is set to **24**, the time is displayed in 24-hour format. +## Adding Response Events -## Adding Response Events +To confirm and cancel selection, add change and cancel events. -To confirm and cancel selection, add **change** and **cancel** events. ``` @@ -114,6 +126,7 @@ To confirm and cancel selection, add **change** and **cancel** events.
``` + ``` /* index.css */ .container { @@ -131,6 +144,7 @@ To confirm and cancel selection, add **change** and **cancel** events. } ``` + ``` // xxx.js import prompt from '@system.prompt'; @@ -150,11 +164,13 @@ export default { } ``` -![](figures/26.gif) +![en-us_image_0000001223127748](figures/en-us_image_0000001223127748.gif) + + +## Example Scenario -## Example Scenario -Implement a health check-in application by using the **** component. +Implement a health check-in application by using the <picker> component. ``` @@ -277,5 +293,5 @@ export default { } ``` -![](figures/qqqq.gif) +![en-us_image_0000001267887877](figures/en-us_image_0000001267887877.gif) diff --git a/en/application-dev/ui/ui-js-components-stepper.md b/en/application-dev/ui/ui-js-components-stepper.md index cab1e9ae62f36ef4570d294f9a64f0cd1f231f62..d9a13be87c74e1e602c5352f6f324cf5d08ed6ea 100644 --- a/en/application-dev/ui/ui-js-components-stepper.md +++ b/en/application-dev/ui/ui-js-components-stepper.md @@ -1,19 +1,22 @@ -# Stepper +# <stepper> Development -When multiple steps are required to complete a task, you can use the **** component to navigate your users through the whole process. For details, see [stepper](../reference/arkui-js/js-components-container-stepper.md). ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. +When multiple steps are required to complete a task, you can use the <stepper> component to navigate your users through the whole process. For details, see [stepper](../reference/arkui-js/js-components-container-stepper.md). -## Creating a Component -Create a **** component in the **.hml** file under **pages/index**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> This component is supported since API version 5. + + +## Creating a <stepper> Component + +Create a <stepper> component in the .hml file under pages/index. + ```
- - + Step 1 @@ -23,6 +26,7 @@ Create a **** component in the **.hml** file under **pages/index*
``` + ``` /* xxx.css */ .container { @@ -38,11 +42,13 @@ text{ } ``` -![](figures/2-7.gif) +![en-us_image_0000001223287656](figures/en-us_image_0000001223287656.gif) + -## Setting the Index +## Setting the Index + +Set index to the index value of the step that you want to display by default. -Set **index** to the index value of the step that you want to display by default. ``` @@ -61,6 +67,7 @@ Set **index** to the index value of the step that you want to display by defau ``` + ``` /* index.css */ .container { @@ -74,9 +81,10 @@ text{ } ``` -![](figures/10.gif) +![en-us_image_0000001267767837](figures/en-us_image_0000001267767837.gif) + +Set the label attribute to customize the button text for the <stepper-item>. -Set the **label** attribute to customize the button text for the ****. ``` @@ -98,6 +106,7 @@ Set the **label** attribute to customize the button text for the ** ``` + ``` /* index.css */ .container { @@ -111,14 +120,12 @@ text{ } ``` + ``` /* index.js */ export default { data: { - label_1:{ - nextLabel: 'NEXT', - status: 'normal' - }, + label_1:{ nextLabel: 'NEXT', status: 'normal' }, label_2:{ prevLabel: 'BACK', nextLabel: 'NEXT', @@ -133,11 +140,12 @@ export default { } ``` -![](figures/11-8.gif) +![en-us_image_0000001267767841](figures/en-us_image_0000001267767841.gif) -## Setting the Style -By default, the **** component fills entire space of its container. The sample code below shows how to set the border and background color using the **border** and **background-color** attributes. +## Setting the Style + + By default, the <stepper> component fills entire space of its container. The sample code below shows how to set the border and background color using the border and background-color attributes. ``` @@ -152,6 +160,7 @@ By default, the **** component fills entire space of its container. ``` + ``` /* index.css */ .container { @@ -165,8 +174,7 @@ By default, the **** component fills entire space of its container. height: 300px; } .stepperClass{ - border:1px solid silver ; - background-color: white; + border:1px solid silver ; background-color: white; } text{ width: 100%; @@ -175,14 +183,16 @@ text{ } ``` -![](figures/02.png) +![en-us_image_0000001223287668](figures/en-us_image_0000001223287668.png) -## Adding Events -The **** component supports the **finish**, **change**, **next**, **back**, and **skip** events. +## Adding Events -- When the **change** and **next** or **back** events exist at the same time, the **next** or **back** event is executed before the **change** event. -- Before resetting the **index** attribute, you must remove the current value. Otherwise, the value change cannot be detected. +The <stepper> component supports the finish, change, next, back, and skip events. + +- When the change and next or back events exist at the same time, the next or back event is executed before the change event. + +- Before resetting the index attribute, you must remove the current value. Otherwise, the value change cannot be detected. ``` @@ -205,6 +215,7 @@ The **** component supports the **finish**, **change**, **next**, ``` + ``` /* xxx.css */ .doc-page { @@ -231,6 +242,7 @@ button{ } ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -272,13 +284,15 @@ export default { } ``` -![](figures/37.gif) +![en-us_image_0000001267607869](figures/en-us_image_0000001267607869.gif) + -## Example Scenario +## Example Scenario Select the options displayed on the page. Your selection will be shown in real time. Click the next button to dynamically change the font color and font size on the page. -Use the **** component to navigate through the steps. Create a [****](../reference/arkui-js/js-components-basic-toggle.md) component to implement the functions of selection and displaying the selection result. Then use the [****](../reference/arkui-js/js-components-basic-select.md) component to dynamically change the font color or size of the selected options. +Use the <stepper> component to navigate through the steps. Create a [<toggle>](../reference/arkui-js/js-components-basic-toggle.md) component to implement the functions of selection and displaying the selection result. Then use the [<select>](../reference/arkui-js/js-components-basic-select.md) component to dynamically change the font color or size of the selected options. + ```
@@ -321,6 +335,7 @@ Use the **** component to navigate through the steps. Create a [**<
``` + ``` /* xxx.css */ .container { @@ -340,6 +355,7 @@ Use the **** component to navigate through the steps. Create a [**< } ``` + ``` /* index.js */ import prompt from '@system.prompt'; @@ -382,5 +398,4 @@ export default { } ``` -![](figures/28.gif) - +![en-us_image_0000001267887817](figures/en-us_image_0000001267887817.gif) diff --git a/en/application-dev/ui/ui-js-components-text.md b/en/application-dev/ui/ui-js-components-text.md index 99942a3c164a191a8dff423bce1965e22bd49c93..68fc3006a34b48456df5a99ebbbcf39fd338f5d4 100644 --- a/en/application-dev/ui/ui-js-components-text.md +++ b/en/application-dev/ui/ui-js-components-text.md @@ -1,23 +1,27 @@ -# Text +# <text> Development -The **** component is used to display a piece of textual information. For details, see [text](../reference/arkui-js/js-components-basic-text.md). -## Creating a Component +The <text> component is used to display a piece of textual information. For details, see [text](../reference/arkui-js/js-components-basic-text.md). + + +## Creating a <text> Component + +Create a <text> component in the .hml file under pages/index. -Create a **** component in the **.hml** file under **pages/index**. ```
- - Hello World - + Hello World
``` + ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; align-items: center; justify-content: center; @@ -25,141 +29,174 @@ Create a **** component in the **.hml** file under **pages/index**. } ``` -![](figures/01.png) +![en-us_image_0000001222807780](figures/en-us_image_0000001222807780.png) -## Setting the Text Style and Attributes -- Adding a text style +## Setting the Text Style and Attributes -Set the **color**, **font-size**, and **allow-scale** attributes. +- Adding a text style -``` - -
- - This is a passage - -
-``` -![](figures/01-0.png) + Set the color, font-size, allow-scale, word-spacing, and text-valign attributes to apply the color, size, zoom, spacing, and vertical alignment styles to the text. -- Adding a text modifier + ``` + +
+ + This is a passage + + + This is a passage + +
+ ``` + + + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: #F1F3F5; + } + ``` -Set the **text-decoration** attribute to add an underline, overline, line-through, or a combination of lines to selected text. For values of **text-decoration**, see [Text Style](../reference/arkui-js/js-components-basic-text.md). -``` - -
- - This is a passage - - - This is a passage - -
-``` + ![en-us_image_0000001222967764](figures/en-us_image_0000001222967764.png) -``` -/* xxx.css */ -.container { - flex-direction: column; - align-items: center; - justify-content: center; -} -text{ - font-size: 50px; -} -``` +- Adding a text modifier -![](figures/3.png) -- Hiding text content + Set the text-decoration attribute to add a line to selected text. Set the text-decoration-color attribute to apply specific color to the added line. For values of text-decoration, see [Text Style](../reference/arkui-js/js-components-basic-text.md). -Set the **text-overflow** attribute to **ellipsis** so that overflowed text is displayed as an ellipsis. + ``` + +
+ + This is a passage + + + This is a passage + +
+ ``` + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + } + text{ + font-size: 50px; + } + ``` -``` - -
- - This is a passage - -
-``` -``` -/* xxx.css */ -.container { - flex-direction: column; - align-items: center; - background-color: #F1F3F5; - justify-content: center; -} -.text{ - width: 200px; - max-lines: 1; - text-overflow:ellipsis; -} -``` + ![en-us_image_0000001223287688](figures/en-us_image_0000001223287688.png) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- **text-overflow** must be used together with **max-lines**. ->- **max-lines** indicates the maximum number of lines in the text. +- Hiding text content -![](figures/05.png) -- Setting the text line breaking mode + Set the text-overflow attribute to ellipsis so that overflowed text is displayed as an ellipsis. -Set the **word-break** attribute to specify how to break lines of text. For values of **word-break**, see [Text Styles](../reference/arkui-js/js-components-basic-text.md). - -``` - -
-
- - Welcome to the world - - - Welcome to the world + ``` + +
+ + This is a passage
-
-``` + ``` + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + background-color: #F1F3F5; + justify-content: center; + } + .text{ + width: 200px; + max-lines: 1; + text-overflow:ellipsis; + } + ``` + + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: + > - text-overflow must be used together with max-lines. + > + > - max-lines indicates the maximum number of lines in the text. -``` -/* xxx.css */ -.container { - background-color: #F1F3F5; - flex-direction: column; - align-items: center; - justify-content: center; -} -.content{ - width: 50%; - flex-direction: column; - align-items: center; - justify-content: center; -} -.text1{ - height: 200px; - border:1px solid #1a1919; - margin-bottom: 50px; - text-align: center; - word-break: break-word; - font-size: 40px; -} -.text2{ - height: 200px; - border:1px solid #0931e8; - text-align: center; - word-break: break-all; - font-size: 40px; -} -``` -![](figures/8.png) +![en-us_image_0000001267647865](figures/en-us_image_0000001267647865.png) -- Setting the [****](../reference/arkui-js/js-components-basic-span.md) child component + +- Setting the text line breaking mode + + + Set the word-break attribute to specify how to break lines of text. For values of word-break, see [Text Styles](../reference/arkui-js/js-components-basic-text.md). + + ``` + +
+
+ + Welcome to the world + + + Welcome to the world + +
+
+ ``` + + ``` + /* xxx.css */ + .container { + background-color: #F1F3F5; + flex-direction: column; + align-items: center; + justify-content: center; + } + .content{ + width: 50%; + flex-direction: column; + align-items: center; + justify-content: center; + } + .text1{ + height: 200px; + border:1px solid #1a1919; + margin-bottom: 50px; + text-align: center; + word-break: break-word; + font-size: 40px; + } + .text2{ + height: 200px; + border:1px solid #0931e8; + text-align: center; + word-break: break-all; + font-size: 40px; + } + ``` + + + ![en-us_image_0000001267767865](figures/en-us_image_0000001267767865.png) + +- Setting the [<span>](../reference/arkui-js/js-components-basic-span.md)child component ``` @@ -168,47 +205,45 @@ Set the **word-break** attribute to specify how to break lines of text. For va This is a passage - This - - 1 - - is a - - 1 - - passage + This 1 is a 1 passage
``` -![](figures/01-1.png) ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When the **** child component is used to form a text paragraph, incorrect **** attribute settings \(for example, setting of **font-weight** to **1000**\) will result in abnormal display of the text paragraph. ->- When the **** child component is being used, do not include any text you want to show in the **** component, as such text will not be displayed if you do so. +![en-us_image_0000001223127720](figures/en-us_image_0000001223127720.png) -## Example Scenario -Use the **** component to display text content through data binding. Use the **** child component to hide or display text content by setting the **show** attribute. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: +> - When the <span> child component is used to form a text paragraph, incorrect <span> attribute settings (for example, setting of font-weight to 1000) will result in abnormal display of the text paragraph. +> +> - When the <span> child component is being used, do not include any text you want to show in the <text> component, as such text will not be displayed if you do so. + + +## Example Scenario + +Use the <text> component to display text content through data binding. Use the <span> child component to hide or display text content by setting the show attribute. + + + ``` + +
+
+ + {{ content }} + + +
+ + {{ content }} + + 1 + + Hide clip + +
+ ``` -``` - -
-
- - {{ content }} - - -
- - {{ content }} - - 1 - - Hide clip - -
-``` ``` /* xxx.css */ @@ -226,6 +261,7 @@ Use the **** component to display text content through data binding. Us } ``` + ``` // xxx.js export default { @@ -240,5 +276,4 @@ export default { } ``` -![](figures/1.gif) - +![en-us_image_0000001267887849](figures/en-us_image_0000001267887849.gif) diff --git a/en/application-dev/ui/ui-js-custom-components.md b/en/application-dev/ui/ui-js-custom-components.md index 1799c5b51a44cfc754851dc129c239609155bdb6..c2a5c96faa10df363c415c32ec9e80db9a752560 100644 --- a/en/application-dev/ui/ui-js-custom-components.md +++ b/en/application-dev/ui/ui-js-custom-components.md @@ -1,100 +1,106 @@ -# Custom Components +# Custom Components -The ArkUI that uses the JavaScript-based web-like development paradigm supports custom components for you to extend existing components. You can encapsulate custom private attributes and events into new components to reuse them multiple times in your project. This also improves code readability. The following is an example: -- **Building a custom component** +The ArkUI that uses the JavaScript-based web-like development paradigm supports custom components for you to extend existing components. You can encapsulate custom private attributes and events into new components to reuse them multiple times in your project. This also improves code readability. The following is an example: - ``` - -
- {{title}} - Click to view the hidden text. - hello world -
- ``` - ``` - /* comp.css */ - .item { - width: 700px; - flex-direction: column; - height: 300px; - align-items: center; - margin-top: 100px; - } - .text-style { - width: 100%; - text-align: center; - font-weight: 500; - font-family: Courier; - font-size: 36px; - } - .title-style { - font-weight: 500; - font-family: Courier; - font-size: 50px; - color: #483d8b; - } - ``` +- Building a custom component + + ``` + +
+ {{title}} + Click to view the hidden text. + hello world +
+ ``` - ``` - // comp.js - export default { - props: { - title: { - default: 'title', - }, - showObject: {}, - }, - data() { - return { - showObj: this.showObject, - }; - }, - childClicked () { - this.$emit('eventType1', {text: 'Receive the parameters from the child component.'}); - this.showObj = !this.showObj; - }, - } - ``` + + ``` + /* comp.css */ + .item { + width: 700px; + flex-direction: column; + height: 300px; + align-items: center; + margin-top: 100px; + } + .text-style { + width: 100%; + text-align: center; + font-weight: 500; + font-family: Courier; + font-size: 36px; + } + .title-style { + font-weight: 500; + font-family: Courier; + font-size: 50px; + color: #483d8b; + } + ``` -- **Introducing the custom component** + + ``` + // comp.js + export default { + props: { + title: { + default: 'title', + }, + showObject: {}, + }, + data() { + return { + showObj: this.showObject, + }; + }, + childClicked () { + this.$emit('eventType1', {text: 'Receive the parameters from the child component.'}); + this.showObj = !this.showObj; + }, + } + ``` - ``` - - -
- Parent component: {{text}} - -
- ``` +- Introducing the custom component + + ``` + + +
+ Parent component: {{text}} + +
+ ``` - ``` - /* xxx.css */ - .container { - background-color: #f8f8ff; - flex: 1; - flex-direction: column; - align-content: center; - } - ``` + + ``` + /* xxx.css */ + .container { + background-color: #f8f8ff; + flex: 1; + flex-direction: column; + align-content: center; + } + ``` - ``` - // xxx.js - export default { - data: { - text: 'Start' - isShow: false, - }, - textClicked (e) { - this.text = e.detail.text; - }, - } - ``` + + ``` + // xxx.js + export default { + data: { + text: 'Start' + isShow: false, + }, + textClicked (e) { + this.text = e.detail.text; + }, + } + ``` -In this example, the parent component passes the customized attribute through **title** to the child component, and the child component receives the attribute value in **props**. The child component passes **text** to the parent through the bound event, and the passed value is obtained via **e.detail**. To successfully bind the child component event to the parent component, ensure that the event name meet the requirements for event binding. For details, see [Basic Usage of Custom Components](../reference/arkui-js/js-components-custom-basic-usage.md). The following figures show how the custom component works. +In this example, the parent component passes the customized attribute through title to the child component, and the child component receives the attribute value in props. The child component passes text to the parent through the bound event, and the passed value is obtained via e.detail. To successfully bind the child component event to the parent component, ensure that the event name meet the requirements for event binding. For details, see [Basic Usage of Custom Components](../reference/arkui-js/js-components-custom-basic-usage.md). The following figures show how the custom component works. -**Figure 1** Running effect -![](figures/running-effect.png "running-effect") + figure1 Running effect + ![en-us_image_0000001222807816](figures/en-us_image_0000001222807816.png) diff --git a/en/application-dev/ui/ui-js-overview.md b/en/application-dev/ui/ui-js-overview.md index 7d9da6ca4f2bb6ff1edde7c22e8f4616febaa06e..39612e9d878502f3a855b24dae62eee1ea8b5436 100644 --- a/en/application-dev/ui/ui-js-overview.md +++ b/en/application-dev/ui/ui-js-overview.md @@ -1,35 +1,29 @@ -# Overview +# Overview - ArkUI with the JavaScript-based web-like development paradigm provides UI components \(basic, container, canvas, and more\) and standard CSS animation capabilities. -## Basic Capabilities +The web-like development paradigm uses the classical three-stage programming model, in which OpenHarmony Markup Language (HML) is used for building layouts, CSS for defining styles, and JavaScript for adding processing logic. UI components are associated with data through one-way data-binding. This means that when data changes, the UI automatically updates with the new data. This development paradigm has a low learning curve for frontend web developers, allowing them to quickly transform existing web applications into ArkUI applications. It could be helpful if you are developing small- and medium-sized applications with simple UIs. -- **Web-like development paradigm** - ArkUI supports languages that are similar to those for web development, such as HTML and CSS. You can use them to describe the page layout and style, and use JavaScript \(conforming to the ECMAScript specification\) for page behavior. With ArkUI, you can configure the UI in an intuitive manner, eliminating the need to code for UI state switching. +## Overall Architecture +ArkUI with the JavaScript-based web-like development paradigm consists of the following layers: application layer, frontend framework layer, engine layer, and porting layer. -## Overall Structure - ArkUI with the JavaScript-based web-like development paradigm consists of the following layers: application layer, frontend framework layer, engine layer, and porting layer. +![en-us_image_0000001223127696](figures/en-us_image_0000001223127696.png) -![](figures/zh-cn_image_0000001077953992.png) +- Application -- **Application** + Contains applications with FAs you developed. The FA application in this document refers to the application with FAs developed using JavaScript. - Contains applications with FAs you developed. The FA application in this document refers to the application with FAs developed using JavaScript. +- Framework -- **Framework** + Parses UI pages and provides the Model-View-ViewModel (MVVM), page routing, custom components and more for front end development. - Parses UI pages and provides the Model-View-ViewModel \(MVVM\), page routing, custom components and more for front end development. +- Engine -- **Engine** - - Accomplishes animation parsing, Document Object Model \(DOM\) building, layout computing, rendering command building and drawing, and event management. - -- **Porting Layer** - - Abstracts the platform layer to provide abstract interfaces to connect to the platform. For example, event interconnection, rendering pipeline interconnection, and lifecycle interconnection. + Accomplishes animation parsing, Document Object Model (DOM) building, layout computing, rendering command building and drawing, and event management. +- Porting Layer + Abstracts the platform layer to provide abstract interfaces to connect to the platform. For example, event interconnection, rendering pipeline interconnection, and lifecycle interconnection. diff --git a/en/application-dev/ui/ui-ts-building-category-grid-layout.md b/en/application-dev/ui/ui-ts-building-category-grid-layout.md index 534482f62ed38279b90570e1e32bcba6b1849173..9a2e8febf63fcff3a00531ea4d31a348b1523e75 100644 --- a/en/application-dev/ui/ui-ts-building-category-grid-layout.md +++ b/en/application-dev/ui/ui-ts-building-category-grid-layout.md @@ -1,371 +1,373 @@ -# Building a Food Category Grid Layout +# Building a Food Category Grid Layout -The diet application allows food on the home page to display in list or grid mode. You can implement switching between food categories through tabs in grid mode. - -1. Import the **Category** enumeration type to the **FoodCategoryList** page. - - ``` - import { Category, FoodData } from '../model/FoodData' - ``` - -2. Create the **FoodCategoryList** and **FoodCategory** components. The **FoodCategoryList** component is used as the entry component of the new page, and the **initializeOnStartup** method is invoked in the entry component. - - ``` - @Component - struct FoodList { - private foodItems: FoodData[] - build() { - ...... - } - } - - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - ...... - } - } - - @Entry - @Component - struct FoodCategoryList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - ...... - } - } - ``` - -3. Create the **showList** member variable in the **FoodCategoryList** component to control the rendering switchover between the list layout and grid layout. The conditional rendering statement **if...else...** is required. - - ``` - @Entry - @Component - struct FoodCategoryList { - private foodItems: FoodData[] = initializeOnStartup() - private showList: boolean = false - - build() { - Stack() { - if (this.showList) { - FoodList({ foodItems: this.foodItems }) - } else { - FoodCategory({ foodItems: this.foodItems }) - } - } - } - } - ``` - -4. In the upper right corner of the page, create an icon for switching between the list and grid layouts. Set the stack alignment mode to **TopEnd**, top-bottom alignment. Create an image component, and set the click event, that is, negation of **showList**. - - ``` - @Entry - @Component - struct FoodCategoryList { - private foodItems: FoodData[] = initializeOnStartup() - private showList: boolean = false - - build() { - Stack({ alignContent: Alignment.TopEnd }) { - if (this.showList) { - FoodList({ foodItems: this.foodItems }) - } else { - FoodCategory({ foodItems: this.foodItems }) - } - Image($r('app.media.Switch')) - .height(24) - .width(24) - .margin({ top: 15, right: 10 }) - .onClick(() => { - this.showList = !this.showList - }) - }.height('100%') - } - } - ``` - -5. Add the **@State** decorator. After you click the switch tab in the upper right corner, the page does not change. This is because the **showList** does not have state data and its change does not trigger the page refresh. You need to add the **@State** decorator to make it state data. The change of the **@State** decorator will cause re-rendering of the component where the decorator is located. - - ``` - @Entry - @Component - struct FoodCategoryList { - private foodItems: FoodData[] = initializeOnStartup() - @State private showList: boolean = false - - build() { - Stack({ alignContent: Alignment.TopEnd }) { - if (this.showList) { - FoodList({ foodItems: this.foodItems }) - } else { - FoodCategory({ foodItems: this.foodItems }) - } - Image($r('app.media.Switch')) - .height(24) - .width(24) - .margin({ top: 15, right: 10 }) - .onClick(() => { - this.showList = !this.showList - }) - }.height('100%') - } - } - - ``` - - When you click the switch icon, the **FoodList** component is displayed. When you click the switch icon again, the **FoodList** component is hidden. - - ![](figures/video_2021-10-22_103503.gif) - -6. Create a tab to display all food categories \(**All**\). Create the **** component and its child component **TabContent** in the **FoodCategory** component, and set **tabBar** to **All**. Set the width of the **TabBars** to 280 and the layout mode to **Scrollable**. This means that the **TabBars** can be scrolled when the total length exceeds 280. The **** component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a **TabContent**. - - ``` - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() {}.tabBar('All') - } - .barWidth(280) - .barMode(BarMode.Scrollable) - } - } - } - ``` - - ![](figures/en-us_image_0000001204538065.png) - -7. Create the **FoodGrid** component to function as a child component of the **TabContent** component. - ``` - @Component - struct FoodGrid { - private foodItems: FoodData[] - build() {} - } - - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() { - FoodGrid({ foodItems: this.foodItems }) - }.tabBar('All') - } - .barWidth(280) - .barMode(BarMode.Scrollable) - } - } - } - ``` - -8. Implement a 2 x 6 grid layout \(12 food data resources in total\). Create a **Grid** component, and set **columnsTemplate** to **\('1fr 1fr'\)**, **rowsTemplate** to **\('1fr 1fr 1fr 1fr 1fr 1fr'\)**, and both **rowsGap** and **columnsGap** to **8**. Create a **Scroll** component so that it can be slid. - - ``` - @Component - struct FoodGrid { - private foodItems: FoodData[] - build() { - Scroll() { - Grid() { - ForEach(this.foodItems, (item: FoodData) => { - GridItem() {} - }, (item: FoodData) => item.id.toString()) - } - .rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr') - .columnsTemplate('1fr 1fr') - .columnsGap(8) - .rowsGap(8) - } - .scrollBar(BarState.Off) - .padding({left: 16, right: 16}) - } - } - ``` - -9. Create a **FoodGridItem** component to display the food image, name, and calories and implement the UI layout. The **FoodGridItem** component is a child component of the **GridItem** component. The height of each **FoodGridItem** is **184**, and the line spacing is **8**. The total height of the **Grid** component is calculated as follows: \(184 + 8\) x 6 – 8 = 1144. - - ``` - @Component - struct FoodGridItem { - private foodItem: FoodData - build() { - Column() { - Row() { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .height(152) - .width('100%') - }.backgroundColor('#FFf1f3f5') - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - .padding({ left: 8 }) - Text(this.foodItem.calories + 'kcal') - .fontSize(14) - .margin({ right: 6 }) - } - .height(32) - .width('100%') - .backgroundColor('#FFe5e5e5') - } - .height(184) - .width('100%') - } - } - - @Component - struct FoodGrid { - private foodItems: FoodData[] - build() { - Scroll() { - Grid() { - ForEach(this.foodItems, (item: FoodData) => { - GridItem() { - FoodGridItem({foodItem: item}) - } - }, (item: FoodData) => item.id.toString()) - } - .rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr') - .columnsTemplate('1fr 1fr') - .columnsGap(8) - .rowsGap(8) - .height(1144) - } - .scrollBar(BarState.Off) - .padding({ left: 16, right: 16 }) - } - } - ``` - - ![](figures/video_2021-10-21_105602.gif) - -10. Create the **Category.Vegetable**, **Category.Fruit**, **Category.Nut**, **Category.SeaFood**, and **Category.Dessert** tabs. - - ``` - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() { - FoodGrid({ foodItems: this.foodItems }) - }.tabBar('All') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) - }.tabBar('Vegetable') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) - }.tabBar('Fruit') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) - }.tabBar('Nut') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) - }.tabBar('Seafood') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) - }.tabBar('Dessert') - } - .barWidth(280) - .barMode(BarMode.Scrollable) - } - } - } - ``` - -11. Set the number of rows and height of grids for different food categories. Because the number of foods varies according to the category, the **''1fr 1fr 1fr 1fr 1fr 1fr '** constant cannot be used to set the number of rows to 6. - - Create member variables **gridRowTemplate** and **HeightValue**, and set the number of grid rows and height by using these member variables. - - ``` - @Component - struct FoodGrid { - private foodItems: FoodData[] - private gridRowTemplate : string = '' - private heightValue: number - build() { - Scroll() { - Grid() { - ForEach(this.foodItems, (item: FoodData) => { - GridItem() { - FoodGridItem({foodItem: item}) - } - }, (item: FoodData) => item.id.toString()) - } - .rowsTemplate(this.gridRowTemplate) - .columnsTemplate('1fr 1fr') - .columnsGap(8) - .rowsGap(8) - .height(this.heightValue) - } - .scrollBar(BarState.Off) - .padding({left: 16, right: 16}) - } - } - ``` - - Invoke the **aboutToAppear** API to calculate the number of rows \(**gridRowTemplate**\) and height \(**heightValue**\). - - ``` - aboutToAppear() { - var rows = Math.round(this.foodItems.length / 2); - this.gridRowTemplate = '1fr '.repeat(rows); - this.heightValue = rows * 192 - 8; - } - ``` - - The custom component provides two lifecycle callbacks: **aboutToAppear** and **aboutToDisappear**. **aboutToAppear** is executed after the custom component is created and before the **build** method of the custom component is executed. **aboutToDisappear** is executed when the custom component is deinitialized. - - ![](figures/en-us_image_0000001215113569.png) - - ``` - @Component - struct FoodGrid { - private foodItems: FoodData[] - private gridRowTemplate : string = '' - private heightValue: number - - aboutToAppear() { - var rows = Math.round(this.foodItems.length / 2); - this.gridRowTemplate = '1fr '.repeat(rows); - this.heightValue = rows * 192 - 8; - } - - build() { - Scroll() { - Grid() { - ForEach(this.foodItems, (item: FoodData) => { - GridItem() { - FoodGridItem({foodItem: item}) - } - }, (item: FoodData) => item.id.toString()) - } - .rowsTemplate(this.gridRowTemplate) - .columnsTemplate('1fr 1fr') - .columnsGap(8) - .rowsGap(8) - .height(this.heightValue) - } - .scrollBar(BarState.Off) - .padding({left: 16, right: 16}) - } - } - ``` - - ![](figures/video_2021-10-21_105956.gif) +The diet application allows food on the home page to display in list or grid mode. You can implement switching between food categories through tabs in grid mode. +1. Import the Category enumeration type to the FoodCategoryList page. + + ``` + import { Category, FoodData } from '../model/FoodData' + ``` + +2. Create the FoodCategoryList and FoodCategory components. The FoodCategoryList component is used as the entry component of the new page, and the initializeOnStartup method is invoked in the entry component. + + ``` + @Component + struct FoodList { + private foodItems: FoodData[] + build() { + ...... + } + } + + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + ...... + } + } + + @Entry + @Component + struct FoodCategoryList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + ...... + } + } + ``` + +3. Create the showList member variable in the FoodCategoryList component to control the rendering switchover between the list layout and grid layout. The conditional rendering statement if...else... is required. + + ``` + @Entry + @Component + struct FoodCategoryList { + private foodItems: FoodData[] = initializeOnStartup() + private showList: boolean = false + + build() { + Stack() { + if (this.showList) { + FoodList({ foodItems: this.foodItems }) + } else { + FoodCategory({ foodItems: this.foodItems }) + } + } + } + } + ``` + +4. In the upper right corner of the page, create an icon for switching between the list and grid layouts. Set the stack alignment mode to TopEnd, top-bottom alignment. Create an image component, and set the click event, that is, negation of showList. + + ``` + @Entry + @Component + struct FoodCategoryList { + private foodItems: FoodData[] = initializeOnStartup() + private showList: boolean = false + + build() { + Stack({ alignContent: Alignment.TopEnd }) { + if (this.showList) { + FoodList({ foodItems: this.foodItems }) + } else { + FoodCategory({ foodItems: this.foodItems }) + } + Image($r('app.media.Switch')) + .height(24) + .width(24) + .margin({ top: 15, right: 10 }) + .onClick(() => { + this.showList = !this.showList + }) + }.height('100%') + } + } + ``` + +5. Add the @State decorator. After you click the switch tab in the upper right corner, the page does not change. This is because the showList does not have state data and its change does not trigger the page refresh. You need to add the @State decorator to make it state data. The change of the @State decorator will cause re-rendering of the component where the decorator is located. + + ``` + @Entry + @Component + struct FoodCategoryList { + private foodItems: FoodData[] = initializeOnStartup() + @State private showList: boolean = false + + build() { + Stack({ alignContent: Alignment.TopEnd }) { + if (this.showList) { + FoodList({ foodItems: this.foodItems }) + } else { + FoodCategory({ foodItems: this.foodItems }) + } + Image($r('app.media.Switch')) + .height(24) + .width(24) + .margin({ top: 15, right: 10 }) + .onClick(() => { + this.showList = !this.showList + }) + }.height('100%') + } + } + + ``` + + When you click the switch icon, the FoodList component is displayed. When you click the switch icon again, the FoodList component is hidden. + + ![en-us_image_0000001222807800](figures/en-us_image_0000001222807800.gif) + +6. Create a tab to display all food categories (All). Create the component and its child component TabContent in the FoodCategory component, and set tabBar to All. Set the width of the TabBars to 280 and the layout mode to Scrollable. This means that the TabBars can be scrolled when the total length exceeds 280. The component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a TabContent. + + ``` + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + Stack() { + Tabs() { + TabContent() {}.tabBar('All') + } + .barWidth(280) + .barMode(BarMode.Scrollable) + } + } + } + ``` + + ![en-us_image_0000001267647881](figures/en-us_image_0000001267647881.png) + +7. Create the FoodGrid component to function as a child component of the TabContent component. + + ``` + @Component + struct FoodGrid { + private foodItems: FoodData[] + build() {} + } + + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + Stack() { + Tabs() { + TabContent() { + FoodGrid({ foodItems: this.foodItems }) + }.tabBar('All') + } + .barWidth(280) + .barMode(BarMode.Scrollable) + } + } + } + ``` + +8. Implement a 2 x 6 grid layout (12 food data resources in total). Create a Grid component, and set columnsTemplate to ('1fr 1fr'), rowsTemplate to ('1fr 1fr 1fr 1fr 1fr 1fr'), and both rowsGap and columnsGap to 8. Create a Scroll component so that it can be slid. + + ``` + @Component + struct FoodGrid { + private foodItems: FoodData[] + build() { + Scroll() { + Grid() { + ForEach(this.foodItems, (item: FoodData) => { + GridItem() {} + }, (item: FoodData) => item.id.toString()) + } + .rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr') + .columnsTemplate('1fr 1fr') + .columnsGap(8) + .rowsGap(8) + } + .scrollBar(BarState.Off) + .padding({left: 16, right: 16}) + } + } + ``` + +9. Create a FoodGridItem component to display the food image, name, and calories and implement the UI layout. The FoodGridItem component is a child component of the GridItem component. The height of each FoodGridItem is 184, and the line spacing is 8. The total height of the Grid component is calculated as follows: (184 + 8) x 6 – 8 = 1144. + + ``` + @Component + struct FoodGridItem { + private foodItem: FoodData + build() { + Column() { + Row() { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + .height(152) + .width('100%') + }.backgroundColor('#FFf1f3f5') + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Text(this.foodItem.name) + .fontSize(14) + .flexGrow(1) + .padding({ left: 8 }) + Text(this.foodItem.calories + 'kcal') + .fontSize(14) + .margin({ right: 6 }) + } + .height(32) + .width('100%') + .backgroundColor('#FFe5e5e5') + } + .height(184) + .width('100%') + } + } + + @Component + struct FoodGrid { + private foodItems: FoodData[] + build() { + Scroll() { + Grid() { + ForEach(this.foodItems, (item: FoodData) => { + GridItem() { + FoodGridItem({foodItem: item}) + } + }, (item: FoodData) => item.id.toString()) + } + .rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr') + .columnsTemplate('1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height(1144) + } + .scrollBar(BarState.Off) + .padding({ left: 16, right: 16 }) + } + } + ``` + + ![en-us_image_0000001223287708](figures/en-us_image_0000001223287708.gif) + +10. Create the Category.Vegetable, Category.Fruit, Category.Nut, Category.SeaFood, and Category.Dessert tabs. + + ``` + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + Stack() { + Tabs() { + TabContent() { + FoodGrid({ foodItems: this.foodItems }) + }.tabBar('All') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) + }.tabBar('Vegetable') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) + }.tabBar('Fruit') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) + }.tabBar('Nut') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) + }.tabBar('Seafood') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) + }.tabBar('Dessert') + } + .barWidth(280) + .barMode(BarMode.Scrollable) + } + } + } + ``` + +11. Set the number of rows and height of grids for different food categories. Because the number of foods varies according to the category, the ''1fr 1fr 1fr 1fr 1fr 1fr ' constant cannot be used to set the number of rows to 6. + Create member variables gridRowTemplate and HeightValue, and set the number of grid rows and height by using these member variables. + + + ``` + @Component + struct FoodGrid { + private foodItems: FoodData[] + private gridRowTemplate : string = '' + private heightValue: number + build() { + Scroll() { + Grid() { + ForEach(this.foodItems, (item: FoodData) => { + GridItem() { + FoodGridItem({foodItem: item}) + } + }, (item: FoodData) => item.id.toString()) + } + .rowsTemplate(this.gridRowTemplate) + .columnsTemplate('1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height(this.heightValue) + } + .scrollBar(BarState.Off) + .padding({left: 16, right: 16}) + } + } + ``` + + Invoke the aboutToAppear API to calculate the number of rows (gridRowTemplate) and height (heightValue). + + + ``` + aboutToAppear() { + var rows = Math.round(this.foodItems.length / 2); + this.gridRowTemplate = '1fr '.repeat(rows); + this.heightValue = rows * 192 - 8; + } + ``` + + The custom component provides two lifecycle callbacks: aboutToAppear and aboutToDisappear. aboutToAppear is executed after the custom component is created and before the build method of the custom component is executed. aboutToDisappear is executed when the custom component is deinitialized. + + ![en-us_image_0000001267647885](figures/en-us_image_0000001267647885.png) + + + ``` + @Component + struct FoodGrid { + private foodItems: FoodData[] + private gridRowTemplate : string = '' + private heightValue: number + + aboutToAppear() { + var rows = Math.round(this.foodItems.length / 2); + this.gridRowTemplate = '1fr '.repeat(rows); + this.heightValue = rows * 192 - 8; + } + + build() { + Scroll() { + Grid() { + ForEach(this.foodItems, (item: FoodData) => { + GridItem() { + FoodGridItem({foodItem: item}) + } + }, (item: FoodData) => item.id.toString()) + } + .rowsTemplate(this.gridRowTemplate) + .columnsTemplate('1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height(this.heightValue) + } + .scrollBar(BarState.Off) + .padding({left: 16, right: 16}) + } + } + ``` + + ![en-us_image_0000001267887869](figures/en-us_image_0000001267887869.gif) diff --git a/en/application-dev/ui/ui-ts-building-category-list-layout.md b/en/application-dev/ui/ui-ts-building-category-list-layout.md index 7aff7b7bbffbc5386d82886a410b0cdd3715471d..78c21c0a62c8c3d3d450867052c35168b62cbbc0 100644 --- a/en/application-dev/ui/ui-ts-building-category-list-layout.md +++ b/en/application-dev/ui/ui-ts-building-category-list-layout.md @@ -1,259 +1,261 @@ -# Building a Food Category List Layout +# Building a Food Category List Layout -Use the **List** component and **ForEach** loop to build the food category list layout. -1. Create a page file named **FoodCategoryList.ets** in the **pages** directory, rename the **index.ets** file **FoodDetail.ets**, and add the renamed file to the **"pages"** tag in the **config.json** file. The first page under the tag is the home page. +Use the List component and ForEach loop to build the food category list layout. - ``` - "js": [ - { - "pages": [ - "pages/FoodCategoryList", - "pages/FoodDetail" - ], - ] - ``` -2. Create a **List** component named **FoodList** as the page entry point. Then, add a **ListItem** component named **FoodListItem** as its child component. The **List** component is used to display data of the same type. Its child component **** is used to display specific items in the list. +1. Create a page file named FoodCategoryList.ets in the pages directory, rename the index.ets file FoodDetail.ets, and add the renamed file to the "pages" tag in the config.json file. The first page under the tag is the home page. + + ``` + "js": [ + { + "pages": [ + "pages/FoodCategoryList", + "pages/FoodDetail" + ], + ] + ``` - ``` - @Component - struct FoodListItem { - build() {} - } - - @Entry - @Component - struct FoodList { - build() { - List() { - ListItem() { - FoodListItem() - } - } - } - } - ``` +2. Create a List component named FoodList as the page entry point. Then, add a ListItem component named FoodListItem as its child component. The List component is used to display data of the same type. Its child component is used to display specific items in the list. + + ``` + @Component + struct FoodListItem { + build() {} + } + + @Entry + @Component + struct FoodList { + build() { + List() { + ListItem() { + FoodListItem() + } + } + } + } + ``` -3. Import the **FoodData** class and **initializeOnStartup** method. +3. Import the FoodData class and initializeOnStartup method. + + ``` + import { FoodData } from '../model/FoodData' + import { initializeOnStartup } from '../model/FoodDataModels' + ``` - ``` - import { FoodData } from '../model/FoodData' - import { initializeOnStartup } from '../model/FoodDataModels' - ``` +4. Configure the FoodList and FoodListItem components to pass values. Create a member variable named foodItems of the FoodData[] type in the FoodList component and invoke the initializeOnStartup method to assign a value to the variable. Create a member variable foodItem of the FoodData type in the FoodListItem component. Pass the foodItems[0] of the first element in the parent foodItems array as a parameter to FoodListItem. + + ``` + import { FoodData } from '../model/FoodData' + import { initializeOnStartup } from '../model/FoodDataModels' + + @Component + struct FoodListItem { + private foodItem: FoodData + build() {} + } + + @Entry + @Component + struct FoodList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + List() { + ListItem() { + FoodListItem({ foodItem: this.foodItems[0] }) + } + } + } + } + ``` -4. Configure the **FoodList** and **FoodListItem** components to pass values. Create a member variable named **foodItems** of the **FoodData\[\]** type in the **FoodList** component and invoke the **initializeOnStartup** method to assign a value to the variable. Create a member variable **foodItem** of the **FoodData** type in the **FoodListItem** component. Pass the **foodItems\[0\]** of the first element in the parent **foodItems** array as a parameter to **FoodListItem**. +5. Declare the UI layout of the FoodListItem child component. Create a Flex component, including the food image thumbnail, food name, and calories in the food. + + ``` + import { FoodData } from '../model/FoodData' + import { initializeOnStartup } from '../model/FoodDataModels' + + @Component + struct FoodListItem { + private foodItem: FoodData + build() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + .height(40) + .width(40) + .backgroundColor('#FFf1f3f5') + .margin({ right: 16 }) + Text(this.foodItem.name) + .fontSize(14) + .flexGrow(1) + Text(this.foodItem.calories + ' kcal') + .fontSize(14) + } + .height(64) + .margin({ right: 24, left:32 }) + } + } + + @Entry + @Component + struct FoodList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + List() { + ListItem() { + FoodListItem({ foodItem: this.foodItems[0] }) + } + } + } + } + ``` - ``` - import { FoodData } from '../model/FoodData' - import { initializeOnStartup } from '../model/FoodDataModels' - - @Component - struct FoodListItem { - private foodItem: FoodData - build() {} - } - - @Entry - @Component - struct FoodList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - List() { - ListItem() { - FoodListItem({ foodItem: this.foodItems[0] }) - } - } - } - } - ``` + ![en-us_image_0000001267887833](figures/en-us_image_0000001267887833.png) -5. Declare the UI layout of the **FoodListItem** child component. Create a **Flex** component, including the food image thumbnail, food name, and calories in the food. +6. Create two FoodListItem objects. Create two FoodListItem objects in the List component and pass the first element this.foodItems[0] and the second element foodItem: this.foodItems[1] to the FoodListItem. + + ``` + import { FoodData } from '../model/FoodData' + import { initializeOnStartup } from '../model/FoodDataModels' + + @Component + struct FoodListItem { + private foodItem: FoodData + build() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + .height(40) + .width(40) + .backgroundColor('#FFf1f3f5') + .margin({ right: 16 }) + Text(this.foodItem.name) + .fontSize(14) + .flexGrow(1) + Text(this.foodItem.calories + ' kcal') + .fontSize(14) + } + .height(64) + .margin({ right: 24, left:32 }) + } + } + + @Entry + @Component + struct FoodList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + List() { + ListItem() { + FoodListItem({ foodItem: this.foodItems[0] }) + } + ListItem() { + FoodListItem({ foodItem: this.foodItems[1] }) + } + } + } + } + ``` - ``` - import { FoodData } from '../model/FoodData' - import { initializeOnStartup } from '../model/FoodDataModels' - - @Component - struct FoodListItem { - private foodItem: FoodData - build() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .height(40) - .width(40) - .backgroundColor('#FFf1f3f5') - .margin({ right: 16 }) - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - Text(this.foodItem.calories + ' kcal') - .fontSize(14) - } - .height(64) - .margin({ right: 24, left:32 }) - } - } - - @Entry - @Component - struct FoodList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - List() { - ListItem() { - FoodListItem({ foodItem: this.foodItems[0] }) - } - } - } - } - ``` + ![en-us_image_0000001267767849](figures/en-us_image_0000001267767849.png) - ![](figures/en-us_image_0000001204776353.png) +7. Import ForEach so that you do not need to create FoodListItem objects one by one. + + ``` + ForEach( + arr: any[], // Array to be iterated + itemGenerator: (item: any) => void, // child component generator + keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. + ) + ``` -6. Create two **FoodListItem** objects. Create two **FoodListItem** objects in the **List** component and pass the first element **this.foodItems\[0\]** and the second element **foodItem: this.foodItems\[1\]** to the **FoodListItem**. + The ForEach group has three parameters. The first parameter is the array to be traversed, the second parameter is the lambda function for generating child components, and the third parameter is the key value generator. The third parameter is optional. Yet, for performance reasons, it is strongly recommended that you provide it. keyGenerator enables the development framework to better recognize array changes without having to rebuild all nodes after item changes. - ``` - import { FoodData } from '../model/FoodData' - import { initializeOnStartup } from '../model/FoodDataModels' - - @Component - struct FoodListItem { - private foodItem: FoodData - build() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .height(40) - .width(40) - .backgroundColor('#FFf1f3f5') - .margin({ right: 16 }) - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - Text(this.foodItem.calories + ' kcal') - .fontSize(14) - } - .height(64) - .margin({ right: 24, left:32 }) - } - } - - @Entry - @Component - struct FoodList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - List() { - ListItem() { - FoodListItem({ foodItem: this.foodItems[0] }) - } - ListItem() { - FoodListItem({ foodItem: this.foodItems[1] }) - } - } - } - } - ``` + Traverse the foodItems array to cyclically create the ListItem component. Pass each item in foodItems as a parameter to the FoodListItem component. - ![](figures/en-us_image_0000001204537865.png) + + ``` + ForEach(this.foodItems, item => { + ListItem() { + FoodListItem({ foodItem: item }) + } + }, item => item.id.toString()) + ``` -7. Import **ForEach** so that you do not need to create **FoodListItem** objects one by one. + The code is as follows: - ``` - ForEach( - arr: any[], // Array to be iterated - itemGenerator: (item: any) => void, // child component generator - keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. - ) - ``` - - The **ForEach** group has three parameters. The first parameter is the array to be traversed, the second parameter is the lambda function for generating child components, and the third parameter is the key value generator. The third parameter is optional. Yet, for performance reasons, it is strongly recommended that you provide it. **keyGenerator** enables the development framework to better recognize array changes without having to rebuild all nodes after item changes. - - Traverse the **foodItems** array to cyclically create the **ListItem** component. Pass each item in **foodItems** as a parameter to the **FoodListItem** component. - - ``` - ForEach(this.foodItems, item => { - ListItem() { - FoodListItem({ foodItem: item }) - } - }, item => item.id.toString()) - ``` - - The code is as follows: - - ``` - import { FoodData } from '../model/FoodData' - import { initializeOnStartup } from '../model/FoodDataModels' - - @Component - struct FoodListItem { - private foodItem: FoodData - build() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .height(40) - .width(40) - .backgroundColor('#FFf1f3f5') - .margin({ right: 16 }) - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - Text(this.foodItem.calories + ' kcal') - .fontSize(14) - } - .height(64) - .margin({ right: 24, left:32 }) - } - } - - @Entry - @Component - struct FoodList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - List() { - ForEach(this.foodItems, item => { - ListItem() { - FoodListItem({ foodItem: item }) - } - }, item => item.id.toString()) - } - } - } - ``` - -8. Add a title for the **FoodList**. - - ``` - @Entry - @Component - struct FoodList { - private foodItems: FoodData[] = initializeOnStartup() - build() { - Column() { - Flex({justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}) { - Text('Food List') - .fontSize(20) - .margin({ left:20 }) - } - .height('7%') - .backgroundColor('#FFf1f3f5') - List() { - ForEach(this.foodItems, item => { - ListItem() { - FoodListItem({ foodItem: item }) - } - }, item => item.id.toString()) - } - .height('93%') - } - } - } - ``` - - ![](figures/en-us_image_0000001169678922.png) + + ``` + import { FoodData } from '../model/FoodData' + import { initializeOnStartup } from '../model/FoodDataModels' + + @Component + struct FoodListItem { + private foodItem: FoodData + build() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + .height(40) + .width(40) + .backgroundColor('#FFf1f3f5') + .margin({ right: 16 }) + Text(this.foodItem.name) + .fontSize(14) + .flexGrow(1) + Text(this.foodItem.calories + ' kcal') + .fontSize(14) + } + .height(64) + .margin({ right: 24, left:32 }) + } + } + + @Entry + @Component + struct FoodList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + List() { + ForEach(this.foodItems, item => { + ListItem() { + FoodListItem({ foodItem: item }) + } + }, item => item.id.toString()) + } + } + } + ``` +8. Add a title for the FoodList. + + ``` + @Entry + @Component + struct FoodList { + private foodItems: FoodData[] = initializeOnStartup() + build() { + Column() { + Flex({justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}) { + Text('Food List') + .fontSize(20) + .margin({ left:20 }) + } + .height('7%') + .backgroundColor('#FFf1f3f5') + List() { + ForEach(this.foodItems, item => { + ListItem() { + FoodListItem({ foodItem: item }) + } + }, item => item.id.toString()) + } + .height('93%') + } + } + } + ``` + ![en-us_image_0000001267607877](figures/en-us_image_0000001267607877.png) diff --git a/en/application-dev/ui/ui-ts-building-data-model.md b/en/application-dev/ui/ui-ts-building-data-model.md index 2068f1e12080202c598480f2fedae47462ad4baf..66b713bf5e693cfc6f58b7172ecd370450c8dd99 100644 --- a/en/application-dev/ui/ui-ts-building-data-model.md +++ b/en/application-dev/ui/ui-ts-building-data-model.md @@ -1,99 +1,80 @@ -# Building a Food Data Model +# Building a Food Data Model + On the created page, we use various items to describe food, such as food names, calories, proteins, fats, carbohydrates, and vitamin C. This form of coding is impractical in actual development. Therefore, you need to create food data models to store and manage data in a unified manner. -![](figures/en-us_image_0000001215433095.png) - -1. Create a folder named **model** and create a file named **FoodData.ets** therein. - - ![](figures/en-us_image_0000001195119619.png) - -2. Define a food data storage model, **FoodData**, and an enum variable, **Category**. The **FoodData** class contains the food ID, name, category, image, calories, protein, fat, carbohydrates, and vitamin C attributes. - - The eTS programming language is an extension of the TS language and also supports the TS syntax. - - ``` - enum Category { - Fruit, - Vegetable, - Nut, - Seafood, - Dessert - } - - let NextId = 0; - class FoodData { - id: string; - name: string; - image: Resource; - category: Category; - calories: number; - protein: number; - fat: number; - carbohydrates: number; - vitaminC: number; - - constructor(name: string, image: Resource, category: Category, calories: number, protein: number, fat: number, carbohydrates: number, vitaminC: number) { - this.id = `${ NextId++ }`; - this.name = name; - this.image = image; - this.category = category; - this.calories = calories; - this.protein = protein; - this.fat = fat; - this.carbohydrates = carbohydrates; - this.vitaminC = vitaminC; - } - } - ``` - -3. Store food image resources in the **resources** \> **phone** \> **media** directory. Use food names as the image names. - - ![](figures/en-us_image_0000001195117633.png) - -4. Create food resource data. Create **FoodDataModels.ets** in the **model** folder and declare a food composition array, **FoodComposition** on the page. - - In this example, 12 pieces of food data are used. You can customize more data resources when needed. Use **LazyForEach** to load data if a large amount of food data is involved. The following nutritional data is sourced from the Internet. - - ``` - const FoodComposition: any[] = [ - { 'name': 'Tomato', 'image': $r('app.media.Tomato'), 'category': Category.Vegetable, 'calories': 17, 'protein': 0.9, 'fat': 0.2, 'carbohydrates': 3.9, 'vitaminC': 17.8 }, - { 'name': 'Walnut', 'image': $r('app.media.Walnut'), 'category': Category.Nut, 'calories': 654 , 'protein': 15, 'fat': 65, 'carbohydrates': 14, 'vitaminC': 1.3 }, - { 'name': 'Cucumber', 'image': $r('app.media.Cucumber'), 'category': Category.Vegetable, 'calories': 30, 'protein': 3, 'fat': 0, 'carbohydrates': 1.9, 'vitaminC': 2.1 }, - { 'name': 'Blueberry', 'image': $r('app.media.Blueberry'), 'category': Category.Fruit, 'calories': 57, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 14, 'vitaminC': 9.7 }, - { 'name': 'Crab', 'image': $r('app.media.Crab'), 'category': Category.Seafood, 'calories': 97, 'protein': 19, 'fat': 1.5, 'carbohydrates': 0, 'vitaminC': 7.6 }, - { 'name': 'IceCream', 'image': $r('app.media.IceCream'), 'category': Category.Dessert, 'calories': 207, 'protein': 3.5, 'fat': 11, 'carbohydrates': 24, 'vitaminC': 0.6 }, - { 'name': 'Onion', 'image': $r('app.media.Onion'), 'category': Category.Vegetable, 'calories': 39, 'protein': 1.1, 'fat': 0.1, 'carbohydrates': 9, 'vitaminC': 7.4 }, - { 'name': 'Mushroom', 'image': $r('app.media.Mushroom'), 'category': Category.Vegetable, 'calories': 22, 'protein': 3.1, 'fat': 0.3, 'carbohydrates': 3.3, 'vitaminC': 2.1 }, - { 'name': 'Kiwi', 'image': $r('app.media.Kiwi'), 'category': Category.Fruit, 'calories': 60 , 'protein': 1.1, 'fat': 0.5, 'carbohydrates': 15, 'vitaminC': 20.5 }, - { 'name': 'Pitaya', 'image': $r('app.media.Pitaya'), 'category': Category.Fruit, 'calories': 60, 'protein': 1.2, 'fat': 0, 'carbohydrates': 10, 'vitaminC': 60.9 }, - { 'name': 'Avocado', 'image': $r('app.media.Avocado'), 'category': Category.Fruit, 'calories': 160, 'protein': 2, 'fat': 15, 'carbohydrates': 9, 'vitaminC': 10 }, - { 'name': 'Strawberry', 'image': $r('app.media.Strawberry'), 'category': Category.Fruit, 'calories': 32, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 8, 'vitaminC': 58.8 } - ] - ``` - -5. Create the **initializeOnStartUp** method to initialize the **FoodData** array. Export the **FoodData** class from **FoodData.ets**, and import **FoodData** and **Category** in **FoodDataModels.ets**. - - ``` - // FoodData.ets - export enum Category { + +![en-us_image_0000001267767897](figures/en-us_image_0000001267767897.png) + + +1. Create a folder named model and create a file named FoodData.ets therein. + ![en-us_image_0000001223127760](figures/en-us_image_0000001223127760.png) + +2. Define a food data storage model, FoodData, and an enum variable, Category. The FoodData class contains the food ID, name, category, image, calories, protein, fat, carbohydrates, and vitamin C attributes. + The eTS programming language is an extension of the TS language and also supports the TS syntax. + + + ``` + enum Category { + Fruit, + Vegetable, + Nut, + Seafood, + Dessert + } + + let NextId = 0; + class FoodData { + id: string; + name: string; + image: Resource; + category: Category; + calories: number; + protein: number; + fat: number; + carbohydrates: number; + vitaminC: number; + + constructor(name: string, image: Resource, category: Category, calories: number, protein: number, fat: number, carbohydrates: number, vitaminC: number) { + this.id = `${ NextId++ }`; + this.name = name; + this.image = image; + this.category = category; + this.calories = calories; + this.protein = protein; + this.fat = fat; + this.carbohydrates = carbohydrates; + this.vitaminC = vitaminC; + } + } + ``` + +3. Store food image resources in the resources > base > media directory. Use food names as the image names. + +4. Create food resource data. Create FoodDataModels.ets in the model folder and declare a food composition array, FoodComposition on the page. + In this example, you can customize more data resources when needed. Use LazyForEach to load data if a large amount of food data is involved. + +5. Create the initializeOnStartUp method to initialize the FoodData array. Export the FoodData class from FoodData.ets, and import FoodData and Category in FoodDataModels.ets. + + ``` + // FoodData.ets + export enum Category { + ...... + } + export class FoodData { ...... - } - export class FoodData { - ...... - } - // FoodDataModels.ets - import { Category, FoodData } from './FoodData' - - export function initializeOnStartup(): Array { - let FoodDataArray: Array = [] - FoodComposition.forEach(item => { - FoodDataArray.push(new FoodData(item.name, item.image, item.category, item.calories, item.protein, item.fat, item.carbohydrates, item.vitaminC )); - }) - return FoodDataArray; - } - ``` + } + // FoodDataModels.ets + import { Category, FoodData } from './FoodData' + export function initializeOnStartup(): Array { + let FoodDataArray: Array = [] + FoodComposition.forEach(item => { + FoodDataArray.push(new FoodData(item.name, item.image, item.category, item.calories, item.protein, item.fat, item.carbohydrates, item.vitaminC )); + }) + return FoodDataArray; + } + ``` -The data resources for the diet application are now ready. You can continue to create a food category list by loading the data. +The data resources for the diet application are now ready. You can continue to create a food category list by loading the data. diff --git a/en/application-dev/ui/ui-ts-components-web.md b/en/application-dev/ui/ui-ts-components-web.md index 45220f270d672c3466c67be863c24a2f02dc7c77..c1a6363dfd7588d4ad9854539b1d8d54f47ef8c1 100644 --- a/en/application-dev/ui/ui-ts-components-web.md +++ b/en/application-dev/ui/ui-ts-components-web.md @@ -1,10 +1,10 @@ # Web -The **\** component can be used to display web pages. For details, see [Web API](../reference/arkui-ts/ts-basic-components-web.md). +The \ component can be used to display web pages. For details, see [Web API](../reference/arkui-ts/ts-basic-components-web.md). ## Creating a Component -Create a **\** component in the .ets file under **main/ets/MainAbility/pages**. Then, in the created component, use **src** to specify the web page URI to be referenced, and bind a controller to the component to call the component APIs. +Create a \ component in the .ets file under main/ets/MainAbility/pages. Then, in the created component, use src to specify the web page URI to be referenced, and bind a controller to the component to call the component APIs. ``` // xxx.ets @@ -22,7 +22,7 @@ Create a **\** component in the .ets file under **main/ets/MainAbility/page ## Setting Styles and Attributes -When using the **\** component, you need to specify the styles and attributes. The sample code is as follows. +When using the \ component, you need to specify the styles and attributes. The sample code is as follows. ``` // xxx.ets @@ -50,7 +50,7 @@ struct WebComponent { ``` ## Adding Events and Methods -Add the **onProgressChange** event for the **\** component, which is triggered when the loading progress changes and returns the progress value in its callback. Assign the progress value to the **\** component to control the status of the component. When the progress reaches 100%, the **\** component is hidden, and the web page loading is complete. +Add the onProgressChange event for the \ component, which is triggered when the loading progress changes and returns the progress value in its callback. Assign the progress value to the \ component to control the status of the component. When the progress reaches 100%, the \ component is hidden, and the web page loading is complete. ``` // xxx.ets @@ -89,7 +89,7 @@ struct WebComponent { } } ``` -Add the **runJavaScript** method to the **onPageEnd** event. The **onPageEnd** event is triggered when the web page finishes loading. In this case, the **runJavaScript** method can be used to execute JavaScript scripts in the HTML file. In the sample code below, when the web page finishes loading, the **onPageEnd** event is triggered to call the **test** method in the HTML file and print information on the console. +Add the runJavaScript method to the onPageEnd event. The onPageEnd event is triggered when the web page finishes loading. In this case, the runJavaScript method can be used to execute JavaScript scripts in the HTML file. In the sample code below, when the web page finishes loading, the onPageEnd event is triggered to call the test method in the HTML file and print information on the console. ``` // xxx.ets @@ -134,7 +134,7 @@ struct WebComponent { } ``` -Create an HTML file in **main/resources/rawfile**. +Create an HTML file in main/resources/rawfile. ``` @@ -153,7 +153,7 @@ Create an HTML file in **main/resources/rawfile**. ``` ## Scenario Example -In this example, you'll implement a **\** component where videos can be played dynamically. Embed a video resource into an HTML page, and then use the **\** component controller to invoke the **onActive** and **onInactive** methods to activate and pause page rendering, respectively. When the page is hidden, the **\** component stops rendering and the video playback pauses. When the page is displayed, the **\** component is activated and the video playback resumes. +In this example, you'll implement a \ component where videos can be played dynamically. Embed a video resource into an HTML page, and then use the \ component controller to invoke the onActive and onInactive methods to activate and pause page rendering, respectively. When the page is hidden, the \ component stops rendering and the video playback pauses. When the page is displayed, the \ component is activated and the video playback resumes. ``` // xxx.ets diff --git a/en/application-dev/ui/ui-ts-components.md b/en/application-dev/ui/ui-ts-components.md index a72ec12ada141779b6a31af7d978836f0a6ee2e4..c6676800713d25a34656222a9704746c15a13737 100644 --- a/en/application-dev/ui/ui-ts-components.md +++ b/en/application-dev/ui/ui-ts-components.md @@ -1,19 +1,23 @@ -# Getting to Know Components +# Getting to Know Components -Before customizing a component, get to know what the [component and decorator](#section1094392618525) are and initialize the component. Then, [modify the component attributes and constructor parameters](#section19391124065216) to customize a component. -## Components and Decorators +Before customizing a component, get to know what the [component and decorator](#components-and-decorators) are and initialize the component. Then, [modify the component attributes and constructor parameters](#modifying-component-attributes-and-constructor-parameters) to customize a component. -In a declarative UI, all pages are composed of components. The data structure of the component is **struct**, and the decorator [@Component](ts-component-based-component.md) is the component-based flag. The struct decorated by **@Component** indicates that the struct has the component capability. + +## Components and Decorators + +In a declarative UI, all pages are composed of components. The data structure of the component is struct, and the decorator [@Component](ts-component-based-component.md) is the component-based flag. The struct decorated by @Component indicates that the struct has the component capability. The method for declaring a custom component is as follows: + ``` @Component struct MyComponent {} ``` -In an IDE project template, **MyComponent** is a custom component that can display text in the center. You can describe your UI structures in the **build** method of the component, by complying with the API constraints of the **Builder**. +In an IDE project template, MyComponent is a custom component that can display text in the center. You can describe your UI structures in the build method of the component, by complying with the API constraints of the Builder. + ``` interface Builder { @@ -21,59 +25,58 @@ interface Builder { } ``` -The component decorated by [@Entry](ts-component-based-entry.md) indicates that the component is the main entry of the page and can also be considered as the root node of the page. Note that a page must have one and only one **@Entry**. Only the **@Entry** decorated component and its child components are displayed on the page. +The component decorated by [@Entry](ts-component-based-entry.md) indicates that the component is the main entry of the page and can also be considered as the root node of the page. **NOTE** that a page must have one and only one @Entry. Only the @Entry decorated component and its child components are displayed on the page. -**@Component** and **@Entry** are basic and important decorators. To put it simply, a decorator assigns a capability to an object to be decorated. For example, **@Entry** assigns the capability of the page entry, and **@Component** assigns the component capability. +@Component and @Entry are basic and important decorators. To put it simply, a decorator assigns a capability to an object to be decorated. For example, @Entry assigns the capability of the page entry, and @Component assigns the component capability. With a basic knowledge of the component and decorator, you are ready to develop a diet application. -## Modifying Component Attributes and Constructor Parameters -When you create a system component, the default style is used. You can change the display of the component by changing its attributes and styles. - -1. Modify the **fontSize** attribute of the **** component to change the font size of the component. In this example, the font size is set to 26 and font weight 500. Two configuration methods are available for setting the font weight: - - 1. The value of the number type ranges from 100 to 900. The default value is **400**. A larger value indicates a thicker font. - 2. **fontWeight** is a built-in enumeration type. Its value can be **Lighter**, **Normal**, **Bold**, or **Bolder**. - - The attribute method must follow the component and be connected by the operator ".". You can also configure multiple attributes of the component in method chaining mode. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(26) - .fontWeight(500) - } - .width('100%') - .height('100%') - } - } - ``` - - ![](figures/en-us_image_0000001168728272.png) - -2. Change the display content of the **** component from **Hello World** to **Tomato** by modifying the constructor parameters of the **** component. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - .width('100%') - .height('100%') - } - } - ``` - - ![](figures/en-us_image_0000001168888224.png) +## Modifying Component Attributes and Constructor Parameters +When you create a system component, the default style is used. You can change the display of the component by changing its attributes and styles. +1. Modify the fontSize attribute of the component to change the font size of the component. In this example, the font size is set to 26 and font weight 500. Two configuration methods are available for setting the font weight: + 1. The value of the number type ranges from 100 to 900. The default value is 400. A larger value indicates a thicker font. + 2. fontWeight is a built-in enumeration type. Its value can be Lighter, Normal, Bold, or Bolder. + + The attribute method must follow the component and be connected by the operator ".". You can also configure multiple attributes of the component in method chaining mode. + + + ``` + @Entry + @Component + struct MyComponent { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(26) + .fontWeight(500) + } + .width('100%') + .height('100%') + } + } + ``` + + ![en-us_image_0000001267767845](figures/en-us_image_0000001267767845.png) + +2. Change the display content of the component from Hello World to Tomato by modifying the constructor parameters of the component. + + ``` + @Entry + @Component + struct MyComponent { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + .width('100%') + .height('100%') + } + } + ``` + + ![en-us_image_0000001267887829](figures/en-us_image_0000001267887829.png) diff --git a/en/application-dev/ui/ui-ts-creating-project.md b/en/application-dev/ui/ui-ts-creating-project.md index 06eaa9f60525e7638535adc21a0239733e1eb557..97453c3fd1cbd7decac01ea704bb360c91d225bf 100644 --- a/en/application-dev/ui/ui-ts-creating-project.md +++ b/en/application-dev/ui/ui-ts-creating-project.md @@ -1,67 +1,69 @@ -# Creating a Declarative UI Project +# Creating a Declarative UI Project -Before creating a project, you need to install DevEco Studio. For details, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387). -1. Open DevEco Studio and click **Create Project**. If there is already a project, choose **File** \> **New** \> **New project**. +Before creating a project, you need to install DevEco Studio. - ![](figures/en-us_image_0000001168956332.png) -2. On the page for selecting an ability template, select **\[Standard\]Empty Ability**. +1. Open DevEco Studio and click Create Project. If there is already a project, choose File > New > New project. + ![en-us_image_0000001267607861](figures/en-us_image_0000001267607861.png) - ![](figures/en-us_image_0000001168059158.png) +2. ​ -3. Install the OpenHarmony SDK. - ![](figures/en-us_image_0000001213462329.png) + On the page for selecting an ability template, select [Standard]Empty Ability. -4. On the project configuration page, set Project Name to **HealthyDiet**, **Project Type** to **Application**, **Device Type** to **Phone**, **Language** to **eTS**, and **Compatible API Version** to **SDK: API Version 7**. By default, DevEco Studio saves the project to drive C. You can change the save path by setting **Save Location**. When you are done, click **Finish**. + ![en-us_image_0000001223127704](figures/en-us_image_0000001223127704.png) - ![](figures/en-us_image_0000001167746622.png) +3. + Install the OpenHarmony SDK. -5. After the project is created, open the **app.ets** file. + ![en-us_image_0000001223127700](figures/en-us_image_0000001223127700.png) - The **app.ets** file provides the **onCreate** and **onDestroy** methods for the application lifecycle. **onCreate** is called when an application is created, and **onDestroy** is called when an application is destroyed. Global variables can be declared in the **app.ets** file, wherein the declared data and methods are shared by the entire application. +4. On the project configuration page, set Project Name to HealthyDiet, Project Type to Application, Device Type to Phone, Language to eTS, and Compatible API Version to SDK: API Version 7. By default, DevEco Studio saves the project to drive C. You can change the save path by setting Save Location. When you are done, click Finish. - ``` - export default { - onCreate() { - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, - } - ``` -6. In the project navigation tree, open **index.ets**. This page displays the current UI description. The declarative UI framework automatically generates a component-based **struct**, which complies with the **Builder** API declaration. The current layout and components are declared in the **build** method. + ![en-us_image_0000001267647849](figures/en-us_image_0000001267647849.png) - ``` - @Entry - @Component - struct MyComponent { - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - .height('100%') - } - } - ``` +5. After the project is created, open the app.ets file. + The app.ets file provides the onCreate and onDestroy methods for the application lifecycle. onCreate is called when an application is created, and onDestroy is called when an application is destroyed. Global variables can be declared in the app.ets file, wherein the declared data and methods are shared by the entire application. -7. Click **Previewer** on the right to open the **Previewer** window. In the **Previewer** window of the phone type, **Hello World** is displayed in the middle and in bold. + ``` + export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } + ``` - If the **Previewer** button is unavailable, choose **Settings** \> **SDK Manager** \>OpenHarmony SDK \> **Tools** to check whether the **Previewer** is installed. +6. In the project navigation tree, open index.ets. This page displays the current UI description. The declarative UI framework automatically generates a component-based struct, which complies with the Builder API declaration. The current layout and components are declared in the build method. - ![](figures/en-us_image_0000001214595111.png) + ``` + @Entry + @Component + struct MyComponent { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } + } + ``` -8. Install the application on the phone and run the application. Connect the phone to the computer. After the IDE identifies the phone, click **Run'entry'**. +7. Click Previewer on the right to open the Previewer window. Hello World is displayed in the middle and in bold. + If the Previewer button is unavailable, choose Settings > SDK Manager >OpenHarmony SDK > Tools to check whether the Previewer is installed. - ![](figures/en-us_image_0000001148858818.png) + ![en-us_image_0000001222807756](figures/en-us_image_0000001222807756.png) - Before the installation, you must configure an application signature. For details, see [Configuring the OpenHarmony App Signature](../quick-start/configuring-openharmony-app-signature.md). After the installation is complete, click the **Run** icon on the screen to open the application. **Hello World** is displayed in the center of the screen. +8. Install the application and run the application. Connect the device to the computer. After the IDE identifies the device, click Run'entry'. + ![en-us_image_0000001267607865](figures/en-us_image_0000001267607865.png) - ![](figures/en-us_image_0000001158896538.png) + Before the installation, you must configure an application signature. For details, see Configuring the OpenHarmony App Signature. After the installation is complete, click the Run icon on the screen to open the application. Hello World is displayed in the center of the screen. + ![en-us_image_0000001267647841](figures/en-us_image_0000001267647841.png) diff --git a/en/application-dev/ui/ui-ts-creating-simple-page.md b/en/application-dev/ui/ui-ts-creating-simple-page.md index ca6be86def635a49f870cbf0a3d653f093e60774..41163ac0a11a249d4adc17762bedcc0a70462e86 100644 --- a/en/application-dev/ui/ui-ts-creating-simple-page.md +++ b/en/application-dev/ui/ui-ts-creating-simple-page.md @@ -1,559 +1,542 @@ -# Creating a Simple Page - -In this section, we will develop an infographic food details page, by building custom components through the container components **** and **** as well as basic components **** and ****. - -## Building the Stack Layout - -1. Create a food name. - - Delete the code of the **build** method in the project template, create a **** component, and place the **** component in the braces of the **** component so that the **** component becomes a child component of the **** component. A **** component consists of one or more child components. The latter child component overwrites the former one. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack() { - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - } - } - ``` - - ![](figures/en-us_image_0000001214128687.png) - -2. Display food pictures. - - Create an **** component and specify a URL for it. The **** and **** components are mandatory. To display the **** component above the **** component, you need to declare the **** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the **$rawfile\('_filename_ loaded\)** format, where **filename** indicates the relative path of the file in the **rawfile** folder. Currently, **$rawfile** only allows the **** component to reference image resources. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack() { - Image($rawfile('Tomato.png')) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - } - } - ``` - - ![](figures/en-us_image_0000001168410342.png) - -3. Access images through resources. - - In addition to specifying the image path, you can also use the media resource symbol **$r** to reference resources based on the resource qualifier rules in the **resources** folder. Right-click the **resources** folder, choose **New** \> **Resource Directory**, set **Resource Type** to **Media** \(image resource\), and set the resource qualifier to **Device-Phone** \(currently, phones are used\). - - ![](figures/en-us_image_0000001168570318.png) - - Click **OK**. The **phone.media** folder is generated in the **resources** folder. Place **Tomato.png** in the folder. - - ![](figures/en-us_image_0000001214330169.png) - - You can then can reference the application resource in the **$r\('app.type.name'\)** format, that is, **$r\('app.media.Tomato'\)**. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack() { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - } - } - ``` - -4. Set the width and height of the image, and set the **objectFit** attribute of the image to **ImageFit.Contain**, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary. - - If the image fills the entire screen, the possible causes are as follows: - - 1. The width and height of the image are not set. - 2. The default attribute of **objectFit** of the image is **ImageFit.Cover**, that is, the image is zoomed in or zoomed out to fill the entire display boundary with the aspect ratio locked. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack() { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) +# Creating a Simple Page + + +In this section, we will develop an infographic food details page, by building custom components through the container components <Stack> and <Flex> as well as basic components <Image> and <Text>. + + +## Building the Stack Layout + +1. Create a food name. + Delete the code of the build method in the project template, create a <Stack> component, and place the <Text> component in the braces of the <Stack> component so that the <Text> component becomes a child component of the <Stack> component. A <Stack> component consists of one or more child components. The latter child component overwrites the former one. + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack() { + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + } + } + ``` + + ![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png) + +2. Display food pictures. + Create an <Image> component and specify a URL for it. The <Image> and <Text> components are mandatory. To display the <Text> component above the <Image> component, you need to declare the <Image> component first. Image resources are stored in the rawfile folder in resources. When referencing the resources in the rawfile folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the rawfile folder. Currently, `$rawfile` only allows the <Image> component to reference image resources. + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack() { + Image($rawfile('Tomato.png')) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + } + } + ``` + + ![en-us_image_0000001267887861](figures/en-us_image_0000001267887861.png) + +3. Access images through resources. + In addition to specifying the image path, you can also use the media resource symbol $r to reference resources based on the resource qualifier rules in the resources folder. Right-click the resources folder, choose New > Resource Directory, set Resource Type to Media (image resource).Place Tomato.png in the media folder. + + You can then can reference the application resource in the ` "$r('app.type.name')"` format, that is, `$r('app.media.Tomato')`. + + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack() { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + } + } + ``` + +4. Set the width and height of the image, and set the objectFit attribute of the image to ImageFit.Contain, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary.If the image fills the entire screen, the possible causes are as follows: + 1. The width and height of the image are not set. + 2. The default attribute of objectFit of the image is ImageFit.Cover, that is, the image is zoomed in or zoomed out to fill the entire display boundary with the aspect ratio locked. + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack() { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + } + } + ``` + +![en-us_image_0000001223127732](figures/en-us_image_0000001223127732.png) +​ +5. Set the food image and name layout. Set the alignment mode of the stack to bottom alignment. By default, the stack is center aligned. Set alignContent to Alignment.BottomStart. Similar to FontWeight, Alignment is a built-in enumeration type provided by the framework. + +``` + @Entry + @Component + struct MyComponent { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - } - } - ``` - - ![](figures/en-us_image_0000001214210217.png) - -5. Set the food image and name layout. Set the alignment mode of the stack to bottom alignment. By default, the stack is center aligned. Set **alignContent** to **Alignment.BottomStart**. Similar to **FontWeight**, **Alignment** is a built-in enumeration type provided by the framework. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - } - } - ``` - - ![](figures/en-us_image_0000001168728872.png) - -6. You can change the background color of the food image by setting the background color of the stack. You can set the background color in either of the following ways: - - 1. By using the built-in enumeration value of **Color** provided by the framework. For example, **backgroundColor\(Color.Red\)** indicates that the background color is set to red. - 2. By using the parameter of the string type. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting **backgroundColor\(??\#0000FF??\)** and set the background color to white by setting **backgroundColor\(??rgb\(255, 255, 255\)??\)**. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - } - .backgroundColor('#FFedf2f5') - } - } - ``` - - ![](figures/en-us_image_0000001168888822.png) - -7. Adjust the left and bottom margin of the **** component. Margin is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows: - - 1. When the parameter is set to **Length**, the outer margins of the four edges are specified. For example, **margin\(20\)** indicates that the outer margins of the top, right, bottom, and left edges are all 20. - 2. **\{top?: Length, right?: Length, bottom?: Length, left?:Length\}** specifies the margins of the four edges. For example, **margin\(\{ left: 26, bottom: 17.4 \}\)** indicates that the left margin is 26 and the bottom margin is 17.4. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - .margin({left: 26, bottom: 17.4}) - } - .backgroundColor('#FFedf2f5') - } - } - ``` - - ![](figures/en-us_image_0000001213968747.png) - -8. Adjust the structure between components and semanticize component names. Create the **FoodDetail** page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems\(HorizontalAlign.Center\)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component. - - A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. - - ``` - @Component - struct FoodImageDisplay { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - .margin({ left: 26, bottom: 17.4 }) - } - .height(357) - .backgroundColor('#FFedf2f5') - } - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - -## Building the Flex Layout - -You can use the **Flex** layout to build a food composition table. In this way you do not need to worry about the width and height calculation. The size of different cells can be flexibly set based on the proportion. - -1. Create a **ContentTable** component as a child component of the **FoodDetail** component. - - ``` - @Component - struct FoodImageDisplay { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - .margin({ left: 26, bottom: 17.4 }) - } - .backgroundColor('#FFedf2f5') - } - } - - @Component - struct ContentTable { - build() {} - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - -2. Create a **Flex** component to display two food composition categories in the tomato: Calories and Nutrition. - - **Calories** contains information about calories. **Nutrition** contains information about protein, fat, carbohydrates, and vitamin C. - - Create the Calories class. Create a **Flex** component and set its height to **280**, and the top, right, and left margins to **30**. The **Flex** component contains three **Text** child components, which represent the category name \(**Calories**\), content name \(**Calories**\), and contain value \(**17 kcal**\), respectively. By default, child components in the **Flex** component are arranged horizontally. - - In the following example, code of **FoodImageDisplay** is omitted, and only code of **ContentTable** is provided. - - ``` - @Component - struct ContentTable { - build() { - Flex() { - Text('Calories') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - Text('Calories') - .fontSize(17.4) - Text('17kcal') - .fontSize(17.4) - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - ![](figures/en-us_image_0000001169759552.png) - -3. Adjust the layout and set the proportion \(**layoutWeight**\) of each part. Set the proportion of the category name to 1, and the total proportion of content name and content value to **2**. The content name and content value are in a same **Flex**, and the content name occupies all remaining space **flexGrow\(1\)**. - - ``` - @Component - struct FoodImageDisplay { - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image($m('Tomato.png')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) - .margin({ left: 26, bottom: 17.4 }) - } + .fontSize(26) + .fontWeight(500) + } + } + } +``` + + ![en-us_image_0000001267647873](figures/en-us_image_0000001267647873.png) + +6. You can change the background color of the food image by setting the background color of the stack. You can set the background color in either of the following ways: + 1. By using the built-in enumeration value of Color provided by the framework. For example, backgroundColor(Color.Red) indicates that the background color is set to red. + 2. By using the parameter of the string type. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting backgroundColor(??\#0000FF??) and set the background color to white by setting backgroundColor(??rgb(255, 255, 255)??). + + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } + .backgroundColor('#FFedf2f5') + } + } + ``` + + ![en-us_image_0000001222967772](figures/en-us_image_0000001222967772.png) + +7. Adjust the left and bottom margin of the <Text> component. Margin is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows: + 1. When the parameter is set to Length, the outer margins of the four edges are specified. For example, margin(20) indicates that the outer margins of the top, right, bottom, and left edges are all 20. + 2. {top?: Length, right?: Length, bottom?: Length, left?:Length} specifies the margins of the four edges. For example, margin({ left: 26, bottom: 17.4 }) indicates that the left margin is 26 and the bottom margin is 17.4. + + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + .margin({left: 26, bottom: 17.4}) + } .backgroundColor('#FFedf2f5') - } - } - - @Component - struct ContentTable { - build() { - Flex() { - Text('Calories') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('Calories') - .fontSize(17.4) - .flexGrow(1) - Text('17kcal') - .fontSize(17.4) - } - .layoutWeight(2) - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - ![](figures/en-us_image_0000001215079443.png) - -4. Create the **Nutrient** class in a similar process. **Nutrition** consists of four parts: **Protein**, **Fat**, **Carbohydrates**, and **VitaminC**. The names of the last three parts are omitted in the table and represented by spaces. - - Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**. - - ``` - @Component - struct ContentTable { - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - Flex() { - Text('Calories') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('Calories') - .fontSize(17.4) - .flexGrow(1) - Text('17kcal') - .fontSize(17.4) - } - .layoutWeight(2) - } - Flex() { - Text('Nutrition') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('Protein') - .fontSize(17.4) - .flexGrow(1) - Text('0.9g') - .fontSize(17.4) - } - .layoutWeight(2) - } - Flex() { - Text(' ') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('Fat') - .fontSize(17.4) - .flexGrow(1) - Text('0.2g') - .fontSize(17.4) - } - .layoutWeight(2) - } - Flex() { - Text(' ') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('Carbohydrates') - .fontSize(17.4) - .flexGrow(1) - Text('3.9g') - .fontSize(17.4) - } - .layoutWeight(2) - } - Flex() { - Text(' ') - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text('vitaminC') - .fontSize(17.4) - .flexGrow(1) - Text('17.8mg') - .fontSize(17.4) - } - .layoutWeight(2) - } - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - -5. Use the custom constructor **@Builder** to simplify the code. It can be found that the food groups in each food composition table are actually of the same UI structure. - - ![](figures/en-us_image_0000001169599582.png) - - Currently, all food groups are declared, resulting in code duplication and redundancy. You can use **@Builder** to build a custom method and abstract the same UI structure declaration. The **@Builder** decorated method and the **build** method for the **@Component** decorated component are used to declare some UI rendering structures and comply with the same eTS syntax. You can define one or more methods decorated by **@Builder**, but a component decorated by **@Component** can have only one **build** method. - - Declare the **IngredientItem** method decorated by **@Builder** in **ContentTable** to declare the UI descriptions for the category name, content name, and content value. - - ``` - @Component - struct ContentTable { - @Builder IngredientItem(title:string, colorValue: string, name: string, value: string) { - Flex() { - Text(title) - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex({ alignItems: ItemAlign.Center }) { - Circle({width: 6, height: 6}) - .margin({right: 12}) - .fill(colorValue) - Text(name) - .fontSize(17.4) - .flexGrow(1) - Text(value) - .fontSize(17.4) - } - .layoutWeight(2) - } - } - } - ``` - - When the **IngredientItem** API is called in the **build** method of **ContentTable**, **this** needs to be used to invoke the method in the scope of the component to distinguish the global method call. - - ``` - @Component - struct ContentTable { - ...... - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - this.IngredientItem('Calories', 'Calories', '17kcal') - this.IngredientItem('Nutrition', 'Protein', '0.9g') - this.IngredientItem('', 'Fat', '0.2g') - this.IngredientItem('', 'Carbohydrates', '3.9g') - this.IngredientItem('', 'VitaminC', '17.8mg') - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - ``` - - The overall code of the **ContentTable** component is as follows: - - ``` - @Component - struct ContentTable { - @Builder IngredientItem(title:string, name: string, value: string) { - Flex() { - Text(title) - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text(name) - .fontSize(17.4) - .flexGrow(1) - Text(value) - .fontSize(17.4) - } - .layoutWeight(2) - } - } - - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - this.IngredientItem('Calories', 'Calories', '17kcal') - this.IngredientItem('Nutrition', 'Protein', '0.9g') - this.IngredientItem('', 'Fat', '0.2g') - this.IngredientItem('', 'Carbohydrates', '3.9g') - this.IngredientItem('', 'VitaminC', '17.8mg') - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - - @Entry - @Component - struct FoodDetail { - build() { - Column() { - FoodImageDisplay() - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - ![](figures/en-us_image_0000001215199399.png) - + } + } + ``` + + ![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png) + +8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in FoodDetail, and set the alignment to alignItems(HorizontalAlign.Center). Change the name of the MyComponent component to FoodImageDisplay, which is a child component of the FoodDetail component. + A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. + + + ``` + @Component + struct FoodImageDisplay { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 17.4 }) + } + .height(357) + .backgroundColor('#FFedf2f5') + } + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + + +## Building the Flex Layout + +You can use the Flex layout to build a food composition table. In this way you do not need to worry about the width and height calculation. The size of different cells can be flexibly set based on the proportion. + +1. Create a ContentTable component as a child component of the FoodDetail component. + + ``` + @Component + struct FoodImageDisplay { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 17.4 }) + } + .backgroundColor('#FFedf2f5') + } + } + + @Component + struct ContentTable { + build() {} + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + +2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition. + Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C. + + Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally. + + In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided. + + + ``` + @Component + struct ContentTable { + build() { + Flex() { + Text('Calories') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + Text('Calories') + .fontSize(17.4) + Text('17kcal') + .fontSize(17.4) + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + + ![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png) + +3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to 1, and the total proportion of content name and content value to 2. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). + + ``` + @Component + struct FoodImageDisplay { + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image($m('Tomato.png')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 17.4 }) + } + .backgroundColor('#FFedf2f5') + } + } + + @Component + struct ContentTable { + build() { + Flex() { + Text('Calories') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('Calories') + .fontSize(17.4) + .flexGrow(1) + Text('17kcal') + .fontSize(17.4) + } + .layoutWeight(2) + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + + ![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png) + +4. Create the Nutrient class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces. + Set FlexDirection.Column, FlexAlign.SpaceBetween, and ItemAlign.Start. + + + ``` + @Component + struct ContentTable { + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + Flex() { + Text('Calories') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('Calories') + .fontSize(17.4) + .flexGrow(1) + Text('17kcal') + .fontSize(17.4) + } + .layoutWeight(2) + } + Flex() { + Text('Nutrition') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('Protein') + .fontSize(17.4) + .flexGrow(1) + Text('0.9g') + .fontSize(17.4) + } + .layoutWeight(2) + } + Flex() { + Text(' ') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('Fat') + .fontSize(17.4) + .flexGrow(1) + Text('0.2g') + .fontSize(17.4) + } + .layoutWeight(2) + } + Flex() { + Text(' ') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('Carbohydrates') + .fontSize(17.4) + .flexGrow(1) + Text('3.9g') + .fontSize(17.4) + } + .layoutWeight(2) + } + Flex() { + Text(' ') + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text('vitaminC') + .fontSize(17.4) + .flexGrow(1) + Text('17.8mg') + .fontSize(17.4) + } + .layoutWeight(2) + } + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + +5. Use the custom constructor @Builder to simplify the code. It can be found that the food groups in each food composition table are actually of the same UI structure. + + ![en-us_image_0000001223287704](figures/en-us_image_0000001223287704.png) + + Currently, all food groups are declared, resulting in code duplication and redundancy. You can use @Builder to build a custom method and abstract the same UI structure declaration. The @Builder decorated method and the build method for the @Component decorated component are used to declare some UI rendering structures and comply with the same eTS syntax. You can define one or more methods decorated by @Builder, but a component decorated by @Component can have only one build method. + + Declare the IngredientItem method decorated by @Builder in ContentTable to declare the UI descriptions for the category name, content name, and content value. + + + ``` + @Component + struct ContentTable { + @Builder IngredientItem(title:string, name: string, value: string) { + Flex() { + Text(title) + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex({ alignItems: ItemAlign.Center }) { + Circle({width: 6, height: 6}) + .margin({right: 12}) + .fill(colorValue) + Text(name) + .fontSize(17.4) + .flexGrow(1) + Text(value) + .fontSize(17.4) + } + .layoutWeight(2) + } + } + } + ``` + + When the IngredientItem API is called in the build method of ContentTable, this needs to be used to invoke the method in the scope of the component to distinguish the global method call. + + + ``` + @Component + struct ContentTable { + ...... + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + this.IngredientItem('Calories', 'Calories', '17kcal') + this.IngredientItem('Nutrition', 'Protein', '0.9g') + this.IngredientItem('', 'Fat', '0.2g') + this.IngredientItem('', 'Carbohydrates', '3.9g') + this.IngredientItem('', 'VitaminC', '17.8mg') + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + ``` + + The overall code of the ContentTable component is as follows: + + + ``` + @Component + struct ContentTable { + @Builder IngredientItem(title:string, name: string, value: string) { + Flex() { + Text(title) + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text(name) + .fontSize(17.4) + .flexGrow(1) + Text(value) + .fontSize(17.4) + } + .layoutWeight(2) + } + } + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + this.IngredientItem('Calories', 'Calories', '17kcal') + this.IngredientItem('Nutrition', 'Protein', '0.9g') + this.IngredientItem('', 'Fat', '0.2g') + this.IngredientItem('', 'Carbohydrates', '3.9g') + this.IngredientItem('', 'VitaminC', '17.8mg') + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + + @Entry + @Component + struct FoodDetail { + build() { + Column() { + FoodImageDisplay() + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + + ![en-us_image_0000001222807792](figures/en-us_image_0000001222807792.png) You've learned how to build a simple food details page. Read on to learn how to define the page layout and connection. - -## Samples - -The following sample is provided to help you better understand how to use build a simple page: - -- [eTSBuildCommonView](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSBuildCommonView) - - This sample shows how to build a common view to display the picture of tomatoes and nutrition information, with the stack layout and flex layout. - - diff --git a/en/application-dev/ui/ui-ts-experiencing-declarative-ui.md b/en/application-dev/ui/ui-ts-experiencing-declarative-ui.md deleted file mode 100644 index 9b9c92657e1cc0373916facd7fbfa8e29eb7b665..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-ts-experiencing-declarative-ui.md +++ /dev/null @@ -1,9 +0,0 @@ -# Experiencing the Declarative UI - -- **[Creating a Declarative UI Project](ui-ts-creating-project.md)** - -- **[Getting to Know Components](ui-ts-components.md)** - -- **[Creating a Simple Page](ui-ts-creating-simple-page.md)** - - diff --git a/en/application-dev/ui/ui-ts-overview.md b/en/application-dev/ui/ui-ts-overview.md index cc1ab7d987b871b9b46f53fa4f7244786491682e..bb34ef82c1acff6cbbb552461d07f6021dcc3e61 100644 --- a/en/application-dev/ui/ui-ts-overview.md +++ b/en/application-dev/ui/ui-ts-overview.md @@ -1,53 +1,47 @@ -# Overview +# Overview -The TypeScript-based declarative development paradigm of ArkUI is a simplified, high-performance UI development framework for cross-device applications on OpenHarmony. -## Basic Capabilities +The TypeScript-based declarative development paradigm of ArkUI is a simplified, high-performance UI development framework for cross-device applications. -In ArkUI that uses the TypeScript-based declarative development paradigm, the programming mode is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development. The UI capabilities are provided from three dimensions: component, animation, and state management. System capability APIs are also provided to allow for effortless invocation of system capabilities. -- **Out-of-the-box components** +## Basic Capabilities - A wide range of preset system components are provided. You can set the rendering effect of these components in method chaining mode. You can combine system components to form custom components. In this way, page components are divided into independent UI units to implement independent creation, development, and reuse of different units on pages, making pages more engineering-oriented. +In ArkUI that uses the TypeScript-based declarative development paradigm, the programming mode is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development. The UI capabilities are provided from three dimensions: component, animation, and state management. System capability APIs are also provided to allow for effortless invocation of system capabilities. -- **A diverse array of animation APIs** +- Out-of-the-box components + A wide range of preset system components are provided. You can set the rendering effect of these components in method chaining mode. You can combine system components to form custom components. In this way, page components are divided into independent UI units to implement independent creation, development, and reuse of different units on pages, making pages more engineering-oriented. - By drawing from the standard SVG drawing capability and various open animation APIs, you can customize animation tracks by encapsulating physical models or calling the provided APIs. +- A diverse array of animation APIs + By drawing from the standard SVG drawing capability and various open animation APIs, you can customize animation tracks by encapsulating physical models or calling the provided APIs. -- **State and data management** - State data management provides clear page update and rendering processes and pipes through decorators with different functions. State management covers UI component states and application states. With these features, you are able to build an application-wide data update and UI rendering process. +- State and data management + State data management provides clear page update and rendering processes and pipes through decorators with different functions. State management covers UI component states and application states. With these features, you are able to build an application-wide data update and UI rendering process. -- **System capability APIs** +- System capability APIs + Development has never been so easy, with a diverse array of encapsulated system capability APIs, from UI design to system capability invoking. - Development has never been so easy, with a diverse array of encapsulated system capability APIs, from UI design to system capability invoking. +## Overall Architecture -## Overall Architecture -![](figures/en-us_image_0000001169532276.png) -- **Declarative UI frontend** +![en-us_image_0000001223287712](figures/en-us_image_0000001223287712.png) - Provides basic language specifications of the UI development paradigm, built-in UI components, layouts, and animations, and multiple state management mechanisms, with a wide array of APIs for you to call as required. +- Declarative UI frontend + Provides basic language specifications of the UI development paradigm, built-in UI components, layouts, and animations, and multiple state management mechanisms, with a wide array of APIs for you to call as required. -- **Language runtime** +- Language runtime + Provides the parsing capability for the UI paradigm syntax and allows for cross-language API calls for a high-performance running environment of the TS language. - Provides the parsing capability for the UI paradigm syntax and allows for cross-language API calls for a high-performance running environment of the TS language. - -- **Declarative UI backend engine** - - Provides UI rendering pipelines that are compatible with different development paradigms, multiple basic components, layout calculation, dynamic effects, and interaction events, with state management and drawing capabilities. - -- **Render engine** - - Provides efficient drawing capabilities, which enable rendering instructions collected by the rendering pipeline to be drawn to the screen. - -- **Porting layer** - - Provides abstract APIs to connect to different systems, such as system rendering pipelines and lifecycle scheduling. +- Declarative UI backend engine + Provides UI rendering pipelines that are compatible with different development paradigms, multiple basic components, layout calculation, dynamic effects, and interaction events, with state management and drawing capabilities. +- Render engine + Provides efficient drawing capabilities, which enable rendering instructions collected by the rendering pipeline to be drawn to the screen. +- Porting layer + Provides abstract APIs to connect to different systems, such as system rendering pipelines and lifecycle scheduling. diff --git a/en/application-dev/ui/ui-ts-page-layout-connections.md b/en/application-dev/ui/ui-ts-page-layout-connections.md deleted file mode 100644 index b1ecb7fa250587d29c727f0d53d437efdc69f8b6..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-ts-page-layout-connections.md +++ /dev/null @@ -1,11 +0,0 @@ -# Defining Page Layout and Connection - -- **[Building a Food Data Model](ui-ts-building-data-model.md)** - -- **[Building a Food Category List Layout](ui-ts-building-category-list-layout.md)** - -- **[Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md)** - -- **[Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md)** - - diff --git a/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md b/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md index e1ef96fc52a31ee3659ae19d48cce27d80641153..f65db6474acbd9d2e48ddc2bde718fe26adbaeb4 100644 --- a/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md +++ b/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md @@ -1,279 +1,274 @@ -# Implementing Page Redirection and Data Transmission +# Implementing Page Redirection and Data Transmission + This section describes how to implement page redirection and data transmission between pages: -1. Page redirection: Click a food item on the food list page to go to the food details page. Click the back button on the food details page to go back to the food list page. -2. Data transmission between pages: After you click a food item, **FoodDetail** receives data from the previous page and renders the corresponding food details page. -## Page Redirection +1. Page redirection: Click a food item on the food list page to go to the food details page. Click the back button on the food details page to go back to the food list page. -The declarative UI paradigm provides two mechanisms for page redirection: +2. Data transmission between pages: After you click a food item, FoodDetail receives data from the previous page and renders the corresponding food details page. -1. **Navigator**: encapsulates the page routing capability. After the page target is specified, all child components in the page target have the routing capability. -2. Router APIs: called to implement various operations of page routing. You'll need to import **router** before calling the router APIs. -The procedure below uses these two mechanisms for redirection between the page list page and food details page. +## Page Redirection -1. Click **FoodListItem**. The **FoodDetail** page is displayed. Create a **Navigator** component in **FoodListItem** to enable its child components to have the routing function. The target page is **'pages/FoodDetail'**. - - ``` - @Component - struct FoodListItem { - private foodItem: FoodData - build() { - Navigator({ target: 'pages/FoodDetail' }) { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .height(40) - .width(40) - .backgroundColor('#FFf1f3f5') - .margin({ right: 16 }) - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - Text(this.foodItem.calories + ' kcal') - .fontSize(14) - } - .height(64) - } - .margin({ right: 24, left:32 }) - } - } - ``` - - ![](figures/listrouter.gif) - -2. Click **FoodGridItem**. The **FoodDetail** page is displayed. Import the **router** module, and then call the **push** API of this module to push the **FoodDetail** page to the route stack to implement page redirection. - - ``` - import router from '@system.router' - - @Component - struct FoodGridItem { - private foodItem: FoodData - build() { - Column() { - ...... - } - .height(184) - .width('100%') - .onClick(() => { - router.push({ uri: 'pages/FoodDetail' }) - }) - } - } - ``` - - ![](figures/routercategory.gif) - -3. Add the icon for returning from the **FoodDetail** page to the food list page. Save the **Back.png** file to the **resources** \> **phone** \> **media** directory. Create a custom component **PageTitle**, which contains the back icon and Food Detail text. Call the **router.back\(\)** API of the router to display the top page of the route stack, that is, the upper-level page. - - ``` - // FoodDetail.ets - import router from '@system.router' - - @Component - struct PageTitle { - build() { - Flex({ alignItems: ItemAlign.Start }) { - Image($r('app.media.Back')) - .width(21.8) - .height(19.6) - Text('Food Detail') - .fontSize(21.8) - .margin({left: 17.4}) - } - .height(61) - .backgroundColor('#FFedf2f5') - .padding({ top: 13, bottom: 15, left: 28.3 }) - .onClick(() => { - router.back() - }) - } - } - ``` - -4. Create the Stack component in the **FoodDetail** component, including the **FoodImageDisplay** and **PageTitle** child components. Set the alignment mode to **TopStart**. - - ``` - @Entry - @Component - struct FoodDetail { - build() { - Column() { - Stack( { alignContent: Alignment.TopStart }) { - FoodImageDisplay() - PageTitle() - } - ContentTable() - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - ![](figures/en-us_image_0000001214998349.png) - - -## Data Transmission Between Pages - -We have implemented the redirection and going back of the **FoodCategoryList** and **FoodDetail** pages. At this point, the tomato details page is displayed no matter which **FoodListItem**/**FoodGridItem** is clicked. This is because the data transmission between pages is not yet configured. To configure data transmission between pages, set the routing with parameters as follows: - -1. Set the **params** attribute in the **Navigator** of the **FoodListItem** component. The **params** attribute accepts the key-value object. - - ``` - // FoodList.ets - @Component - struct FoodListItem { - private foodItem: FoodData - build() { - Navigator({ target: 'pages/FoodDetail' }) { - ...... - } - .params({ foodData: this.foodItem }) - } - } - ``` - - The router API called by **FoodGridItem** also has the capability of redirection with parameters. The method of using the router API is similar to that of using the **Navigator**. - - ``` - router.push({ - uri: 'pages/FoodDetail', - params: { foodData: this.foodItem } - }) - ``` - -2. Import the **FoodData** class to the **FoodDetail** page and add the **foodItem** member variable to the **FoodDetail** component. - - ``` - // FoodDetail.ets - import { FoodData } from '../model/FoodData' - - @Entry - @Component - struct FoodDetail { - private foodItem: FoodData - build() { - ...... - } - } - ``` - -3. Obtain the value of **foodData**. Call **router.getParams\(\).foodData** to obtain the data corresponding to **foodData** carried when the **FoodCategoryList** page is displayed. - - ``` - @Entry - @Component - struct FoodDetail { - private foodItem: FoodData = router.getParams().foodData - - build() { - ...... - } - } - ``` - -4. Re-build the components on the **FoodDetail** page. During building, the food information on the **FoodDetail** page is all directly declared constants. You need to use the passed **FoodData** data to assign a new value to the constants. The code is as follows: - - ``` - @Component - struct PageTitle { - build() { - Flex({ alignItems: ItemAlign.Start }) { - Image($r('app.media.Back')) - .width(21.8) - .height(19.6) - Text('Food Detail') - .fontSize(21.8) - .margin({left: 17.4}) - } - .height(61) - .backgroundColor('#FFedf2f5') - .padding({ top: 13, bottom: 15, left: 28.3 }) - .onClick(() => { - router.back() - }) - } - } - - @Component - struct FoodImageDisplay { - private foodItem: FoodData - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - Text(this.foodItem.name) - .fontSize(26) - .fontWeight(500) - .margin({ left: 26, bottom: 17.4 }) - } - .height(357) - .backgroundColor('#FFedf2f5') - } - } - - @Component - struct ContentTable { - private foodItem: FoodData - - @Builder IngredientItem(title:string, name: string, value: string) { - Flex() { - Text(title) - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex() { - Text(name) - .fontSize(17.4) - .flexGrow(1) - Text(value) - .fontSize(17.4) - } - .layoutWeight(2) - } - } - - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - this.IngredientItem('Calories', 'Calories', this.foodItem.calories + 'kcal') - this.IngredientItem('Nutrition', 'Protein', this.foodItem.protein + 'g') - this.IngredientItem('', 'Fat', this.foodItem.fat + 'g') - this.IngredientItem('', 'Carbohydrates', this.foodItem.carbohydrates + 'g') - this.IngredientItem('', 'VitaminC', this.foodItem.vitaminC + 'mg') - } - .height(280) - .padding({ top: 30, right: 30, left: 30 }) - } - } - - @Entry - @Component - struct FoodDetail { - private foodItem: FoodData = router.getParams().foodData - - build() { - Column() { - Stack( { alignContent: Alignment.TopStart }) { - FoodImageDisplay({ foodItem: this.foodItem }) - PageTitle() - } - ContentTable({ foodItem: this.foodItem }) - } - .alignItems(HorizontalAlign.Center) - } - } - ``` - - -## Samples - -The following sample is provided to help you better understand how to define the page layout and connection: - -- [eTSDefiningPageLayoutAndConnection](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSDefiningPageLayoutAndConnection) - - This sample exemplifies the basic usage of the list layout, grid layout, and page routing, by building the food list page and food details page. +The declarative UI paradigm provides two mechanisms for page redirection: +1. Navigator: encapsulates the page routing capability. After the page target is specified, all child components in the page target have the routing capability. + +2. Router APIs: called to implement various operations of page routing. You'll need to import router before calling the router APIs. + +The procedure below uses these two mechanisms for redirection between the page list page and food details page. +1. Click FoodListItem. The FoodDetail page is displayed. Create a Navigator component in FoodListItem to enable its child components to have the routing function. The target page is 'pages/FoodDetail'. + + ``` + @Component + struct FoodListItem { + private foodItem: FoodData + build() { + Navigator({ target: 'pages/FoodDetail' }) { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + .height(40) + .width(40) + .backgroundColor('#FFf1f3f5') + .margin({ right: 16 }) + Text(this.foodItem.name) + .fontSize(14) + .flexGrow(1) + Text(this.foodItem.calories + ' kcal') + .fontSize(14) + } + .height(64) + } + .margin({ right: 24, left:32 }) + } + } + ``` + + ![en-us_image_0000001223127744](figures/en-us_image_0000001223127744.gif) + +2. Click FoodGridItem. The FoodDetail page is displayed. Import the router module, and then call the push API of this module to push the FoodDetail page to the route stack to implement page redirection. + + ``` + import router from '@system.router' + + @Component + struct FoodGridItem { + private foodItem: FoodData + build() { + Column() { + ...... + } + .height(184) + .width('100%') + .onClick(() => { + router.push({ uri: 'pages/FoodDetail' }) + }) + } + } + ``` + + ![en-us_image_0000001267607909](figures/en-us_image_0000001267607909.gif) + +3. Add the icon for returning from the FoodDetail page to the food list page. Save the Back.png file to the resources > base > media directory. Create a custom component PageTitle, which contains the back icon and Food Detail text. Call the router.back() API of the router to display the top page of the route stack, that is, the upper-level page. + + ``` + // FoodDetail.ets + import router from '@system.router' + + @Component + struct PageTitle { + build() { + Flex({ alignItems: ItemAlign.Start }) { + Image($r('app.media.Back')) + .width(21.8) + .height(19.6) + Text('Food Detail') + .fontSize(21.8) + .margin({left: 17.4}) + } + .height(61) + .backgroundColor('#FFedf2f5') + .padding({ top: 13, bottom: 15, left: 28.3 }) + .onClick(() => { + router.back() + }) + } + } + ``` + +4. Create the Stack component in the FoodDetail component, including the FoodImageDisplay and PageTitle child components. Set the alignment mode to TopStart. + + ``` + @Entry + @Component + struct FoodDetail { + build() { + Column() { + Stack( { alignContent: Alignment.TopStart }) { + FoodImageDisplay() + PageTitle() + } + ContentTable() + } + .alignItems(HorizontalAlign.Center) + } + } + ``` + + ![en-us_image_0000001267767881](figures/en-us_image_0000001267767881.png) + + +## Data Transmission Between Pages + +We have implemented the redirection and going back of the FoodCategoryList and FoodDetail pages. At this point, the tomato details page is displayed no matter which FoodListItem/FoodGridItem is clicked. This is because the data transmission between pages is not yet configured. To configure data transmission between pages, set the routing with parameters as follows: + +1. Set the params attribute in the Navigator of the FoodListItem component. The params attribute accepts the key-value object. + + ``` + // FoodList.ets + @Component + struct FoodListItem { + private foodItem: FoodData + build() { + Navigator({ target: 'pages/FoodDetail' }) { + ...... + } + .params({ foodData: this.foodItem }) + } + } + ``` + + The router API called by FoodGridItem also has the capability of redirection with parameters. The method of using the router API is similar to that of using the Navigator. + + + ``` + router.push({ + uri: 'pages/FoodDetail', + params: { foodData: this.foodItem } + }) + ``` + +2. Import the FoodData class to the FoodDetail page and add the foodItem member variable to the FoodDetail component. + + ``` + // FoodDetail.ets + import { FoodData } from '../model/FoodData' + + @Entry + @Component + struct FoodDetail { + private foodItem: FoodData + build() { + ...... + } + } + ``` + +3. Obtain the value of foodData. Call router.getParams().foodData to obtain the data corresponding to foodData carried when the FoodCategoryList page is displayed. + + ``` + @Entry + @Component + struct FoodDetail { + private foodItem: FoodData = router.getParams().foodData + + build() { + ...... + } + } + ``` + +4. Re-build the components on the FoodDetail page. During building, the food information on the FoodDetail page is all directly declared constants. You need to use the passed FoodData data to assign a new value to the constants. The code is as follows: + + ``` + @Component + struct PageTitle { + build() { + Flex({ alignItems: ItemAlign.Start }) { + Image($r('app.media.Back')) + .width(21.8) + .height(19.6) + Text('Food Detail') + .fontSize(21.8) + .margin({left: 17.4}) + } + .height(61) + .backgroundColor('#FFedf2f5') + .padding({ top: 13, bottom: 15, left: 28.3 }) + .onClick(() => { + router.back() + }) + } + } + + @Component + struct FoodImageDisplay { + private foodItem: FoodData + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + Text(this.foodItem.name) + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 17.4 }) + } + .height(357) + .backgroundColor('#FFedf2f5') + } + } + + @Component + struct ContentTable { + private foodItem: FoodData + + @Builder IngredientItem(title:string, name: string, value: string) { + Flex() { + Text(title) + .fontSize(17.4) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex() { + Text(name) + .fontSize(17.4) + .flexGrow(1) + Text(value) + .fontSize(17.4) + } + .layoutWeight(2) + } + } + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + this.IngredientItem('Calories', 'Calories', this.foodItem.calories + 'kcal') + this.IngredientItem('Nutrition', 'Protein', this.foodItem.protein + 'g') + this.IngredientItem('', 'Fat', this.foodItem.fat + 'g') + this.IngredientItem('', 'Carbohydrates', this.foodItem.carbohydrates + 'g') + this.IngredientItem('', 'VitaminC', this.foodItem.vitaminC + 'mg') + } + .height(280) + .padding({ top: 30, right: 30, left: 30 }) + } + } + + @Entry + @Component + struct FoodDetail { + private foodItem: FoodData = router.getParams().foodData + + build() { + Column() { + Stack( { alignContent: Alignment.TopStart }) { + FoodImageDisplay({ foodItem: this.foodItem }) + PageTitle() + } + ContentTable({ foodItem: this.foodItem }) + } + .alignItems(HorizontalAlign.Center) + } + } + ``` diff --git a/en/application-dev/webgl/figures/en-us_image_0000001238544451.png b/en/application-dev/webgl/figures/en-us_image_0000001238544451.png index 9d953fc57d179bd67edebd43c2a247585bad7bbe..dd22fb9659c6290be58c58e3e6b35c0c15bad800 100644 Binary files a/en/application-dev/webgl/figures/en-us_image_0000001238544451.png and b/en/application-dev/webgl/figures/en-us_image_0000001238544451.png differ diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 71699978011412397074ac275ab88d6143835626..d76de1125db661cd26cbe8e1db4bafacac40cd6d 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -1,20 +1,22 @@ -# OpenHarmony Application Development Documentation +# Application Development - [Application Development Overview](application-dev-guide.md) - Quick Start - - [Getting Started with Application Development](quick-start/Readme-EN.md) - - DevEco Studio (OpenHarmony) User Guide - - [Overview](quick-start/deveco-studio-overview.md) - - [Version Change History](quick-start/deveco-studio-release-notes.md) - - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [Creating an OpenHarmony Project](quick-start/create-openharmony-project.md) - - [Using the Project Wizard to Create a Project](quick-start/use-wizard-to-create-project.md) - - [Importing a Sample to Create a Project](quick-start/import-sample-to-create-project.md) - - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) - - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) - [Directory Structure](quick-start/package-structure.md) + - [Resource File Categories](quick-start/basic-resource-file-categories.md) - Development + - Ability Development + - FA Model + - [FA Model Overview](ability/fa-brief.md) + - [Page Ability Development](ability/fa-pageability.md) + - [Service Ability Development](ability/fa-serviceability.md) + - [Data Ability Development](ability/fa-dataability.md) + - [FA Widget Development](ability/fa-formability.md) + + - Other + - [Ability Assistant Usage](ability/ability-assistant-guidelines.md) - UI + - [ArkUI Overview](ui/arkui-overview.md) - JavaScript-based Web-Like Development Paradigm - [Overview](ui/ui-js-overview.md) - Framework @@ -41,21 +43,24 @@ - [Defining Events](ui/ui-js-building-ui-event.md) - [Defining Page Routes](ui/ui-js-building-ui-routes.md) - Common Component Development Guidelines - - [Text](ui/ui-js-components-text.md) - - [Input](ui/ui-js-components-input.md) - - [Button](ui/ui-js-components-button.md) - - [List](ui/ui-js-components-list.md) - - [Picker](ui/ui-js-components-picker.md) - - [Dialog](ui/ui-js-components-dialog.md) - - [Form](ui/ui-js-components-form.md) - - [Stepper](ui/ui-js-components-stepper.md) - - [Tabs](ui/ui-js-component-tabs.md) - - [Image](ui/ui-js-components-images.md) - - Animation Development Guidelines + - Container Components + - [List](ui/ui-js-components-list.md) + - [Dialog](ui/ui-js-components-dialog.md) + - [Form](ui/ui-js-components-form.md) + - [Stepper](ui/ui-js-components-stepper.md) + - [Tabs](ui/ui-js-component-tabs.md) + - Basic Components + - [Text](ui/ui-js-components-text.md) + - [Input](ui/ui-js-components-input.md) + - [Button](ui/ui-js-components-button.md) + - [Picker](ui/ui-js-components-picker.md) + - [Image](ui/ui-js-components-images.md) + - Animation Development Guidelines - CSS Animation - [Defining Attribute Style Animations](ui/ui-js-animate-attribute-style.md) - [Defining Animations with the transform Attribute](ui/ui-js-animate-transform.md) - [Defining Animations with the background-position Attribute](ui/ui-js-animate-background-position-style.md) + - [Defining Animations for SVG Components](ui/ui-js-animate-svg.md) - JS Animation - [Component Animation](ui/ui-js-animate-component.md) - Interpolator Animation @@ -70,6 +75,8 @@ - [Rules for Accessing Application Code Files](ui/ts-framework-file-access-rules.md) - ["js" Tag](ui/ts-framework-js-tag.md) - Resource Access + - [Accessing Application Resources](ui/ts-application-resource-access.md) + - [Accessing System Resources](ui/ts-system-resource-access.md) - [Media Resource Types](ui/ts-media-resource-type.md) - [Pixel Units](ui/ts-pixel-units.md) - [Types](ui/ts-types.md) @@ -124,12 +131,16 @@ - [Building a Food Category Grid Layout](ui/ui-ts-building-category-grid-layout.md) - [Implementing Page Redirection and Data Transmission](ui/ui-ts-page-redirection-data-transmission.md) - Basic Functions - - Agent-Powered Scheduled Reminders - - [Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) - - [Development Guidelines](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) - - Background Task Management - - [Background Task Management Overview](background-task-management/background-task-overview.md) - - [Background Task Management Development](background-task-management/background-task-dev-guide.md) + - Window Manager + - Window + - [Window Overview](windowmanager/window-overview.md) + - [Window Development](windowmanager/window-guidelines.md) + - Display + - [Display Overview](windowmanager/display-overview.md) + - [Display Development](windowmanager/display-guidelines.md) + - Screenshot + - [Screenshot Overview](windowmanager/screenshot-overview.md) + - [Screenshot Development](windowmanager/screenshot-guidelines.md) - WebGL - [WebGL Overview](webgl/webgl-overview.md) - [WebGL Development](webgl/webgl-guidelines.md) @@ -137,16 +148,19 @@ - Audio - [Audio Overview](media/audio-overview.md) - [Audio Playback Development](media/audio-playback.md) - - [Audio Playback Development Using AudioRenderer](media/audio-renderer.md) + - [Audio Rendering Development](media/audio-renderer.md) - [Audio Recording Development](media/audio-recorder.md) - - [Audio Recorder Development Using AudioCapturer](media/audio-capturer) + - [Audio Capture Development](media/audio-capturer.md) - Video - [Video Playback Development](media/video-playback.md) - - [Video Recording Development](media/video-recorder.md) + - Image + - [Image Development](media/image.md) - Security - User Authentication - [User Authentication Overview](security/userauth-overview.md) - [User Authentication Development](security/userauth-guidelines.md) + - hapsigner + - [hapsigner Guide](security/hapsigntool-guidelines.md) - Connectivity - IPC & RPC - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) @@ -162,6 +176,12 @@ - Lightweight Data Store - [Lightweight Data Store Overview](database/database-preference-overview.md) - [Lightweight Data Store Development](database/database-preference-guidelines.md) + - Agent-Powered Scheduled Reminders + - [Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) + - [Development Guidelines](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - Background Task Management + - [Background Task Management Overview](background-task-management/background-task-overview.md) + - [Background Task Management Development](background-task-management/background-task-dev-guide.md) - Device - USB Service - [USB Service Overview](device/usb-overview.md) @@ -170,24 +190,37 @@ - [Location Overview](device/device-location-overview.md) - [Obtaining Device Location Information](device/device-location-info.md) - [Geocoding and Reverse Geocoding Capabilities](device/device-location-geocoding.md) + - Sensor + - [Sensor Overview](device/sensor-overview.md) + - [Sensor Development](device/sensor-guidelines.md) + - Vibrator + - [Vibrator Overview](device/vibrator-overview.md) + - [Vibrator Development](device/vibrator-guidelines.md) + - Device Usage Statistics + - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) + - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) - DFX - Application Event Logging - [Overview of Application Event Logging](dfx/hiappevent-overview.md) - [Development Guidelines on Application Event Logging](dfx/hiappevent-guidelines.md) + - Performance Tracing + - [Overview of Performance Tracing](dfx/hitracemeter-overview.md) + - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) + - Distributed Call Chain Tracing + - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) + - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) + - Internationalization + - [Overview](internationalization/international-overview.md) + - [Internationalization Development (intl)](internationalization/intl-guidelines.md) + - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - Tools - - DevEco Studio (OpenHarmony) User Guide - - [Overview](quick-start/deveco-studio-overview.md) - - [Version Change History](quick-start/deveco-studio-release-notes.md) - - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [Creating an OpenHarmony Project](quick-start/create-openharmony-project.md) - - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) - - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) + - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - API References - Compent Reference (JavaScript-based Web-like Development Paradigm) - - [Components](reference/arkui-js/js-components.md) - - [Common](reference/arkui-js/js-components-common.md) + - Components + - Common - [Universal Attributes](reference/arkui-js/js-components-common-attributes.md) - [Universal Styles](reference/arkui-js/js-components-common-styles.md) - [Universal Events](reference/arkui-js/js-components-common-events.md) @@ -197,7 +230,7 @@ - [Transition Styles](reference/arkui-js/js-components-common-transition.md) - [Custom Font Styles](reference/arkui-js/js-components-common-customizing-font.md) - [Atomic Layout](reference/arkui-js/js-components-common-atomic-layout.md) - - [Container Component](reference/arkui-js/js-components-container.md) + - Container Components - [badge](reference/arkui-js/js-components-container-badge.md) - [dialog](reference/arkui-js/js-components-container-dialog.md) - [div](reference/arkui-js/js-components-container-div.md) @@ -215,7 +248,7 @@ - [tabs](reference/arkui-js/js-components-container-tabs.md) - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) - [tab-content](reference/arkui-js/js-components-container-tab-content.md) - - [Basic Components](reference/arkui-js/js-components-basic.md) + - Basic Components - [button](reference/arkui-js/js-components-basic-button.md) - [chart](reference/arkui-js/js-components-basic-chart.md) - [divider](reference/arkui-js/js-components-basic-divider.md) @@ -243,9 +276,10 @@ - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) - [toggle](reference/arkui-js/js-components-basic-toggle.md) - - [Media Components](reference/arkui-js/js-components-media.md) + - [web](reference/arkui-js/js-components-basic-web.md) + - Media Components - [video](reference/arkui-js/js-components-media-video.md) - - [Canvas Components](reference/arkui-js/js-components-canvas.md) + - Canvas Components - [canvas](reference/arkui-js/js-components-canvas-canvas.md) - [CanvasRenderingContext2D](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - [Image](reference/arkui-js/js-components-canvas-image.md) @@ -255,12 +289,12 @@ - [ImageBitmap](reference/arkui-js/js-components-canvas-imagebitmap.md) - [OffscreenCanvas](reference/arkui-js/js-components-canvas-offscreencanvas.md) - [OffscreenCanvasRenderingContext2D](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - - [Grid](reference/arkui-js/js-components-grid.md) + - Grid - [Basic Concepts](reference/arkui-js/js-components-grid-basic-concepts.md) - [grid-container](reference/arkui-js/js-components-grid-container.md) - [grid-row](reference/arkui-js/js-components-grid-row.md) - [grid-col](reference/arkui-js/js-components-grid-col.md) - - [SVG Components](reference/arkui-js/js-svg.md) + - SVG Components - [Universal Attributes](reference/arkui-js/js-components-svg-common-attributes.md) - [svg](reference/arkui-js/js-components-svg.md) - [rect](reference/arkui-js/js-components-svg-rect.md) @@ -276,25 +310,27 @@ - [animate](reference/arkui-js/js-components-svg-animate.md) - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - - [Custom Components](reference/arkui-js/js-components-custom.md) + - Custom Components - [Basic Usage](reference/arkui-js/js-components-custom-basic-usage.md) - [Custom Events](reference/arkui-js/js-components-custom-events.md) - [props](reference/arkui-js/js-components-custom-props.md) - [Event Parameter](reference/arkui-js/js-components-custom-event-parameter.md) - [slot](reference/arkui-js/js-components-custom-slot.md) - [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md) - - [Appendix](reference/arkui-js/js-appendix.md) - - [Type Attributes](reference/arkui-js/js-appendix-types.md) + - [Type Attributes](reference/arkui-js/js-appendix-types.md) - Compent Reference (TypeScript-based Declarative Development Paradigm) - - [Components](reference/arkui-ts/ts-components.md) - - [Universal Components](reference/arkui-ts/ts-universal-components.md) - - [Universal Events](reference/arkui-ts/ts-universal-events.md) + - Components + - Universal Components + - Universal Events - [Click Event](reference/arkui-ts/ts-universal-events-click.md) - [Touch](reference/arkui-ts/ts-universal-events-touch.md) - [Show/Hide Event](reference/arkui-ts/ts-universal-events-show-hide.md) + - [Drag/Drop Event](reference/arkui-ts/ts-universal-events-drag-drop.md) - [Key Event](reference/arkui-ts/ts-universal-events-key.md) - - [Component Area Change Event](reference/arkui-ts/ts-universal-events-component-area-change.md) - - [Universal Attributes](reference/arkui-ts/ts-universal-attributes.md) + - [Focus Event](reference/arkui-ts/ts-universal-focus-event.md) + - [Mouse Event](reference/arkui-ts/ts-universal-mouse-key.md) + - [Component Area Change Event](reference/arkui-ts/ts-universal-component-area-change-event.md) + - Universal Attributes - [Size](reference/arkui-ts/ts-universal-attributes-size.md) - [Location](reference/arkui-ts/ts-universal-attributes-location.md) - [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) @@ -314,11 +350,15 @@ - [Gradient Color](reference/arkui-ts/ts-universal-attributes-gradient-color.md) - [Popup Control](reference/arkui-ts/ts-universal-attributes-popup.md) - [Menu Control](reference/arkui-ts/ts-universal-attributes-menu.md) - - [Click Control](reference/arkui-ts/ts-universal-attributes-touchable.md) - - [Touch Target](reference/arkui-ts/ts-universal-attributes-response-region.md) - - [Gesture Processing](reference/arkui-ts/ts-gesture-processing.md) + - [Click Control](reference/arkui-ts/ts-universal-attributes-click.md) + - [Focus Control](reference/arkui-ts/ts-universal-attributes-focus.md) + - [Hover Effect](reference/arkui-ts/ts-universal-attributes-hover-effect.md) + - [Component ID](reference/arkui-ts/ts-universal-attributes-component-id.md) + - [Touch Target](reference/arkui-ts/ts-universal-attributes-touch-target.md) + - [Polymorphic Style](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) + - Gesture Processing - [Gesture Binding Methods](reference/arkui-ts/ts-gesture-settings.md) - - [Basic Gestures](reference/arkui-ts/ts-basic-gestures.md) + - Basic Gestures - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) @@ -326,28 +366,45 @@ - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) - [Combined Gestures](reference/arkui-ts/ts-combined-gestures.md) - - [Basic Components](reference/arkui-ts/ts-basic-components.md) + - Basic Components - [Blank](reference/arkui-ts/ts-basic-components-blank.md) - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) + - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - [Divider](reference/arkui-ts/ts-basic-components-divider.md) - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) - [Image](reference/arkui-ts/ts-basic-components-image.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [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) + - [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) - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [Search](reference/arkui-ts/ts-basic-components-search.md) - [Select](reference/arkui-ts/ts-basic-components-select.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [Text](reference/arkui-ts/ts-basic-components-text.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) + - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - - [Container Components](reference/arkui-ts/ts-components-container.md) + - [Web](reference/arkui-ts/ts-basic-components-web.md) + - [Xcomponent](reference/arkui-ts/ts-basic-components-xcomponent.md) + - Container Components - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - [Badge](reference/arkui-ts/ts-container-badge.md) - [Column](reference/arkui-ts/ts-container-column.md) @@ -359,159 +416,250 @@ - [GridItem](reference/arkui-ts/ts-container-griditem.md) - [List](reference/arkui-ts/ts-container-list.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md) - - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Navigation](reference/arkui-ts/ts-container-navigation.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Row](reference/arkui-ts/ts-container-row.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [ScrollBar](reference/arkui-ts/ts-container-scrollbar.md) + - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [Stack](reference/arkui-ts/ts-container-stack.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - - [Drawing Components](reference/arkui-ts/ts-drawing-components.md) + - Media Components + - [Video](reference/arkui-ts/ts-media-components-video.md) + - Drawing Components - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) - [Line](reference/arkui-ts/ts-drawing-components-line.md) - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) - - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) - - [Canvas Components](reference/arkui-ts/ts-components-canvas.md) + - Canvas Components - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) - [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md) - [OffscreenCanvasRenderingConxt2D](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) - [Path2D](reference/arkui-ts/ts-components-canvas-path2d.md) - - [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md) - [ImageBitmap](reference/arkui-ts/ts-components-canvas-imagebitmap.md) - [ImageData](reference/arkui-ts/ts-components-canvas-imagedata.md) - - [Animation](reference/arkui-ts/ts-animation.md) + - Animation - [Attribute Animation](reference/arkui-ts/ts-animatorproperty.md) - [Explicit Animation](reference/arkui-ts/ts-explicit-animation.md) - - [Transition Animation](reference/arkui-ts/ts-transition-animation.md) + - Transition Animation - [Page Transition](reference/arkui-ts/ts-page-transition-animation.md) - [Component Transition](reference/arkui-ts/ts-transition-animation-component.md) - [Transition of Shared Elements](reference/arkui-ts/ts-transition-animation-shared-elements.md) - [Motion Path Animation](reference/arkui-ts/ts-motion-path-animation.md) - [Matrix Transformation](reference/arkui-ts/ts-matrix-transformation.md) - [Interpolation Calculation](reference/arkui-ts/ts-interpolation-calculation.md) - - [Global UI Methods](reference/arkui-ts/ts-global-ui-methods.md) - - [Alert Dialog Box](reference/arkui-ts/ts-methods-alert-dialog-box.md) - - [Custom Dialog box](reference/arkui-ts/ts-methods-custom-dialog-box.md) - - [Image Cache](reference/arkui-ts/ts-methods-image-cache.md) - - [Media Query](reference/arkui-ts/ts-methods-media-query.md) - - [List Selection Dialog Box](reference/arkui-ts/ts-methods-action-sheet.md) - - [Appendix](reference/arkui-ts/ts-appendix.md) - - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) + - Global UI Methods + - Dialog Box + - [Alert Dialog Box](reference/arkui-ts/ts-methods-alert-dialog-box.md) + - [Action Sheet](reference/arkui-ts/ts-methods-action-sheet.md) + - [Custom Dialog Box](reference/arkui-ts/ts-methods-custom-dialog-box.md) + - [Date Picker Dialog Box](reference/arkui-ts/ts-methods-datepicker-dialog.md) + - [Text Picker Dialog Box](reference/arkui-ts/ts-methods-textpicker-dialog.md) + - [Menu](reference/arkui-ts/ts-methods-menu.md) + - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - APIs - Ability Framework - - [FeatureAbility Module](reference/apis/js-apis-featureAbility.md) - - [ParticleAbility Module](reference/apis/js-apis-particleAbility.md) - - [DataAbilityHelper Module](reference/apis/js-apis-dataAbilityHelper.md) - - [DataUriUtils Module](reference/apis/js-apis-DataUriUtils.md) - - [Bundle Module](reference/apis/js-apis-Bundle.md) - - [Context Module](reference/apis/js-apis-Context.md) - - Event Notification - - [CommonEvent Module](reference/apis/js-apis-commonEvent.md) - - [Notification Module](reference/apis/js-apis-notification.md) - - [Reminder Agent](reference/apis/js-apis-reminderAgent.md) - - Resource Management - - [Resource Manager](reference/apis/js-apis-resource-manager.md) - - [Internationalization (intl)](reference/apis/js-apis-intl.md) - - [Internationalization (i18n)](reference/apis/js-apis-i18n.md) + + - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) + - [@ohos.application.Ability](reference/apis/js-apis-application-ability.md) + - [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage ](reference/apis/js-apis-application-abilitystage.md) + - [@ohos.application.appManager](reference/apis/js-apis-appmanager.md) + - [@ohos.application.Configuration](reference/apis/js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant](reference/apis/js-apis-configurationconstant.md) + - [@ohos.ability.featureAbility](reference/apis/js-apis-featureAbility.md) + - [@ohos.application.formBindingData](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.FormExtension](reference/apis/js-apis-formextension.md) + - [@ohos.application.missionManager](reference/apis/js-apis-missionManager.md) + - [@ohos.application.formProvider](reference/apis/js-apis-formprovider.md) + - [@ohos.ability.particleAbility](reference/apis/js-apis-particleAbility.md) + - [@ohos.application.ServiceExtensionAbility](reference/apis/js-apis-service-extension-ability.md) + - [@ohos.application.uriPermissionManager](reference/apis/js-apis-uripermissionmanager.md) + - [@ohos.wantAgent](reference/apis/js-apis-wantAgent.md) + - [dataAbilityHelper](reference/apis/js-apis-dataAbilityHelper.md) + - [context](reference/apis/js-apis-Context.md) + - [AbilityContext](reference/apis/js-apis-ability-context.md) + - [AbilityRunningInfo](reference/apis/js-apis-abilityrunninginfo.md) + - [AbilityStageContext](reference/apis/js-apis-abilitystagecontext.md) + - [Context](reference/apis/js-apis-application-context.md) + - [ExtensionContext](reference/apis/js-apis-extension-context.md) + - [ExtensionRunningInfo](reference/apis/js-apis-extensionrunninginfo.md) + - [FormExtensionContext](reference/apis/js-apis-formextensioncontext.md) + - [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md) + - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) + - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) + - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) + + - Common Event and Notification + + - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) + - [@ohos.events.emitter](reference/apis/js-apis-emitter.md) + - [@ohos.notification](reference/apis/js-apis-notification.md) + - [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md) + - [EventHub](reference/apis/js-apis-eventhub.md) + + - Bundle Management + + - [@ohos.bundle](reference/apis/js-apis-Bundle.md) + - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.zlib](reference/apis/js-apis-zlib.md) + + - UI Page + + - [@ohos.animator](reference/apis/js-apis-animator.md) + + - Graphics + + - [@ohos.display ](reference/apis/js-apis-display.md) + - [@ohos.screenshot](reference/apis/js-apis-screenshot.md) + - [@ohos.window](reference/apis/js-apis-window.md) + - [webgl](reference/apis/js-apis-webgl.md) + - [webgl2](reference/apis/js-apis-webgl2.md) + - Media - - [Audio Management](reference/apis/js-apis-audio.md) - - [Media](reference/apis/js-apis-media.md) + + - [@ohos.multimedia.audio](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.image](reference/apis/js-apis-image.md) + - [@ohos.multimedia.media](reference/apis/js-apis-media.md) + - [@ohos.multimedia.medialibrary](reference/apis/js-apis-medialibrary.md) + + - Resource Management + - [@ohos.i18n](reference/apis/js-apis-i18n.md) + - [@ohos.intl](reference/apis/js-apis-intl.md) + - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) + + - Resource Scheduling + + - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) + + - Custom Management + + - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) + - Security - - [User Authentication](reference/apis/js-apis-useriam-userauth.md) - - [Access Control](reference/apis/js-apis-abilityAccessCtrl.md) + + - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) + - Data Management - - [Lightweight Storage (deprecated since 8)](reference/apis/js-apis-data-storage.md) - - [Distributed Data Management](reference/apis/js-apis-distributed-data.md) - - [Relational Database](reference/apis/js-apis-data-rdb.md) - - [Result Set](reference/apis/js-apis-data-resultset.md) - - [DataAbilityPredicates](reference/apis/js-apis-data-ability.md) - - [Settings](reference/apis/js-apis-settings.md) + + - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) + - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) + - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) + - [@ohos.settings](reference/apis/js-apis-settings.md) + - [resultSet](reference/apis/js-apis-data-resultset.md) + - File Management - - [File Management](reference/apis/js-apis-fileio.md) - - [Statfs](reference/apis/js-apis-statfs.md) - - [Environment](reference/apis/js-apis-environment.md) - - [Public File Access and Management](reference/apis/js-apis-filemanager.md) - - [App Storage Statistics](reference/apis/js-apis-storage-statistics.md) - - [Volume Management](reference/apis/js-apis-volumemanager.md) - - Account Management - - [Distributed Account Management](reference/apis/js-apis-distributed-account.md) - - [App Account Management](reference/apis/js-apis-appAccount.md) + + - [@ohos.environment](reference/apis/js-apis-environment.md) + - [@ohos.fileio](reference/apis/js-apis-fileio.md) + - [@ohos.fileManager](reference/apis/js-apis-filemanager.md) + - [@ohos.statfs](reference/apis/js-apis-statfs.md) + - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) + - Telephony Service - - [Call](reference/apis/js-apis-call.md) - - [SMS](reference/apis/js-apis-sms.md) - - [SIM Management](reference/apis/js-apis-sim.md) - - [Radio](reference/apis/js-apis-radio.md) - - [observer](reference/apis/js-apis-observer.md) - - [Cellular Data](reference/apis/js-apis-telephony-data.md) - - Network and Connectivity - - [WLAN](reference/apis/js-apis-wifi.md) - - [Bluetooth](reference/apis/js-apis-bluetooth.md) - - [RPC](reference/apis/js-apis-rpc.md) - - Device Management - - [Sensor](reference/apis/js-apis-sensor.md) - - [Vibrator](reference/apis/js-apis-vibrator.md) - - [Brightness](reference/apis/js-apis-brightness.md) - - [Battery Info](reference/apis/js-apis-battery-info.md) - - [Power Management](reference/apis/js-apis-power.md) - - [Thermal Management](reference/apis/js-apis-thermal.md) - - [Running Lock](reference/apis/js-apis-runninglock.md) - - [Device Info](reference/apis/js-apis-device-info.md) - - [systemParameter](reference/apis/js-apis-system-parameter.md) - - [Device Management](reference/apis/js-apis-device-manager.md) - - [Window](reference/apis/js-apis-window.md) - - [Display](reference/apis/js-apis-display.md) - - [Update](reference/apis/js-apis-update.md) - - [USB](reference/apis/js-apis-usb.md) - - [Location](reference/apis/js-apis-geolocation.md) + + - [@ohos.contact](reference/apis/js-apis-contact.md) + - [@ohos.telephony.call](reference/apis/js-apis-call.md) + - [@ohos.telephony.observer](reference/apis/js-apis-observer.md) + - [@ohos.telephony.radio](reference/apis/js-apis-radio.md) + - [@ohos.telephony.sim](reference/apis/js-apis-sim.md) + - [@ohos.telephony.sms](reference/apis/js-apis-sms.md) + - [@ohos.telephony.data](reference/apis/js-apis-telephony-data.md) + + - Network Management + - [@ohos.net.connection](reference/apis/js-apis-net-connection.md) + - [@ohos.net.http](reference/apis/js-apis-http.md) + - [@ohos.request](reference/apis/js-apis-request.md) + - [@ohos.net.socket](reference/apis/js-apis-socket.md) + - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) + + - Connectivity + + - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) + - [@ohos.rpc](reference/apis/js-apis-rpc.md) + - [@ohos.wifi](reference/apis/js-apis-wifi.md) + - [@ohos.wifiext](reference/apis/js-apis-wifiext.md) + - Basic Features - - [Application Context](reference/apis/js-apis-basic-features-app-context.md) - - [Console Logs](reference/apis/js-apis-basic-features-logs.md) - - [Page Routing](reference/apis/js-apis-basic-features-routes.md) - - [Pop-up Window](reference/apis/js-apis-basic-features-pop-up.md) - - [Application Configuration](reference/apis/js-apis-basic-features-configuration.md) - - [Timer](reference/apis/js-apis-basic-features-timer.md) - - [Setting the System Time](reference/apis/js-apis-system-time.md) - - [Animation](reference/apis/js-apis-basic-features-animator.md) - - [WebGL](reference/apis/js-apis-webgl.md) - - [WebGL2](reference/apis/js-apis-webgl2.md) - - [Screenshot](reference/apis/js-apis-screenshot.md) - - DFX - - [HiAppEvent](reference/apis/js-apis-hiappevent.md) - - [Performance Tracing](reference/apis/js-apis-hitracemeter.md) - - [Fault Logger](reference/apis/js-apis-faultLogger.md) - - [Distributed Call Chain Tracing](reference/apis/js-apis-hitracechain.md) - - [HiLog](reference/apis/js-apis-hilog.md) - - [HiChecker](reference/apis/js-apis-hichecker.md) - - [HiDebug](reference/apis/js-apis-hidebug.md) + + - [@ohos.accessibility](reference/apis/js-apis-accessibility.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](reference/apis/js-apis-hidebug.md) + - [@ohos.hilog](reference/apis/js-apis-hilog.md) + - [@ohos.hiTraceChain](reference/apis/js-apis-hitracechain.md) + - [@ohos.hiTraceMeter](reference/apis/js-apis-hitracemeter.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.wallpaper](reference/apis/js-apis-wallpaper.md) + - [Timer](reference/apis/js-apis-timer.md) + + - Device Management + + - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.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.multimodalInput.inputConsumer](reference/apis/js-apis-inputconsumer.md) + - [@ohos.multimodalInput.inputDevice](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputMonitor](reference/apis/js-apis-inputmonitor.md) + - [@ohos.power](reference/apis/js-apis-power.md) + - [@ohos.runningLock](reference/apis/js-apis-runninglock.md) + - [@ohos.sensor](reference/apis/js-apis-sensor.md) + - [@ohos.systemParameter](reference/apis/js-apis-system-parameter.md) + - [@ohos.thermal](reference/apis/js-apis-thermal.md) + - [@ohos.update](reference/apis/js-apis-update.md) + - [@ohos.usb](reference/apis/js-apis-usb.md) + - [@ohos.vibrator](reference/apis/js-apis-vibrator.md) + + - Account Management + + - [@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) + - Language Base Class Library - - [Obtaining Process Information](reference/apis/js-apis-process.md) - - [URL String Parsing](reference/apis/js-apis-url.md) - - [URI String Parsing](reference/apis/js-apis-uri.md) - - [Util](reference/apis/js-apis-util.md) - - [XML Parsing and Generation](reference/apis/js-apis-xml.md) - - [XML-to-JavaScript Conversion](reference/apis/js-apis-convertxml.md) - - [Worker Startup](reference/apis/js-apis-worker.md) - - [Linear Container ArrayList](reference/apis/js-apis-arraylist.md) - - [Linear Container Deque](reference/apis/js-apis-deque.md) - - [Linear Container List](reference/apis/js-apis-list.md) - - [Linear Container LinkedList](reference/apis/js-apis-linkedlist.md) - - [Linear Container Queue](reference/apis/js-apis-queue.md) - - [Linear Container Stack](reference/apis/js-apis-stack.md) - - [Linear Container Vector](reference/apis/js-apis-vector.md) - - [Nonlinear Container HashSet](reference/apis/js-apis-hashset.md) - - [Nonlinear Container HashMap](reference/apis/js-apis-hashmap.md) - - [Nonlinear Container PlainArray](reference/apis/js-apis-plainarray.md) - - [Nonlinear Container TreeMap](reference/apis/js-apis-treemap.md) - - [Nonlinear Container TreeSet](reference/apis/js-apis-treeset.md) - - [Nonlinear Container LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [Nonlinear Container LightWeightSet](reference/apis/js-apis-lightweightset.md) \ No newline at end of file + + - [@ohos.convertxml](reference/apis/js-apis-convertxml.md) + - [@ohos.process](reference/apis/js-apis-process.md) + - [@ohos.uri](reference/apis/js-apis-uri.md) + - [@ohos.url](reference/apis/js-apis-url.md) + - [@ohos.util](reference/apis/js-apis-util.md) + - [@ohos.util.ArrayList](reference/apis/js-apis-arraylist.md) + - [@ohos.util.Deque](reference/apis/js-apis-deque.md) + - [@ohos.util.HashMap](reference/apis/js-apis-hashmap.md) + - [@ohos.util.HashSet](reference/apis/js-apis-hashset.md) + - [@ohos.util.LightWeightMap](reference/apis/js-apis-lightweightmap.md) + - [@ohos.util.LightWeightSet](reference/apis/js-apis-lightweightset.md) + - [@ohos.util.LinkedList](reference/apis/js-apis-linkedlist.md) + - [@ohos.util.List](reference/apis/js-apis-list.md) + - [@ohos.util.PlainArray](reference/apis/js-apis-plainarray.md) + - [@ohos.util.Queue](reference/apis/js-apis-queue.md) + - [@ohos.util.Stack](reference/apis/js-apis-stack.md) + - [@ohos.util.TreeMap](reference/apis/js-apis-treemap.md) + - [@ohos.util.TreeSet](reference/apis/js-apis-treeset.md) + - [@ohos.util.Vector](reference/apis/js-apis-vector.md) + - [@ohos.worker](reference/apis/js-apis-worker.md) + - [@ohos.xml](reference/apis/js-apis-xml.md) + + - APIs No Longer Maintained + + - [@ohos.bytrace](reference/apis/js-apis-bytrace.md) + - [@ohos.data.storage](reference/apis/js-apis-data-storage.md) + - [@system.sensor](reference/apis/js-apis-system-sensor.md) + - [@system.vibrator](reference/apis/js-apis-system-vibrate.md) + - [console](reference/apis/js-apis-logs.md) \ No newline at end of file diff --git a/en/application-dev/windowmanager/window-guidelines.md b/en/application-dev/windowmanager/window-guidelines.md index 0f265cb868132595fb4311c07dae0ecd69934207..8a6b8dbfaa82264841e42cba4e117a29ecf388b4 100644 --- a/en/application-dev/windowmanager/window-guidelines.md +++ b/en/application-dev/windowmanager/window-guidelines.md @@ -5,7 +5,7 @@ The interface layer of the window runs in the application process. It loads the By calling these APIs, you can create and destroy a window, set the position and size of a window, and enter the immersive mode (full-screen mode). ## Available APIs -For details about the APIs, see [Window](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-window.md). +For details about the APIs, see [Window](../reference/apis/js-apis-window.md). **Table 1** Main window APIs diff --git a/en/application-dev/work-scheduler/Readme.md b/en/application-dev/work-scheduler/Readme-EN.md similarity index 100% rename from en/application-dev/work-scheduler/Readme.md rename to en/application-dev/work-scheduler/Readme-EN.md diff --git a/en/contribute/documentation-contribution.md b/en/contribute/documentation-contribution.md index a6cdcf8425ada7a63487c070f74b178b1de213a4..fe1813e80db33653f650413b1003bf194f416c99 100755 --- a/en/contribute/documentation-contribution.md +++ b/en/contribute/documentation-contribution.md @@ -1,25 +1,25 @@ -# Documentation Contribution +# Documentation Contribution You are welcome to make contributions to OpenHarmony documentation, in any of the methods provided below. You can help us improve the existing documents or submit new, original content. Excellent contributors will be awarded and the contributions will be publicized in the developer community. -- [Contribution Methods](#section5723203852414) +- [Contribution Methods](#contribution-methods) - [Writing Instructions](writing-instructions.md) -## Content Copyright +## Content Copyright The content and images submitted by you must be original and must not infringe others' intellectual property rights. OpenHarmony has the right to modify the adopted content according to the community regulations and specifications. -## License +## License [Creative Commons License version 4.0](https://creativecommons.org/licenses/by/4.0/legalcode) -## Contribution Methods +## Contribution Methods -### Submitting Issues for Existing Documents +### Submitting Issues for Existing Documents Your feedback matters. Submit issues and leave as detailed information as possible, so we can better fix the issues and improve our documents. @@ -35,7 +35,7 @@ Your feedback matters. Submit issues and leave as detailed information as possib >- Search the list of existing issues to see if any related or similar issues have been submitted. >- If an issue is associated with another issue or a pull request (PR), you can use its full URL or the combination of the number sign (#) and PR number to reference it. -### Editing Existing Documents +### Editing Existing Documents You can perform the following steps to modify or supplement a file: @@ -48,7 +48,7 @@ You can perform the following steps to modify or supplement a file: Signed-off-by: user.name <user.email> // Note that *user.name* and *user.email* must be the same as those used for DCO signing. -![](figures/Signed-off-by-example.png.png) +![](figures/Signed-off-by-example.png) The Docs team will review your edits and update the file accordingly. @@ -61,7 +61,7 @@ To help developers efficiently use each release, OpenHarmony provides related do You are welcome to contribute documents to the release. For details, see [Writing Documents for a Release](docs-release-process.md). -### Sharing Experience +### Sharing Experience You are welcome to share your experience and expertise with other developers to help them get started. For example, you can contribute tutorials and FAQs by using the following templates: diff --git a/en/device-dev/device-dev-guide.md b/en/device-dev/device-dev-guide.md index 1668634117cc3f5cc8cedb45978aa27715cefe84..5bf3cede07eb781eb67807ab026423b786385033 100644 --- a/en/device-dev/device-dev-guide.md +++ b/en/device-dev/device-dev-guide.md @@ -32,141 +32,28 @@ In addition, OpenHarmony provides a series of optional system components that ca **Table 1** Mini and small system development guidelines \(reference memory < 128 MB\) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Topic

-

Development Scenario

-

Documents

-

About OpenHarmony

-

Getting familiar with OpenHarmony

-
-

Development resources

-

Preparing for your development

-
-

Quick start

-

Getting started with setup, build, burning, debugging, and running of OpenHarmony

-

Mini and Small Systems

-

Basic capabilities

-

Using basic capabilities of OpenHarmony

-
-

Advanced development

-

Developing smart devices based on system capabilities

-
-

Porting and adaptation

-
  • Porting and adapting the OpenHarmony to an SoC
  • Porting and adapting the OpenHarmony to a third-party library
-
-

Contributing components

-

Contributing components to OpenHarmony

-
-

Reference

-

Referring to development specifications

-
-
+| Topic | Development Scenario | Documents | +| -------- | -------- | -------- | +| About OpenHarmony | Getting familiar with OpenHarmony | - [About OpenHarmony](https://gitee.com/openharmony)
- [Glossary](glossary/glossary.md) | +| Development resources | Preparing for your development | - [Obtaining Source Code](get-code/sourcecode-acquire.md)
- [Tool Acquisition](get-code/gettools-acquire.md) | +| Quick start | Getting started with setup, build,
 burning, debugging, and
 running of OpenHarmony | [Mini and Small Systems](quick-start/quickstart-lite-overview.md)) | +| Basic capabilities | Using basic capabilities of
 OpenHarmony | - [Kernel for Mini Systems](kernel/kernel-mini-overview.md)
- [Kernel for Small Systems](kernel/kernel-small-overview.md)
- [Drivers](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-mini-lite.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md) | +| Advanced development | Developing smart devices based
 on system capabilities | - [WLAN-connected Products](guide/device-wlan-led-control.md)
- [Cameras Without a Screen](guide/device-iotcamera-control-overview.md)
- [Cameras with a Screen](guide/device-camera-control-overview.md) | +| Porting and adaptation | - Porting and adapting the 
OpenHarmony to an SoC
- Porting and adapting the
 OpenHarmony to a
 third-party library | - [Mini System SoC Porting Guide](porting/oem_transplant_chip_prepare_knows.md)
- [Small System SoC Porting Guide](porting/porting-smallchip-prepare-needs.md)
- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty-overview.md) | +| Contributing components | Contributing components
 to OpenHarmony | - [HPM Part Overview](bundles/hpm-part-about.md)
- [HPM Part Development](bundles/hpm-part-development.md)
- [HPM Part Reference](bundles/hpm-part-reference.md) | +| Reference | Referring to development specifications | [FAQs](faqs/faqs-overview.md) | + **Table 2** Standard system development guidelines \(reference memory ≥ 128 MB\) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Topic

-

Development Scenario

-

Documents

-

About OpenHarmony

-

Getting familiar with OpenHarmony

-
-

Development resources

-

Preparing for your development

-
-

Quick start

-

Getting started with setup, build, burning, debugging, and running of OpenHarmony

-

Standard System

-

Basic capabilities

-

Using basic capabilities of OpenHarmony

-
-

Advanced development

-

Developing smart devices based on system capabilities

-
-

Porting and adaptation

-

Porting and adapting the OpenHarmony to a third-party library

-
-

Contributing components

-

Contributing components to OpenHarmony

-
-

Reference

-

Referring to development specifications

-
-
+| Topic | Development Scenario | Documents | +| -------- | -------- | -------- | +| About OpenHarmony | Getting familiar with OpenHarmony | - [About OpenHarmony](https://gitee.com/openharmony/docs/blob/master/en/OpenHarmony-Overview.md)
- [Glossary](glossary/glossary.md) | +| Development resources | Preparing for your development | - [Obtaining Source Code](get-code/sourcecode-acquire.md)
- [Tool Acquisition](get-code/gettools-acquire.md) | +| Quick start | Getting started with setup, build,
 burning, debugging, and
 running of OpenHarmony | [Standard System](quick-start/quickstart-standard-overview.md) | +| Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Standard Systems](kernel/kernel-standard-overview.md)
- [Drivers](driver/driver-hdf-overview.md)
- [Subsystems](subsystems/subsys-build-standard-large.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- [Privacy Protection](security/security-privacy-protection.md) | +| Advanced development | Developing smart devices
 based on system capabilities | - [Development Guidelines on Clock Apps](guide/device-clock-guide.md)
- [Development Example for Platform Drivers](guide/device-driver-demo.md)
- [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) | +| Porting and adaptation | Porting and adapting the
 OpenHarmony to a third-party library | - [Standard System Porting Guide](porting/standard-system-porting-guide.md)
- [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) | +| Contributing components | Contributing components
 to OpenHarmony | - [HPM Part Overview](bundles/hpm-part-about.md)
- [HPM Part Development](bundles/hpm-part-development.md)
- [HPM Part Reference](bundles/hpm-part-reference.md) | +| Reference | Referring to development specifications | [FAQs](faqs/faqs-overview.md) diff --git a/en/device-dev/faqs/faqs-burning.md b/en/device-dev/faqs/faqs-burning.md index c157de63787c14d919c9a9b271849bcbfa27b7a0..3d096a6c3b1f78f12555e13365e4ec151ce2c2c3 100644 --- a/en/device-dev/faqs/faqs-burning.md +++ b/en/device-dev/faqs/faqs-burning.md @@ -78,7 +78,7 @@ 2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB. - Select the U-Boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128) + Select the U-Boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](../quick-start/quickstart-lite-steps-hi3516-running.md)/[Programming Flash Memory on the Hi3518](../quick-start/quickstart-lite-steps-hi3518-running.md) 3. Log in to the serial port after the burning is complete. diff --git a/en/device-dev/guide/device-clock-guide.md b/en/device-dev/guide/device-clock-guide.md index 91454ad50c606446bea689e747d42c8a81879880..aabc19dc53b98c03eb56b41de2080ee729ad3a46 100644 --- a/en/device-dev/guide/device-clock-guide.md +++ b/en/device-dev/guide/device-clock-guide.md @@ -247,7 +247,7 @@ To build such an app, we can create a page that has a flexible layout with two r ## Signing and Packaging -After finishing writing the app code, you need to sign and package the app before running it on a real device. For details, see [Signing and Packaging Guide](../../application-dev/quick-start/configuring-openharmony-app-signature.md). +After finishing writing the app code, you need to sign and package the app before running it on a real device. For details, see [Signing and Packaging Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768)). ## Running on the Real Device diff --git a/en/device-dev/kernel/kernel-small-debug-user-guide-use-api.md b/en/device-dev/kernel/kernel-small-debug-user-guide-use-api.md index 5ed88069026d5cb7f980f77409895b34b801815a..2841f08b6e801f7eb12251102f22bdb1acedf249 100644 --- a/en/device-dev/kernel/kernel-small-debug-user-guide-use-api.md +++ b/en/device-dev/kernel/kernel-small-debug-user-guide-use-api.md @@ -40,7 +40,7 @@ int main() ## Compilation ``` -$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home//harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) +$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home//directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) ``` >![](../public_sys-resources/icon-note.gif) **NOTE:** @@ -48,7 +48,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp >- When compiling user programs and required libraries, add the option **-funwind-tables -rdynamic -g** for stack backtracking. >- The **-mfloat-abi=softfp**, **-mcpu=cortex-a7**, and **-mfpu=neon-vfpv4** options specify the floating-point calculation optimization, chip architecture, and FPU, which must be the same as the compilation options used by the libc library. Otherwise, the libc library file cannot be found during the link time. >- **-target arm-liteos** specifies the path of the library files related to the compiler. ->- **--sysroot=/home//harmony/out/hispark\_taurus/ipcamera\_hispark\_taurus/sysroot** specifies the root directory of the compiler library files. In this example, the OpenHarmony project code is stored in **/home//harmony**. The **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory indicates the product specified by the **hb set** command during compilation. In this example, **ipcamera\_hispark\_taurus** is the product specified. +>- **--sysroot=/home//directory/out/hispark\_taurus/ipcamera\_hispark\_taurus/sysroot** specifies the root directory of the compiler library files. In this example, the OpenHarmony project code is stored in **/home//directory**. The **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory indicates the product specified by the **hb set** command during compilation. In this example, **ipcamera\_hispark\_taurus** is the product specified. >- **$\(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a\)** specifies the path of the unwind library. ## Debugging Information diff --git a/en/device-dev/quick-start/figures/appearance-of-the-hi3861-mother-board.png b/en/device-dev/quick-start/figures/appearance-of-the-hi3861-mother-board.png index 8a4060e64fdd059143a3ec1adb9ee6937fa4af84..f58498fb620fb55c909c3ba5ae2f259470da0093 100644 Binary files a/en/device-dev/quick-start/figures/appearance-of-the-hi3861-mother-board.png and b/en/device-dev/quick-start/figures/appearance-of-the-hi3861-mother-board.png differ diff --git a/en/device-dev/quick-start/figures/hi3516d-v300-front-view-1.png b/en/device-dev/quick-start/figures/hi3516d-v300-front-view-1.png index 1ccb47f20022261cc291e8b435f263c00e8d4a27..d5cc1dc9d10c2346630068c18dfc1bcbe6b54583 100644 Binary files a/en/device-dev/quick-start/figures/hi3516d-v300-front-view-1.png and b/en/device-dev/quick-start/figures/hi3516d-v300-front-view-1.png differ diff --git a/en/device-dev/quick-start/figures/hi3516d-v300-front-view.png b/en/device-dev/quick-start/figures/hi3516d-v300-front-view.png index 1ccb47f20022261cc291e8b435f263c00e8d4a27..104d678519e65bbbc8ce84fbceb53210d826ba6d 100644 Binary files a/en/device-dev/quick-start/figures/hi3516d-v300-front-view.png and b/en/device-dev/quick-start/figures/hi3516d-v300-front-view.png differ diff --git a/en/device-dev/subsystems/subsys-application-framework-envbuild.md b/en/device-dev/subsystems/subsys-application-framework-envbuild.md index ce4868dc56950e71499b7e24654b859c665ee22c..54a1a61ee4dc397549fe03d2337111b792586ca4 100644 --- a/en/device-dev/subsystems/subsys-application-framework-envbuild.md +++ b/en/device-dev/subsystems/subsys-application-framework-envbuild.md @@ -2,6 +2,7 @@ - Development board: Hi3516D V300 -- [Download the source code](../get-code/sourcecode-acquire.md) -- [Build the application framework](../../readme/bundle-management.md). +- Download the source code + +- Build the application framework diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index 5df286d2676a52bb60d097feb926e00b2f2525b2..445c43acafcac18eb778f34eb42d5ca3fe2e78fc 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -101,18 +101,25 @@ C++ Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events. ``` - auto demoListener = std::make_shared(); - // Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD). - ListenerRule tagRule("dfx"); - // Add a ListenerRule object based on the event tag, with RuleType set as REGULAR. - ListenerRule regRule("dfx.*", RuleType::REGULAR); - // Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX. - ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); - std::vector sysRules; - sysRules.push_back(tagRule); - sysRules.push_back(regRule); - sysRules.push_back(domainNameRule); - HiSysEventManager::AddEventListener(demoListener, sysRules); + std::shared_ptr demoListener = nullptr; + try { + demoListener = std::make_shared(); + } catch(...) { + // Catch exception thrown by make_shared + } + if (demoListener != nullptr) { + // Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD). + ListenerRule tagRule("dfx"); + // Add a ListenerRule object based on the event tag, with RuleType set as REGULAR. + ListenerRule regRule("dfx.*", RuleType::REGULAR); + // Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX. + ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); + std::vector sysRules; + sysRules.push_back(tagRule); + sysRules.push_back(regRule); + sysRules.push_back(domainNameRule); + HiSysEventManager::AddEventListener(demoListener, sysRules); + } ``` 2. Configure the **BUILD.gn** file. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 8401862dae6b3bcdf4824334889bb9f6d28a37b6..f6c072308141ba071e5017c0c5212040c1b15cc9 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -86,10 +86,17 @@ C++ } // namespace OHOS // Invoke the query callback API to obtain system events. - auto queryCallBack = std::make_shared(); - struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector mRules; - HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack); + std::shared_ptr queryCallBack = nullptr; + try { + queryCallBack = std::make_shared(); + } catch(...) { + // Catch exception thrown by make_shared + } + if (queryCallBack != nullptr) { + struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); + std::vector rules; + HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack); + } ``` 2. Modify the **BUILD.gn** file. diff --git a/en/device-dev/website.md b/en/device-dev/website.md index dba892f0c1236579f9fe8f947200abf0172a9f5a..1ca0f668d0b4033c7c2bc4c6e3eddc27171c80ab 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -34,6 +34,7 @@ - [Burning Images](quick-start/quickstart-standard-burn.md) - [Running an Image](quick-start/quickstart-standard-running.md) - [FAQs](quick-start/quickstart-standard-faqs.md) + - [Obtaining Source Code](get-code/sourcecode-acquire.md) - Compatibility and Security - [Privacy Protection](security/security-privacy-protection.md) - [Security Guidelines](security/security-guidelines-overall.md) @@ -219,8 +220,8 @@ - [Magic Key](kernel/kernel-small-debug-shell-magickey.md) - [User-Space Exception Information](kernel/kernel-small-debug-shell-error.md) - [Trace](kernel/kernel-small-debug-trace.md) - - [perf](kernel/kernel-mini-memory-perf) - - [LMS](kernel/kernel-small-memory-lms) + - [perf](kernel/kernel-mini-memory-perf.md) + - [LMS](kernel/kernel-small-memory-lms.md) - Process Commissioning - [CPUP](kernel/kernel-small-debug-process-cpu.md) - Memory Debugging @@ -384,15 +385,9 @@ - [HiSysEvent Tool Usage](subsystems/subsys-dfx-hisysevent-tool.md) - Featured Topics - HPM Bundle - - [Development Specifications](bundles/bundles-standard-rules.md) - - Development Guidelines - - [Bundle Development](bundles/bundles-guide-overview.md) - - [Preparations](bundles/bundles-guide-prepare.md) - - [Bundle Development](bundles/bundles-guide-develop.md) - - HPM User Guide - - [Introduction](bundles/bundles-demo-hpmdescription.md) - - [Preparations](bundles/bundles-demo-environment.md) - - [Development Example](bundles/bundles-demo-devsample.md) + - [HPM Part Overview](bundles/hpm-part-about.md) + - [HPM Part Development](bundles/hpm-part-development.md) + - [HPM Part Reference](bundles/hpm-part-reference.md) - Device Development Examples - [Mini- and Small-System Devices](guide/device-lite.md) - [WLAN-connected Products](guide/device-wlan.md) diff --git a/en/readme/ai.md b/en/readme/ai.md index 0294ad8c5aca3d8cc8911f9f644a35cf4f99dc23..9eda709f64cabf5b22d3edf1d666f3fbda38d0cb 100644 --- a/en/readme/ai.md +++ b/en/readme/ai.md @@ -408,20 +408,20 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI ## Repositories Involved -AI subsystem: +[AI subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ai.md) -ai\_engine +[ai_engine](https://gitee.com/openharmony/ai_engine) Dependency repositories: -build\_lite +[build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README.md) -distributedschedule\_services\_samgr\_lite +[distributedschedule\_samgr\_lite](https://gitee.com/openharmony/distributedschedule_samgr_lite/blob/master/README.md) -startup\_init\_lite +[startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README.md) ## Reference -[AI Engine Framework Development Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/development-examples.md) +[AI Engine Framework Development Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-aiframework-guide.md) diff --git a/en/readme/graphics.md b/en/readme/graphics.md index 2b659df208b122472b0eb36cd8b87056478f5002..bdf107f3206d854d29bd3a8cc2d42ab4af18e2c9 100644 --- a/en/readme/graphics.md +++ b/en/readme/graphics.md @@ -13,7 +13,7 @@ The Graphics subsystem mainly consists of user interface \(UI\) components, layo The related modules are described as follows: -- View: provides application components, including UIView, UIViewGoup, UIButton, UILabel, UILabelButton, UIList, and UISlider. +- View: provides application components, including UIView, UIViewGroup, UIButton, UILabel, UILabelButton, UIList, and UISlider. - Animator: defines functions for customizing animators. - Layout: lays out components, including Flexlayout, GridLayout, and ListLayout. - Transform: rotates, translates, or scales images. @@ -98,7 +98,7 @@ The following figure shows the architecture of the Graphics subsystem. Provides multi-window capabilities. -- Input Manger +- Input Manager Functions as the multimodal input module that receives input events. diff --git a/zh-cn/OpenHarmony-Overview_zh.md b/zh-cn/OpenHarmony-Overview_zh.md index a20a54b234aa6cc76ec2c62464fbe831d22b96ac..7ffbea5ed269926310d193d8b6bed0eb355d1d04 100644 --- a/zh-cn/OpenHarmony-Overview_zh.md +++ b/zh-cn/OpenHarmony-Overview_zh.md @@ -5,6 +5,7 @@ - [技术特性](#section12212842173518) - [系统类型](#section145241459142416) - [详细特征](#section25831825174419) +- [支持的开发板](#section25831825174123) - [快速入门](#section44681652104210) - [代码仓地址](#section107651249181914) - [开发者文档](#section21031470109) @@ -128,6 +129,7 @@ OpenHarmony支持如下几种系统类型: 以下为OpenHarmony中相关的子系统简介,详细介绍见子系统Readme文档,入口:[https://gitee.com/openharmony/docs/tree/master/zh-cn/readme](https://gitee.com/openharmony/docs/tree/master/zh-cn/readme)。 + - @@ -301,14 +303,14 @@ OpenHarmony支持如下几种系统类型: - - @@ -344,11 +346,23 @@ OpenHarmony支持如下几种系统类型:

子系 统

简 介

@@ -195,7 +197,7 @@ OpenHarmony支持如下几种系统类型:

升级服务

可支持OpenHarmony设备的OTA(Over The Air)升级。

+

可支持OpenHarmony设备的OTA(Over The Air)升级。

标准系统

分布式软总线

分布式软总线旨在为OpenHarmony系统提供跨进程或跨设备的通信能力,主要包含软总线和进程间通信两部分。其中,软总线为应用和系统提供近场设备间分布式通信的能力,提供不区分通信方式的设备发现,连接,组网和传输功能;而进程间通信则提供不区分设备内或设备间的进程间通信能力。

+

分布式软总线旨在为OpenHarmony系统提供跨进程或跨设备的通信能力,主要包含软总线和进程间通信两部分。其中,软总线为应用和系统提供近场设备间分布式通信的能力,提供不区分通信方式的设备发现,连接,组网和传输功能;而进程间通信则提供了对设备内或设备间无差别的进程间通信能力。

所有系统

XTS

XTS是OpenHarmony生态认证测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套,后续会拓展dcts(device compatibility test suite)设备兼容性测试套等。

+

XTS是OpenHarmony兼容性测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套,后续会拓展dcts(device compatibility test suite)设备兼容性测试套等。

所有系统

-## 快速入门 +## 支持的开发板 + +当前OpenHarmony社区支持以下6款开发板,具体介绍如下: -- 设备开发快速入门:[device-dev/quick-start/Readme-CN.md](device-dev/quick-start/Readme-CN.md) -- 应用开发快速入门:[application-dev/quick-start/Readme-CN.md](application-dev/quick-start/Readme-CN.md) +| 系统类型 | 开发板型号 | 芯片型号 | 主要能力 | 典型应用场景 | 开发板代码仓 | 社区每日构建版本获取 | +| -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| 标准系统 | Hi3516DV300 | Hi3516DV300 | Hi3516DV300是新一代Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器、高性能NNIE引擎,在低码率、高画质、智能处理和分析、低功耗等方面有较好的性能。 | 可用在带屏设备上,比如带屏冰箱、车机等。 | [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)
[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)
[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) | 社区每日构建版本获取地址:http://ci.openharmony.cn/dailybuilds| +| 标准系统 | 润和DAYU200 | RK3568 | 润和HH-SCDAYU200是基于Rockchip RK3568,集成双核心架构GPU以及高效能NPU;板载四核64位Cortex-A55 处理器采用22nm先进工艺,主频高达2.0GHz;支持蓝牙、Wi-Fi、音频、视频和摄像头等功能,拥有丰富的扩展接口,支持多种视频输入输出接口;配置双千兆自适应RJ45以太网口,可满足NVR、工业网关等多网口产品需求。 | 影音娱乐、智慧出行、智能家居,如烟机、烤箱、跑步机等。 | [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) | +| 轻量 | 汇顶GR5515-STARTER-KIT | GR5515 | 支持Bluetooth 5.1的单模低功耗蓝牙SoC,多功能按键和LED指示灯。 | 智能硬件,如手表、手环、价格类标签。 | [device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)
[device_board_goodix](https://gitee.com/openharmony/device_board_goodix) | +| 轻量 | 郎国LANG0200 | ASR582X | LANG0200 IOT开发板,集成了高性能的WIFI-BLE双模芯片ASR5822、外部存储芯片、语音播放芯片以及模数转换等,同时支持SPI等IOT设备常用外设接口,可外扩OLED显示屏、红外遥控等。 | 智能家居连接类模组。 | [device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)
[device_board_lango](https://gitee.com/openharmony/device_board_lango)
[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro) | +| 轻量 | 欧智通V200ZR | BES2600 | Multi-modal V200Z-R开发板是基于恒玄科技BES2600WM芯片的一款高性能、多功能、高性价比AIoT SoC开发板Multi-modal V200Z-R开发板,单模组集成四核ARM处理器(最高主频1GHz),集成双频WiFi + 双模蓝牙,支持标准的802.11 a/b/g/n/协议,支持BT/BLE 5.2协议,内建多种容量的RAM(最大42MB)和Flash(最大32MB),支持MIPI DSI及CSI,适用于各种AIoT多模态VUI + GUI交互硬件场景。 | 智能硬件带屏类模组产品,如音箱、手表等。 | [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)
[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)
[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) | +| 轻量 | 小熊派BearPi-HM Nano | Hi3861 | BearPi-HM_Nano开发板是一块专门为OpenHarmony设计的开发板,板载高度集成的2.4GHz WiFi SoC芯片Hi3861,并板载NFC电路及标准的E53接口,标准的E53接口可扩展智能加湿器、智能台灯、智能安防、智能烟感等案例。 | 智慧路灯、智慧物流、人体红外等连接类设备。 | [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)
[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)
[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi) | + +## 快速入门 +- [设备开发快速入门](device-dev/quick-start/quickstart-ide-lite-overview.md) +- [应用开发快速入门](application-dev/quick-start/start-overview.md) ## 代码仓地址 diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 410850413bf83f387027b0a706063d1fe54e2ecb..395ccdf29dd656986c403c68310cd8fcb7228ccb 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -3,11 +3,17 @@ - [应用开发导读](application-dev-guide.md) - 了解OpenHarmony - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - - [术语](../device-dev/glossary/glossary.md) + - [术语](../glossary.md) - [版本说明](../release-notes/Readme.md) - 快速开始 - - [应用开发快速入门](quick-start/Readme-CN.md) - - [应用开发包结构说明](quick-start/package-structure.md) + - 快速入门 + - [前言](quick-start/start-overview.md) + - [使用eTS语言开发](quick-start/start-with-ets.md) + - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) + - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) + - 开发基础知识 + - [应用开发包结构说明](quick-start/package-structure.md) + - [资源文件的分类](quick-start/basic-resource-file-categories.md) - 开发 - [Ability开发](ability/Readme-CN.md) - [UI开发](ui/Readme-CN.md) diff --git a/zh-cn/application-dev/ability/Readme-CN.md b/zh-cn/application-dev/ability/Readme-CN.md index 1cc9425d38e5c9ae19989a031a07617805e4fd5f..cf4dd4d97bd16cc17ef8b3eeca7061c020749325 100644 --- a/zh-cn/application-dev/ability/Readme-CN.md +++ b/zh-cn/application-dev/ability/Readme-CN.md @@ -1,19 +1,10 @@ # Ability开发 - - [Ability框架概述](ability-brief.md) - - FA模型 - - [FA模型综述](fa-brief.md) - - [PageAbility开发指导](fa-pageability.md) - - [ServiceAbility开发指导](fa-serviceability.md) - - [DataAbility开发指导](fa-dataability.md) - - [FA卡片开发指导](fa-formability.md) - - Stage模型 - - [Stage模型综述](stage-brief.md) - - [Ability开发指导](stage-ability.md) - - [ServiceExtensionAbility开发指导](stage-serviceextension.md) - - [跨端迁移开发指导](stage-ability-continuation.md) - - [Call调用开发指导](stage-call.md) - - [Stage卡片开发指导](stage-formextension.md) - - 其他 - - [WantAgent开发指导](wantagent.md) - - [Ability助手使用指导](ability-assistant-guidelines.md) - - [测试框架使用指导](ability-delegator.md) +- [FA模型综述](fa-brief.md) +- [PageAbility开发指导](fa-pageability.md) +- [ServiceAbility开发指导](fa-serviceability.md) +- [DataAbility开发指导](fa-dataability.md) +- [FA卡片开发指导](fa-formability.md) +- 其他 + - [WantAgent开发指导](wantagent.md) + - [Ability助手使用指导](ability-assistant-guidelines.md) + - [测试框架使用指导](ability-delegator.md) diff --git a/zh-cn/application-dev/ability/ability-assistant-guidelines.md b/zh-cn/application-dev/ability/ability-assistant-guidelines.md index 02ac9057198c5b78f334879c8fbbafd1cb1f2510..6a3745fe0b00273eb0b34efba10de4206f37690e 100644 --- a/zh-cn/application-dev/ability/ability-assistant-guidelines.md +++ b/zh-cn/application-dev/ability/ability-assistant-guidelines.md @@ -1,6 +1,6 @@ # Ability助手使用指导 -Ability assistant(Ability助手,简称为aa)是实现应用、原子化服务及测试用例启动功能,为开发者提供基本的调试及测试应用的工具。通过该工具,开发者可以在hdc shell中,发出命令以执行各种系统操作,比如启动Ability、强制停止进程、打印Ability相关信息等。 +Ability assistant(Ability助手,简称为aa)是实现应用、原子化服务、及测试用例启动功能的工具,为开发者提供基本的应用调试和测试的能力。通过该工具,开发者可以在hdc shell中,发送命令以执行各种系统操作,比如启动Ability、强制停止进程、打印Ability相关信息等。 ## 开发指导 @@ -87,15 +87,15 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 ``` aa dump -a ``` - ![aa-dump-a](figures/aa-dump-a.png) + ![aa-dump-a](figures/aa-dump-a.PNG) ``` aa dump -l ``` - ![aa-dump-l](figures/aa-dump-l.png) + ![aa-dump-l](figures/aa-dump-l.PNG) ``` aa dump -i 12 ``` -![aa-dump-i](figures/aa-dump-i.png) + ![aa-dump-i](figures/aa-dump-i.PNG) - **force-stop** 通过bundle name强制停止一个进程。 diff --git a/zh-cn/application-dev/ability/ability-brief.md b/zh-cn/application-dev/ability/ability-brief.md deleted file mode 100644 index 2deda438bf166380bedbf0d31b55ea2bc08c0f07..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/ability-brief.md +++ /dev/null @@ -1,31 +0,0 @@ -# Ability框架概述 - -​ Ability是应用所具备能力的抽象,也是应用程序的重要组成部分。Ability是系统调度应用的最小单元,是能够完成一个独立功能的组件,一个应用可以包含一个或多个Ability。 - -​ Ability框架模型结构具有两种形态: - -- 第一种形态为FA模型。API 8及其更早版本的应用程序只能使用FA模型进行开发。 FA模型将Ability分为FA(Feature Ability)和PA(Particle Ability)两种类型,其中FA支持Page Ability,PA支持Service Ability、Data Ability、以及FormAbility; -- 第二种形态为Stage模型。从API 9开始,Ability框架引入了Stage模型作为第二种应用形态,Stage模型将Ability分为Ability和ExtensionAbility两大类,其中ExtensionAbility又被扩展为ServiceExtensionAbility、FormExtensionAbility、DataShareExtensionAbility等等一系列ExtensionAbility,以便满足更多的使用场景。 - -​ Stage模型的设计,主要是为了方便开发者更加方便地开发出分布式环境下的复杂应用。下表给出了两种模型在设计上的差异: - -| 对比 | FA模型 | Stage模型 | -| -------------- | ------------------------------------------------------------ | -------------------------------------------------------- | -| 开发方式 | 提供类Web的 api,UI开发与Stage模型一致。 | 提供面向对象的开发方式,UI开发与FA模型一致。 | -| 引擎实例 | 每个进程内的每个Ability独享一个JS VM引擎实例。 | 每个进程内的多个Ability实例共享一个JS VM引擎实例。 | -| 进程内对象共享 | 不支持。 | 支持。 | -| 包描述文件 | 使用config.json描述HAP包和组件信息,组件必须使用固定的文件名。 | 使用module.json描述HAP包和组件信息,可以指定入口文件名。 | -| 组件 | 提供PageAbility(页面展示),ServiceAbility(服务),DataAbility(数据分享), FormAbility(卡片)。 | 提供Ability(页面展示)、Extension(基于场景的服务扩展)。 | - -​ 除了上述设计上的差异外,对于开发者而言,两种模型的主要区别在于: - -* Ability类型存在差异; - - ![favsstage](figures/favsstage.png) - -* Ability生命周期存在差异; - - ![lifecycle](figures/lifecycle.png) - - -​ 两种模型的基本介绍,详见[FA模型综述](fa-brief.md)及[Stage模型综述](stage-brief.md)。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/ability-delegator.md b/zh-cn/application-dev/ability/ability-delegator.md index aab7f699807e8ff43b87ba84ab96bc1162e96ac0..3a470e83dff9e91607a42df6cd11317adbdeacaf 100755 --- a/zh-cn/application-dev/ability/ability-delegator.md +++ b/zh-cn/application-dev/ability/ability-delegator.md @@ -10,7 +10,11 @@ Delegator测试框架是OpenHarmony提供的一套开发者应用自测试框架 ## 测试框架启动 -测试框架启动有两种方式,方式一:通过`aa test`命令启动,方式二:通过IDE启动。 +测试框架启动有两种方式: + +- 方式一:通过`aa test`命令启动。 +- 方式二:通过IDE启动。 + ### aa test启动 开发者可通过 `aa test` 命令启动启动测试框架,开发者可以自行指定使用的runner以及runner所在hap包的package name/module name,具体命令示例如下: diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index ee4bd1c1680d875b8189bf84fb4090f5b5cbec02..5ccb3b88869bf5cc05eb7564921cdab8cf8f5f5c 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -1,12 +1,12 @@ -# FA模型综述 +# Ability综述 ## 整体架构 -OpenHarmony用户程序的开发本质上就是开发Ability,OpenHarmony系统也是通过调度Ability,通过系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。 +OpenHarmony用户程序的开发本质上就是开发Ability。OpenHarmony系统是通过对Ability调度,结合系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。 Ability框架在API 8及更早版本使用FA模型。FA模型中Ability分为PageAbility、ServiceAbility、DataAbility、FormAbility几种类型。其中: -- PageAbility是具备ArkUI实现的Ability,是用户具体可见并可以交互的Ability实例; -- ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行; -- DataAbility也是没有UI的Ability,提供其他Ability进行数据的增删查服务,在后台运行; +- PageAbility是具备ArkUI实现的Ability,是用户具体可见并可以交互的Ability实例。 +- ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行。 +- DataAbility也是没有UI的Ability,提供其他Ability进行数据的增删查服务,在后台运行。 - FormAbility是卡片Ability,是一种界面展示形式。 ## 应用包结构 @@ -14,7 +14,7 @@ Ability框架在API 8及更早版本使用FA模型。FA模型中Ability分为Pag ![fa-package-info](figures/fa-package-info.png) -应用包结构的配置请参见[包结构说明](../quick-start/package-structure.md)。 +应用包结构的配置请参见[应用包结构配置文件的说明](../quick-start/package-structure.md)。 ## 生命周期 diff --git a/zh-cn/application-dev/ability/fa-dataability.md b/zh-cn/application-dev/ability/fa-dataability.md index ffd04efb5b54eab5225486e27df7d19fa6ed1088..682d23b1fadc33b85d7d7466e758ecf9ea9b38fd 100644 --- a/zh-cn/application-dev/ability/fa-dataability.md +++ b/zh-cn/application-dev/ability/fa-dataability.md @@ -276,9 +276,9 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 针对dataAbility开发,有以下示例工程可供参考: -- [eTSDataAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSDataAbility) +- [DataAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/DataAbility) -本示例eTSDataAbility中: +本示例DataAbility中: 在DataAbility目录中的data.ts文件创建一个Data实例。 diff --git a/zh-cn/application-dev/ability/fa-formability.md b/zh-cn/application-dev/ability/fa-formability.md index b2ee576395c1aac87630656e6df016a1b21bca72..7bccb13b64844658e4357ad14be4b0f3a10b1298 100644 --- a/zh-cn/application-dev/ability/fa-formability.md +++ b/zh-cn/application-dev/ability/fa-formability.md @@ -231,7 +231,7 @@ Form需要在应用配置文件config.json中进行配置。 } ``` -具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。 +具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-storage-guidelines.md)。 需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片: @@ -324,4 +324,12 @@ Form需要在应用配置文件config.json中进行配置。 最终可以得到,如下卡片: -![fa-form-example](figures/fa-form-example.png) \ No newline at end of file +![fa-form-example](figures/fa-form-example.png) + +## 开发实例 + +针对FA模型卡片提供方的开发,有以下示例工程可供参考: + +[FormAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/FormAbility) + +本示例FormAbility提供了一张卡片。用户可以通过桌面或者自己开发的卡片使用方,进行卡片的创建、更新和删除等操作。并且本示例通过轻量级数据存储实现了卡片信息的持久化。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index 724b309120b5eab643bb891f4b77bb4b68c34672..54ff540cec4b0f031682b2b6e7b4152f2028e0dc 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -2,28 +2,30 @@ ## 概述 ### 功能简介 -PageAbility是具备ArkUI实现的Ability,是开发者具体可见并可以交互的Ability实例,开发者通过IDE创建Ability时,IDE会自动创建相关模板代码。PageAbility相关能力通过单例featureAbility暴露,生命周期相关回调通过app.js/app.ets中回调函数暴露。 +PageAbility是具备ArkUI实现的Ability,是开发者具体可见并可以交互的Ability实例。开发者通过IDE创建Ability时,IDE会自动创建相关模板代码。PageAbility相关能力通过单独的featureAbility实现,生命周期相关回调则通过app.js/app.ets中各个回调函数实现。 ### PageAbility的生命周期 -**Ability生命周期介绍**(Ability Life Cycle): +**PageAbility生命周期介绍**(Ability Life Cycle): -Ability生命周期是Ability被调度到INACTIVE、ACTIVE、BACKGROUND等各个状态的统称。PageAbility生命周期流转如下图所示: +PageAbility生命周期是PageAbility被调度到INACTIVE、ACTIVE、BACKGROUND等各个状态的统称。 + +PageAbility生命周期流转如下图所示: ![PageAbility-Lifecycle](figures/page-ability-lifecycle.png) **Ability生命周期状态说明:** - - **UNINITIALIZED**:未初始状态,为临时状态,Ability被创建后会由UNINITIALIZED状态进入INITIAL状态。 + - **UNINITIALIZED**:未初始状态,为临时状态,PageAbility被创建后会由UNINITIALIZED状态进入INITIAL状态。 - - **INITIAL**:初始化状态,也表示停止状态,表示当前Ability未运行,Ability被启动后由INITIAL态进入INACTIVE状态。 + - **INITIAL**:初始化状态,也表示停止状态,表示当前PageAbility未运行,PageAbility被启动后由INITIAL态进入INACTIVE状态。 - **INACTIVE**:失去焦点状态,表示当前窗口已显示但是无焦点状态。 - **ACTIVE**:前台激活状态,表示当前窗口已显示,并获取焦点。 - - **BACKGROUND**:后台状态,表示当前Ability退到后台,Ability在被销毁后由BACKGROUND状态进入INITIAL状态,或者重新被激活后由BACKGROUND状态进入ACTIVE状态。 + - **BACKGROUND**:后台状态,表示当前PageAbility退到后台,PageAbility在被销毁后由BACKGROUND状态进入INITIAL状态,或者重新被激活后由BACKGROUND状态进入ACTIVE状态。 **PageAbility生命周期回调与生命周期状态的关系如下图所示:** @@ -31,6 +33,18 @@ Ability生命周期是Ability被调度到INACTIVE、ACTIVE、BACKGROUND等各个 PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写生命周期相关回调函数 。目前`app.js`环境中仅支持onCreate和onDestroy回调,`app.ets`环境支持全量生命周期回调。 +### 启动模式 +ability支持单实例、多实例和指定实例3种启动模式。 +在config.json中通过launchType配置项,可以配置具体的启动模式,其中: + +| 启动模式 | 描述 |说明 | +| ----------- | ------- |---------------- | +| standard | 多实例 | 每次startAbility都会启动一个新的实例 | +| singleton | 单实例 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例 | +| specified | 指定实例 | 运行时由ability内部业务决定是否创建多实例 | + +缺省情况下是standard模式。 + ## 开发指导 ### featureAbility接口说明 @@ -100,6 +114,7 @@ PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写 ``` `want`参数也可以使用parameters参数,使用key-value的方式输入。 + **示例** ```javascript @@ -148,6 +163,7 @@ PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写 ``` 从DeviceManager获取`deviceId`,具体示例代码如下: + ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; let dmClass; @@ -166,7 +182,8 @@ PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写 } ``` -在跨设备场景下,需要向开发者申请数据同步的权限。具体示例代码如下: +在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: + ```ts import abilityAccessCtrl from "@ohos.abilityAccessCtrl"; import bundle from '@ohos.bundle'; @@ -204,18 +221,20 @@ PageAbility提供命周期回调,开发者可以在`app.js/app.ets`中重写 ``` ### 生命周期接口说明 + **表2** 生命周期回调函数介绍 | 接口名 | 描述 | | ------------ | ------------------------------------------------------------ | -| onShow() | Ability由后台不可见状态切换到前台可见状态调用onShow方法,此时开发者在屏幕可以看到该Ability | -| onHide() | Ability由前台切换到后台不可见状态时调用onHide方法,此时开发者在屏幕看不到该Ability。 | +| onShow() | Ability由后台不可见状态切换到前台可见状态调用onShow方法,此时用户在屏幕可以看到该Ability | +| onHide() | Ability由前台切换到后台不可见状态时调用onHide方法,此时用户在屏幕看不到该Ability。 | | onDestroy() | 应用退出,销毁Ability对象前调用onDestroy方法,开发者可以在该方法里做一些回收资源、清空缓存等应用退出前的准备工作。 | | onCreate() | Ability第一次启动创建Ability时调用onCreate方法,开发者可以在该方法里做一些应用初始化工作。 | | onInactive() | Ability失去焦点时调用onInactive方法,Ability在进入后台状态时会先失去焦点,再进入后台。 | | onActive() | Ability切换到前台,并且已经获取焦点时调用onActive方法。 | **示例** + 开发者需要重写`app.js/app.ets`中相关生命周期回调函数,IDE模板默认生成`onCreate()`和`onDestroy()`方法,其他方法需要开发者自行实现。 ```javascript diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index ea740e6904d06a7e7e0ccec9e4d2142e93566346..f0b676b53d610a4b8f362dd78da727cc62ff8cf4 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -390,9 +390,9 @@ export default { ### 针对serviceAbility开发,有以下示例工程可供参考: -- [eTSServiceAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSServiceAbility) +- [ServiceAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility) -本示例eTSServiceAbility中: +本示例ServiceAbility中: 在ServiceAbility目录中的service.ts文件创建一个本地Service。 diff --git a/zh-cn/application-dev/ability/figures/ExtensionAbility.png b/zh-cn/application-dev/ability/figures/ExtensionAbility.png deleted file mode 100644 index 3287f23c7587e3980ca32efe275d5b672e6b9903..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/ExtensionAbility.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/continuation-info.png b/zh-cn/application-dev/ability/figures/continuation-info.png deleted file mode 100755 index 69c38949921686520378a118df2e9f82912967a8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/continuation-info.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/favsstage.png b/zh-cn/application-dev/ability/figures/favsstage.png deleted file mode 100644 index 45f6b0ef255b01730dc42023430391e1141291c2..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/favsstage.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/lifecycle.png b/zh-cn/application-dev/ability/figures/lifecycle.png deleted file mode 100644 index 694238d99c7e70d16d6bd1a37c86bcd599a9b2f3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/lifecycle.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png b/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png deleted file mode 100644 index 4c94556b5c2516ad2978a9a31d833cfb2cf3dd01..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/stage-call.png b/zh-cn/application-dev/ability/figures/stage-call.png deleted file mode 100644 index 28f2a0f7ea9d86fc81e0c1a37d556384b14a9bdd..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/stage-call.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/stageabilitylifecyclecallback.png b/zh-cn/application-dev/ability/figures/stageabilitylifecyclecallback.png deleted file mode 100644 index 9e17ed71f1dc9d118a490109c1e5181d738e63db..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/stageabilitylifecyclecallback.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/stageconcept.png b/zh-cn/application-dev/ability/figures/stageconcept.png deleted file mode 100644 index 8b14ea5430b7c94092eca2f6ef9aee350b006504..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/stageconcept.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/stagedesign.png b/zh-cn/application-dev/ability/figures/stagedesign.png deleted file mode 100644 index 75f5344d83e7c1c60a0a480042473a10a701449d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/stagedesign.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/stageprocessmodel.png b/zh-cn/application-dev/ability/figures/stageprocessmodel.png deleted file mode 100644 index 18745767786674c496d6a41afe2e8df937745a4d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/stageprocessmodel.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/stage-ability-continuation.md b/zh-cn/application-dev/ability/stage-ability-continuation.md deleted file mode 100755 index 45909d126ca25d83298a39058a41c5d77e333cbc..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-ability-continuation.md +++ /dev/null @@ -1,232 +0,0 @@ -# 跨端迁移开发指导 - -## 场景介绍 - -迁移的主要工作是实现将应用当前任务,包括页面控件状态变量、分布式对象等,迁移到远端设备。页面控件状态变量用于同步页面UI数据,分布式对象用于同步内存中的数据。 - -## 接口说明 - -迁移提供的能力如下,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md)。 - -**表1** 应用迁移API接口功能介绍 - -|接口名 | 描述| -|:------ | :------| -| onContinue(wantParams : {[key: string]: any}): OnContinueResult | 迁移**发起端**在该回调中保存迁移所需要的数据,同时返回是否同意迁移:0表示同意,拒绝返回相应错误码。 | -| onCreate(want: Want,param:LaunchParam): void | 迁移**目标端**在该回调中完成数据恢复,并触发页面恢复。 | -| **enum** OnContinueResult | onContinue的返回值类型:AGREE表示同意;REJECT表示拒绝;MISMATCH表示版本不匹配 | - - - -**图1** 迁移开发示意图 - -![continuation_dev](figures/continuation-info.png) - -## 开发步骤 - -### 迁移应用 - -1. 配置 - - - 配置应用支持迁移 - - 在module.json5中配置continuable字段:true表示支持迁移,false表示不支持,默认为false。配置为false的应用将被系统识别为无法迁移。 - - ```javascript - "continuable": true - ``` - - - - * 配置应用启动类型 - - 迁移当前只支持多实例应用,需要在在module.json5中配置launchType字段为standard。 - - ```javascript - "launchType": "standard" - ``` - - - - * 申请分布式权限 - - 支持跨端迁移的应用需要在module.json5申请分布式权限 DISTRIBUTED_DATASYNC。 - - ```javascript - "requestPermissions": [ - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" - }, - ``` - - 这个权限需要在应用首次启动的时候弹窗让用户授予,可以通过在ability的onWindowStageCreate中添加如下代码实现: - - ```javascript - requestPermissions = async () => { - let permissions: Array = [ - "ohos.permission.DISTRIBUTED_DATASYNC" - ]; - let needGrantPermission = false - let accessManger = accessControl.createAtManager() - Logger.info("app permission get bundle info") - let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100) - Logger.info(`app permission query permission ${bundleInfo.accessTokenId.toString()}`) - for (const permission of permissions) { - Logger.info(`app permission query grant status ${permission}`) - try { - let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission) - if (grantStatus === PERMISSION_REJECT) { - needGrantPermission = true - break; - } - } catch (err) { - Logger.error(`app permission query grant status error ${permission} ${JSON.stringify(err)}`) - needGrantPermission = true - break; - } - } - if (needGrantPermission) { - Logger.info("app permission needGrantPermission") - try { - await this.context.requestPermissionsFromUser(permissions) - } catch (err) { - Logger.error(`app permission ${JSON.stringify(err)}`) - } - } else { - Logger.info("app permission already granted") - } - } - ``` - - - -2. 实现onContinue接口 - - onContinue接口在**发起端**被调用,主要用于在迁移发起时,通知开发者保存控件状态变量和内存中数据,准备迁移。当应用准备完成后,需要返回OnContinueResult.AGREE(0)表示同意迁移,否则返回相应的错误码拒绝迁移。如果不实现该接口,系统将默认为拒绝迁移。 - - 导入模块 - - ```javascript - import Ability from '@ohos.application.Ability'; - import AbilityConstant from '@ohos.application.AbilityConstant'; - ``` - - - 要实现迁移,此接口必须实现并返回AGREE,否则默认为拒绝迁移。 - - - - 示例 - - ```javascript - onContinue(wantParam : {[key: string]: any}) { - Logger.info("onContinue using distributedObject") - // set user input data into want params - wantParam["input"] = AppStorage.Get('ContinueInput'); - Logger.info(`onContinue input = ${wantParam["input"]}`); - return AbilityConstant.OnContinueResult.AGREE - } - ``` - - - -3. 在onCreate接口中实现迁移逻辑 - - onCreate接口在迁移**目标端**被调用,在目标端ability被拉起时,通知开发者同步已保存的内存数据和控件状态,完成后触发页面的恢复。如果不实现该接口中迁移相关逻辑,ability将会作为普通的启动方式拉起,无法恢复页面。 - - - 远端设备上,在onCreate中根据launchReason判断该次启动是否为迁移LaunchReason.CONTINUATION - - - - 完成数据恢复后,开发者需要调用**restoreWindowStage**来触发页面恢复。 - - - * 示例 - - ```javascript - onCreate(want, launchParam) { - Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) - globalThis.abilityWant = want; - if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) { - let input = want.parameters.input // get user data from want params - AppStorage.SetOrCreate('ContinueInput', input) - Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`) - - this.contentStorage = new ContentStorage(); - this.context.restoreWindowStage(this.contentStorage); - } - } - ``` - - - -### 迁移数据 - -1. 使用分布式对象 - - 分布式数据对象提供了与本地变量类似的操作,实现两个设备的数据同步,当设备1的应用A的分布式数据对象增、删、改数据后,设备2的应用A也可以获取到对应的数据变化,同时还能监听数据变更以及对端数据对象的上下线。用法详见[分布式对象指导文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/database/database-distributedobject-guidelines.md)。 - - 迁移场景中,分布式对象(distributedDataObject)主要用于将本机内存数据同步到目标设备。 - - - 发起端在onContinue中,将待迁移的数据存入分布式对象中,然后设置好session id,并通过wantParams将session id传到远端设备。 - - ```javascript - import Ability from '@ohos.application.Ability'; - import distributedObject from '@ohos.data.distributedDataObject'; - - var g_object = distributedObject.createDistributedObject({name:undefined}); - - export default class MainAbility extends Ability { - contentStorage : ContenStorage - sessionId : string; - - onContinue(wantParam : {[key: string]: any}) { - Logger.info("onContinue using distributedObject") - this.sessionId = distributedObject.genSessionId(); - //set distributed data object session id - g_object.setSessionId(this.sessionId); - g_object.name = "Amy"; - // set session id into want params - wantParam["session"] = this.sessionId; - return AbilityConstant.OnContinueResult.AGREE - } - - ``` - - - 目标设备在onCreate中,取出发起端传过来的session id,建立分布式对象并关联该session id,这样就能实现分布式对象的同步。需要注意的是,在调用restoreWindowStage之前,迁移需要的分布式对象必须全部关联完,保证能够获取到正确的数据。 - - ```javascript - import Ability from '@ohos.application.Ability'; - import distributedObject from '@ohos.data.distributedDataObject'; - - var g_object = distributedObject.createDistributedObject({name:undefined}); - - export default class MainAbility extends Ability { - contentStorage : ContentStorage - sessionId : string; - - statusCallback(sessionId, networkid, status) { - Logger.info(`continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`) - } - - onCreate(want, launchParam) { - Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) - if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) { - // get distributed data object session id from want params - this.sessionId = want.parameters.session - Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`) - - g_object.on("status", this.statusCallback); - // set session id, so it will sync data from remote device - g_object.setSessionId(this.sessionId); - - this.contentStorage = new ContentStorage(); - this.context.restoreWindowStage(this.contentStorage); - } - } - } - ``` - - - -以上完整的示例见sample - - - diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md deleted file mode 100644 index dafb7e4337e502f3c297a1934ce23d45596a2aad..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-ability.md +++ /dev/null @@ -1,267 +0,0 @@ -# Ability开发指导 -## 场景介绍 -Stage模型是基于API version 9的应用开发模型,对此模型的介绍详见[Stage模型综述](stage-brief.md)。基于Stage模型的Ability应用开发,主要涉及如下功能逻辑: -- 创建Page Ability应用,如视频播放、新闻资讯等,需要通过屏幕进行浏览的应用,以及支持人机交互。 -- 获取Ability的配置信息,如ApplicationInfo、AbilityInfo及HapModuleInfo等。 -- 启动/带参数启动/带返回结果启动/带AccountId启动其他Ability。 -- 应用向用户申请授权。 -- 系统环境变化通知给AbilityStage及Ability。 -- 通用组件Call功能,详见[Call调用开发指导](stage-call.md)。 -- 连接ServiceAbility,与ServiceAbility断开连接,详见[ServiceExtensionAbility开发指导](stage-serviceextension.md)。 -- 应用迁移,详见[应用迁移开发指导](stage-ability-continuation.md)。 - -## 接口说明 -AbilityStage功能如下(AbilityStage类,拥有context属性,具体的API详见[接口文档](../reference/apis/js-apis-application-abilitystage.md)): - -**表1** AbilityStage API接口功能介绍 -|接口名|描述| -|:------|:------| -|void onCreate()|AbilityStage初始化时被调用。| -|string onAcceptWant(want: Want)|启动指定Ability时被调用。| -|void onConfigurationUpdated(config: Configuration)|全局配置发生变更时被调用。| - -Ability功能如下(Ability类,具体的API详见[接口文档](../reference/apis/js-apis-application-ability.md)): - -**表2** Ability API接口功能介绍 -|接口名|描述| -|:------|:------| -|void onCreate(want: Want, param: AbilityConstant.LaunchParam)|Ability生命周期回调,Ability启动时被调用。| -|void onDestroy()|Ability生命周期回调,Ability销毁时被调用。| -|void onWindowStageCreate(windowStage: window.WindowStage)|Ability生命周期回调,创建window stage时被调用,应用开发者可通过window.WindowStage的接口执行页面加载等操作。| -|void onWindowStageDestroy()|Ability生命周期回调,销毁window stage时被调用。| -|void onForeground()|Ability生命周期回调,Ability切换至前台时被调用。| -|void onBackground()|Ability生命周期回调,Ability切换至后台时被调用。| -|void onNewWant(want: Want)|Ability回调,Ability的启动模式设置为单例时被调用。| -|void onConfigurationUpdated(config: Configuration)|Ability回调,Ability的系统配置更新时被调用。| - -Ability类拥有context属性,context属性为AbilityContext类,AbilityContext类拥有abilityInfo、currentHapModuleInfo等属性,具体的API详见[接口文档](../reference/apis/js-apis-ability-context.md)。 - -**表3** AbilityContext API接口功能介绍 -|接口名|描述| -|:------|:------| -|void startAbility(want: Want, callback: AsyncCallback)|启动Ability。| -|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback)|启动Ability。| -|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带AccountId启动Ability。| -|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带AccountId启动Ability。| -|void startAbilityForResult(want: Want, callback: AsyncCallback)|带返回结果启动Ability。| -|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback)|带返回结果启动Ability。| -|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| -|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| -|void terminateSelf(callback: AsyncCallback)|销毁当前的Page Ability。| -|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback)|带返回结果销毁当前的Page Ability。| - -## 开发步骤 -### 创建Page Ability应用 -创建Stage模型的Page Ability应用,需实现AbilityStage接口及Ability生命周期接口,并使用窗口提供的方法设置页面。具体示例代码如下: -1. 导入AbilityStage模块。 - ``` - import AbilityStage from "@ohos.application.AbilityStage" - ``` -2. 实现AbilityStage接口。 - ```ts - export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - } - } - ``` -3. 导入Ability模块。 - ```js - import Ability from '@ohos.application.Ability' - ``` -4. 实现Ability生命周期接口。 - - 在`onWindowStageCreate(windowStage)`中通过loadContent接口设置应用要加载的页面,window接口的使用详见[窗口开发指导](../windowmanager/window-guidelines.md)。 - ```ts - export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("MainAbility onCreate") - } - - onDestroy() { - console.log("MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - console.log("MainAbility onWindowStageCreate") - - windowStage.loadContent("pages/index").then((data) => { - console.log("MainAbility load content succeed with data: " + JSON.stringify(data)) - }).catch((error) => { - console.error("MainAbility load content failed with error: "+ JSON.stringify(error)) - }) - } - - onWindowStageDestroy() { - console.log("MainAbility onWindowStageDestroy") - } - - onForeground() { - console.log("MainAbility onForeground") - } - - onBackground() { - console.log("MainAbility onBackground") - } - } - ``` -### 获取AbilityStage及Ability的配置信息 -AbilityStage类及Ability类均拥有context属性,应用可以通过`this.context`获取Ability实例的上下文,进而获取详细的配置信息。如下示例展示了AbilityStage通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下: -```ts -import AbilityStage from "@ohos.application.AbilityStage" -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let context = this.context - console.log("MyAbilityStage bundleCodeDir" + context.bundleCodeDir) - - let currentHapModuleInfo = context.currentHapModuleInfo - console.log("MyAbilityStage hap module name" + currentHapModuleInfo.name) - console.log("MyAbilityStage hap module mainAbilityName" + currentHapModuleInfo.mainAbilityName) - - let config = this.context.config - console.log("MyAbilityStage config language" + config.language) - } -} -``` - -如下示例展示了Ability通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下: -```ts -import Ability from '@ohos.application.Ability' -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("MainAbility onCreate") - let context = this.context - console.log("MainAbility bundleCodeDir" + context.bundleCodeDir) - - let abilityInfo = this.context.abilityInfo; - console.log("MainAbility ability bundleName" + abilityInfo.bundleName) - console.log("MainAbility ability name" + abilityInfo.name) - - let config = this.context.config - console.log("MyAbilityStage config language" + config.language) - } -} -``` - -### 启动Ability -应用可以通过`this.context`获取Ability实例的上下文,进而使用AbilityContext中的StartAbility相关接口启动Ability。启动Ability可指定Want、StartOptions、accountId,通过callback形式或promise形式实现。具体示例代码如下: -```ts -let context = this.context -var want = { - "deviceId": "", - "bundleName": "com.example.MyApplication", - "abilityName": "MainAbility" -}; -var options = { - windowMode: 0, - displayId: 2 -}; -context.startAbility(want, options).then((data) => { - console.log("Succeed to start ability with data: " + JSON.stringify(data)) -}).catch((error) => { - console.error("Failed to start ability with error: "+ JSON.stringify(error)) -}) -``` - -### 跨设备启动Ability(当前仅对系统应用开放) ->说明:由于DeviceManager的getTrustedDeviceListSync接口仅对系统应用开放,当前跨设备启动Ability仅支持系统应用 -跨设备场景下,需指定对端设备deviceId,具体示例代码如下: -```ts -let context = this.context -var want = { - "deviceId": getRemoteDeviceId(), - "bundleName": "com.example.MyApplication", - "abilityName": "MainAbility" -}; -context.startAbility(want).then((data) => { - console.log("Succeed to start remote ability with data: " + JSON.stringify(data)) -}).catch((error) => { - console.error("Failed to start remote ability with error: "+ JSON.stringify(error)) -}) -``` -从DeviceManager获取指定设备的deviceId。具体示例代码如下: -```ts -import deviceManager from '@ohos.distributedHardware.deviceManager'; -function getRemoteDeviceId() { - if (typeof dmClass === 'object' && dmClass != null) { - var list = dmClass.getTrustedDeviceListSync(); - if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { - console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null"); - return; - } - console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId); - return list[0].deviceId; - } else { - console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null"); - } -} -``` - -### 应用向用户申请授权 -应用需要某些权限如存储、位置信息、访问日历时,需要向用户申请授权。明确需要申请的权限后,在`module.json`中添加待申请的权限,同时通过接口`requestPermissionsFromUser`以动态弹窗的方式向用户申请授权。以访问日历为例,具体示例代码如下: -module.json的修改: -```json -"requestPermissions": [ - { - "name": "ohos.permission.READ_CALENDAR" - } -] -``` -通过动态弹窗向用户申请授权: -```ts -let context = this.context -let permissions: Array = ['ohos.permission.READ_CALENDAR'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) -``` -在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: -```ts -let context = this.context -let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) -``` - -### 系统环境变化通知给AbilityStage及Ability -全局配置,比如系统语言和颜色模式发生变化时,通过`onConfigurationUpdated`接口通知给AbilityStage和Ability。系统应用可以通过`updateConfiguration`接口更新系统语言和颜色模式。如下示例展示了AbilityStage的`onConfigurationUpdated`回调实现,系统语言和颜色模式发生变化时触发该回调。具体示例代码如下: -```ts -import Ability from '@ohos.application.Ability' -import ConfigurationConstant from '@ohos.application.ConfigurationConstant' -export default class MyAbilityStage extends AbilityStage { - onConfigurationUpdated(config) { - console.log("MyAbilityStage onConfigurationUpdated") - console.log("MyAbilityStage config language" + config.language) - console.log("MyAbilityStage config colorMode" + config.colorMode) - } -} -``` - -如下示例展示了Ability的`onConfigurationUpdated`回调实现,系统语言、颜色模式以及Display相关的参数,比如方向、Density,发生变化时触发该回调。具体示例代码如下: -```ts -import Ability from '@ohos.application.Ability' -import ConfigurationConstant from '@ohos.application.ConfigurationConstant' -export default class MainAbility extends Ability { { - onConfigurationUpdated(config) { - console.log("MainAbility onConfigurationUpdated") - console.log("MainAbility config language" + config.language) - console.log("MainAbility config colorMode" + config.colorMode) - console.log("MainAbility config direction" + config.direction) - console.log("MainAbility config screenDensity" + config.screenDensity) - console.log("MainAbility config displayId" + config.displayId) - } -} -``` - -## 开发实例 -针对Stage模型Ability开发,有以下示例工程可供参考: - -[eTSStageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSStageCallAbility) - -本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"为Ability的页面,在CaleeAbility目录实现另一个Ability并设置"pages/second"为Ability的页面。支持MainAbility启动CaleeAbility。 diff --git a/zh-cn/application-dev/ability/stage-brief.md b/zh-cn/application-dev/ability/stage-brief.md deleted file mode 100644 index 9da6f1c43224ceb365908fb31fadf59868b2eb0f..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-brief.md +++ /dev/null @@ -1,80 +0,0 @@ -# Stage模型综述 - -### 设计思想 - -​ Stage模型的设计,主要是为了解决FA模型无法解决的开发场景问题,方便开发者更加方便地开发出分布式环境下的复杂应用。 - -​ Stage模型的设计思想如下图所示。 - -![stagedesign](figures/stagedesign.png) - -​ Stage模型的设计基于如下三个出发点: - -- **应用的能力与系统总体功能和功耗的平衡** - - ​ 在系统运行过程中,前台应用的资源占用会被优先保障,与此同时由于应用能力不同而产生的功耗,也需要符合系统整体功耗的要求。Stage模型通过Ability与UI分离、严格的后台管控、基于场景的服务机制及单进程模型来达成这种应用能力与整体系统功耗的平衡。 - -- **原生支持组件级的迁移和协同** - - ​ OpenHarmony是原生支持分布式的操作系统,应用框架需要从架构设计上使得组件更易于实现迁移和协同。Stage模型通过Ability与UI分离及UI展示与服务能力合一等模型特性,实现这一设计目标。 - -- **支持多设备和多窗口形态的特点** - - ​ 为了支持多种设备形态和更易于实现多种不同的窗口形态,需要组件管理服务和窗口管理服务在架构层面上是解耦的,从而方便裁剪,更有利于定制不同的窗口形态。Stage模型通过重新定义了Ability生命周期定义和设计组件管理服务和窗口管理服务的单项依赖解决这一问题。 - - -### 基本概念 - -​ 下图展示了Stage模型中的基本概念。 - -![stageconcept](figures/stageconcept.png) - -- **HAP**:即HarmonyAbilityPackage,OpenHarmony应用编译、分发、加载的基本单位,也称为module,每个HAP都有一个应用内唯一的名称,成为moduleName; -- **Bundle**:通过appid标识的OpenHarmony应用,Bundle可以包含多个HAP,每个应用都有一个bundleName,但是bundleName并不能唯一标识一个应用,appid中包含bundleName以及其他的更多信息,能够唯一标识一个应用; -- **AbilityStage**:对应HAP的运行期类,在HAP首次加载到进程中时创建,运行期开发者可见; -- **Application**:对应Bundle的运行期类,运行期开发者不可见; -- **Context**:提供运行期开发者可以调用的各种能力,Ability组件和各种ExtensionAbility都有各自不同的context类,他们都继承自基类Context,基类提供包名、moduleName、路径等信息; -- **Ability**:提供生命周期回调,持有AbilityContext,支持组件迁移/协同; -- **ExtensionAbility**:基于场景的服务扩展能力统称,系统定义了多种基于场景的ExtensionAbility类,它们持有各自的ExtensionAbilityContext; -- **WindowStage**:本地窗口管理器; -- **Window**:窗口 管理器管理的基本单元,持有一个ArkUI引擎实例; -- **Ark UI Page**:Ark声明式UI展示。 - - -### 生命周期 - -​ Ability及AbilityStage的生命周期是应用的基本流程中最重要的概念。在[Ability框架概述](ability-brief.md)中,给出了FA模型与Stage模型的生命周期对比,这里重点对Ability生命周期切换以及和AbilityStage、WindowStage之间的调度关系进行介绍。 - -![stageabilitylifecyclecallback](figures/stageabilitylifecyclecallback.png) - -​ 为了实现多设备形态上的裁剪和多窗口的可扩展性,OpenHarmony对组件管理和窗口管理进行了解耦。Stage模型定义Ability组件的生命周期,只包含创建、销毁、前后台等状态,而将与界面相关内容强相关的获焦、失焦状态放在WindowStage之中,从而实现Ability与窗口之间的弱耦合;在服务侧,窗口管理服务依赖于组件管理服务,前者通知后者前后台变化,这样组件管理服务仅感知前后台变化,不感知焦点变化。 - -### ExtensionAbility机制 - -​ 不同于用于页面展示的Ability,ExtensionAbility提供的是一种受限的服务运行环境。ExtensionAbility具有如下特点: - -- 独立于主进程的单独进程运行,与主进程无IPC,共享一个存储沙箱; - -- 独立的Context提供基于业务场景的api能力; - -- 由系统触发创建,应用不能直接创建; - -- ExtensionAbility和进程的生命周期受系统管理。 - -​ 下图以卡片服务使用场景为例进行展示,系统提供了FormExtensionAbility基类,开发者通过派生提供卡片的具体信息。FormExtensionAbility实例及其所在的ExtensionAbility进程的整个生命周期,都是由系统服务FormManagerService进行管理。 - -![ExtensionAbility](figures/ExtensionAbility.png) - -### 进程模型 - -​ OpenHarmony系统中的应用均满足单进程模型。所谓的单进程模型,是指不允许应用配置多进程,应用中所有的进程都是由系统创建和管理的。每个应用至多并存三类进程: - -- 主进程:运行所有的Ability组件、页面和业务逻辑; - -- Extension进程:运行应用中的ExtensionAbility派生类,该进程由系统中的特定场景的服务管理其生命周期; - -- Render进程:专门为webview创建的进程,用于加载webview的渲染库。 - - 下图展示了应用的进程模型。 - - ![stageprocessmodel](figures/stageprocessmodel.png) diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md deleted file mode 100644 index 72821e4911541776745621295f5785e83c001384..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-call.md +++ /dev/null @@ -1,250 +0,0 @@ -# Call调用开发指导 -## 场景介绍 -Ability Call调用是Ability能力的扩展,它为Ability提供一种能够被外部调用的能力。使Ability既能被拉起到前台展示UI,也支持Ability在后台被创建并运行。应用开发者可通过Call调用,使用IPC通信实现不同Ability之间的数据共享。Call调用的场景主要包括: -- 创建Callee被调用端。 -- 访问Callee被调用端。 - -本文中的Caller和Callee分别表示调用者和被调用者,Call调用流程示意图如下。 - -![stage-call](figures/stage-call.png) - -## 接口说明 -Caller及Callee功能如下:具体的API详见[接口文档](../reference/apis/js-apis-application-ability.md#caller)。 - -**表1** Call API接口功能介绍 -|接口名|描述| -|:------|:------| -|Promise startAbilityByCall(want: Want)|获取指定通用组件的Caller通信接口,拉起指定通用组件并将其切换到后台。| -|void on(method: string, callback: CaleeCallBack)|Callee.on,通用组件Callee注册method对应的callback方法。| -|void off(method: string)|Callee.off,通用组件Callee去注册method的callback方法。| -|Promise call(method: string, data: rpc.Sequenceable)|Caller.call,向通用组件Callee发送约定序列化数据。| -|Promise callWithResult(method: string, data: rpc.Sequenceable)|Caller.callWithResult,向通用组件Callee发送约定序列化数据, 并将返回的约定序列化数据带回。| -|void release()|Caller.release,释放通用组件的Caller通信接口。| -|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease,注册通用组件通信断开监听通知。| - -## 开发步骤 -### 创建Callee被调用端 -Callee被调用端,需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。 -1. 配置Ability的启动模式 - - 配置module.json5,将Callee被调用端所在的Ability配置为单实例"singleton"。 - -|Json字段|字段说明| -|:------|:------| -|"launchType"|Ability的启动模式,设置为"singleton"类型 | - -Ability配置标签示例如下: -```json -"abilities":[{ - "name": ".CalleeAbility", - "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts", - "launchType": "singleton", - "description": "$string:CalleeAbility_desc", - "icon": "$media:icon", - "label": "$string:CalleeAbility_label", - "visible": true -}] -``` -2. 导入Ability模块 -``` -import Ability from '@ohos.application.Ability' -``` -3. 定义约定的序列化数据 - - 调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。具体示例代码如下: -```ts -export default class MySequenceable { - num: number = 0 - str: String = "" - - constructor(num, string) { - this.num = num - this.str = string - } - - marshalling(messageParcel) { - messageParcel.writeInt(this.num) - messageParcel.writeString(this.str) - return true - } - - unmarshalling(messageParcel) { - this.num = messageParcel.readInt() - this.str = messageParcel.readString() - return true - } -} -``` -4. 实现Callee.on监听及Callee.off解除监听 - - 被调用端Callee的监听函数注册时机, 取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在Ability的onCreate注册'CalleeSortMethod'监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回,应用开发者根据实际需要做相应处理。具体示例代码如下: -```ts -const TAG: string = '[CalleeAbility]' -const MSG_SEND_METHOD: string = 'CallSendMsg' - -function sendMsgCallback(data) { - Logger.log(TAG, 'CalleeSortFunc called') - - // 获取Caller发送的序列化数据 - let receivedData = new MySequenceable(0, '') - data.readSequenceable(receivedData) - Logger.log(TAG, `receiveData[${receivedData.num}, ${receivedData.str}]`) - - // 作相应处理 - // 返回序列化数据result给Caller - return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`) -} - -export default class CalleeAbility extends Ability { - onCreate(want, launchParam) { - try { - this.callee.on(MSG_SEND_METHOD, sendMsgCallback) - } catch (error) { - Logger.error(TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) - } - } - - onDestroy() { - try { - this.callee.off(MSG_SEND_METHOD) - } catch (error) { - console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`) - } - } -} -``` - -### 访问Callee被调用端 -1. 导入Ability模块 -``` -import Ability from '@ohos.application.Ability' -``` -2. 获取Caller通信接口 - - Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过`this.context`获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。具体示例代码如下: -```ts -async onButtonGetCaller() { - try { - this.caller = await context.startAbilityByCall({ - bundleName: 'com.samples.CallApplication', - abilityName: 'CalleeAbility' - }) - if (this.caller === undefined) { - Logger.error(TAG, 'get caller failed') - return - } - Logger.log(TAG, 'get caller success') - this.regOnRelease(this.caller) - } catch (error) { - Logger.error(TAG, `get caller failed with ${error}`) - } -}.catch((error) => { - console.error(TAG + 'get caller failed with ' + error) -}) -``` -在跨设备场景下,需指定对端设备deviceId。具体示例代码如下: -```ts -let TAG = '[MainAbility] ' -var caller = undefined -let context = this.context - -context.startAbilityByCall({ - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.CallApplication', - abilityName: 'CalleeAbility' -}).then((data) => { - if (data != null) { - caller = data - console.log(TAG + 'get remote caller success') - // 注册caller的release监听 - caller.onRelease((msg) => { - console.log(TAG + 'remote caller onRelease is called ' + msg) - }) - console.log(TAG + 'remote caller register OnRelease succeed') - } -}).catch((error) => { - console.error(TAG + 'get remote caller failed with ' + error) -}) -``` -从DeviceManager获取指定设备的deviceId,getTrustedDeviceListSync接口仅对系统应用开放。具体示例代码如下: -```ts -import deviceManager from '@ohos.distributedHardware.deviceManager'; -var dmClass; -function getRemoteDeviceId() { - if (typeof dmClass === 'object' && dmClass != null) { - var list = dmClass.getTrustedDeviceListSync(); - if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { - console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null"); - return; - } - console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId); - return list[0].deviceId; - } else { - console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null"); - } -} -``` -在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: -```ts -let context = this.context -let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) -``` -3. 发送约定序列化数据 - -向被调用端发送Sequenceable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Calee被调用端发送数据。具体示例代码如下: -```ts -const MSG_SEND_METHOD: string = 'CallSendMsg' -async onButtonCall() { - try { - let msg = new MySequenceable(1, 'origin_Msg') - await this.caller.call(MSG_SEND_METHOD, msg) - } catch (error) { - Logger.error(TAG, `caller call failed with ${error}`) - } -} -``` - -如下示例调用CallWithResult接口,向Calee被调用端发送待处理的数据`originMsg`,并将'CallSendMsg'方法处理完毕的数据赋值给`backMsg`。具体示例代码如下: -```ts -const MSG_SEND_METHOD: string = 'CallSendMsg' -originMsg: string = '' -backMsg: string = '' -async onButtonCallWithResult(originMsg, backMsg) { - try { - let msg = new MySequenceable(1, originMsg) - const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg) - Logger.log(TAG, 'caller callWithResult succeed') - - let result = new MySequenceable(0, '') - data.readSequenceable(result) - backMsg(result.str) - Logger.log(TAG, `caller result is [${result.num}, ${result.str}]`) - } catch (error) { - Logger.error(TAG, `caller callWithResult failed with ${error}`) - } -} -``` -4. 释放Caller通信接口 - -Caller不再使用后,应用开发者可以通过release接口释放Caller。具体示例代码如下: -```ts -try { - this.caller.release() - this.caller = undefined - Logger.log(TAG, 'caller release succeed') -} catch (error) { - Logger.error(TAG, `caller release failed with ${error}`) -} -``` - -## 开发实例 -针对Stage模型本地Call功能开发,有以下示例工程可供参考: - -[eTSStageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSStageCallAbility) - -本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"为Ability的页面,在CaleeAbility目录实现Ability的接口、Callee被调用端,设置"pages/second"为Ability的页面。MainAbility作为调用端,CalleeAbility作为被调用端。MainAbility拉起CalleeAbility,获取Caller通信接口后,支持用户输入字符串,做序列化处理后传递给CaleeAbility处理,CaleeAbility根据收到的数据做页面刷新并返回结果给MainAbility。 diff --git a/zh-cn/application-dev/ability/stage-formextension.md b/zh-cn/application-dev/ability/stage-formextension.md deleted file mode 100644 index 0b7654299c9c4cd59be254a3b07ae5d86af917e5..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-formextension.md +++ /dev/null @@ -1,340 +0,0 @@ -# Stage卡片开发指导 - -## 卡片概述 - -卡片是一种界面展示形式,可以将应用的重要信息或操作前置到卡片,以达到服务直达,减少体验层级的目的。 - -卡片常用于嵌入到其他应用(当前只支持系统应用)中作为其界面的一部分显示,并支持拉起页面,发送消息等基础的交互功能。卡片使用方负责显示卡片。 - -卡片的基本概念: - -- 卡片提供方 - 提供卡片显示内容原子化服务,控制卡片的显示内容、控件布局以及控件点击事件。 -- 卡片使用方 - 显示卡片内容的宿主应用,控制卡片在宿主中展示的位置。 -- 卡片管理服务 - 用于管理系统中所添加卡片的常驻代理服务,包括卡片对象的管理与使用,以及卡片周期性刷新等。 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 卡片使用方和提供方不要求常驻运行,在需要添加/删除/请求更新卡片时,卡片管理服务会拉起卡片提供方获取卡片信息。 - -开发者仅需作为卡片提供方进行卡片内容的开发,卡片使用方和卡片管理服务由系统自动处理。 - -卡片提供方控制卡片实际显示的内容、控件布局以及点击事件。 - -## 场景介绍 - -Stage卡片开发,即基于[Stage模型综述](stage-brief.md)的卡片提供方开发,主要涉及如下功能逻辑: - -- 卡片生命周期回调函数FormExtension开发。 -- 创建卡片数据FormBindingData对象。 -- 通过FormProvider更新卡片。 -- 卡片页面开发。 - -## 接口说明 - -FormExtension功能如下:FormExtension类,拥有context属性,具体的API详见[接口文档](../reference/apis/js-apis-formextension.md)。 - -**表1** FormExtension API接口功能介绍 - -| 接口名 | 描述 | -| :----------------------------------------------------------- | :------------------------------------------- | -| onCreate(want: Want): formBindingData.FormBindingData | 卡片提供方接收创建卡片的通知接口。 | -| onCastToNormal(formId: string): void | 卡片提供方接收临时卡片转常态卡片的通知接口。 | -| onUpdate(formId: string): void | 卡片提供方接收更新卡片的通知接口。 | -| onVisibilityChange(newStatus: { [key: string]: number }): void | 卡片提供方接收修改可见性的通知接口。 | -| onEvent(formId: string, message: string): void | 卡片提供方接收处理卡片事件的通知接口。 | -| onDestroy(formId: string): void | 卡片提供方接收销毁卡片的通知接口。 | -| onConfigurationUpdated(config: Configuration): void; | 当系统配置更新时调用。 | - -FormExtension类拥有context属性,context属性为FormExtensionContext类,具体的API详见[接口文档](../reference/apis/js-apis-formextensioncontext.md)。 - -**表2** FormExtensionContext API接口功能介绍 - -| 接口名 | 描述 | -| :----------------------------------------------------------- | :------------------------ | -| updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void | 回调形式主动更新卡片。 | -| updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\ | Promise形式主动更新卡片。 | - -FormProvider类具体的API详见[接口文档](../reference/apis/js-apis-formprovider.md)。 - -**表3** FormProvider API接口功能介绍 - -| 接口名 | 描述 | -| :----------------------------------------------------------- | :------------------------------------------------ | -| setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void; | 设置指定卡片的下一次更新时间。 | -| setFormNextRefreshTime(formId: string, minute: number): Promise<void>; | 设置指定卡片的下一次更新时间,以promise方式返回。 | -| updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback<void>): void; | 更新指定的卡片。 | -| updateForm(formId: string, formBindingData: FormBindingData): Promise<void>; | 更新指定的卡片,以promise方式返回。 | - -## 开发步骤 - -### 创建卡片FormExtension - -创建Stage模型的卡片,需实现FormExtension生命周期接口。具体示例代码如下: - -1. 导入相关模块 - - ```javascript - import FormExtension from '@ohos.application.FormExtension' - import formBindingData from '@ohos.application.formBindingData' - import formInfo from '@ohos.application.formInfo' - import formProvider from '@ohos.application.formProvider' - ``` - -2. 实现FormExtension生命周期接口 - - ```javascript - export default class FormAbility extends FormExtension { - onCreate(want) { - console.log('FormAbility onCreate'); - // 由开发人员自行实现,将创建的卡片信息持久化,以便在下次获取/更新该卡片实例时进行使用 - let obj = { - "title": "titleOnCreate", - "detail": "detailOnCreate" - }; - let formData = formBindingData.createFormBindingData(obj); - return formData; - } - onCastToNormal(formId) { - // 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理 - console.log('FormAbility onCastToNormal'); - } - onUpdate(formId) { - // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要覆写该方法以支持数据更新 - console.log('FormAbility onUpdate'); - let obj = { - "title": "titleOnUpdate", - "detail": "detailOnUpdate" - }; - let formData = formBindingData.createFormBindingData(obj); - formProvider.updateForm(formId, formData).catch((error) => { - console.log('FormAbility updateForm, error:' + JSON.stringify(error)); - }); - } - onVisibilityChange(newStatus) { - // 使用方发起可见或者不可见通知触发,提供方需要做相应的处理 - console.log('FormAbility onVisibilityChange'); - } - onEvent(formId, message) { - // 若卡片支持触发事件,则需要覆写该方法并实现对事件的触发 - console.log('FormAbility onEvent'); - } - onDestroy(formId) { - // 删除卡片实例数据 - console.log('FormAbility onDestroy'); - } - onAcquireFormState(want) { - console.log('FormAbility onAcquireFormState'); - return formInfo.FormState.READY; - } - } - ``` - -### 配置卡片配置文件 - -Form需要在应用配置文件module.json中进行配置。 - -- extensionAbility模块,内部字段结构说明: - - | 属性名称 | 含义 | 数据类型 | 是否可缺省 | - | ----------- | ------------------------------------------------------------ | ---------- | -------------------- | - | name | 表示extensionAbility的名字。该标签不可缺省。 | 字符串 | 否 | - | srcEntrance | 表示extensionAbility所对应的JS的代码路径。该标签不可缺省。 | 字符串 | 否 | - | description | 表示extensionAbility的描述。可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | - | icon | 表示extensionAbility的图标资源文件的索引。 | 字符串 | 可缺省,缺省值为空。 | - | label | 表示extensionAbility的标签信息,即extensionAbility对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。 | 字符串 | 可缺省,缺省值为空。 | - | type | 表示extensionAbility的类型。取值form、service等 | 字符串 | 否 | - | permissions | 表示其他应用的Ability调用此Ability时需要申请的权限。 | 字符串数组 | 可缺省,缺省值为空。 | - | metadata | 表示extensionAbility的元信息。用于描述extensionAbility的配置信息。 | 对象 | 可缺省,缺省值为空 | - - 对于FormExtensionAbility来说,type需要配置为form,并且需要填写metadata元信息,用于配置卡片的具体信息。 - - 配置示例如下: - - ```json - "extensionAbilities": [{ - "name": "FormAbility", - "srcEntrance": "./ets/FormAbility/FormAbility.ts", - "label": "$string:form_FormAbility_label", - "description": "$string:form_FormAbility_desc", - "type": "form", - "metadata": [{ - "name": "ohos.extension.form", - "resource": "$profile:form_config" - }] - }] - ``` - -- 卡片profile模块。在 FormExtensionAbility 的元信息中,需要使用 ohos.extension.form 指定的资源文件的路径,如使用 $profile:form_config 指定开发视图的 resources/base/profile/ 目录下的 form_config.json 作为卡片profile配置文件。 - - 内部字段结构说明: - - | 属性名称 | 含义 | 数据类型 | 是否可缺省 | - | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | - | name | 表示卡片的类名。字符串最大长度为127字节。 | 字符串 | 否 | - | description | 表示卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省为空。 | - | src | 表示卡片对应的UI代码的完整路径。 | 字符串 | 否 | - | window | 用于定义与显示窗口相关的配置。 | 对象 | 可缺省 | - | isDefault | 表示该卡片是否为默认卡片,每个Ability有且只有一个默认卡片。
true:默认卡片。
false:非默认卡片。 | 布尔值 | 否 | - | colorMode | 表示卡片的主题样式,取值范围如下:
auto:自适应。
dark:深色主题。
light:浅色主题。 | 字符串 | 可缺省,缺省值为“auto”。 | - | supportDimensions | 表示卡片支持的外观规格,取值范围:
1 * 2:表示1行2列的二宫格。
2 * 2:表示2行2列的四宫格。
2 * 4:表示2行4列的八宫格。
4 * 4:表示4行4列的十六宫格。 | 字符串数组 | 否 | - | defaultDimension | 表示卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 否 | - | updateEnabled | 表示卡片是否支持周期性刷新,取值范围:
true:表示支持周期性刷新,可以在定时刷新(updateDuration)和定点刷新(scheduledUpdateTime)两种方式任选其一,优先选择定时刷新。
false:表示不支持周期性刷新。 | 布尔类型 | 否 | - | scheduledUpdateTime | 表示卡片的定点刷新的时刻,采用24小时制,精确到分钟。 | 字符串 | 可缺省,缺省值为“0:0”。 | - | updateDuration | 表示卡片定时刷新的更新周期,单位为30分钟,取值为自然数。
当取值为0时,表示该参数不生效。
当取值为正整数N时,表示刷新周期为30*N分钟。 | 数值 | 可缺省,缺省值为“0”。 | - | formConfigAbility | 表示用于调整卡片的设施或活动的名称。 | 字符串 | 可缺省,缺省值为空。 | - | formVisibleNotify | 标识是否允许卡片使用卡片可见性通知 | 字符串 | 可缺省,缺省值为空。 | - | metaData | 表示卡片的自定义信息,包含customizeData数组标签。 | 对象 | 可缺省,缺省值为空。 | - - 配置示例如下: - - ```json - { - "forms": [{ - "name": "widget", - "description": "This is a service widget.", - "src": "./js/widget/pages/index/index", - "window": { - "autoDesignWidth": true, - "designWidth": 720 - }, - "isDefault": true, - "colorMode": "auto", - "supportDimensions": ["2*2"], - "defaultDimension": "2*2", - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1 - }] - } - ``` - - -### 卡片信息的持久化 - -因大部分卡片提供方都不是常驻服务,只有在需要使用时才会被拉起获取卡片信息,且卡片管理服务支持对卡片进行多实例管理,卡片ID对应实例ID,因此若卡片提供方支持对卡片数据进行配置,则需要对卡片的业务数据按照卡片ID进行持久化管理,以便在后续获取、更新以及拉起时能获取到正确的卡片业务数据。 - -```javascript - onCreate(want) { - console.log('FormAbility onCreate'); - - let formId = want.parameters["ohos.extra.param.key.form_identity"]; - let formName = want.parameters["ohos.extra.param.key.form_name"]; - let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"]; - // 由开发人员自行实现,将创建的卡片信息持久化,以便在下次获取/更新该卡片实例时进行使用 - storeFormInfo(formId, formName, tempFlag, want); - - let obj = { - "title": "titleOnCreate", - "detail": "detailOnCreate" - }; - let formData = formBindingData.createFormBindingData(obj); - return formData; - } -``` - -且需要适配onDestroy卡片删除通知接口,在其中实现卡片实例数据的删除。 - -```javascript - onDestroy(formId) { - // 删除卡片实例数据 - deleteFormInfo(formId); - console.log('FormAbility onDestroy'); - } -``` - -具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。 - -需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片: - -常态卡片:卡片使用方会持久化的卡片; - -临时卡片:卡片使用方不会持久化的卡片; - -由于临时卡片的数据具有非持久化的特殊性,某些场景比如卡片服务框架死亡重启,此时临时卡片数据在卡片管理服务中已经删除,且对应的卡片ID不会通知到提供方,所以卡片提供方需要自己负责清理长时间未删除的临时卡片数据。同时对应的卡片使用方可能会将之前请求的临时卡片转换为常态卡片。如果转换成功,卡片提供方也需要对对应的临时卡片ID进行处理,把卡片提供方记录的临时卡片数据转换为常态卡片数据,防止提供方在清理长时间未删除的临时卡片时,把已经转换为常态卡片的临时卡片信息删除,导致卡片信息丢失。 - -### 开发卡片页面 -开发者可以使用hml+css+json开发JS卡片页面: - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 当前仅支持JS扩展的类Web开发范式来实现卡片的UI页面。 - - - hml: - ```html -
- -
- -
-
- {{title}} - {{detail}} -
-
-
- ``` - - - css: - - ```css -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.bg-img { - flex-shrink: 0; - height: 100%; -} - -.container-inner { - flex-direction: column; - justify-content: flex-end; - align-items: flex-start; - height: 100%; - width: 100%; - padding: 12px; -} - -.title { - font-size: 19px; - font-weight: bold; - color: white; - text-overflow: ellipsis; - max-lines: 1; -} - -.detail_text { - font-size: 16px; - color: white; - opacity: 0.66; - text-overflow: ellipsis; - max-lines: 1; - margin-top: 6px; -} - ``` - - - json: - ```json - { - "data": { - "title": "TitleDefault", - "detail": "TextDefault" - }, - "actions": { - "routerEvent": { - "action": "router", - "abilityName": "com.example.MyApplication.hmservice.FormAbility", - "params": { - "message": "add detail" - } - } - } - } - ``` - -最终可以得到,如下卡片: - -![fa-form-example](figures/fa-form-example.png) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/stage-serviceextension.md b/zh-cn/application-dev/ability/stage-serviceextension.md deleted file mode 100644 index cd9a3cca6addd1f23b60534c77350979ebfff4ec..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ability/stage-serviceextension.md +++ /dev/null @@ -1,87 +0,0 @@ -# ServiceExtensionAbility开发指导 - -## 场景介绍 -ExtensionAbility,是Stage模型中新增的扩展组件的基类,一般用于处理无界面的任务,生命周期较简单,没有前后台生命周期。ServiceExtensionAbility是ExtensionAbility的扩展类。 - -开发者可以自定义类继承ServiceExtensionAbility,通过重写基类中相关生命周期方法,来做初始化、连接中、断开连接时相关业务逻辑操作。 - -## 接口说明 - -**表1** ServiceExtensionAbility中相关生命周期功能介绍 -|接口名|描述| -|:------|:------| -|onCreate|首次调用startAbility、connectAbility时触发,开发者可以进行初始化操作。| -|onRequest|每次调用startAbility都会触发,首次调用时startId为1,重复调用startAbility递增。| -|onConnect|调用connectAbility触发,重复调用不会再次触发,除非调用disconnectAbility解除绑定后再调用;onConnect返回一个进程通信类RemoteObject。| -|onDisconnect|调用disconnectAbility触发,Extension如果是用connectAbility拉起的,并且已经没有其他应用绑定这个Extension,则会触发onDestroy生命周期销毁组件。| -|onDestroy|调用停止当前ability接口terminateSelf会触发。| - - -## 约束与限制 - -- OpenHarmony当前不支持三方应用创建ServiceExtensionAbility。 - - -## 开发步骤 - -1.创建ServiceExtensionAbility - -开发者在创建TS文件中自定义类继承ServiceExtensionAbility,重写基类回调函数,示例如下: - - ```js - import rpc from '@ohos.rpc' - class StubTest extends rpc.RemoteObject { - constructor(des) { - super(des); - } - onRemoteRequest(code, data, reply, option) { - } - } - - class ServiceExt extends ServiceExtensionAbility { - onCreate(want) { - console.log('onCreate, want:' + want.abilityName); - } - onRequest(want, startId) { - console.log('onRequest, want:' + want.abilityName); - } - onConnect(want) { - console.log('onConnect , want:' + want.abilityName); - return new StubTest("test"); - } - onDisconnect(want) { - console.log('onDisconnect, want:' + want.abilityName); - } - onDestroy() { - console.log('onDestroy'); - } - } - ``` - - -2.注册ServiceExtensionAbility - -需要在应用配置文件module.json中进行注册,注册类型type需要设置为service。 - -**module.json配置样例** - -```json -"extensionAbilities":[{ - "name": "ServiceExtAbility", - "icon": "$media:icon", - "description": "service", - "type": "service", - "visible": true, - "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts" -}] -``` - -## 开发实例 - -针对ServiceExtensionAbility开发,有以下示例工程可供参考: - -- [ServiceExtensionAbility]() - -本示例ServiceExtensionAbility中: - -在ServiceExtensionAbility目录中的ServiceExtAbility.ts文件创建一个ServiceExtensionAbility实例。 diff --git a/zh-cn/application-dev/application-dev-guide-for-gitee.md b/zh-cn/application-dev/application-dev-guide-for-gitee.md new file mode 100644 index 0000000000000000000000000000000000000000..52c978dcf3379b89157f3c6fc417da189d8cc5df --- /dev/null +++ b/zh-cn/application-dev/application-dev-guide-for-gitee.md @@ -0,0 +1,62 @@ +# 应用开发导读 + +应用开发文档用于指导开发者通过OpenHarmony提供的接口完成应用开发。当前应用开发文档提供了在标准系统上开发应用的JS接口。 + +在应用开发的文档中,您可以获取到如下几方面的内容: + +### 快速开始 + +[快速开始](quick-start/Readme-CN.md)可以帮助开发者了解应用开发的基本方法。 + +这一部分包含了快速构建首个应用的快速入门,以及开发OpenHarmony应用所必备的基础知识。 + +开发的基础知识包含了OpenHarmony应用程序的包结构配置文件说明,以及资源文件的使用指导。 + +### 开发 + +为了帮助开发者更好的理解OpenHarmony提供的能力,我们对重点功能提供了开发指导,辅助开发者完成应用的开发。 + +首先,提供了支撑OpenHarmony应用的两个重要框架: + +- 应用程序的框架:[Ability开发](ability/Readme-CN.md) +- UI的框架:[UI开发](ui/Readme-CN.md) + +所有应用都应该在这两个框架的基础之上进行功能的开发。 + +在此基础上,还提供了如下功能的开发指导: +- [窗口管理](windowmanager/Readme-CN.md) +- [WebGL](webgl/Readme-CN.md) +- [媒体](media/Readme-CN.md) +- [安全](security/Readme-CN.md) +- [网络与连接](connectivity/Readme-CN.md) +- [数据管理](database/Readme-CN.md) +- [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md) +- [后台任务管理](background-task-management/Readme-CN.md) +- [设备管理](device/Readme-CN.md) +- [设备使用信息统计](device-usage-statistics/Readme-CN.md) +- [DFX](dfx/Readme-CN.md) +- [国际化](internationalization/Readme-CN.md) + +### 工具 + +DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 +在[工具](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)部分,讲解了DevEco Studio工具的详细用法,包括使用该工具进行工程创建、应用签名、应用调试、应用安装运行的指导。 + +### 示例教程 + +我们提供了[Sample工程](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md)和[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 + +### API参考 + +API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助开发者快速查找到指定接口的详细描述和调用方法。 + +内容包括: +- [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) +- [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) +- [接口参考](reference/apis/Readme-CN.md) + + +### Readme + +如果需要了解各子系统的原理和基本信息,可以参考“[docs/zh-cn/readme](../readme)”目录中各子系统readme的介绍。 + diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index 6676f769e4211306992c7581004c2a851a11bb9e..a6e2c32ba4d4992f7f05f719b93bcc8b965fb118 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -4,13 +4,13 @@ 在应用开发的文档中,您可以获取到如下几方面的内容: -### 入门 +### 快速开始 -[入门部分](quick-start/Readme-CN.md)可以帮助开发者了解应用开发的基本方法。 +[快速开始](quick-start/start-overview.md)可以帮助开发者了解应用开发的基本方法。 -这一部分包含了IDE工具DevEco Studio的基本使用方法,以及快速构建首个应用的快速入门。 +这一部分包含了快速构建首个应用的快速入门,以及开发OpenHarmony应用所必备的基础知识。 -此外,还在此部分详述了OpenHarmony应用程序的包结构,以及资源文件的使用指导。 +开发的基础知识包含了OpenHarmony应用程序的包结构配置文件说明,以及资源文件的使用指导。 ### 开发 @@ -18,28 +18,29 @@ 首先,提供了支撑OpenHarmony应用的两个重要框架: -- 应用程序的框架:[Ability开发](ability/Readme-CN.md) -- UI的框架:[UI开发](ui/Readme-CN.md) +- 应用程序的框架:[Ability开发](ability/fa-brief.md) +- UI的框架:[UI开发](ui/arkui-overview.md) 所有应用都应该在这两个框架的基础之上进行功能的开发。 在此基础上,还提供了如下功能的开发指导: -- [窗口管理](windowmanager/Readme-CN.md) -- [WebGL](webgl/Readme-CN.md) -- [媒体](media/Readme-CN.md) -- [安全](security/Readme-CN.md) -- [网络与连接](connectivity/Readme-CN.md) -- [数据管理](database/Readme-CN.md) -- [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md) -- [后台任务管理](background-task-management/Readme-CN.md) -- [设备管理](device/Readme-CN.md) -- [设备使用信息统计](device-usage-statistics/Readme-CN.md) -- [DFX](dfx/Readme-CN.md) +- [窗口管理](windowmanager/window-overview.md) +- [WebGL](webgl/webgl-overview.md) +- [媒体](media/audio-overview.md) +- [安全](security/userauth-overview.md) +- [网络与连接](connectivity/ipc-rpc-overview.md) +- [数据管理](database/database-mdds-overview.md) +- [后台代理提醒](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) +- [后台任务管理](background-task-management/background-task-overview.md) +- [设备管理](device/usb-overview.md) +- [设备使用信息统计](device-usage-statistics/device-usage-statistics-overview.md) +- [DFX](dfx/hiappevent-overview.md) +- [国际化](internationalization/international-overview.md) ### 工具 DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 -在[工具](quick-start/deveco-studio-user-guide-for-openharmony.md)部分,讲解了DevEco Studio工具的详细用法,包括使用该工具进行工程创建、应用签名、应用调试、应用安装运行的指导。 +在[工具](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)部分,讲解了DevEco Studio工具的详细用法,包括使用该工具进行工程创建、应用签名、应用调试、应用安装运行的指导。 ### 示例教程 @@ -50,12 +51,6 @@ DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助开发者快速查找到指定接口的详细描述和调用方法。 内容包括: -- [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) -- [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) -- [接口参考](reference/apis/Readme-CN.md) - - -### Readme - -如果需要了解各子系统的原理和基本信息,可以参考“[docs/zh-cn/readme](../readme)”目录中各子系统readme的介绍。 - +- [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/js-components-common-attributes.md) +- [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/ts-universal-events-click.md) +- [接口参考](reference/apis/js-apis-DataUriUtils.md) diff --git a/zh-cn/application-dev/application-dev-website.md b/zh-cn/application-dev/application-dev-website.md index 207bf47591d88f88ddf0a5f7fe0d3ee0a6f174e2..b144c5e1f5be369e81d60f76a558ff5c08b2dc11 100644 --- a/zh-cn/application-dev/application-dev-website.md +++ b/zh-cn/application-dev/application-dev-website.md @@ -1,41 +1,27 @@ +# OpenHarmony应用开发文档 - [应用开发导读](application-dev-guide.md) - 快速开始 - - 应用开发快速入门 - - DevEco Studio(OpenHarmony)使用指南 - - [概述](quick-start/deveco-studio-overview.md) - - [版本变更说明](quick-start/deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - 创建OpenHarmony工程 - - [使用工程向导创建新工程](quick-start/use-wizard-to-create-project.md) - - [通过导入Sample方式创建新工程](quick-start/import-sample-to-create-project.md) - - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) - - 快速入门 - - [前言](quick-start/start-overview.md) - - [使用eTS语言开发](quick-start/start-with-ets.md) - - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) - - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) - - [应用开发包结构说明](quick-start/package-structure.md) - - [资源文件的分类](quick-start/basic-resource-file-categories.md) + + - 快速入门 + - [开发准备](quick-start/start-overview.md) + - [使用eTS语言开发](quick-start/start-with-ets.md) + - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) + - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) + - 开发基础知识 + - [应用开发包结构说明](quick-start/package-structure.md) + - [资源文件的分类](quick-start/basic-resource-file-categories.md) + - [SysCap说明](quick-start/syscap.md) - 开发 - - [Ability开发](ability/Readme-CN.md) - - [Ability框架概述](ability/ability-brief.md) - - FA模型 - - [FA模型综述](ability/fa-brief.md) - - [PageAbility开发指导](ability/fa-pageability.md) - - [ServiceAbility开发指导](ability/fa-serviceability.md) - - [DataAbility开发指导](ability/fa-dataability.md) - - [FormAbility开发指导](ability/fa-formability.md) - - Stage模型 - - [Stage模型综述](ability/stage-brief.md) - - [Ability开发指导](ability/stage-ability.md) - - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) - - [FormExtensionAbility开发指导](ability/stage-formextension.md) - - [应用迁移开发指导](ability/stage-ability-continuation.md) + - Ability开发 + - [FA模型综述](ability/fa-brief.md) + - [PageAbility开发指导](ability/fa-pageability.md) + - [ServiceAbility开发指导](ability/fa-serviceability.md) + - [DataAbility开发指导](ability/fa-dataability.md) + - [FormAbility开发指导](ability/fa-formability.md) - 其他 - [WantAgent使用指导](ability/wantagent.md) - [Ability助手使用指导](ability/ability-assistant-guidelines.md) - - [UI开发](ui/Readme-CN.md) + - UI开发 - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) - 基于JS扩展的类Web开发范式 - [概述](ui/ui-js-overview.md) @@ -87,6 +73,7 @@ - [Qrcode开发指导](ui/ui-js-components-qrcode.md) - [Search开发指导](ui/ui-js-components-search.md) - Canvas开发指导 + - [Canvas对象](ui/ui-js-components-canvas.md) - [CanvasRenderingContext2D对象](ui/ui-js-components-canvasrenderingcontext2d.md) - [Path2D对象](ui/ui-js-components-path2d.md) - [OffscreenCanvas对象](ui/ui-js-components-offscreencanvas.md) @@ -116,6 +103,8 @@ - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) - [js标签配置](ui/ts-framework-js-tag.md) - 资源访问 + - [访问应用资源](ui/ts-application-resource-access.md) + - [访问系统资源](ui/ts-system-resource-access.md) - [媒体资源类型说明](ui/ts-media-resource-type.md) - [像素单位](ui/ts-pixel-units.md) - [类型定义](ui/ts-types.md) @@ -161,6 +150,13 @@ - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - [语法糖](ui/ts-syntactic-sugar.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) @@ -175,7 +171,7 @@ - 窗口 - [窗口开发概述](windowmanager/window-overview.md) - [窗口开发指导](windowmanager/window-guidelines.md) - - 显示设备 + - 屏幕属性 - [屏幕属性开发概述](windowmanager/display-overview.md) - [屏幕属性开发指导](windowmanager/display-guidelines.md) - 屏幕截图 @@ -193,7 +189,6 @@ - [音频采集开发指导](media/audio-capturer.md) - 视频 - [视频播放开发指导](media/video-playback.md) - - [视频录制开发指导](media/video-recorder.md) - 图片 - [图片开发指导](media/image.md) - 安全 @@ -221,8 +216,8 @@ - [关系型数据库概述](database/database-relational-overview.md) - [关系型数据库开发指导](database/database-relational-guidelines.md) - 轻量级数据存储 - - [轻量级数据存储概述](database/database-preference-overview.md) - - [轻量级数据存储开发指导](database/database-preference-guidelines.md) + - [轻量级数据存储概述](database/database-storage-overview.md) + - [轻量级数据存储开发指导](database/database-storage-guidelines.md) - 分布式数据对象 - [分布式数据对象概述](database/database-distributedobject-overview.md) - [分布式数据对象开发指导](database/database-distributedobject-guidelines.md) @@ -245,7 +240,7 @@ - [传感器开发概述](device/sensor-overview.md) - [传感器开发指导](device/sensor-guidelines.md) - 振动 - - [振动开发概述](device/vibrator-guidelines.md) + - [振动开发概述](device/vibrator-overview.md) - [振动开发指导](device/vibrator-guidelines.md) - 设备使用信息统计 - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) @@ -265,13 +260,7 @@ - [Intl开发指导](internationalization/intl-guidelines.md) - [I18n开发指导](internationalization/i18n-guidelines.md) - 工具 - - DevEco Studio(OpenHarmony)使用指南 - - [概述](quick-start/deveco-studio-overview.md) - - [版本变更说明](quick-start/deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [创建OpenHarmony工程](quick-start/create-openharmony-project.md) - - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) + - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) @@ -375,8 +364,7 @@ - [事件参数](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-appendix-types.md) + - [类型说明](reference/arkui-js/js-appendix-types.md) - 组件参考(基于TS扩展的声明式开发范式) - 组件 - 通用 @@ -433,24 +421,36 @@ - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) - [Image](reference/arkui-ts/ts-basic-components-image.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [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) + - [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) - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [Search](reference/arkui-ts/ts-basic-components-search.md) - [Select](reference/arkui-ts/ts-basic-components-select.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [Span](reference/arkui-ts/ts-basic-components-span.md) - [Text](reference/arkui-ts/ts-basic-components-text.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [Web](reference/arkui-ts/ts-basic-components-web.md) + - [Xcomponent](reference/arkui-ts/ts-basic-components-xcomponent.md) - 容器组件 - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - [Badge](reference/arkui-ts/ts-container-badge.md) @@ -464,18 +464,16 @@ - [List](reference/arkui-ts/ts-container-list.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Row](reference/arkui-ts/ts-container-row.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [Stack](reference/arkui-ts/ts-container-stack.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - 媒体组件 - [Video](reference/arkui-ts/ts-media-components-video.md) - 绘制组件 @@ -507,8 +505,6 @@ - [矩阵变换](reference/arkui-ts/ts-matrix-transformation.md) - [插值计算](reference/arkui-ts/ts-interpolation-calculation.md) - 全局UI方法 - - [图片缓存](reference/arkui-ts/ts-methods-image-cache.md) - - [媒体查询](reference/arkui-ts/ts-methods-media-query.md) - 弹窗 - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) - [列表选择弹窗](reference/arkui-ts/ts-methods-action-sheet.md) @@ -516,128 +512,210 @@ - [日期时间选择弹窗](reference/arkui-ts/ts-methods-datepicker-dialog.md) - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [菜单](reference/arkui-ts/ts-methods-menu.md) - - 附录 - - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) + - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) - 接口参考 - Ability框架 - - [FeatureAbility模块](reference/apis/js-apis-featureAbility.md) - - [ParticleAbility模块](reference/apis/js-apis-particleAbility.md) - - [DataAbilityHelper模块](reference/apis/js-apis-dataAbilityHelper.md) - - [DataUriUtils模块](reference/apis/js-apis-DataUriUtils.md) - - [Bundle模块](reference/apis/js-apis-Bundle.md) - - [Context模块](reference/apis/js-apis-Context.md) - - 事件与通知 - - [CommonEvent模块](reference/apis/js-apis-commonEvent.md) - - [Notification模块](reference/apis/js-apis-notification.md) - - [后台代理提醒](reference/apis/js-apis-reminderAgent.md) - - 资源管理 - - [资源管理](reference/apis/js-apis-resource-manager.md) - - [国际化-Intl](reference/apis/js-apis-intl.md) - - [国际化-I18n](reference/apis/js-apis-i18n.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.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.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.ability.featureAbility (FeatureAbility模块)](reference/apis/js-apis-featureAbility.md) + - [@ohos.application.formBindingData (卡片数据绑定类)](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) + - [@ohos.application.formHost (FormHost)](reference/apis/js-apis-formhost.md) + - [@ohos.application.formInfo (FormInfo)](reference/apis/js-apis-formInfo.md) + - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) + - [@ohos.application.formProvider (FormProvider)](reference/apis/js-apis-formprovider.md) + - [@ohos.ability.particleAbility (particleAbility模块)](reference/apis/js-apis-particleAbility.md) + - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) + - [@ohos.wantAgent (WantAgent模块)](reference/apis/js-apis-wantAgent.md) + - [dataAbilityHelper (DataAbilityHelper模块)](reference/apis/js-apis-dataAbilityHelper.md) + - [context (Context模块)](reference/apis/js-apis-Context.md) + - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) + - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) + - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) + - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) + - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) + - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) + - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) + - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) + - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) + - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) + - 公共事件与通知 + + - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.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) + - 应用程序包管理 + + - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) + - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.zlib (Zip模块)](reference/apis/js-apis-zlib.md) + - UI界面 + + - [@ohos.animator (动画)](reference/apis/js-apis-animator.md) + - [@ohos.mediaquery (媒体查询)](reference/apis/js-apis-mediaquery.md) + - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.router (页面路由)](reference/apis/js-apis-router.md) + - 图形图像 + + - [@ohos.display (屏幕属性)](reference/apis/js-apis-display.md) + - [@ohos.screenshot (屏幕截图)](reference/apis/js-apis-screenshot.md) + - [@ohos.window (窗口)](reference/apis/js-apis-window.md) + - [webgl (WebGL)](reference/apis/js-apis-webgl.md) + - [webgl2 (WebGL2)](reference/apis/js-apis-webgl2.md) - 媒体 - - [音频管理](reference/apis/js-apis-audio.md) - - [媒体服务](reference/apis/js-apis-media.md) - - [图片处理](reference/apis/js-apis-image.md) - - [相机管理](reference/apis/js-apis-camera.md) + + - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.image (图片处理)](reference/apis/js-apis-image.md) + - [@ohos.multimedia.media (媒体服务)](reference/apis/js-apis-media.md) + - [@ohos.multimedia.medialibrary (媒体库管理)](reference/apis/js-apis-medialibrary.md) + - 资源管理 + - [@ohos.i18n (国际化-I18n)](reference/apis/js-apis-i18n.md) + - [@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.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) - 安全 - - [用户认证](reference/apis/js-apis-useriam-userauth.md) - - [访问控制](reference/apis/js-apis-abilityAccessCtrl.md) - - [通用密钥库系统](reference/apis/js-apis-huks.md) + + - [@ohos.abilityAccessCtrl (访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.security.huks (通用密钥库系统)](reference/apis/js-apis-huks.md) + - [@ohos.userIAM.userAuth (用户认证)](reference/apis/js-apis-useriam-userauth.md) + - [@system.cipher (加密算法)](reference/apis/js-apis-system-cipher.md) - 数据管理 - - [轻量级存储](reference/apis/js-apis-data-preferences.md) - - [分布式数据管理](reference/apis/js-apis-distributed-data.md) - - [关系型数据库](reference/apis/js-apis-data-rdb.md) - - [结果集](reference/apis/js-apis-data-resultset.md) - - [DataAbility 谓词](reference/apis/js-apis-data-ability.md) - - [设置数据项名称](reference/apis/js-apis-settings.md) + + - [@ohos.data.dataAbility (DataAbility谓词)](reference/apis/js-apis-data-ability.md) + - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) + - [@ohos.data.distributedDataObject (分布式数据对象)](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.rdb (关系型数据库)](reference/apis/js-apis-data-rdb.md) + - [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md) + - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.md) + - [resultSet (结果集)](reference/apis/js-apis-data-resultset.md) - 文件管理 - - [文件管理](reference/apis/js-apis-fileio.md) - - [Statfs](reference/apis/js-apis-statfs.md) - - [目录环境](reference/apis/js-apis-environment.md) - - [公共文件访问与管理](reference/apis/js-apis-filemanager.md) - - [应用空间统计](reference/apis/js-apis-storage-statistics.md) - - [卷管理](reference/apis/js-apis-volumemanager.md) - - 账号管理 - - [系统帐号管理](reference/apis/js-apis-osAccount.md) - - [分布式帐号管理](reference/apis/js-apis-distributed-account.md) - - [应用帐号管理](reference/apis/js-apis-appAccount.md) + + - [@ohos.environment (目录环境能力)](reference/apis/js-apis-environment.md) + - [@ohos.fileio (文件管理)](reference/apis/js-apis-fileio.md) + - [@ohos.fileManager (公共文件访问与管理)](reference/apis/js-apis-filemanager.md) + - [@ohos.statfs (statfs)](reference/apis/js-apis-statfs.md) + - [@ohos.storageStatistics (应用空间统计)](reference/apis/js-apis-storage-statistics.md) - 电话服务 - - [拨打电话](reference/apis/js-apis-call.md) - - [短信服务](reference/apis/js-apis-sms.md) - - [SIM卡管理](reference/apis/js-apis-sim.md) - - [网络搜索](reference/apis/js-apis-radio.md) - - [observer](reference/apis/js-apis-observer.md) - - [蜂窝数据](reference/apis/js-apis-telephony-data.md) + + - [@ohos.contact (联系人)](reference/apis/js-apis-contact.md) + - [@ohos.telephony.call (拨打电话)](reference/apis/js-apis-call.md) + - [@ohos.telephony.observer (observer)](reference/apis/js-apis-observer.md) + - [@ohos.telephony.radio (网络搜索)](reference/apis/js-apis-radio.md) + - [@ohos.telephony.sim (SIM卡管理)](reference/apis/js-apis-sim.md) + - [@ohos.telephony.sms (短信服务)](reference/apis/js-apis-sms.md) + - [@ohos.telephony.data (蜂窝数据)](reference/apis/js-apis-telephony-data.md) - 网络管理 - - [网络连接管理](reference/apis/js-apis-net-connection.md) - - [Socket连接](reference/apis/js-apis-socket.md) - - [WebSocket连接](reference/apis/js-apis-webSocket.md) - - [数据请求](reference/apis/js-apis-http.md) + - [@ohos.net.connection (网络连接管理)](reference/apis/js-apis-net-connection.md) + - [@ohos.net.http (数据请求)](reference/apis/js-apis-http.md) + - [@ohos.request (上传下载)](reference/apis/js-apis-request.md) + - [@ohos.net.socket (Socket连接)](reference/apis/js-apis-socket.md) + - [@ohos.net.webSocket (WebSocket连接)](reference/apis/js-apis-webSocket.md) - 通信与连接 - - [WLAN](reference/apis/js-apis-wifi.md) - - [Bluetooth](reference/apis/js-apis-bluetooth.md) - - [RPC通信](reference/apis/js-apis-rpc.md) + + - [@ohos.bluetooth (蓝牙)](reference/apis/js-apis-bluetooth.md) + - [@ohos.connectedTag (有源标签)](reference/apis/js-apis-connectedTag.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.accessibility (辅助功能)](reference/apis/js-apis-accessibility.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.hiTraceChain (分布式跟踪)](reference/apis/js-apis-hitracechain.md) + - [@ohos.hiTraceMeter (性能打点)](reference/apis/js-apis-hitracemeter.md) + - [@ohos.inputMethod (输入法框架)](reference/apis/js-apis-inputmethod.md) + - [@ohos.inputMethodEngine (输入法服务)](reference/apis/js-apis-inputmethodengine.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.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) + - [Timer (定时器)](reference/apis/js-apis-timer.md) - 设备管理 - - [传感器](reference/apis/js-apis-sensor.md) - - [振动](reference/apis/js-apis-vibrator.md) - - [屏幕亮度](reference/apis/js-apis-brightness.md) - - [电量信息](reference/apis/js-apis-battery-info.md) - - [系统电源管理](reference/apis/js-apis-power.md) - - [热管理](reference/apis/js-apis-thermal.md) - - [Runninglock锁](reference/apis/js-apis-runninglock.md) - - [设备信息](reference/apis/js-apis-device-info.md) - - [系统属性](reference/apis/js-apis-system-parameter.md) - - [设备管理](reference/apis/js-apis-device-manager.md) - - [窗口](reference/apis/js-apis-window.md) - - [显示设备属性](reference/apis/js-apis-display.md) - - [升级](reference/apis/js-apis-update.md) - - [USB管理](reference/apis/js-apis-usb.md) - - [位置服务](reference/apis/js-apis-geolocation.md) - - 基本功能 - - [应用上下文](reference/apis/js-apis-system-app.md) - - [日志打印](reference/apis/js-apis-basic-features-logs.md) - - [页面路由](reference/apis/js-apis-system-router.md) - - [弹窗](reference/apis/js-apis-system-prompt.md) - - [应用配置](reference/apis/js-apis-system-configuration.md) - - [定时器](reference/apis/js-apis-basic-features-timer.md) - - [设置系统时间](reference/apis/js-apis-system-time.md) - - [动画](reference/apis/js-apis-basic-features-animator.md) - - [WebGL](reference/apis/js-apis-webgl.md) - - [WebGL2](reference/apis/js-apis-webgl2.md) - - [屏幕截图](reference/apis/js-apis-screenshot.md) - - [输入法框架](reference/apis/js-apis-inputmethod.md) - - [输入法服务](reference/apis/js-apis-inputmethodengine.md) - - [辅助功能](reference/apis/js-apis-accessibility.md) - - DFX - - [应用打点](reference/apis/js-apis-hiappevent.md) - - [性能打点](reference/apis/js-apis-hitracemeter.md) - - [故障日志获取](reference/apis/js-apis-faultLogger.md) - - [分布式跟踪](reference/apis/js-apis-hitracechain.md) - - [日志打印](reference/apis/js-apis-hilog.md) - - [检测模式](reference/apis/js-apis-hichecker.md) - - [Debug调试](reference/apis/js-apis-hidebug.md) + + - [@ohos.batteryInfo (电量信息)](reference/apis/js-apis-battery-info.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.multimodalInput.inputConsumer (组合按键)](reference/apis/js-apis-inputconsumer.md) + - [@ohos.multimodalInput.inputDevice (输入设备)](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputEventClient (注入按键)](reference/apis/js-apis-inputeventclient.md) + - [@ohos.multimodalInput.inputMonitor (输入监听)](reference/apis/js-apis-inputmonitor.md) + - [@ohos.power (系统电源管理)](reference/apis/js-apis-power.md) + - [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md) + - [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md) + - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.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.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) - 语言基础类库 - - [获取进程相关的信息](reference/apis/js-apis-process.md) - - [URL字符串解析](reference/apis/js-apis-url.md) - - [URI字符串解析](reference/apis/js-apis-uri.md) - - [util工具函数](reference/apis/js-apis-util.md) - - [xml解析与生成](reference/apis/js-apis-xml.md) - - [xml转换JavaScript](reference/apis/js-apis-convertxml.md) - - [启动一个worker](reference/apis/js-apis-worker.md) - - [线性容器ArrayList](reference/apis/js-apis-arraylist.md) - - [线性容器Deque](reference/apis/js-apis-deque.md) - - [线性容器List](reference/apis/js-apis-list.md) - - [线性容器LinkedList](reference/apis/js-apis-linkedlist.md) - - [线性容器Queue](reference/apis/js-apis-queue.md) - - [线性容器Stack](reference/apis/js-apis-stack.md) - - [线性容器Vector](reference/apis/js-apis-vector.md) - - [非线性容器HashSet](reference/apis/js-apis-hashset.md) - - [非线性容器HashMap](reference/apis/js-apis-hashmap.md) - - [非线性容器PlainArray](reference/apis/js-apis-plainarray.md) - - [非线性容器TreeMap](reference/apis/js-apis-treemap.md) - - [非线性容器TreeSet](reference/apis/js-apis-treeset.md) - - [非线性容器LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [非线性容器LightWeightSet](reference/apis/js-apis-lightweightset.md) - - 定制管理 - - [配置策略](reference/apis/js-apis-config-policy.md) - - [企业设备管理](reference/apis/js-apis-enterprise-device-manager.md) \ No newline at end of file + + - [@ohos.convertxml (xml转换JavaScript)](reference/apis/js-apis-convertxml.md) + - [@ohos.process (获取进程相关的信息)](reference/apis/js-apis-process.md) + - [@ohos.uri (URI字符串解析)](reference/apis/js-apis-uri.md) + - [@ohos.url (URL字符串解析)](reference/apis/js-apis-url.md) + - [@ohos.util (util工具函数)](reference/apis/js-apis-util.md) + - [@ohos.util.ArrayList (线性容器ArrayList)](reference/apis/js-apis-arraylist.md) + - [@ohos.util.Deque (线性容器Deque)](reference/apis/js-apis-deque.md) + - [@ohos.util.HashMap (非线性容器HashMap)](reference/apis/js-apis-hashmap.md) + - [@ohos.util.HashSet (非线性容器HashSet)](reference/apis/js-apis-hashset.md) + - [@ohos.util.LightWeightMap (非线性容器LightWeightMap)](reference/apis/js-apis-lightweightmap.md) + - [@ohos.util.LightWeightSet (非线性容器LightWeightSet)](reference/apis/js-apis-lightweightset.md) + - [@ohos.util.LinkedList (线性容器LinkedList)](reference/apis/js-apis-linkedlist.md) + - [@ohos.util.List (线性容器List)](reference/apis/js-apis-list.md) + - [@ohos.util.PlainArray (非线性容器PlainArray)](reference/apis/js-apis-plainarray.md) + - [@ohos.util.Queue (线性容器Queue)](reference/apis/js-apis-queue.md) + - [@ohos.util.Stack (线性容器Stack)](reference/apis/js-apis-stack.md) + - [@ohos.util.TreeMap (非线性容器TreeMap)](reference/apis/js-apis-treemap.md) + - [@ohos.util.TreeSet (非线性容器TreeSet)](reference/apis/js-apis-treeset.md) + - [@ohos.util.Vector (线性容器Vector)](reference/apis/js-apis-vector.md) + - [@ohos.worker (启动一个Worker)](reference/apis/js-apis-worker.md) + - [@ohos.xml (xml解析与生成)](reference/apis/js-apis-xml.md) + - 测试 + - [@ohos.application.testRunner (TestRunner)](reference/apis/js-apis-testRunner.md) + - [@ohos.uitest (UiTest)](reference/apis/js-apis-uitest.md) + - 已停止维护的接口 + + - [@ohos.bytrace (性能打点)](reference/apis/js-apis-bytrace.md) + - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.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) + - [@system.brightness (屏幕亮度)](reference/apis/js-apis-system-brightness.md) + - [@system.configuration (应用配置)](reference/apis/js-apis-system-configuration.md) + - [@system.device (设备信息)](reference/apis/js-apis-system-device.md) + - [@system.fetch (数据请求)](reference/apis/js-apis-system-fetch.md) + - [@system.file (文件存储)](reference/apis/js-apis-system-file.md) + - [@system.geolocation (地理位置)](reference/apis/js-apis-system-location.md) + - [@system.mediaquery (媒体查询)](reference/apis/js-apis-system-mediaquery.md) + - [@system.network (网络状态)](reference/apis/js-apis-system-network.md) + - [@system.notification (通知消息)](reference/apis/js-apis-system-notification.md) + - [@system.package (应用管理)](reference/apis/js-apis-system-package.md) + - [@system.prompt (弹窗)](reference/apis/js-apis-system-prompt.md) + - [@system.request (上传下载)](reference/apis/js-apis-system-request.md) + - [@system.router (页面路由)](reference/apis/js-apis-system-router.md) + - [@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) \ No newline at end of file diff --git a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index bb77011ba0b4182153bf0bf1fdcace9e7d7f3d10..354cf1f372dbbc825a03e30ad2163b98eef427e6 100644 --- a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -150,12 +150,12 @@ interface LocalDateTime:时间信息实例 } ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, title: "this is title", content: "this is content", @@ -209,12 +209,12 @@ calendar: { }, ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, ringDuration: 5, snoozeTimes: 2, @@ -247,12 +247,12 @@ alarm: { }, ], wantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.example.phone", - abilityName: "com.example.phone.MainAbility" + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" }, ringDuration: 5, snoozeTimes: 2, diff --git a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md index eec3aa88bcc77702c024bbff63dfe7d4727b62e8..895b897cff25f9ba6ed6c6a0b7363de1e8655d88 100755 --- a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md +++ b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md @@ -17,4 +17,4 @@ IPC(Inter-Process Communication)与RPC(Remote Procedure Call)机制用 ## 相关模块 -分布式任务调度子系统 +[分布式任务调度子系统](https://gitee.com/openharmony/distributedschedule_dms_fwk) diff --git a/zh-cn/application-dev/database/Readme-CN.md b/zh-cn/application-dev/database/Readme-CN.md index ab2703c93e686776ff8c3a85f06ce6859624f55b..e6cbed82a9c2654f1f6f572464c6e144d11d0039 100644 --- a/zh-cn/application-dev/database/Readme-CN.md +++ b/zh-cn/application-dev/database/Readme-CN.md @@ -7,8 +7,8 @@ - [关系型数据库概述](database-relational-overview.md) - [关系型数据库开发指导](database-relational-guidelines.md) - 轻量级数据存储 - - [轻量级数据存储概述](database-preference-overview.md) - - [轻量级数据存储开发指导](database-preference-guidelines.md) + - [轻量级数据存储概述](database-storage-overview.md) + - [轻量级数据存储开发指导](database-storage-guidelines.md) - 分布式数据对象 - [分布式数据对象概述](database-distributedobject-overview.md) - [分布式数据对象开发指导](database-distributedobject-guidelines.md) diff --git a/zh-cn/application-dev/database/database-preference-guidelines.md b/zh-cn/application-dev/database/database-storage-guidelines.md similarity index 100% rename from zh-cn/application-dev/database/database-preference-guidelines.md rename to zh-cn/application-dev/database/database-storage-guidelines.md diff --git a/zh-cn/application-dev/database/database-preference-overview.md b/zh-cn/application-dev/database/database-storage-overview.md similarity index 100% rename from zh-cn/application-dev/database/database-preference-overview.md rename to zh-cn/application-dev/database/database-storage-overview.md diff --git a/zh-cn/application-dev/device/figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png b/zh-cn/application-dev/device/figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png new file mode 100644 index 0000000000000000000000000000000000000000..769100279a9c6c61f8e5746a3fa2a2970807453e Binary files /dev/null and b/zh-cn/application-dev/device/figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png differ diff --git a/zh-cn/application-dev/device/figures/fad1a124-a90e-460f-84fc-e87d6caebb21.png b/zh-cn/application-dev/device/figures/fad1a124-a90e-460f-84fc-e87d6caebb21.png new file mode 100644 index 0000000000000000000000000000000000000000..50252039ff298fb9d0ddcc7b283c324c10aafde1 Binary files /dev/null and b/zh-cn/application-dev/device/figures/fad1a124-a90e-460f-84fc-e87d6caebb21.png differ diff --git a/zh-cn/application-dev/device/figures/zh-cn_image_0000001180249428.png b/zh-cn/application-dev/device/figures/zh-cn_image_0000001180249428.png deleted file mode 100644 index 0f8cd72f3fc88533dc99761c08764b3a498ce115..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/device/figures/zh-cn_image_0000001180249428.png and /dev/null differ diff --git a/zh-cn/application-dev/device/figures/zh-cn_image_0000001226521897.png b/zh-cn/application-dev/device/figures/zh-cn_image_0000001226521897.png deleted file mode 100644 index b00280219ffe5b8fa4f4f090a6d13254b01db042..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/device/figures/zh-cn_image_0000001226521897.png and /dev/null differ diff --git a/zh-cn/application-dev/device/sensor-guidelines.md b/zh-cn/application-dev/device/sensor-guidelines.md index d69088647aa8c1feee551bc1e872930399796b11..8d5ea44d2a7d547406372f06730da98a1bfbf814 100644 --- a/zh-cn/application-dev/device/sensor-guidelines.md +++ b/zh-cn/application-dev/device/sensor-guidelines.md @@ -67,67 +67,47 @@ "when":"inuse" } }, - { - "name":"ohos.permission.VIBRATE", - "reason"":"", - "usedScene":{ - "ability": [".MainAbility"], - "when":"inuse" - } - }, ] ``` - + 2. 持续监听传感器数据变化。 ``` import sensor from "@ohos.sensor" - sensor.on(sensor.sensorType,function(error,data){ - if (error) {//调用失败,打印error.code和error.message - console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message); - return; - }; - console.info("Subscription succeeded. data = "+ data);//调用成功,打印对应传感器的数据 + sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){ + console.info("Subscription succeeded. data = " + data);//调用成功,打印对应传感器的数据 } ); ``` - + 以SensorType为SENSOR_TYPE_ID_ACCELEROMETER为例展示运行结果,持续监听传感器接口的结果如下图所示: - + ![zh-cn_image_0000001241693881](figures/zh-cn_image_0000001241693881.png) 3. 注销传感器数据监听。 ``` import sensor from "@ohos.sensor" - sensor.off(sensor.sensorType,function(error) { - if (error) {//注销失败,返回error.code和error.message - console.error("Failed to unsubscribe from acceleration sensor data. Error code: " + error.code + "; message: " + error.message); - return; - }; + sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() { console.info("Succeeded in unsubscribing from acceleration sensor data.");//注销成功,返回打印结果 } ); ``` - + 以SensorType为SENSOR_TYPE_ID_ACCELEROMETER为例展示运行结果,注销传感器成功结果如下图所示: - + ![zh-cn_image_0000001196654004](figures/zh-cn_image_0000001196654004.png) 4. 获取一次传感器数据变化。 ``` import sensor from "@ohos.sensor" - sensor.once(sensor.sensorType,function(error, data) { - if (error) {//获取数据失败,返回error.code和error.message - console.error("Failed to obtain data. Error code: " + error.code + "; message: " + error.message); - return; - }; - console.info("Data obtained successfully. data="+data);//获取数据成功,打印对应传感器的数据 + sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { + console.info("Data obtained successfully. data=" + data);//获取数据成功,打印对应传感器的数据 } ); ``` - + 以SensorType为SENSOR_TYPE_ID_ACCELEROMETER为例展示运行结果,获取数据成功日志如下图所示: - + ![zh-cn_image_0000001241733907](figures/zh-cn_image_0000001241733907.png) diff --git a/zh-cn/application-dev/device/sensor-overview.md b/zh-cn/application-dev/device/sensor-overview.md index dc3cde6fe248b61a7ac1b051a31db0d1dfa42417..69b6c06539343276191a53ccd9227a7f2b7e7faa 100644 --- a/zh-cn/application-dev/device/sensor-overview.md +++ b/zh-cn/application-dev/device/sensor-overview.md @@ -4,86 +4,40 @@ OpenHarmony系统传感器是应用访问底层硬件传感器的一种设备抽象概念。开发者根据传感器提供的Sensor API,可以查询设备上的传感器,订阅传感器数据,并根据传感器数据定制相应的算法开发各类应用,比如指南针、运动健康、游戏等。 -根据传感器的用途,可以将传感器分为六大类:运动类传感器、环境类传感器、方向类传感器、光线类传感器、健康类传感器、其他传感器(如霍尔传感器),每一大类传感器都包含不同类型的传感器,某些类型的传感器可能是单一的物理传感器,也可能是由多个物理传感器复合而成。下面为传感器列表: - - - **表1** 运动类-ohos.sensor.agent.CategoryMotionAgent - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| -------------------------------------- | --------- | ---------------------------------------- | --------------- | -| SENSOR_TYPE_ACCELEROMETER | 加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的加速度(包括重力加速度),单位 : m/s2 | 检测运动状态 | -| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | 未校准加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的未校准的加速度(包括重力加速度),单位 : m/s2 | 检测加速度偏差估值 | -| SENSOR_TYPE_LINEAR_ACCELERATION | 线性加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的线性加速度(不包括重力加速度),单位 : m/s2 | 检测每个单轴方向上的线性加速度 | -| SENSOR_TYPE_GRAVITY | 重力传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的重力加速度,单位 : m/s2 | 测量重力大小 | -| SENSOR_TYPE_GYROSCOPE | 陀螺仪传感器 | 测量三个物理轴(x、y 和 z)上,设备的旋转角速度,单位 : rad/s | 测量旋转的角速度 | -| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | 未校准陀螺仪传感器 | 测量三个物理轴(x、y 和 z)上,设备的未校准旋转角速度,单位 : rad/s | 测量旋转的角速度及偏差估值 | -| SENSOR_TYPE_SIGNIFICANT_MOTION | 大幅度动作传感器 | 测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动 | 用于检测设备是否存在大幅度运动 | -| SENSOR_TYPE_DROP_DETECTION | 跌落检测传感器 | 检测设备的跌落状态;如果取值为1则代表发生跌落,取值为0则代表没有发生跌落 | 用于检测设备是否发生了跌落 | -| SENSOR_TYPE_PEDOMETER_DETECTION | 计步器检测传感器 | 检测用户的计步动作;如果取值为1则代表用户产生了计步行走的动作;取值为0则代表用户没有发生运动 | 用于检测用户是否有计步的动作 | -| SENSOR_TYPE_PEDOMETER | 计步器传感器 | 统计用户的行走步数 | 用于提供用户行走的步数数据 | - - - **表2** 环境类-ohos.sensor.agent.CategoryOrientationAgent - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| --------------------------------------- | -------- | ---------------------------------------- | --------------- | -| SENSOR_TYPE_AMBIENT_TEMPERATURE | 环境温度传感器 | 测量环境温度,单位 : 摄氏度 (°C) | 测量环境温度 | -| SENSOR_TYPE_MAGNETIC_FIELD | 磁场传感器 | 测量三个物理轴向(x、y、z)上,环境地磁场,单位 : μT | 创建指南针 | -| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | 未校准磁场传感器 | 测量三个物理轴向(x、y、z)上,未校准环境地磁场,单位 : μT | 测量地磁偏差估值 | -| SENSOR_TYPE_HUMIDITY | 湿度传感器 | 测量环境的相对湿度,以百分比 (%) 表示 | 监测露点、绝对湿度和相对湿度 | -| SENSOR_TYPE_BAROMETER | 气压计传感器 | 测量环境气压,单位 : hPa 或 mbar | 测量环境气压 | -| SENSOR_TYPE_SAR | 比吸收率传感器 | 测量比吸收率,单位:W/kg | 测量设备的电磁波能量吸收比值。 | - - - **表3** 方向类-ohos.sensor.agent.CategoryOrientationAgent - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| ---------------------------------------- | ----------------------- | ---------------------------------------- | --------------------------------- | -| SENSOR_TYPE_6DOF | 自由度传感器 | 测量上下、前后、左右方向上的位移,单位:m或mm;测量俯仰、偏摆、翻滚的角度,单位:rad | 检测设备的三个平移自由度以及旋转自由度,用于目标定位追踪,如:VR | -| SENSOR_TYPE_SCREEN_ROTATION | 屏幕旋转传感器 | 检测设备屏幕的旋转状态 | 用于检测设备屏幕是否发生了旋转 | -| SENSOR_TYPE_DEVICE_ORIENTATION | 设备方向传感器 | 测量设备的旋转方向,单位:rad | 用于检测设备旋转方向的角度值 | -| SENSOR_TYPE_ORIENTATION | 方向传感器 | 测量设备围绕所有三个物理轴(x、y、z)旋转的角度值,单位:rad | 用于提供屏幕旋转的3个角度值 | -| SENSOR_TYPE_ROTATION_VECTOR | 旋转矢量传感器 | 测量设备旋转矢量,复合传感器:由加速度传感器、磁场传感器、陀螺仪传感器合成 | 检测设备相对于东北天坐标系的方向 | -| SENSOR_TYPE_GAME_ROTATION_VECTOR
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | 游戏旋转矢量传感器
地磁旋转矢量传感器 | 测量设备游戏旋转矢量,复合传感器:由加速度传感器、陀螺仪传感器合成
测量设备地磁旋转矢量,复合传感器:由加速度传感器、磁场传感器合成 | 应用于游戏场景
用于测量地磁旋转矢量 | - - - **表4** 光线类-ohos.sensor.agent.CategoryLightAgent - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| ----------------------------- | -------- | ---------------------- | -------------------- | -| SENSOR_TYPE_PROXIMITY | 接近光传感器 | 测量可见物体相对于设备显示屏的接近或远离状态 | 通话中设备相对人的位置 | -| SENSOR_TYPE_TOF | ToF传感器 | 测量光在介质中行进一段距离所需的时间 | 人脸识别 | -| SENSOR_TYPE_AMBIENT_LIGHT | 环境光传感器 | 测量设备周围光线强度,单位:lux | 自动调节屏幕亮度,检测屏幕上方是否有遮挡 | -| SENSOR_TYPE_COLOR_TEMPERATURE | 色温传感器 | 测量环境中的色温 | 应用于设备的影像处理 | -| SENSOR_TYPE_COLOR_RGB | RGB颜色传感器 | 测量环境中的RGB颜色值 | 通过三原色的反射比率实现颜色检测 | -| SENSOR_TYPE_COLOR_XYZ | XYZ颜色传感器 | 测量环境中的XYZ颜色值 | 用于辨识真色色点,还原色彩更真实 | - - - **表5** 健康类-ohos.sensor.agent.CategoryBodyAgent - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| -------------------------- | ------- | --------- | -------------- | -| SENSOR_TYPE_HEART_RATE | 心率传感器 | 测量用户的心率数值 | 用于提供用户的心率健康数据 | -| SENSOR_TYPE_WEAR_DETECTION | 佩戴检测传感器 | 检测用户是否佩戴 | 用于检测用户是否佩戴智能穿戴 | - - - **表6** 其他 - -| 传感器类型 | 中文描述 | 说明 | 主要用途 | -| ----------------------------- | ------- | -------------- | ---------------- | -| SENSOR_TYPE_HALL | 霍尔传感器 | 测量设备周围是否存在磁力吸引 | 设备的皮套模式 | -| SENSOR_TYPE_GRIP_DETECTOR | 手握检测传感器 | 检测设备是否有抓力施加 | 用于检查设备侧边是否被手握住 | -| SENSOR_TYPE_MAGNET_BRACKET | 磁铁支架传感器 | 检测设备是否被磁吸 | 检测设备是否位于车内或者室内 | -| SENSOR_TYPE_PRESSURE_DETECTOR | 按压检测传感器 | 检测设备是否有压力施加 | 用于检测设备的正上方是否存在按压 | +传感器是指用于侦测环境中所发生事件或变化,并将此消息发送至其他电子设备(如中央处理器)的设备,通常由敏感组件和转换组件组成。传感器是实现物联网智能化的重要基石,为实现全场景智慧化战略,支撑“1+8+N”产品需求,需要构筑统一的传感器管理框架,达到为各产品/业务提供低时延、低功耗的感知数据的目的。下面为传感器列表: + +| 传感器类型 | 描述 | 说明 | 主要用途 | +| --------------------------------------- | --------- | ---------------------------------------- | -------------------- | +| SENSOR_TYPE_ACCELEROMETER | 加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的加速度(包括重力加速度),单位 : m/s2 | 检测运动状态 | +| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | 未校准加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的未校准的加速度(包括重力加速度),单位 : m/s2 | 检测加速度偏差估值 | +| SENSOR_TYPE_LINEAR_ACCELERATION | 线性加速度传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的线性加速度(不包括重力加速度),单位 : m/s2 | 检测每个单轴方向上的线性加速度 | +| SENSOR_TYPE_GRAVITY | 重力传感器 | 测量三个物理轴(x、y 和 z)上,施加在设备上的重力加速度,单位 : m/s2 | 测量重力大小 | +| SENSOR_TYPE_GYROSCOPE | 陀螺仪传感器 | 测量三个物理轴(x、y 和 z)上,设备的旋转角速度,单位 : rad/s | 测量旋转的角速度 | +| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | 未校准陀螺仪传感器 | 测量三个物理轴(x、y 和 z)上,设备的未校准旋转角速度,单位 : rad/s | 测量旋转的角速度及偏差估值 | +| SENSOR_TYPE_SIGNIFICANT_MOTION | 大幅度动作传感器 | 测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动 | 用于检测设备是否存在大幅度运动 | +| SENSOR_TYPE_PEDOMETER_DETECTION | 计步器检测传感器 | 检测用户的计步动作;如果取值为1则代表用户产生了计步行走的动作;取值为0则代表用户没有发生运动 | 用于检测用户是否有计步的动作 | +| SENSOR_TYPE_PEDOMETER | 计步器传感器 | 统计用户的行走步数 | 用于提供用户行走的步数数据 | +| SENSOR_TYPE_AMBIENT_TEMPERATURE | 环境温度传感器 | 测量环境温度,单位 : 摄氏度 (°C) | 测量环境温度 | +| SENSOR_TYPE_MAGNETIC_FIELD | 磁场传感器 | 测量三个物理轴向(x、y、z)上,环境地磁场,单位 : μT | 创建指南针 | +| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | 未校准磁场传感器 | 测量三个物理轴向(x、y、z)上,未校准环境地磁场,单位 : μT | 测量地磁偏差估值 | +| SENSOR_TYPE_HUMIDITY | 湿度传感器 | 测量环境的相对湿度,以百分比 (%) 表示 | 监测露点、绝对湿度和相对湿度 | +| SENSOR_TYPE_BAROMETER | 气压计传感器 | 测量环境气压,单位 : hPa 或 mbar | 测量环境气压 | +| SENSOR_TYPE_ORIENTATION | 方向传感器 | 测量设备围绕所有三个物理轴(x、y、z)旋转的角度值,单位:rad | 用于提供屏幕旋转的3个角度值 | +| SENSOR_TYPE_ROTATION_VECTOR | 旋转矢量传感器 | 测量设备旋转矢量,复合传感器:由加速度传感器、磁场传感器、陀螺仪传感器合成 | 检测设备相对于东北天坐标系的方向 | +| SENSOR_TYPE_PROXIMITY | 接近光传感器 | 测量可见物体相对于设备显示屏的接近或远离状态 | 通话中设备相对人的位置 | +| SENSOR_TYPE_AMBIENT_LIGHT | 环境光传感器 | 测量设备周围光线强度,单位:lux | 自动调节屏幕亮度,检测屏幕上方是否有遮挡 | +| SENSOR_TYPE_HEART_RATE | 心率传感器 | 测量用户的心率数值 | 用于提供用户的心率健康数据 | +| SENSOR_TYPE_WEAR_DETECTION | 佩戴检测传感器 | 检测用户是否佩戴 | 用于检测用户是否佩戴智能穿戴 | +| SENSOR_TYPE_HALL | 霍尔传感器 | 测量设备周围是否存在磁力吸引 | 设备的皮套模式 | ## 运作机制 -OpenHarmony传感器包含如下四个模块:Sensor API、Sensor Framework、Sensor Service和HD_IDL层。 +OpenHarmony传感器包含如下四个模块:Sensor API、Sensor Framework、Sensor Service和HDF层。 **图1** OpenHarmony传感器 - ![zh-cn_image_0000001226521897](figures/zh-cn_image_0000001226521897.png) +![fad1a124-a90e-460f-84fc-e87d6caebb21](figures/fad1a124-a90e-460f-84fc-e87d6caebb21.png) - Sensor API:提供传感器的基础API,主要包含查询传感器列表,订阅/取消传感器的数据、执行控制命令等,简化应用开发。 @@ -91,7 +45,7 @@ OpenHarmony传感器包含如下四个模块:Sensor API、Sensor Framework、S - Sensor Service:主要实现HD_IDL层数据接收、解析、分发,前后台的策略管控,对该设备Sensor的管理,Sensor权限管控等。 -- HD_IDL层:对不同的FIFO、频率进行策略选择,以及适配不同设备。 +- HDF层:对不同的FIFO、频率进行策略选择,以及适配不同设备。 ## 约束与限制 @@ -100,12 +54,12 @@ OpenHarmony传感器包含如下四个模块:Sensor API、Sensor Framework、S 表7 传感器数据权限 - | 传感器 | 权限名 | 敏感级别 | 权限描述 | - | ------------------------- | -------------------------------- | ------------ | ----------------------- | - | 加速度传感器,加速度未校准传感器,线性加速度传感器 | ohos.permission.ACCELEROMETER | system_grant | 允许订阅Motion组对应的加速度传感器的数据 | - | 陀螺仪传感器,陀螺仪未校准传感器 | ohos.permission.GYROSCOPE | system_grant | 允许订阅Motion组对应的陀螺仪传感器的数据 | - | 计步器 | ohos.permission.ACTIVITY_MOTION | user_grant | 允许订阅运动状态 | - | 心率计 | ohos.permission.READ_HEALTH_DATA | user_grant | 允许读取健康数据 | +| 传感器 | 权限名 | 敏感级别 | 权限描述 | +| ------------------------- | -------------------------------- | ------------ | ----------------------- | +| 加速度传感器,加速度未校准传感器,线性加速度传感器 | ohos.permission.ACCELEROMETER | system_grant | 允许订阅Motion组对应的加速度传感器的数据 | +| 陀螺仪传感器,陀螺仪未校准传感器 | ohos.permission.GYROSCOPE | system_grant | 允许订阅Motion组对应的陀螺仪传感器的数据 | +| 计步器 | ohos.permission.ACTIVITY_MOTION | user_grant | 允许订阅运动状态 | +| 心率计 | ohos.permission.READ_HEALTH_DATA | user_grant | 允许读取健康数据 | diff --git a/zh-cn/application-dev/device/vibrator-guidelines.md b/zh-cn/application-dev/device/vibrator-guidelines.md index 26fed2b29f902f1a4ccb2eddbef8df40e7986729..a407b2096f22e45c40f1c5129ccfb454ee7f2bf8 100644 --- a/zh-cn/application-dev/device/vibrator-guidelines.md +++ b/zh-cn/application-dev/device/vibrator-guidelines.md @@ -61,7 +61,7 @@ ``` import vibrator from "@ohos.vibrator" - vibrator.vibrate(duration: number).then((error)=>{ + vibrator.vibrate(1000).then((error)=>{ if(error){//调用失败,打印error.code和error.message console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); }else{//调用成功,设备开始振动 @@ -74,11 +74,11 @@ ``` import vibrator from "@ohos.vibrator" - vibrator.stop(stopMode: VibratorStopMode).then((error)=>{ + vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PREET).then((error)=>{ if(error){//调用失败,打印error.code和error.message - console.log(“Promise return failed.error.code”+error.code+“error.message”+error.message); + console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); }else{//调用成功,设备停止振动 - Console.log(“Promise returned to indicate successful.”); + Console.log("Promise returned to indicate successful."); }; }) ``` diff --git a/zh-cn/application-dev/device/vibrator-overview.md b/zh-cn/application-dev/device/vibrator-overview.md index a1bbe9ff4159cc69956db74a57b27464a99c6d3e..037b8bb8326494541b632d14293fcb515ab0f899 100644 --- a/zh-cn/application-dev/device/vibrator-overview.md +++ b/zh-cn/application-dev/device/vibrator-overview.md @@ -6,11 +6,11 @@ ## 运作机制 -Vibrator属于控制类小器件,主要包含以下四个模块:Vibrator API,Vibrator Framework,Vibrator Service和HD_IDL层。 +Vibrator属于控制类小器件,主要包含以下四个模块:Vibrator API,Vibrator Framework,Vibrator Service和HDF层。 **图1** 控制类小器件中的Vibrator - ![zh-cn_image_0000001180249428](figures/zh-cn_image_0000001180249428.png) +![0752d302-aeb9-481a-bb8f-e5524eb61eeb](figures/0752d302-aeb9-481a-bb8f-e5524eb61eeb.png) - Vibrator API:提供振动器基础的API,主要包含振动器的列表查询,振动器的振动器效果查询,触发/关闭振动器等接口。 @@ -18,9 +18,12 @@ Vibrator属于控制类小器件,主要包含以下四个模块:Vibrator API - Vibrator Service:实现控制器的服务管理。 -- HD_IDL层:适配不同设备。 +- HDF层:适配不同设备。 ## 约束与限制 -在使用振动器时,开发者需要配置请求振动器的权限ohos.permission.VIBRATE,才能控制振动器振动。 +在使用振动器时,开发者需要配置请求振动器的权限ohos.permission.VIBRATE,才能控制振动器振动,敏感级别是system_grant。 + + + diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index f069d43ad040419bc6efdbda2b6051b6e3d055cc..4d7b4bd16188112e67ab3b3b5113e2166766f8b0 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -9,7 +9,5 @@ - 视频 - [视频播放开发指导](video-playback.md) - - [视频录制开发指导](video-recorder.md) - - 图片 - [图片开发指导](image.md) diff --git a/zh-cn/application-dev/media/audio-capturer.md b/zh-cn/application-dev/media/audio-capturer.md index 89dfe30f66c2716c046c9d4f23e4fc901d0e9fdd..40dfa18e4dea4a40d6e068b7390e2588df36d5b3 100644 --- a/zh-cn/application-dev/media/audio-capturer.md +++ b/zh-cn/application-dev/media/audio-capturer.md @@ -8,6 +8,8 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioCapturer的状态变更。因为针对AudioCapturer的某些操作,仅在音频采集器在固定状态时才能执行。如果应用在音频采集器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。 +详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md) + ## 开发步骤 1. 使用createAudioCapturer()创建一个AudioCapturer实例。 diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 826e2fa10f5ff7f53ae7dd6a7abafddcc60b85b4..e723548ed6fc93135f0bcd635b64e42e86543107 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -16,7 +16,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index fdc08dad061492b743beb85783bd620a7bfbb89c..6027db0bcb5c223796c7713d7b74d5c396e4bc95 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -16,7 +16,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-renderer.md b/zh-cn/application-dev/media/audio-renderer.md index 7ea9ce05ffc93dab6dae46a083dab7512432f1bc..e1c2509561e1e3b9ab36e9119aac9a80b6ec4ef0 100644 --- a/zh-cn/application-dev/media/audio-renderer.md +++ b/zh-cn/application-dev/media/audio-renderer.md @@ -16,7 +16,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 ### 异步操作 -为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[js-apis-audio](../reference/apis/js-apis-audio.md#audiorenderer8)。 +为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[音频管理API文档AudioRenderer](../reference/apis/js-apis-audio.md#audiorenderer8)。 ## 开发步骤 diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index 7ae121dd86608a0d32bafb663f2ec4a08a77edd0..749bcf03fe58ca3de75ab91976eb9a65788b4c29 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -4,12 +4,10 @@ 图片开发的主要工作是将获取到的图片进行解码,将解码后的pixelmap编码成支持的格式,本文将对图片的解码、编码等场景开发进行介绍说明。 -## 接口说明 - -详细API含义请参考[js-apis-image.md](../reference/apis/js-apis-image.md) - ## 开发步骤 +详细API含义请参考:[图片处理API文档](../reference/apis/js-apis-image.md) + ### 全流程场景 包含流程:创建实例,读取图片信息,读写pixelmap,更新数据,打包像素,释放资源等流程。 diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index cb7610269fe9bd1bb94979fb9a009ec26601ac75..6cef265938cb3311f38ee90a467fd8b53ce167c3 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -35,7 +35,7 @@ ## 开发步骤 -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md) ### 全流程场景 diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md deleted file mode 100644 index fe104cfd0181ff018c8bf43ba5043b06729f43d8..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/media/video-recorder.md +++ /dev/null @@ -1,148 +0,0 @@ -# 视频录制开发指导 - -## 场景介绍 - -视频录制的主要工作是捕获音视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。 - -**图1** 视频录制状态机 - -![zh-ch_image_video_recorder_state_machine](figures/zh-ch_image_video_recorder_state_machine.png) - - - -**图2** 视频录制零层图 - -![zh-ch_image_video_recorder_zero](figures/zh-ch_image_video_recorder_zero.png) - -## 开发步骤 - -详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) - -### 全流程场景 - -包含流程:创建实例,设置录制参数,录制视频,暂停录制,恢复录制,停止录制,释放资源等流程。 - -```js -import media from '@ohos.multimedia.media' -import mediaLibrary from '@ohos.multimedia.mediaLibrary' - -let testFdNumber; - -// pathName是传入的录制文件名,例如:01.mp4,生成后的文件地址:/storage/media/100/local/files/Movies/01.mp4 -// 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA -async function getFd(pathName) { - let displayName = pathName; - const mediaTest = mediaLibrary.getMediaLibrary(); - let fileKeyObj = mediaLibrary.FileKey; - let mediaType = mediaLibrary.MediaType.VIDEO; - let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); - let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); - if (dataUri != undefined) { - let args = dataUri.id.toString(); - let fetchOp = { - selections : fileKeyObj.ID + "=?", - selectionArgs : [args], - } - let fetchFileResult = await mediaTest.getFileAssets(fetchOp); - let fileAsset = await fetchFileResult.getAllObject(); - let fdNumber = await fileAsset[0].open('Rw'); - fdNumber = "fd://" + fdNumber.toString(); - testFdNumber = fdNumber; - } -} - -await getFd('01.mp4'); - -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : testFdNumber, // testFdNumber由getFd生成 - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// 当发生错误上上报的错误回调接口 -function failureCallback(error) { - console.info('error happened, error name is ' + error.name); - console.info('error happened, error code is ' + error.code); - console.info('error happened, error message is ' + error.message); -} - -// 当发生异常时,系统调用的错误回调接口 -function catchCallback(error) { - console.info('catch error happened, error name is ' + error.name); - console.info('catch error happened, error code is ' + error.code); - console.info('catch error happened, error message is ' + error.message); -} - -let videoRecorder = null; // videoRecorder空对象在createVideoRecorder成功后赋值 -let surfaceID = null; // 用于保存getInputSurface返回的surfaceID - -// 创建videoRecorder对象 -await media.createVideoRecorder().then((recorder) => { - console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - } else { - console.info('createVideoRecorder failed'); - } -}, failureCallback).catch(catchCallback); - -// 获取surfaceID并保存下来传递给camera相关接口 -await videoRecorder.getInputSurface().then((surface) => { - console.info('getInputSurface success'); - surfaceID = surface; -}, failureCallback).catch(catchCallback); - -// 视频录制依赖相机相关接口,以下需要先调用相机起流接口后才能继续执行 - -// 视频录制启动接口 -await videoRecorder.start().then(() => { - console.info('start success'); -}, failureCallback).catch(catchCallback); - -// 调用pause接口时需要暂停camera出流 -await videoRecorder.pause().then(() => { - console.info('pause success'); -}, failureCallback).catch(catchCallback); - -// 调用resume接口时需要恢复camera出流 -await videoRecorder.resume().then(() => { - console.info('resume success'); -}, failureCallback).catch(catchCallback); - -// 停止camera出流后,停止视频录制 -await videoRecorder.stop().then(() => { - console.info('stop success'); -}, failureCallback).catch(catchCallback); - -// 重置录制相关配置 -await videoRecorder.reset().then(() => { - console.info('reset success'); -}, failureCallback).catch(catchCallback); - -// 释放视频录制相关资源并释放camera对象相关资源 -await videoRecorder.release().then(() => { - console.info('release success'); -}, failureCallback).catch(catchCallback); - -// 相关对象置null -videoRecorder = null; -surfaceID = null; -``` - diff --git a/zh-cn/application-dev/notification/common-event.md b/zh-cn/application-dev/notification/common-event.md index b9cada5c9dfc1f4daf51b6cc03bec34e08d0c3f2..222dcb4565f86eedb09431dd053e1cbafb2f6890 100644 --- a/zh-cn/application-dev/notification/common-event.md +++ b/zh-cn/application-dev/notification/common-event.md @@ -29,7 +29,7 @@ OpenHarmony通过CES(Common Event Service,公共事件服务)为应用程 import commonEvent from '@ohos.commonEvent'; ``` -2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscrubeInfo文档](../reference/apis/js-apis-commonEventSubscribeInfo.md)介绍。 +2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscribeInfo文档](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo)介绍。 ```javascript private subscriber = null //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 @@ -55,7 +55,7 @@ commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => { }) ``` -4. 创建订阅回调函数,订阅回调函数会在接收到事件时触发。订阅回调函数返回的data内包含了公共事件的名称、发布者携带的数据等信息,公共事件数据的详细参数和数据类型请见[CommonEventData文档](../reference/apis/js-apis-commonEventData.md)介绍。 +4. 创建订阅回调函数,订阅回调函数会在接收到事件时触发。订阅回调函数返回的data内包含了公共事件的名称、发布者携带的数据等信息,公共事件数据的详细参数和数据类型请见[CommonEventData文档](../reference/apis/js-apis-commonEvent.md#commoneventdata)介绍。 ```javascript //订阅公共事件回调 @@ -113,7 +113,7 @@ commonEvent.publish("event", (err) => { import commonEvent from '@ohos.commonEvent' ``` -2. 定义发布事件时需要指定的发布信息,发布信息所包含的详细参数及其参数类型请见[CommonEventPublishData文档](../reference/apis/js-apis-commonEventPublishData.md)介绍。 +2. 定义发布事件时需要指定的发布信息,发布信息所包含的详细参数及其参数类型请见[CommonEventPublishData文档](../reference/apis/js-apis-commonEvent.md#commoneventpublishdata)介绍。 ```javascript //公共事件相关信息 @@ -174,7 +174,7 @@ if (this.subscriber != null) { 针对公共事件开发,有以下示例工程可供参考: -- [EtsCommonEvent](https://gitee.com/openharmony/app_samples/tree/master/ability/EtsCommonEvent) +- [CommonEvent](https://gitee.com/openharmony/app_samples/tree/master/ability/CommonEvent) 本示例展示了在eTS中如何使用CommonEvent的接口完成创建订阅者、订阅公共事件、发布公共事件、取消订阅的功能。 diff --git a/zh-cn/application-dev/notification/notification.md b/zh-cn/application-dev/notification/notification.md index 114232b8fc4edca9b6c0d3a51c4706fa9b48db32..fe23cf4e58540216518515d1688185b87f5b19c5 100644 --- a/zh-cn/application-dev/notification/notification.md +++ b/zh-cn/application-dev/notification/notification.md @@ -131,33 +131,7 @@ var subscriber = { ### 通知发送 -通知发布前,先查询应用通知使能开关是否打开,新安装的应用使能默认是关闭状态。 - -##### 开启通知使能 - -先查询通知使能 - -```js -var bundle = { - bundle: "bundleName1", -} -Notification.isNotificationEnabled(bundle).then((data) => { - console.info("===>isNotificationEnabled success===>"); -}); -``` - -若使能为false关闭状态,需要开启使能 - -```js -var bundle = { - bundle: "bundleName1", -} -Notification.enableNotification(bundle, true, async(err) => { - console.log("===>enableNotification success===>"); -}); -``` - - +通知发布前,先要确认通知发送使能是否开启,新安装的应用使能默认是关闭状态,需要到通知设置里开启。 ##### 通知发布 @@ -170,7 +144,7 @@ Notification.enableNotification(bundle, true, async(err) => { var notificationRequest = { id: 1, content: { - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", @@ -197,25 +171,18 @@ wantAgent使用详见[wantAgent开发文档](https://gitee.com/openharmony/docs/ ```js import wantAgent from '@ohos.wantAgent'; -import { OperationType, Flags } from '@ohos.wantagent'; //WantAgentInfo对象 var wantAgentInfo = { - wants: [ - { - deviceId: 'deviceId', - bundleName: 'com.example.myapplication', - abilityName: 'com.example.myapplication.MainAbility', - action: 'REMINDER_EVENT_REMOVE_NOTIFICATION', - entities: ['entity1'], - type: 'MIMETYPE', - uri: 'key={true,true,false}', - parameters: { myKey0: 1111 }, - } - ], - operationType: OperationType.START_ABILITIES, - requestCode: 0, - wantAgentFlags:[Flags.UPDATE_PRESENT_FLAG] + wants: [ + { + bundleName: 'ohos.samples.eTSNotification', + abilityName: 'ohos.samples.eTSNotification.MainAbility', + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } //wantAgent对象 @@ -241,7 +208,7 @@ wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) //构造NotificationRequest对象 var notificationRequest = { content: { - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "AceApplication_Title", text: "AceApplication_Text", @@ -251,7 +218,7 @@ var notificationRequest = { id: 1, label: 'TEST', wantAgent: WantAgent, - slotType: notify.SlotType.OTHER_TYPES, + slotType: Notification.SlotType.OTHER_TYPES, deliveryTime: new Date().getTime() } @@ -284,9 +251,9 @@ Notification.cancel(1, "label", cancelCallback) 针对通知开发,有以下示例工程可供参考: -- notification +- [Notification](https://gitee.com/openharmony/app_samples/tree/master/Notification/Notification) -本示例展示了在eTS中如何使用Notification的接口完成通知订阅、取消订阅、发布通知、取消通知、查询和开启通知使能功能。 +本示例展示了在eTS中如何使用Notification的接口完成通知订阅、取消订阅、发布通知、取消通知功能。 diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index c3104c0b74b7176584af8df66611c0f6938931db..f86eb55f4a2701fef2c24eeb8b8901ef965c0c75 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -1,19 +1,12 @@ # 入门 -- DevEco Studio(OpenHarmony)使用指南 - - [概述](deveco-studio-overview.md) - - [版本变更说明](deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](configuring-openharmony-sdk.md) - - 创建OpenHarmony工程 - - [使用工程向导创建新工程](use-wizard-to-create-project.md) - - [通过导入Sample方式创建新工程](import-sample-to-create-project.md) - - [配置OpenHarmony应用签名信息](configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](installing-openharmony-app.md) - 快速入门 - - [前言](start-overview.md) + - [开发准备](start-overview.md) - [使用eTS语言开发](start-with-ets.md) - [使用JS语言开发(传统代码方式)](start-with-js.md) - [使用JS语言开发(低代码方式)](start-with-js-low-code.md) -- [包结构说明](package-structure.md) -- [资源文件的分类](basic-resource-file-categories.md) +- 开发基础知识 + - [包结构说明](package-structure.md) + - [资源文件的分类](basic-resource-file-categories.md) + - [SysCap说明](syscap.md) diff --git a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md index 97cdaa0ab35c5fed21c5b15950530cdca098fedb..d2ca64a3857ce8027ff494705bfc99c5790ee3dd 100644 --- a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md +++ b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md @@ -1,5 +1,6 @@ # 资源文件的分类 +应用开发中使用的各类资源文件,需要放入特定子目录中存储管理。 ## resources目录 @@ -24,11 +25,11 @@ resources **表1** resources目录分类 -| 分类 | base目录与限定词目录 | rawfile目录 | -| -------- | -------- | -------- | -| 组织形式 | 按照两级目录形式来组织,目录命名必须符合规范,以便根据设备状态去匹配相应目录下的资源文件。
  一级子目录为**base目录**和**限定词目录**。
- base目录是默认存在的目录。当应用的resources资源目录中没有与设备状态匹配的限定词目录时,会自动引用该目录中的资源文件。
- 限定词目录需要开发者自行创建。目录名称由一个或多个表征应用场景或设备特征的限定词组合而成,具体要求参见[限定词目录](#限定词目录)。
二级子目录为**资源目录**,用于存放字符串、颜色、布尔值等基础元素,以及媒体、动画、布局等资源文件,具体要求参见[资源组目录](#资源组目录)。 | 支持创建多层子目录,目录名称可以自定义,文件夹内可以自由放置各类资源文件。
rawfile目录的文件不会根据设备状态去匹配不同的资源。 | -| 编译方式 | 目录中的资源文件会被编译成二进制文件,并赋予资源文件ID。 | 目录中的资源文件会被直接打包进应用,不经过编译,也不会被赋予资源文件ID。 | -| 引用方式 | 通过指定资源类型(type)和资源名称(name)来引用。 | 通过指定文件路径和文件名来引用。 | +| 分类 | base目录与限定词目录 | 限定词目录 | rawfile目录 | +| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| 组织形式 | base目录是默认存在的目录。当应用的resources目录中没有与设备状态匹配的限定词目录时,会自动引用该目录中的资源文件。
base目录的二级子目录为**资源组目录**,用于存放字符串、颜色、布尔值等基础元素,以及媒体、动画、布局等资源文件,具体要求参见[资源组目录](#资源组目录)。 | 限定词目录需要开发者自行创建。目录名称由一个或多个表征应用场景或设备特征的限定词组合而成,具体要求参见[限定词目录](#限定词目录)。
限定词目录的二级子目录为**资源组目录**,用于存放字符串、颜色、布尔值等基础元素,以及媒体、动画、布局等资源文件,具体要求参见[资源组目录](#资源组目录)。 | 支持创建多层子目录,目录名称可以自定义,文件夹内可以自由放置各类资源文件。
rawfile目录的文件不会根据设备状态去匹配不同的资源。 | +| 编译方式 | 目录中的资源文件会被编译成二进制文件,并赋予资源文件ID。 | 目录中的资源文件会被编译成二进制文件,并赋予资源文件ID。 | 目录中的资源文件会被直接打包进应用,不经过编译,也不会被赋予资源文件ID。 | +| 引用方式 | 通过指定资源类型(type)和资源名称(name)来引用。 | 通过指定资源类型(type)和资源名称(name)来引用。 | 通过指定文件路径和文件名来引用。 | ## 限定词目录 @@ -43,17 +44,17 @@ resources - 限定词的取值范围:每类限定词的取值必须符合限定词取值要求表中的条件,否则,将无法匹配目录中的资源文件。 **表2** 限定词取值要求 - - | 限定词类型 | 含义与取值说明 | - | -------- | -------- | - | 移动国家码和移动网络码 | 移动国家码(MCC)和移动网络码(MNC)的值取自设备注册的网络。MCC后面可以跟随MNC,使用下划线(_)连接,也可以单独使用。例如:mcc460表示中国,mcc460_mnc00表示中国_中国移动。
详细取值范围,请查阅**ITU-T E.212**(国际电联相关标准)。 | - | 语言 | 表示设备使用的语言类型,由2~3个小写字母组成。例如:zh表示中文,en表示英语,mai表示迈蒂利语。
详细取值范围,请查阅**ISO 639**(ISO制定的语言编码标准)。 | - | 文字 | 表示设备使用的文字类型,由1个大写字母(首字母)和3个小写字母组成。例如:Hans表示简体中文,Hant表示繁体中文。
详细取值范围,请查阅**ISO 15924**(ISO制定的文字编码标准)。 | - | 国家或地区 | 表示用户所在的国家或地区,由2~3个大写字母或者3个数字组成。例如:CN表示中国,GB表示英国。
详细取值范围,请查阅**ISO 3166-1**(ISO制定的国家和地区编码标准)。 | - | 横竖屏 | 表示设备的屏幕方向,取值如下:
- vertical:竖屏
- horizontal:横屏 | - | 设备类型 | 表示设备的类型,取值如下:
- phone:手机
- tablet:平板
- car:车机
- tv:智慧屏
- wearable:智能穿戴 | - | 颜色模式 | 表示设备的颜色模式,取值如下:
- dark:深色模式
- light:浅色模式 | - | 屏幕密度 | 表示设备的屏幕密度(单位为dpi),取值如下:
- sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0, 120]的设备。
- mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120, 160]的设备。
- ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160, 240]的设备。
- xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240, 320]的设备。
- xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320, 480]的设备。
- xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | + +| 限定词类型 | 含义与取值说明 | +| ----------- | ---------------------------------------- | +| 移动国家码和移动网络码 | 移动国家码(MCC)和移动网络码(MNC)的值取自设备注册的网络。MCC后面可以跟随MNC,使用下划线(_)连接,也可以单独使用。例如:mcc460表示中国,mcc460_mnc00表示中国_中国移动。
详细取值范围,请查阅**ITU-T E.212**(国际电联相关标准)。 | +| 语言 | 表示设备使用的语言类型,由2~3个小写字母组成。例如:zh表示中文,en表示英语,mai表示迈蒂利语。
详细取值范围,请查阅**ISO 639**(ISO制定的语言编码标准)。 | +| 文字 | 表示设备使用的文字类型,由1个大写字母(首字母)和3个小写字母组成。例如:Hans表示简体中文,Hant表示繁体中文。
详细取值范围,请查阅**ISO 15924**(ISO制定的文字编码标准)。 | +| 国家或地区 | 表示用户所在的国家或地区,由2~3个大写字母或者3个数字组成。例如:CN表示中国,GB表示英国。
详细取值范围,请查阅**ISO 3166-1**(ISO制定的国家和地区编码标准)。 | +| 横竖屏 | 表示设备的屏幕方向,取值如下:
- vertical:竖屏
- horizontal:横屏 | +| 设备类型 | 表示设备的类型,取值如下:
- phone:手机
- tablet:平板
- car:车机
- tv:智慧屏
- wearable:智能穿戴 | +| 颜色模式 | 表示设备的颜色模式,取值如下:
- dark:深色模式
- light:浅色模式 | +| 屏幕密度 | 表示设备的屏幕密度(单位为dpi),取值如下:
- sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0, 120]的设备。
- mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120, 160]的设备。
- ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160, 240]的设备。
- xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240, 320]的设备。
- xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320, 480]的设备。
- xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | **限定词目录与设备状态的匹配规则** @@ -69,11 +70,11 @@ base目录与限定词目录下面可以创建资源组目录(包括element、 **表3** **资源组目录说明** -| 资源组目录 | 目录说明 | 资源文件 | -| -------- | -------- | -------- | -| element | 表示元素资源,以下每一类数据都采用相应的JSON文件来表征。
- boolean,布尔型
- color,颜色
- float,浮点型
- intarray,整型数组
- integer,整型
- pattern,样式
- plural,复数形式
- strarray,字符串数组
- string,字符串 | element目录中的文件名称建议与下面的文件名保持一致。每个文件中只能包含同一类型的数据。
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | -| media | 表示媒体资源,包括图片、音频、视频等非文本格式的文件。 | 文件名可自定义,例如:icon.png。 | -| animation | 表示动画资源,采用XML文件格式。 | 文件名可自定义,例如:zoom_in.xml。 | -| layout | 表示布局资源,采用XML文件格式。 | 文件名可自定义,例如:home_layout.xml。 | -| graphic | 表示可绘制资源,采用XML文件格式。 | 文件名可自定义,例如:notifications_dark.xml。 | -| profile | 表示其他类型文件,以原始文件形式保存。 | 文件名可自定义。 | +| 资源组目录 | 目录说明 | 资源文件 | +| --------- | ---------------------------------------- | ---------------------------------------- | +| element | 表示元素资源,以下每一类数据都采用相应的JSON文件来表征。
- boolean,布尔型
- color,颜色
- float,浮点型
- intarray,整型数组
- integer,整型
- pattern,样式
- plural,复数形式
- strarray,字符串数组
- string,字符串 | element目录中的文件名称建议与下面的文件名保持一致。每个文件中只能包含同一类型的数据。
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | 表示媒体资源,包括图片、音频、视频等非文本格式的文件。 | 文件名可自定义,例如:icon.png。 | +| animation | 表示动画资源,采用XML文件格式。 | 文件名可自定义,例如:zoom_in.xml。 | +| layout | 表示布局资源,采用XML文件格式。 | 文件名可自定义,例如:home_layout.xml。 | +| graphic | 表示可绘制资源,采用XML文件格式。 | 文件名可自定义,例如:notifications_dark.xml。 | +| profile | 表示其他类型文件,以原始文件形式保存。 | 文件名可自定义。 | diff --git a/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md b/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md deleted file mode 100644 index dd3b698de6e88b9ffe0da2977e055878e8166ada..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md +++ /dev/null @@ -1,190 +0,0 @@ -# 配置OpenHarmony应用签名信息 - - -使用真机设备运行和调试OpenHarmony应用前,需要对应用进行签名才能正常运行。该指导用于OpenHarmony应用的签名配置。除此章节以外,DevEco Studio的其余操作指导无差别,具体请访问[HUAWEI DevEco Studio使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/tools_overview-0000001053582387)。配置应用签名信息的流程如下图所示。 - - -![zh-cn_image_0000001113808114](figures/zh-cn_image_0000001113808114.png) - - -## 生成密钥和证书请求文件 - -OpenHarmony应用通过数字证书(.cer文件)和Profile文件(.p7b文件)来保证应用的完整性,需要通过DevEco Studio来生成密钥文件(.p12文件)和证书请求文件(.csr文件)。同时,也可以使用命令行工具的方式来生成密钥文件和证书请求文件。 - - -### 使用DevEco Studio生成 - -1. 在主菜单栏点击**Build > Generate Keyand CSR**。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果本地已有对应的密钥,无需新生成密钥,可以在**Generate Key**界面中点击下方的Skip跳过密钥生成过程,直接使用已有密钥生成证书请求文件。 - -2. 在**Key Store File**中,可以点击**Choose Existing**选择已有的密钥库文件(存储有密钥的.p12文件);如果没有密钥库文件,点击**New**进行创建。下面以新创建密钥库文件为例进行说明。 - ![zh-cn_image_0000001119560738](figures/zh-cn_image_0000001119560738.png) - -3. 在**Create Key Store**窗口中,填写密钥库信息后,点击**OK**。 - - **Key Store File**:选择密钥库文件存储路径。 - - **Password**:设置密钥库密码,必须由大写字母、小写字母、数字和特殊符号中的两种以上字符的组合,长度至少为8位。请记住该密码,后续签名配置需要使用。 - - **Confirm Password**:再次输入密钥库密码。 - - ![zh-cn_image_0000001152674854](figures/zh-cn_image_0000001152674854.png) - -4. 在**Generate Key**界面中,继续填写密钥信息后,点击**Next**。 - - **Alias**:密钥的别名信息,用于标识密钥名称。请记住该别名,后续签名配置需要使用。 - - **Password**:密钥对应的密码,与密钥库密码保持一致,无需手动输入。 - - **Validity**:证书有效期,建议设置为25年及以上,覆盖应用/服务的完整生命周期。 - - **Certificate**:输入证书基本信息,如组织、城市或地区、国家码等。 - - ![zh-cn_image_0000001117639668](figures/zh-cn_image_0000001117639668.png) - -5. 在**Generate CSR**界面,选择密钥和设置CSR文件存储路径。 - ![zh-cn_image_0000001117479776](figures/zh-cn_image_0000001117479776.png) - -6. 点击**OK**按钮,创建CSR文件成功,可以在存储路径下获取生成的密钥库文件(.p12)和证书请求文件(.csr)。 - ![zh-cn_image_0000001163839541](figures/zh-cn_image_0000001163839541.png) - - -### 使用命令行工具生成 - -使用Open JDK携带的Keytool工具生成证书请求文件。 - -1. 使用管理员身份运行命令行工具。 - - ![zh-cn_image_0000001248045243](figures/zh-cn_image_0000001248045243.png) - -2. 切换到keytool工具所在路径,实际路径请根据安装目录进行修改。 - ![zh-cn_image_0000001247125297](figures/zh-cn_image_0000001247125297.png) - -3. 执行如下命令,生成公私钥文件。例如,生成的密钥库名称为ide_demo_app.p12,存储到D盘根目录下。 - ``` - keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=Organization,OU=Unit,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc - ``` - - 生成公私钥文件的参数说明如下: - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 请记录**下alias、storepass**和**keypass**的值,在后续[配置应用签名信息](#配置应用签名信息)操作会使用到。 - - - **alias**:密钥的别名信息,用于标识密钥名称。 - - **sigalg**:签名算法,固定为**SHA256withECDSA**。 - - **dname**:按照操作界面提示进行输入。 - - C:国家/地区代码,如CN。 - - O:组织名称,如Organization。 - - OU:组织单位名称,如Unit。 - - CN:名字与姓氏,建议与别名一致。 - - **validity**:证书有效期,建议设置为9125(25年)。 - - **storepass**:设置密钥库密码,必须由大写字母、小写字母、数字和特殊符号中的两种以上字符的组合,长度至少为8位。请记住该密码,后续签名配置需要使用。 - - **keypass**:设置密钥的密码,请与**storepass**保持一致。 - -4. 执行如下命令,执行后需要输入**storepass**密码,生成证书请求文件,后缀格式为.csr。 - ``` - keytool -certreq -alias "ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -file d:\\idedemokey.csr - ``` - - 生成证书请求文件的参数说明如下: - - - **alias**:与3中输入的alias保持一致。 - - **file**:生成的证书请求文件名称,后缀为.csr。 - - -## 生成应用证书文件 - -使用[生成密钥和证书请求文件](#生成密钥和证书请求文件)中生成的证书请求文件,来生成应用签名所需的数字证书文件。生成方法如下: - -进入DevEco Studio安装目录的**Sdk\toolchains\lib**文件夹下(该SDK目录只能是OpenHarmony SDK,配置方法可参考[配置OpenHarmony SDK](../quick-start/configuring-openharmony-sdk.md)),打开命令行工具,执行如下命令(如果keytool命令不能执行,请在系统环境变量中添加JDK的环境变量)。其中,只需要修改输入和输出即可快速生成证书文件,即修改**-infile**指定证书请求文件csr文件路径,**-outfile**指定输出证书文件名及路径。 - -``` -keytool -gencert -alias "OpenHarmony Application CA" -infile myApplication_ohos.csr -outfile myApplication_ohos.cer -keystore OpenHarmony.p12 -sigalg SHA384withECDSA -storepass 123456 -ext KeyUsage:"critical=digitalSignature" -validity 3650 -rfc -``` - -关于该命令的参数说明如下: - -- **alias**:用于签发证书的CA私钥别名,OpenHarmony社区CA私钥存于OpenHarmony.p12密钥库文件中,该参数不能修改。 - -- **infile**:证书请求(CSR)文件的路径。 - -- **outfile**:输出证书链文件名及路径。 - -- **keystore**:签发证书的CA密钥库路径,OpenHarmony密钥库文件名为OpenHarmony.p12,文件在OpenHarmony SDK中**Sdk\toolchains\lib**路径下,该参数不能修改。请注意,该OpenHarmony.p12文件并不是[生成密钥和证书请求文件](#生成密钥和证书请求文件)中生成的.p12文件。 - -- **sigalg**:证书签名算法,该参数不能修改。 - -- **storepass**:密钥库密码,密码为123456,该参数不能修改。 - -- **ext**:证书扩展项,该参数不能修改。 - -- **validity**:证书有效期,自定义天数。 - -- **rfc**:输出文件格式指定,该参数不能修改。 - - -## 生成应用Profile文件 - -Profile文件包含OpenHarmony应用的包名、数字证书信息、描述应用允许申请的证书权限列表,以及允许应用调试的设备列表(如果应用类型为Release类型,则设备列表为空)等内容,每个应用包中均必须包含一个Profile文件。 - -进入**Sdk\toolchains\lib**目录下,打开命令行工具,执行如下命令。 - -``` -java -jar provisionsigtool.jar sign --in UnsgnedReleasedProfileTemplate.json --out myApplication_ohos_Provision.p7b --keystore OpenHarmony.p12 --storepass 123456 --alias "OpenHarmony Application Profile Release" --sigAlg SHA256withECDSA --cert OpenHarmonyProfileRelease.pem --validity 365 --developer-id ohosdeveloper --bundle-name 包名 --permission 受限权限名(可选) --permission 受限权限名(可选) --distribution-certificate myApplication_ohos.cer -``` - -关于该命令的参数说明如下: - -- **provisionsigtool**:Profile文件生成工具,文件在OpenHarmony SDK的**Sdk\toolchains\lib**路径下。 - -- **in**:Profile模板文件所在路径,文件在OpenHarmony SDK中**Sdk\toolchains\lib**路径下,该参数不能修改。 - -- **out**:输出的Profile文件名和路径。 - -- **keystore**:签发证书的密钥库路径,OpenHarmony密钥库文件名为OpenHarmony.p12,文件在OpenHarmony SDK中**Sdk\toolchains\lib**路径下,该参数不能修改。 - -- **storepass**:密钥库密码,密码为123456,该参数不能修改。 - -- **alias**:用于签名Profile私钥别名,OpenHarmony社区CA私钥存于OpenHarmony.p12密钥库文件中,该参数不能修改。 - -- **sigalg**:证书签名算法,该参数不能修改。 - -- **cert**:签名Profile的证书文件路径,文件在OpenHarmony SDK中**Sdk\toolchains\lib**路径下,该参数不能修改。 - -- **validity**:证书有效期,自定义天数。 - -- **developer-id**:开发者标识符,自定义一个字符串。 - -- **bundle-name**:填写应用包名。 - -- **permission**:可选字段,如果不需要,则可以不用填写此字段;如果需要添加多个受限权限,则如示例所示重复输入。受限权限列表如下:ohos.permission.READ_CONTACTS、ohos.permission.WRITE_CONTACTS。 - -- **distribution-certificate**:[生成应用证书文件](#生成应用证书文件)中生成的证书文件。 - - -## 配置应用签名信息 - -在真机设备上调试前,需要使用到制作的私钥(.p12)文件、证书(.cer)文件和Profile(.p7b)文件对调试的模块进行签名。 - -打开**File > Project Structure**,点击**Project > Signing Configs > debug**窗口中,去除勾选“Automatically generate signing”,然后配置指定模块的调试签名信息。 -- **Store File**:选择密钥库文件,文件后缀为.p12,该文件为[生成密钥和证书请求文件](#生成密钥和证书请求文件)中生成的.p12文件。 - -- **Store Password**:输入密钥库密码,该密码为[生成密钥和证书请求文件](#生成密钥和证书请求文件)中填写的密钥库密码保持一致。 - -- **Key Alias**:输入密钥的别名信息,与[生成密钥和证书请求文件](#生成密钥和证书请求文件)中填写的别名保持一致。 - -- **Key Password**:输入密钥的密码,与**Store Password**保持一致。 - -- **Sign Alg**:签名算法,固定为SHA256withECDSA。 - -- **Profile File**:选择[生成应用Profile文件](#生成应用profile文件)中生成的Profile文件,文件后缀为.p7b。 - -- **Certpath File**:选择[生成应用证书文件](#生成应用证书文件)中生成的数字证书文件,文件后缀为.cer。 - -![zh-cn_image_0000001155643492](figures/zh-cn_image_0000001155643492.png) - -设置完签名信息后,点击**OK**进行保存,然后可以在工程下的build.gradle中查看签名的配置信息。 - -![zh-cn_image_0000001202722349](figures/zh-cn_image_0000001202722349.png) - -默认情况下,DevEco Studio编译hap包的类型为debug类型,如果需要编译release类型的hap包,请打开工程左下角的OhosBuild Variants,设置模块的编译构建类型为release。关于编译构建hap的详细说明请参考[HUAWEI DevEco Studio使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/build_hap-0000001053342418)。 - -![zh-cn_image_0000001115066116](figures/zh-cn_image_0000001115066116.png) - -编译完成后,OpenHarmony应用的Hap包可以从工程的bulid目录下获取。 - -![zh-cn_image_0000001163918627](figures/zh-cn_image_0000001163918627.png) diff --git a/zh-cn/application-dev/quick-start/configuring-openharmony-sdk.md b/zh-cn/application-dev/quick-start/configuring-openharmony-sdk.md deleted file mode 100644 index 435b9d34c56f93e4d2e80cf877f11ab3a2e760aa..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/configuring-openharmony-sdk.md +++ /dev/null @@ -1,165 +0,0 @@ -# 配置OpenHarmony SDK - - -在设置OpenHarmony应用开发环境时,需要开发者在DevEco Studio中配置对应的SDK信息。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 请注意,OpenHarmony SDK版本精简了部分工具链,因此不适用于HarmonyOS应用开发。 - - -## 前提条件 - -已下载并安装好DevEco Studio 3.0 Beta1及以上版本,点击[链接下载](https://developer.harmonyos.com/cn/develop/deveco-studio#download)。 - - -## 配置SDK信息 - -DevEco Studio通过SDK Manager统一管理SDK及工具链,OpenHarmony包含如下SDK包: - -| 类别 | 包名 | 说明 | -| -------- | -------- | -------- | -| SDK | JS | JS语言SDK包。 | -| eTS | eTS(Extended TypeScript) SDK包。 | -| SDK Tool | Toolchains | SDK工具链,OpenHarmony应用开发必备工具集,包括编译、打包、签名、数据库管理等工具的集合。 | -| Previewer | OpenHarmony应用预览器,可以在应用开发过程中查看界面UI布局效果。 | - -1. 运行已安装的DevEco Studio,首次使用,请选择**Do not import settings**,点击OK。 - -2. 进入配置向导页面,设置**npm registry**,DevEco Studio已预置对应的仓,直接点击**Start using DevEco Studio**进入下一步。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果配置向导界面出现的是设置**Set up HTTP Proxy**界面,说明网络受限,请根据[参考信息](#参考信息)配置DevEco Studio代理、NPM代理和Gradle代理后,再下载OpenHarmony SDK。 - - ![zh-cn_image_0000001163314102](figures/zh-cn_image_0000001163314102.png) - -3. DevEco Studio向导指引开发者下载SDK,默认下载OpenHarmony SDK。SDK下载到user目录下,也可以指定对应的存储路径,SDK存储路径不支持中文字符,然后点击**Next**。 - ![zh-cn_image_0000001208394019](figures/zh-cn_image_0000001208394019.png) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果不是首次安装DevEco Studio,可能无法查看进入该界面,可通过欢迎页的**Configure (或**![zh-cn_image_0000001208274069](figures/zh-cn_image_0000001208274069.png)**图标)> Settings > SDK Manager > OpenHarmony SDK**界面,点击**OpenHarmony SDK Location**加载SDK。 - -4. 在弹出的SDK下载信息页面,点击**Next**,并在弹出的**License Agreement**窗口,点击**Accept**开始下载SDK。 - - ![zh-cn_image_0000001163472654](figures/zh-cn_image_0000001163472654.png) - -5. 等待OpenHarmony SDK及工具下载完成,点击**Finish**,界面会进入到DevEco Studio欢迎页。 - ![zh-cn_image_0000001163632602](figures/zh-cn_image_0000001163632602.png) - - -## 参考信息 - -DevEco Studio开发环境需要依赖于网络环境,需要连接上网络才能确保工具的正常使用。 - -一般来说,如果使用的是个人或家庭网络,是不需要设置代理信息的;只有部分企业网络受限的情况下,才需要设置代理信息。 - -如果是第一次打开DevEco Studio,配置向导界面出现设置**Set up HTTP Proxy**界面,说明网络受限,可以通过配置代理的方式来解决,需要配置DevEco Studio代理、NPM代理和Gradle代理。 - -![zh-cn_image_0000001166582138](figures/zh-cn_image_0000001166582138.png) - - -### 配置DevEco Studio代理 - -1. 启动DevEco Studio,配置向导进入**Set up HTTP Proxy**界面,勾选**Manual proxy configuration**,设置DevEco Studio的HTTP Proxy。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果非首次设置向导进入HTTP Proxy,可以通过如下方式进入HTTP Proxy配置界面: - > - > - 在欢迎页点击**Configure(或**![zh-cn_image_0000001212142015](figures/zh-cn_image_0000001212142015.png)**图标) > Settings > Appearance & Behavior > System Settings > HTTP Proxy**进入HTTP Proxy设置界面(Mac系统为**Configure > Preferences > Appearance & Behavior > System Settings > HTTP Proxy**)。 - > - > - 在打开了工程的情况下,可以点击**File > Settings > Appearance & Behavior > System Settings > HTTP Proxy**进入HTTP Proxy设置界面(Mac系统为**DevEco Studio > Preferences > Appearance & Behavior > System Settings > HTTP Proxy**) - - - **HTTP**配置项,设置代理服务器信息。**如果不清楚代理服务器信息,可以咨询你们的网络管理人员**。 - - **Host name**:代理服务器主机名或IP地址。 - - **Port number**:代理服务器对应的端口号。 - - **No proxy for**:不需要通过代理服务器访问的URL或者IP地址(地址之间用英文逗号分隔)。 - - **Proxy authentication**配置项,如果代理服务器需要通过认证鉴权才能访问,则需要设置。否则,请跳过该配置项。 - - **Login**:访问代理服务器的用户名。 - - **Password**:访问代理服务器的密码。 - - **Remember**:勾选,记住密码。 - - ![zh-cn_image_0000001212062065](figures/zh-cn_image_0000001212062065.png) - -2. 配置完成后,点击**Check connection**,输入网络地址(如:https://developer.harmonyos.com),检查网络连通性。提示Connection successful表示代理设置成功。 - -3. 点击**Next: Configure npm**继续设置NPM代理信息,请参考[配置NPM代理](#配置npm代理)。 - - -### 配置NPM代理 - -通过DevEco Studio的设置向导设置NPM代理信息,代理信息将写入用户“users/用户名/”目录下的**.npmrc**文件。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该向导只有第一次安装DevEco Studio才会出现。如果未出现该向导,可以直接在“users/用户名/”目录下的**.npmrc**文件中,添加代理配置信息。 - -- npm registry:设置npm仓的地址信息,建议勾选。 - -- HTTP proxy:代理服务器信息,默认会与DevEco Studio的HTTP proxy设置项保持一致。 - -- Enable Https Proxy:同步设置HTTPS Proxy配置信息,建议勾选。 - -![zh-cn_image_0000001164577336](figures/zh-cn_image_0000001164577336.png) - -然后点击**Start using DevEco Studio**继续下一步操作。 - -如果代理服务器需要认证(需要用户名和密码),请先根据如下指导配置代理服务器的用户名和密码信息,然后再下载OpenHarmony SDK;否则,请跳过该操作,参考[配置SDK信息](#配置sdk信息)进行操作即可。 - -![zh-cn_image_0000001209817299](figures/zh-cn_image_0000001209817299.png) - -1. 进入用户的users目录,打开**.npmrc**文件。 - -2. 修改npm代理信息,在proxy和https-proxy中,增加user和password字段,具体取值请以实际代理信息为准。示例如下所示: - ``` - proxy=http://user:password@proxy.server.com:80 - https-proxy=http://user:password@proxy.server.com:80 - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果password中存在特殊字符,如\@、\#、\*等符号,可能导致配置不生效,建议将特殊字符替换为ASCII码,并在ASCII码前加百分号%。常用符号替换为ASCII码对照表如下: - > - > - !:%21 - > - > - \@:%40 - > - > - \#:%23 - > - > - ¥:%24 - > - > - &:%26 - > - > - \*:%2A - -3. 代理设置完成后,打开命令行工具,执行如下命令进行验证网络是否正常。 - ``` - npm info express - ``` - - 执行结果如下图所示,则说明代理设置成功。 - - ![zh-cn_image_0000001164417356](figures/zh-cn_image_0000001164417356.png) - -4. 网络设置完成后,然后再[配置SDK信息](#配置sdk信息)。 - - -### 设置Gradle代理 - -1. 打开“此电脑”,在文件夹地址栏中输入**%userprofile%**(Mac系统请点击**前往 > 个人**),进入个人用户文件夹。 - ![zh-cn_image_0000001166740700](figures/zh-cn_image_0000001166740700.png) - -2. 创建一个文件夹,命名为**.gradle**。如果已有.gradle文件夹,请跳过此操作。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > macOS系统创建.gradle文件夹前,请将系统设置为“显示隐藏文件”。 - -3. 进入.gradle文件夹,新建一个文本文档,命名为**gradle**,并修改后缀为**.properties**。 - -4. 打开**gradle.properties**文件中,添加如下脚本,然后保存。 - 其中代理服务器、端口、用户名、密码和不使用代理的域名,请根据实际代理情况进行修改。其中不使用代理的nonProxyHosts的配置间隔符是 “|”。 - ``` - systemProp.http.proxyHost=proxy.server.com - systemProp.http.proxyPort=8080 - systemProp.http.nonProxyHosts=*.company.com|10.*|100.* - systemProp.http.proxyUser=userId - systemProp.http.proxyPassword=password - systemProp.https.proxyHost=proxy.server.com - systemProp.https.proxyPort=8080 - systemProp.https.nonProxyHosts=*.company.com|10.*|100.* - systemProp.https.proxyUser=userId - systemProp.https.proxyPassword=password - ``` diff --git a/zh-cn/application-dev/quick-start/create-openharmony-project.md b/zh-cn/application-dev/quick-start/create-openharmony-project.md deleted file mode 100644 index 87112157f03c31ef9fe90d7e73ed33eaad04ce20..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/create-openharmony-project.md +++ /dev/null @@ -1,7 +0,0 @@ -# 创建OpenHarmony工程 - - - -- **[使用工程向导创建新工程](use-wizard-to-create-project.md)** - -- **[通过导入Sample方式创建新工程](import-sample-to-create-project.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/deveco-studio-overview.md b/zh-cn/application-dev/quick-start/deveco-studio-overview.md deleted file mode 100644 index 9c38b56badf16315a1bf1177577e1fb30f2ebef5..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/deveco-studio-overview.md +++ /dev/null @@ -1,44 +0,0 @@ -# 概述 - - -## 总体说明 - -DevEco Studio是HarmonyOS的配套的开发IDE,因为HarmonyOS是基于OpenHarmony开发的,因此,使用DevEco Studio(配套HarmonyOS)也可以进行OpenHarmony的应用开发。 - -使用DevEco Studio开发OpenHarmony应用的流程与开发HarmonyOS的流程完全一样,本文档仅描述OpenHarmony应用开发与HarmonyOS应用开发的差异点。 - -- **搭建开发环境差异**:OpenHarmony应用开发环境需要先安装OpenHarmony SDK,具体可参考[配置OpenHarmony SDK](../quick-start/configuring-openharmony-sdk.md)章节。 - -- **创建OpenHarmony工程**:OpenHarmony应用开发,可以通过工程向导创建一个新工程,或通过导入Sample工程的方式来创建一个新工程,具体可参考[使用工程向导创建新工程](../quick-start/use-wizard-to-create-project.md)。 - -- **调试签名配置**:OpenHarmony应用运行在真机设备上,需要对应用进行签名,关于OpenHarmony应用的签名指导请参考[配置OpenHarmony应用签名信息](../quick-start/configuring-openharmony-app-signature.md)。 - -- **在真机设备上运行应用**:将OpenHarmony的hap包推送到真机设备上进行安装,具体可参考[安装运行OpenHarmony应用](../quick-start/installing-openharmony-app.md)。 - -关于DevEco Studio的详细操作指导,请访问[HUAWEI DevEco Studio使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/tools_overview-0000001053582387)。 - - -## 使用约束 - -- OpenHarmony只支持使用eTS、JS语言开发应用,不支持Java、C/C++语言。 - -- OpenHarmony开发环境DevEco Studio暂只支持Windows系统。 - -OpenHarmony与HarmonyOS的开发工具都是DevEco Studio,下表为OpenHarmony相比HarmonyOS不支持的功能说明: - -| 特性名称 | HarmonyOS版本 | OpenHarmony版本 | -| -------- | -------- | -------- | -| 服务卡片 | **√** | **X** | -| 自动化签名 | **√** | **X** | -| 远程模拟器 | **√** | **X** | -| 本地模拟器 | **√** | **X** | -| 使用DevEco Studio进行日志查看、调优 | **√** | **X** | -| 云测试 | **√** | **X** | -| 安全测试 | **√** | **X** | - - -## DevEco Studio演进路标 - -Huawei DevEco Studio分阶段支持OpenHarmony应用开发的演进路标如下: - -![zh-cn_image_0000001210018359](figures/zh-cn_image_0000001210018359.png) diff --git a/zh-cn/application-dev/quick-start/deveco-studio-release-notes.md b/zh-cn/application-dev/quick-start/deveco-studio-release-notes.md deleted file mode 100644 index 98c7c6c0385ff76a8a2d53c625b3ea4ff3a46fa1..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/deveco-studio-release-notes.md +++ /dev/null @@ -1,32 +0,0 @@ -# 版本变更说明 - - -## V3.0 Beta2(2021-12-31) - - -### 版本兼容性 - -DevEco Studio 3.0 Beta2版本兼容性配套关系如下表所示。 - -| 组件 | 版本要求 | 说明 | -| -------- | -------- | -------- | -| Gradle | 7.3(最低版本要求7.2) | DevEco Studio已自带了Gradle7.3版本,开发者无需单独安装。 | -| JDK | 11.0.x | DevEco Studio已自带了JDK 11版本,开发者无需单独安装。 | -| OpenHarmony SDK | 3.1.0.0(API Version 8 Beta) | 兼容历史版本SDK。 | -| Toolchinas | 3.1.0.0 | 建议更新至最新版本。 | -| hap插件 | 3.0.5.2 | 建议更新至最新版本。 | -| decctest插件 | 1.2.7.2 | 建议更新至最新版本。 | - - -### 版本变更说明 - -| | -| -------- | -| **新增特性:**
- 新增DevEco Studio支持界面功能菜单的汉化版本,默认显示为英文,如需开启汉化版本,请打开DevEco Studio的**Settings**界面,在**Plugins > installed**中手动勾选“Chinese(Simplified)”插件,然后重新启动DevEco Studio即可生效。
- 新增支持OpenHarmony应用或服务的调试和运行,支持断点管理、变量查看、Step Into\Step Over\Step Out等单步调试功能。
**增强特性:**
- OpenHarmony SDK更新至3.1.0.0版本(API Version 8 Beta),配套的hap编译构建插件版本更新至3.0.5.2。
- 工程模板新增支持低代码开发的[Standard]Empty Ability模板。
- 支持eTS组件预览,要求compileSdkVersion为8或以上。
- eTS实时预览支持边修改属性边展示预览效果,无需保存修改才生效,要求compileSdkVersion为8或以上。 | - - -## V3.0 Beta1(2021-09-29) - -| | -| -------- | -| **新增特性:**
- 新增支持OpenHarmony SDK的管理,开发者可通过DevEco Studio的SDK Manager功能来下载和管理OpenHarmony SDK。
- 在编译构建HAP包时,新增支持对单个Module进行编译,对于多Module工程中只需要编译其中一个Module的场景,可以提升编译构建速度;同时还新增支持一键重构建HAP包,即在编译构建HAP前,会自动执行Clean Project操作。
**增强特性:**
- 编译构建插件更新至3.0.3.2版本。
- Json编辑器增强,资源索引错误支持快速修复,并支持快速查看资源的取值。
- 工程视图支持Ohos视图,默认视图为Project视图,开发者可手动切换。
- OpenHarmony工程支持ark方舟编译。
- OpenHarmony工程类型标识字段supportSystem "standard",由模块级build.gradle调整至工程级build.gradle。 | diff --git a/zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md b/zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md index 73aa1cf321f06654f5c69175955cd2effde20567..8db65fe5c1470990ab78a690af09886ba8d21c6c 100644 --- a/zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md +++ b/zh-cn/application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md @@ -2,14 +2,19 @@ -- **[概述](deveco-studio-overview.md)** +HUAWEI DevEco Studio For OpenHarmony(以下简称DevEco Studio)是基于IntelliJ IDEA Community开源版本打造,面向OpenHarmony全场景多设备的一站式集成开发环境(IDE),为开发者提供工程模板创建、开发、编译、调试、发布等E2E的OpenHarmony应用/服务开发。 -- **[版本变更说明](deveco-studio-release-notes.md)** +[DevEco Studio 3.0 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) 作为支撑Openharmony应用和服务开发的IDE,具有以下能力特点: -- **[配置OpenHarmony SDK](configuring-openharmony-sdk.md)** +- 支持一站式的信息获取平台 +- 提供多设备工程模板 +- 高效的代码编辑 +- 支持可视化的界面UI开发 +- 双向、极速的界面UI预览 +- 全新的编译工具Hvigor +- 支持基于设备系统能力集Syscap进行应用开发 +- 支持全自动化的应用签名机制 +- 丰富的代码调试调优能力 -- **[创建OpenHarmony工程](create-openharmony-project.md)** +更多工具体验和使用指导请见:[DevEco Studio (OpenHarmony) 使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)。 -- **[配置OpenHarmony应用签名信息](configuring-openharmony-app-signature.md)** - -- **[安装运行OpenHarmony应用](installing-openharmony-app.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/figures/20220329-103626.gif b/zh-cn/application-dev/quick-start/figures/20220329-103626.gif new file mode 100644 index 0000000000000000000000000000000000000000..1f3a67796fd41dce99b4256a115fd1d0733ebb79 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/20220329-103626.gif differ diff --git a/zh-cn/application-dev/quick-start/figures/SysCap_Overview.jpg b/zh-cn/application-dev/quick-start/figures/SysCap_Overview.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8886b48158dff6792e55ece07158390b626cb8f1 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/SysCap_Overview.jpg differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326064841782.png b/zh-cn/application-dev/quick-start/figures/image-20220326064841782.png new file mode 100644 index 0000000000000000000000000000000000000000..79bf756bc296a3f7129d6e646ab77248110abd06 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326064841782.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326064913834.png b/zh-cn/application-dev/quick-start/figures/image-20220326064913834.png new file mode 100644 index 0000000000000000000000000000000000000000..a48d603f708ad817997a7d89128ff392b515ccd2 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326064913834.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326064955505.png b/zh-cn/application-dev/quick-start/figures/image-20220326064955505.png new file mode 100644 index 0000000000000000000000000000000000000000..dc42bd80c803721d619354ccf0ac997fdeec83f0 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326064955505.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326065043006.png b/zh-cn/application-dev/quick-start/figures/image-20220326065043006.png new file mode 100644 index 0000000000000000000000000000000000000000..77f386e35358d0a7af65d11e95fb690c9754e992 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326065043006.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326065124911.png b/zh-cn/application-dev/quick-start/figures/image-20220326065124911.png new file mode 100644 index 0000000000000000000000000000000000000000..ccb9ad8c7d95788d8734c6627ac12fd019ff7a4b Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326065124911.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326065201867.png b/zh-cn/application-dev/quick-start/figures/image-20220326065201867.png new file mode 100644 index 0000000000000000000000000000000000000000..a7119d0acff9135517db82072009a599e51f1b12 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326065201867.png differ diff --git a/zh-cn/application-dev/quick-start/figures/image-20220326072448840.png b/zh-cn/application-dev/quick-start/figures/image-20220326072448840.png new file mode 100644 index 0000000000000000000000000000000000000000..93919d2bcd509a00337af36386898d025fd774b4 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/image-20220326072448840.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001113808114.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001113808114.png deleted file mode 100644 index da3c279ef8812b9d028a1993074430b5a06d50c9..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001113808114.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001115066116.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001115066116.png deleted file mode 100644 index 357798e173fa7e3b419cc5990aa0737925e1f7b9..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001115066116.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117479776.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117479776.png deleted file mode 100644 index 9250f90cf1e377c8bb33adf9965436ed7ddbadbf..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117479776.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117639668.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117639668.png deleted file mode 100644 index ba3923fef0ad89fa38fa170d2680931d1eb1ea55..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001117639668.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018088.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018088.png deleted file mode 100644 index d4e1c7bd6773fc5b3ab5b473e28593110f3c820f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018088.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018452.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018452.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001118018452.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001119560738.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001119560738.png deleted file mode 100644 index 9a84c3f66275c8ea2a50b9ba9ab0ead3842274cc..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001119560738.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152459178.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152459178.png deleted file mode 100644 index 5ee6a55e53e57843300bd5ec0cce4a175e97a29e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152459178.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152674854.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152674854.png deleted file mode 100644 index 6bef885f7c487473ca1b329d41c6414735555b42..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001152674854.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001155643492.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001155643492.png deleted file mode 100644 index 9e3afd2b96c1a01b3e966c37e60755d1f179363c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001155643492.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001162463400.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001162463400.png deleted file mode 100644 index 48239f38c31b907155d7b0501401ca9dd8635d73..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001162463400.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163314102.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163314102.png deleted file mode 100644 index 286a49def18618c79088deeb49203969ac6ce4c0..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163314102.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163472654.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163472654.png deleted file mode 100644 index 5328a3c1b62eb8281e316d5ae4a6ca11694ec4a2..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163472654.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163632602.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163632602.png deleted file mode 100644 index 10c5cf41ab78ea58c194fe1ed0429352e85a88a8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163632602.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163839541.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163839541.png deleted file mode 100644 index f278f73fb4cd0dba70cae1835dd7a45d2686038b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163839541.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163915523.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163915523.png deleted file mode 100644 index 352eaed40ac96dc5d3bae82591e5c801daaa8d56..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163915523.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163918627.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163918627.png deleted file mode 100644 index 6967c6b140c7e07003fc4548989ea78d9e5fc940..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001163918627.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164417356.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164417356.png deleted file mode 100644 index 97795b40abbea9f58aabe62dd7643eca208315e3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164417356.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164498191.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164498191.png deleted file mode 100644 index 30efd063397893ff925743b681f943696f10512b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164498191.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164577336.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164577336.png deleted file mode 100644 index 1127bbfabc9ef766284eec12c574096f8bb45ac3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001164577336.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166582138.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166582138.png deleted file mode 100644 index 36dc2d05ca4eb23505a73cb0d1606afd3bf844d8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166582138.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166740700.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166740700.png deleted file mode 100644 index 9d9dc95f14cdc94007dbf04f217d496d49f9318c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001166740700.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001196050928.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001196050928.png deleted file mode 100644 index dd75ea8e2b874aae201ecab3254fac3a7bce8fbc..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001196050928.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001202722349.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001202722349.png deleted file mode 100644 index 99330a4f3ef2978dd6736d96e00c88cea8d25f32..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001202722349.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001207744539.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001207744539.png deleted file mode 100644 index 5e1269e9e8fb620f8ed6051395c727590e6dc1bc..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001207744539.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208006117.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208006117.png deleted file mode 100644 index 5c576d84b0ca4b369cdaac5aa7de19718628bc37..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208006117.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208274069.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208274069.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208274069.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208394019.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208394019.png deleted file mode 100644 index aa7f5ffb0d59c7ab7a1784bfde775aeccc16a424..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001208394019.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001209817299.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001209817299.png deleted file mode 100644 index aa7f5ffb0d59c7ab7a1784bfde775aeccc16a424..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001209817299.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001210018359.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001210018359.png deleted file mode 100644 index 7fe695d19f2f15a7ce9c941907f17becf0d9b849..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001210018359.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212062065.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212062065.png deleted file mode 100644 index 708b49814e270289c6d1c96520aa6d90ba0edb9c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212062065.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212142015.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212142015.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001212142015.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001215029852.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001215029852.png deleted file mode 100644 index fa229933bd2e38a0967750e39b2a2c1f5e80b873..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001215029852.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216084724.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216084724.png index a52947400f005bbdb10141626f3fa1982abcb429..a8fac2a024e51aeb0439463dab83f2763fa3fa76 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216084724.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216084724.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216239356.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216239356.png index 4d03d2b8a97319efa04c6c94b394291701371a35..f9a815f39b1f31948c01af0555d164e211de990a 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216239356.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216239356.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216269940.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216269940.png index d2f276bc812f19e6b92cb299222218d1157f512d..0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216269940.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216269940.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216288558.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216288558.png index 0ce709ba3c03c1331c44ebe259aaa8102c160d18..a38ed398f4acd5c4a87bcf0f1b39adad810c224c 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216288558.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216288558.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216600980.gif b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216600980.gif index 36e9929bd55f02e8737346709a8a2427723614ac..58fa6bc0485a3bca823313c4c84e3be37a1ecb05 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216600980.gif and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216600980.gif differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216618320.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216618320.png deleted file mode 100644 index d8d1420760cc657bf7a4928d01be701c1ea6cb24..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216618320.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216753776.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216753776.png deleted file mode 100644 index 5e6825c63fe0c733d72526a44a78a1deae32cc94..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001216753776.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217063248.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217063248.png deleted file mode 100644 index 25ecf03e7113970dc2c43306ed9d423fa88d97fa..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217063248.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217365030.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217365030.png deleted file mode 100644 index c93286ed075c7ea61f21331edc6fdaf575804d97..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217365030.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217384890.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217384890.png deleted file mode 100644 index 84d5fb3fe5c703c5605358c2ca9d1c6e8ed565f8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217384890.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217526428.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217526428.png index 241ddfa8b9c3a29f5a410c454458471bfa004ee8..2c026736133d41d80a1b92eb0db230dd6c0a7feb 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217526428.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217526428.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527892.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527892.png index d2f276bc812f19e6b92cb299222218d1157f512d..0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527892.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527892.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527948.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527948.png deleted file mode 100644 index c93286ed075c7ea61f21331edc6fdaf575804d97..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001217527948.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223397122.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223397122.png new file mode 100644 index 0000000000000000000000000000000000000000..42b475577bcc805372336be8971afa5c69c284bd Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223397122.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223556342.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223556342.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223556342.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223557290.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223557290.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223557290.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558810.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558810.png new file mode 100644 index 0000000000000000000000000000000000000000..33c3fd7d689bf5ce33f76547b0c7f414a5082715 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558810.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558814.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558814.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223558814.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223716826.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223716826.png new file mode 100644 index 0000000000000000000000000000000000000000..14dc492cb36d22c79d22bea78d0f66508867291e Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223716826.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223717294.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223717294.png new file mode 100644 index 0000000000000000000000000000000000000000..75910aaf0daa22be2c0b56ae94febaa672df7424 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223717294.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223722586.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223722586.png new file mode 100644 index 0000000000000000000000000000000000000000..7fd32c25dacf742fcb6fc950fbb7dbb1896f107e Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223722586.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877162.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877162.png new file mode 100644 index 0000000000000000000000000000000000000000..02d730cadf10899edd91f94ce4cb8badd3ba821c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877162.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877210.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877210.png new file mode 100644 index 0000000000000000000000000000000000000000..7de2085c0711c035befe73d65be14c344bba974d Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223877210.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223882030.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223882030.png new file mode 100644 index 0000000000000000000000000000000000000000..68541a5d1ada5127b4b049b7c536165b874a5818 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001223882030.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001239855207.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001239855207.png deleted file mode 100644 index 83ef94f222a2cc30f036057908960badedd4aeca..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001239855207.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001247125297.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001247125297.png deleted file mode 100644 index 32771bf5f9639aa8ebdd1922f8088965404674ca..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001247125297.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001248045243.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001248045243.png deleted file mode 100644 index 61535cb2fe6b4197e95cff8691fe27973c5ecde8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001248045243.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001259949659.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001259949659.png deleted file mode 100644 index fa229933bd2e38a0967750e39b2a2c1f5e80b873..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001259949659.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260189591.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260189591.png deleted file mode 100644 index fa229933bd2e38a0967750e39b2a2c1f5e80b873..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260189591.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260684127.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260684127.png index 241ddfa8b9c3a29f5a410c454458471bfa004ee8..0384e6e0c5283106da9ca4c34be2f831dcd435c9 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260684127.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001260684127.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261129245.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261129245.png deleted file mode 100644 index b774bd7ee5c548fe6ba8b8924f302b5dc7b65b07..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261129245.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261137889.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261137889.png deleted file mode 100644 index 2821c2b055c71abd5ba1d74201c1c4ab9ddd6647..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261137889.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261142799.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261142799.png index b0fe41acdfae007d26b79e6539d1432be4d420db..2d49abf09c08421118b8fddd8df4f0c46d5f1c84 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261142799.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261142799.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233671.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233671.png deleted file mode 100644 index 20bc9853976a1d8b967da762ef88028ee029e150..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233671.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233695.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233695.png deleted file mode 100644 index fa80cdac31d31207b21dbd33072a82c015a002be..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261233695.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261786055.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261786055.png deleted file mode 100644 index c54739143282ad99334f366d35f2b1696d773f92..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001261786055.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262127855.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262127855.png index b0fe41acdfae007d26b79e6539d1432be4d420db..2d49abf09c08421118b8fddd8df4f0c46d5f1c84 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262127855.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262127855.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262327095.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262327095.png deleted file mode 100644 index c93286ed075c7ea61f21331edc6fdaf575804d97..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001262327095.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268077317.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268077317.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268077317.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268082945.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268082945.png new file mode 100644 index 0000000000000000000000000000000000000000..ba6a6b7ee2bc09c33a4ef23ec79742bc698fa604 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268082945.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268198893.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268198893.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2ae3c740dfee9b303d6319516c9facb3574184 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268198893.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268283201.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268283201.png new file mode 100644 index 0000000000000000000000000000000000000000..6e093d7a983e03a37143357001eefd57c3df2c3c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001268283201.png differ diff --git a/zh-cn/application-dev/quick-start/import-sample-to-create-project.md b/zh-cn/application-dev/quick-start/import-sample-to-create-project.md deleted file mode 100644 index 79fddeb9ecc84dc403ffaeb11c4bfcc1323f3b68..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/import-sample-to-create-project.md +++ /dev/null @@ -1,28 +0,0 @@ -# 通过导入Sample方式创建新工程 - - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该功能适用于通过DevEco Studio 2.1 Release及以上版本,创建OpenHarmony工程。 - - -OpenHarmony SDK配置完成后,便可以启动应用开发。针对OpenHarmony应用开发,**可以通过导入Sample工程的方式来创建一个新工程**。 - - -1. 在DevEco Studio的欢迎页,进入**Configure (或**![zh-cn_image_0000001118018452](figures/zh-cn_image_0000001118018452.png)**图标) > Settings > Version Control > Git**界面,点击Test按钮检测是否安装Git工具。 - - 已安装,请根据**步骤2**开始导入Sample。 - ![zh-cn_image_0000001118018088](figures/zh-cn_image_0000001118018088.png) - - 未安装,请点击**Download and Install**,DevEco Studio会自动下载并安装。安装完成后,请根据**步骤2**开始导入Sample。 - ![zh-cn_image_0000001164498191](figures/zh-cn_image_0000001164498191.png) - -2. 在DevEco Studio的欢迎页,点击**Import Sample**按钮,导入Sample工程。 - ![zh-cn_image_0000001208006117](figures/zh-cn_image_0000001208006117.png) - -3. 选择OpenHarmony Samples > common下的**JsHelloWorld**工程,然后点击**Next**。 - ![zh-cn_image_0000001152459178](figures/zh-cn_image_0000001152459178.png) - -4. 设置**App Name**和**Project Location**,然后点击**Finish**,等待Sample工程导入完成。 - ![zh-cn_image_0000001207744539](figures/zh-cn_image_0000001207744539.png) - -5. 等待工程同步完成,同步成功后,便可以进行OpenHarmony应用开发了。 - ![zh-cn_image_0000001163915523](figures/zh-cn_image_0000001163915523.png) diff --git a/zh-cn/application-dev/quick-start/installing-openharmony-app.md b/zh-cn/application-dev/quick-start/installing-openharmony-app.md deleted file mode 100644 index 7dc86e978e8db0d23556c256bc7b2f6635262fb9..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/installing-openharmony-app.md +++ /dev/null @@ -1,32 +0,0 @@ -# 安装运行OpenHarmony应用 - - - -安装OpenHarmony应用可以通过DevEco Studio安装,也可以通过使用hdc工具进行手动安装。 - - -- 通过DevEco Studio安装:将设备连接上DevEco Studio后,点击![zh-cn_image_0000001239855207](figures/zh-cn_image_0000001239855207.png)按钮即可安装。 - -- 通过hdc工具安装:手动执行命令行完成应用的安装。 - hdc工具本身需要手动从开源仓中获取。然后使用工具将编译后的本地hap包发送至设备侧并完成安装。 - - 相关命令如下: - - - 安装命令 - **install [-r/-d/-g] _package_** - - 命令示例: - - ``` - hdc_std install E:\hwadmin.hap - ``` - - 日志抓取命令 - **hilog** - - 命令示例: - - ``` - hdc_std hilog - ``` - - 完整的hdc工具使用指导及命令格式请参见[hdc_std使用指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md)。 diff --git a/zh-cn/application-dev/quick-start/module-structure.md b/zh-cn/application-dev/quick-start/module-structure.md deleted file mode 100644 index f6171cf402b57d56facc02818164990babd466f7..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/module-structure.md +++ /dev/null @@ -1,831 +0,0 @@ - - -# module.json字段说明 - -在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json配置文件中对应用的包结构进行声明。 - -## 配置文件内部结构 - -module.json由app和module这两个部分组成,缺一不可。配置文件的内部结构参见表1。 - -表1 配置文件的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | ---------- | -| app | 表示应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 否 | -| module | 表示HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象内部结构](#module对象内部结构)。 | 对象 | 否 | - -module.json示例: - -```json -{ -    "app": { - "bundleName": "com.application.music", -        "vendor": "application", -        "versionCode": 1, -        "versionName": "1.0", -        "minCompatibleVersionCode": 1, -        "apiCompatibleVersion": 7, -        "apiTargetVersion": 8, -        "apiReleaseType": "Release", -        "debug": false, -        "icon" : "$media:app_icon", -        "label": "$string:app_name", -        "description": "$string:description_application", -        "distributedNotificationEnabled": true, -        "entityType": "game", -        "car": { -            "apiCompatibleVersion": 8 -         } -    }, - "module": { - "name": "myHapName", - "type": "entry|feature|har", - "srcEntrance" : "./MyAbilityStage.js", - "description" : "$string:description_application", - "process": "string", - "mainElement": "MainAbility", - "deviceTypes": [ - "phone", - "tablet", - "tv", - "wearable", - "liteWearable", - "ar", - "vr", - "car", - "earphones", - "pc", - "speaker", - "smartVision", - "linkIoT", - "router", - ], - "deliveryWithInstall": true, - "installationFree": false, - "virtualMachine": "ark | default", - "metadata": [ - { - "name": "string", - "value": "string", - "resource": "$profile:config_file1" - }, - { - "name": "string", - "value": "string", - "resource": "$profile:config_file2" - } - ], - "metadata": [ - { - "name": "string", - "value": "string", - "resource": "$profile:config_file1" - }, - { - "name": "string", - "value": "string", - "resource": "$profile:config_file2" - } - ], - "abilities": [ - { - "name": "MainAbility", - "srcEntrance" : "./login/MyMainAbility.ts", - "description": "$string:description_main_ability", - "icon": "$media:icon", - "label": "HiMusic", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ], - "uris": [ ] - } - ], - "backgroundModes": [ - "dataTransfer", - "audioPlayback", - "audioRecording", - "location", - "bluetoothInteraction", - "multiDeviceConnection", - "wifiInteraction", - "voip", - "taskKeeping" - ], - } - ], - "abilities": [ - { - "name": "MainAbility", - "srcEntrance" : "./login/MyMainAbility.ts", - "description": "$string:description_main_ability", - "icon": "$media:icon", - "label": "HiMusic", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ], - "uris": [ ] - } - ], - "backgroundModes": [ - "dataTransfer", - "audioPlayback", - "audioRecording", - "location", - "bluetoothInteraction", - "multiDeviceConnection", - "wifiInteraction", - "voip", - "taskKeeping" - ], - } - ], - "requestPermissions": [ - { - "name": "ohos.abilitydemo.permission.PROVIDER", - "reason": "$string:reason", - "usedScene": { - "abilities": [ - "FormAbility" - ], - "when": "inuse" - } - } - ] - } -} -``` - -### app对象内部结构 - -该标签为整个应用的属性,影响应用中左右hap及组件,不会被hap或组件所替换。该标签的内部结构参见表2。 - -表2 app对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- | -| bundleName | 该标签表示应用的包名,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则:
1)字符串以字母、数字、下划线和符号”.”组成;
2)以字母开头;
3)最小长度7个字节,最大长度127个字节。
推荐采用反域名形式命名(如:com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。
其中,随系统源码编译的应用需命名为”com.ohos.xxx”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 否 | -| debug | 该标签标识应用是否可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 | -| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 | -| label | 该标签标识应用的的名称,标签值为资源文件的索引,以支持多语言。 | 字符串 | 该标签不可缺省。 | -| description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | -| vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 | -| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | | -| versionName | 该标签标识版本号的文字描述,用于向用户展示。
该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。
第一段:主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。
第二段:次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。
第三段:特性版本号/Feature,范围0-99,标识规划的新版本特性。
第四段:修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 该标签不可缺省 | -| minCompatibleVersionCode | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 | -| minAPIVersion | 该标签标识应用运行需要的API目标版本。 | 数值 | 该标签不可缺省。 | -| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 | -| apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
Canary:受限发布的版本。
Beta:公开发布的Beta版本。
Release:公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 | -| distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 | -| entityType | 该标签标记该应用的类别,具体有:游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 | - -### module对象内部结构 - -hap包的配置信息,该标签下的配置只对当前hap包生效。 - -表3 module对象内部结构 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------- | -| name | 该标签标识当前module的名字,module打包成hap后,表示hap的名称,标签值采用字符串表示(最大长度31个字节),该名称在整个应用要唯一。 | 字符串 | 该标签不可缺省。 | -| type | 该标签表示当前hap的类型。类型有三种,分别是entry、feature和har。 | 字符串 | 该标签不可缺省。 | -| srcEntrance | 该标签表示hap所对应的入口js代码路径,标签值为字符串(最长为127字节)。 | 字符串 | 该标签可缺省。 | -| description | 该标签标识hap包的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | -| process | 该标签标识hap的进程名,标签值为字符串类型(最长为31个字节)。如果在hap标签下配置了process,该应用的所有ability都运行在该进程中。 | 字符串 | 可缺省,缺省为hap的名称。 | -| mainElement | 该标签标识hap的入口ability名称或者extension名称。只有配置为mainElement的ability或者extension才允许在服务中心露出。创建OpenHarmony原子化服务时,该标签不可缺省。 | 字符串 | OpenHarmony应用下,该标签可缺省。 | -| deviceTypes | 该标签标识hap可以运行在哪类设备上,标签值采用字符串数组的表示,系统预定义的设备类型见表4。
与syscap不同的是,deviceTypes是以设备类型为粒度,而syscap是以设备能力(例如蓝牙、wifi)为粒度。 | 字符串数组 | 该标签不可缺省,可以为空值。 | -| deliveryWithInstall | 该标签标识当前hap是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | 布尔值 | 该标签不可缺省。 | -| installationFree | 表示当前HAP是否支持免安装特性。所有Hap包都需要配置不可缺省。
true:表示支持免安装特性,且符合免安装约束。
false:表示不支持免安装特性。

当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为ture。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务需求配置ture或false。 | 布尔值 | 该标签不可缺省。 | -| virtualMachine | 该标签用于标识当前hap运行的目标虚拟机类型,供云端分发使用,如应用市场和分发中心。
该标签值为字符串。如果目标虚拟机类型为方舟虚拟机,则其值为”ark”; 如果目标虚拟机类型不是方舟虚拟机,则其值为”default”。该标签由IDE构建hap的时候自动插入。解包工具解析时,如果hap包没有该标签,设置该标签值为”default”。 | 字符串 | 该标签可缺省,缺省值为“default”。 | -| uiSyntax | syntax定义该JS Component的语法类型。
hml标识该JS Component使用hml/css/js进行开发;
ets标识该JS Component使用ets声明式语法进行开发。 | 字符串 | 该标签可缺省,默认值为hml | -| pages | 该标签是一个profile资源,用于列举JS Component中每个页面信息。pages使用参考pages示例。 | 对象 | 在有ability的场景下,该标签不可缺省。 | -| metadata | 该标签标识Hap的自定义元信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。metadata参考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | -| abilities | 描述元能力的配置信息,标签值为数组类型,该标签下的配置只对当前ability生效。abilities参考[abilities对象内部结构](#abilities对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | -| extensionAbilities | 描述extensionAbilities的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。extensionAbilities参考[extensionAbility对象的内部结构说明](#extensionAbility对象的内部结构说明)。 | 对象 | 该标签可缺省,缺省值为空。 | -| requestPermissions | 该标签标识应用运行时需向系统申请的权限集合,标签值为数组类型。requestPermissions参考[requestPermissions对象内部结构](#requestPermissions对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | - -表4 deviceTypes对象的系统预定义设备 - -| 中文 | 英文 | 枚举值 | 设备类型 | -| ------------ | ------------ | ------------ | -------------------------------------------------------- | -| 智能手机 | smartphone | phone | 手机 | -| 平板 | tablet | tablet | 平板,带屏音箱 | -| 智慧屏 | smart TV | tv | | -| 智能手表 | smart watch | wearable | 智能手表,儿童手表,特指资源较丰富的的手表,具备电话功能 | -| 运动手表 | basic watch | liteWearable | 基本功能手表,运动手表 | -| 增强现实 | AR | ar | | -| 虚拟现实 | VR | vr | | -| 车机 | head unit | car | | -| 耳机 | earphones | earphones | | -| 个人计算机 | PC | pc | | -| 音箱 | speaker | speaker | 无屏音箱,有屏音箱,通过硬件profile | -| 智慧视觉设备 | Smart Vision | smartVision | 带摄像头的设备,通过硬件profile分开是否 | -| 联接类模组 | linkiot | linkIoT | Wi-Fi模组,蓝牙模组 | -| 路由器 | router | router | 路由器 | - -deviceTypes示例: - -```json -{ - "module": { - "name": "myHapName", -        "type": "har", - "deviceTypes" : [ - "phone" - ] - } -} -``` - -pages示例: - -```json -{ - "module": { -       "name": "myHapName", -        "type": "har", - "deviceTypes" : [ - "phone" - ], -        "pages": "$profile:pages_config" -    } -} -``` - -pages_config配置文件 - -```json -{ -    "src": [ -        "pages/index/index", -        "pages/second/second", -        "pages/third/third", -        "pages/four/four" -    ] -} -``` - - - -#### metadata对象内部结构 - -描述的module、ability、extensionAbility配置信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。 - -表5 metadata对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------------- | -| name | 该标签表示数据项的键名称,字符串类型(最大长度255字节)。 | 字符串 | 该标签可缺省,缺省值为空。 | -| value | 该标签表示数据项的值,标签值为字符串(最大长度255字节)。 | 字符串 | 可缺省,缺省为空。 | -| resource | 该标签标识定义用户自定义数据格式,标签值为标识该数据的资源的索引值。 | 字符串 | 可缺省,缺省为空。 | - -metadata示例: - -```json -{  -    "module": { -        "metadata": [ -            { -                "name": "string", -                "value": "string", -                "resource": "$profile:config_file" -            }, -            { -                "name": "string", -                "value": "string", -                "resource": "$profile:config_file" -            } -        ] -    } -} -``` - -#### abilities对象内部结构 - -abilities描述ability的配置信息,标签值为数组类型。 - -表6 abilities对象内部结构说明 - -| 属性 | 含义 | 数据类型 | 是否可缺省 | -| --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | -| name | 该标签标识当前ability的逻辑名,该名称在整个应用要唯一,标签值采用字符串表示(最大长度127个字节)。 | 字符串 | 该标签不可缺省。 | -| srcEntrance | 该标签表示ability所对应的js代码路径,标签值为字符串(最长为127字节)。。 | 字符串 | 该标签不可缺省。 | -| launchType | 该标签标示ability的启动模式,标签值可选"standard"、“singleton”、‘’‘specified“。该标签缺省为"standard"。standard表示普通多实例,spcified表示该ability内部根据业务自己置顶多实例,singleton表示单实例。 | 字符串 | 可缺省,该标签缺省为"standard" | -| description | 该标签标识ability的描述,标签值是是字符串类型或对描述内容的资源索引,要求采用用资源索引方式,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | -| icon | 该标签标识ability图标,标签值为资源文件的索引。该标签可缺省,缺省值为空。
如果ability被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。
如果ability被配置为MainElement,该标签必须配置。 | -| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大255字节),可以是系统预定义的权限,也可以是该应用自定义的权限。如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。该标签可缺省,缺省值为空。 | 字符串数组 | 该标签可缺省,缺省值为空。 | -| metadata | 该标签表示ability的元信息。metadata参考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | -| visible | 该标签标识ability是否可以被其它应用调用,为布尔类型,true表示可以被其它应用调用, false表示不可以被其它应用调用。 | 布尔值 | 该标签可缺省,缺省值为false。 | -| continuable | 该标签标识ability是否可以迁移,为布尔类型,true表示可以被迁移, false表示不可以被迁移。 | 布尔值 | 该标签可缺省,缺省值为false。 | -| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则: entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
skills内部结构参考[skills对象内部结构](#skills对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | -| backgroundModes | 该标签标识ability长时任务集合。指定用于满足特定类型的长时任务。
长时任务类型有如下:
dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback:音频输出业务。
audioRecording:音频输入业务。
location:定位、导航业务。
bluetoothInteraction:蓝牙扫描、连接、传输业务(穿戴)。
multiDeviceConnection:多设备互联业务。
wifiInteraction:Wifi扫描、连接、传输业务(克隆 多屏)。
voip:音视频电话,VOIP业务。
taskKeeping:计算业务。
| 字符串 | 可缺省,缺省为空。 | - -abilities示例 - -```json -{ -    "abilities": [{ -        "name": "MainAbility", -        "srcEntrance": "./ets/login/MyLoginAbility.ts", -        "launchType":"standard" -        "description": "$string:description_main_ability", -        "icon": "$media:icon", -        "label": "Login", -        "permissions": [], -        "metadata": [], -        "visible": true, -        "continuable": true, -        "skills": [{ -            "actions": ["action.system.home"], -            "entities": ["entity.system.home"], -            "uris": [] -        }], -        "backgroundModes": [ -            "dataTransfer", -            "audioPlayback", -            "audioRecording", -            "location", -            "bluetoothInteraction", -            "multiDeviceConnection", -            "wifiInteraction", -            "voip", -            "taskKeeping" -        ], -    }], -} -``` - -#### skills对象内部结构 - -该标签标识ability或者extension能够接收的意图的特征。 - -表7 skills内部结构示例 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | ---------- | -------------------- | -| actions | 该标签标识能够接收的意图的action值的集合,取值通常为系统预定义的action值,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | -| entities | 该标签标识能够接收的Intent的元能力的类别集合,取值通常为系统预定义的类别,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | -| uris | 该标签标识向 want过滤器添加数据规范集合。该规范可以是只有数据类型(mimeType 属性),可以是只有 URI,也可以是既有数据类型又有 URI。uris内部结构参考表8。 | 对象数组 | 可缺省,缺省值为空。 | - -表8 uris对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------- | -------- | -------------------- | -| scheme | 表示uri的scheme值。 | 字符串 | 不可缺省。 | -| host | 表示uri的host值。 | 字符串 | 可缺省,缺省值为空。 | -| port | 表示uri的port值。 | 字符串 | 可缺省,缺省值为空。 | -| path | 表示uri的path值。 | 字符串 | 可缺省,缺省值为空。 | -| type | 表示uri的type值。 | 字符串 | 可缺省,缺省值为空。 | - -skills示例 - -```json -{ -    "abilities": [ -        { -            "skills": [ -                { -                    "actions": [ -                        "action.system.home" -                    ], -                    "entities": [ -                        "entity.system.home" -                    ], -                    "uris": [ -                        { -                            "scheme":"uri2", -                            "host":"host2", -                            "port":"port2", -                            "pathStartWith":"path2", -                            "pathRegex":"/query/.*", -                            "path":"path", -                            "type": "text/*" -                        }, -                    ] -                } -            ], -        } -    ], -    "extensionAbilities": [ -        { -            "skills": [ -                { -                    "actions": [ -                    ], -                    "entities": [ -                    ], -                    "uris": [ -                        { -                            "scheme":"uri2", -                            "host":"host2", -                            "port":"port2", -                            "pathStartWith":"path2", -                            "pathRegex":"/query/.*", -                            "path":"path", -                            "type": "text/*" -                        }, -                    ] -                } -            ], -        } -    ], -} -``` - -#### extensionAbility对象的内部结构说明 - -描述extensionAbility的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。 - -表9 extensionAbility对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ----------- | ------------------------------------------------------------ | ---------- | ----------------------------- | -| name | 该标签标识当前extensionAbility的逻辑名,标签值采用字符串表示(最大长度127个字节),该名称在整个应用要唯一。 | 字符串 | 该标签不可缺省。 | -| srcEntrance | 该标签表示extensionAbility所对应的js代码路径,标签值为字符串(最长为127字节)。 | 字符串 | 该标签不可缺省。 | -| description | 该标签标识extensionAbility的描述,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | -| icon | 该标签标识extensionAbility图标,标签值为资源文件的索引。如果extensionAbility被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。 | -| label | 该标签标识extensionAbility对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。
如果extensionAbility被配置为MainElement,该标签必须配置,且应用内唯一。 | 字符串 | 该标签不可缺省。 | -| type | 该标签标识extensionAbility的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper其中之一。 | 字符串 | 该标签不可缺省。 | -| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大255字节),可以是系统预定义的权限,也可以是该应用自定义的权限。如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。 | 字符串数组 | 该标签可缺省,缺省值为空。 | -| uri | 该标签标识ability提供的数据uri,为字符数组类型(最大长度255),用反向域名的格式表示。该标签在type为dataShare类型的extensionAbility时,不可缺省。 | 字符串 | 该标签可缺省,缺省值为空。 | -| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则: entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
skills内部结构参考[skills对象内部结构](#skills对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | -| metadata | 该标签表示extensionAbility的元信息。metadata内部结构参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | -| visible | 该标签标识extensionAbility是否可以被其它应用调用,为布尔类型。true表示可以被其它应用调用, false表示不可以被其它应用调用。 | | 该标签可缺省,缺省值为false。 | - -extensionAbility示例: - -```json -{ -    "extensionAbilities": [ -        { -            "name": "FormName", -            "srcEntrance": "./form/MyForm.ts", -            "icon": "$media:icon", -            "label" : "$string:extension_name", -            "description": "$string:form_description", -            "type": "form",  -            "permissions": ["ohos.abilitydemo.permission.PROVIDER"], -            "readPermission": "", -            "writePermission": "", -            "visible": true, -            "uri":"scheme://authority/path/query" -            "skills": [{ -                "actions": [], -                "entities": [], -                "uris": [] -            }], -            "metadata": [ -                { -                    "name": "ohos.extability.form", -                    "resource": "$profile:form_config",  -                } -            ], -        } -    ] -} - -``` - -#### requestPermissions对象内部结构 - -该标签标识应用运行时需向系统申请的权限集合。 - -表10 requestPermissions权限申请字段说明 - -| 属性名称 | 含义 | **类型** | **取值范围** | **默认值** | **规则约束** | -| --------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | -| name | 必须,填写需要使用的权限名称。 | 字符串 | 自定义 | 无 | 未填写时,解析失败。 | -| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 显示文字长度不能超过256个字节。 | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 | -| usedScene | 可选,当申请的权限为user_grant权限时此字段必填。描述权限使用的场景和时机。场景类型有:ability、when(调用时机)。可配置多个ability。 | ability:字符串数组when:字符串 | ability:ability的名称when:inuse(使用时)、always(始终) | ability:空when:inuse | user_grant权限必填ability,可选填when。 | - -requestPermissions示例: - -```json -{ -    "usedScene": { -        "abilities": [ -            "AudioAbility", -            "VedioAbility", -        ], -        "when": "inuse" -    } -} -``` - -#### form对象内部结构 - -forms标签表示卡片的配置,form卡片是可以嵌入桌面上并接收定期更新的应用简要视图。在以下场景中可以包含form标签。 - -1. extensions中指定type为form。 - -2. metadata中指定form信息,其中: - name:指定form的名称。使用ohos.extability.form作为form信息的标识。 - resource:指定form信息的资源位置。 - -表11 forms对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ----------------- | ------------------------------------------------------------ | ---------- | ----------------------------- | -| name | 表示卡片的类名。字符串最大长度为127字节。 | 字符串 | 否 | -| description | 表示卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省为空。 | -| src | 该标签标识JS卡片对应的UI代码。建议开发者通过自适应布局显示不同规格卡片,如果不同规格卡片布局相差较大,建议通过不同卡片来区分。 | 字符串 | 可缺省,缺省为空。 | -| window | 该标签标识JS卡片的自适应能力。window结构参考表12。 | 对象 | 可缺省,缺省为空。 | -| isDefault | 表示该卡片是否为默认卡片,每个Ability有且只有一个默认卡片。 true:默认卡片。 false:非默认卡片。 | 布尔值 | 否 | -| colorMode | 表示卡片的主题样式,取值范围如下: auto:自适应。 dark:深色主题。 light:浅色主题。 | 字符串 | 可缺省,缺省值为“auto”。 | -| supportDimensions | 表示卡片支持的外观规格,取值范围: 1 * 2:表示1行2列的二宫格。 2 * 2:表示2行2列的四宫格。 2 * 4:表示2行4列的八宫格。 4 * 4:表示4行4列的十六宫格。 | 字符串数组 | 否 | -| defaultDimension | 表示卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 否 | -| updateDuration | 该标签标识卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数值。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 | 数值 | 可缺省,缺省为空。 | -| metadata | 该标签表示卡片的自定义信息。metadata内部结构参考表5。 | 对象 | 可缺省,缺省为空。 | -| formConfigAbility | 该标签标识卡片调整的Ability名称。标签值为字符串类型(最长127字符)。该标签值必须满足下面的格式:
ability://单个ability名字
单个ability名字必须为本应用的ability。 | 字符串 | 可缺省,缺省为空。 | -| formVisibleNotify | 该标签标识卡片是否被允许使用卡片可见性通知。标签值为true或false | 布尔值 | 该标签可缺省,默认值为false。 | - -表12 window内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| --------------- | ------------------------------------------------------------ | -------- | -------------------- | -| designWidth | 指示页面设计的基线宽度,以像素为单位。 元素的大小由实际设备宽度缩放。 这个标签是一个整数。 | 数值 | 可缺省,缺省值为空。 | -| autoDesignWidth | 指定是否自动计算页面设计的基线宽度。 如果设置为true,则designWidth属性无效。基线宽度根据设备宽度和屏幕密度计算。 | 布尔值 | 可缺省,缺省值为空。 | - -form示例: - -在开发视图的resources/base/profile下面定义配置文件form_config.json(文件名称可由开发者定义) - -```json -{ -    "forms": [ -        { -            "name": "Form_Js", -            "description": "$string:form_description", -            "src": "./js/pages/card/index", -            "window": { -                "designWidth": 720, -                "autoDesignWidth": true -            }, -            "colorMode": "auto", -            "formConfigAbility": "ability://xxxxx", -            "formVisibleNotify": false, -            "isDefault": true, -            "updateEnabled": true, -            "scheduledUpdateTime": "10:30", -            "updateDuration": 1, -            "defaultDimension": "2*2", -            "supportDimensions": [ -                "2*2" -            ], -           "metadata": [ -             { -                "name": "string", -                "value": "string", -                "resource": "$profile:config_file" -             } -           ]  -        } -    ] -} -``` - -在module.json的extension组件下面定义metadata信息 - -```json -{ - "extensionAbilities": [ - { - "name": "MyForm", - "type": "form",  - "metadata": [ - { - "name": "ohos.extability.form", - "resource": "$profile:form_config", - } - ], - } - ] -} -``` - -#### shortcuts对象内部结构 - -标识应用的快捷方式信息。标签值为数组,最多可以配置四个快捷方式。其包含四个子标签shortcutId、label、icon、intents。 - -metadata中指定shortcut信息,其中: -1)name:指定shortcuts的名称。使用ohos.ability.shortcut作为shortcuts信息的标识。 -2)resource:指定shortcuts信息的资源位置。 - -表13 shortcuts对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------------------------------------ | -------- | -------------------------- | -| shortcutId | 表示快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 否 | -| label | 表示快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省为空。 | -| icon | 该标签标识shortcut的图标,标签值为资源文件的索引。 | 字符串 | 该标签可缺省,缺省值为空。 | -| wants | 该标签标识快捷方式内定义的目标wants信息集合,每个want可配置两个子标签,bundleName,abilityName。
bundleName:快捷方式目标包名,字符串类型。
abilityName:快捷方式的目标组件名,字符串类型。 | 对象 | 该标签可缺省,缺省为空。 | - -在开发视图的resources/base/profile下面定义配置文件shortcut_config.json(文件名称可由开发者定义)。 - -```json -{ -        "shortcuts": [ -            { -                "shortcutId": "id_test1", -                "label": "$string:shortcut", -                "icon": "$media:aa_icon", -                "wants": [ -                    { -                       "bundleName": "com.ohos.hello" -                       "abilityName": "MainAbility" -                    } -                ] -            } -        ] -} -``` - -在config.json的module下面定义metadata信息,如下: - -```json -{ -    "module": { -        "name": "MyAbilityStage", -        "abilities" : [ -            { -                "name" : "MyAbility", -                "srcEntrance": "./abilities/MyAbility.ts", -                "skills": [{ -                            "actions": ["action.system.home"], -                            "entities": ["entity.system.home"], -                            "uris": [] -                }], -                "metadata": [ -                    { -                        "name": "ohos.ability.shortcut", -                        "resource": "$profile:shortcuts_config",  -                    } -                ], -            } -        ] -    } -} -``` - -#### commonEvents对象内部结构 - -commonEvents标签标识注册静态公共事件信息。标签值为数组。 -metadata中指定commonEvent信息,其中: - -1. name:指定commonEvent的名称。使用ohos.extability.staticSubscriber作为commonEvent信息的标识。 - -2. resource:指定commonEvent信息的资源位置。 - -表14 commonEvents对象内部结构 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------------------------------------ | ---------- | -------------------------- | -| name | 该标签指明当前静态公共事件对应的ability名,该类需要在ability中标明。 | 字符串 | 该标签不可缺省。 | -| permission | 该标签标识实现该静态公共事件需要申请的权限,以字符串类型表示一个权限名称,通常采用反向域名方式表示(最大255字节)。 | 字符串 | 可缺省,缺省值为空。 | -| types | 该标签配置当前静态公共事件的类别数组,字符串数组类型,每个数组元素为一个类别名称。 | 字符串数组 | 该标签可缺省,缺省值为空。 | -| events | 该标签标识能够接收的意图的event值的集合,取值通常为系统预定义的event值,也允许自定义。 | 字符串数组 | 该标签不可缺省。 | - -在开发视图的resources/base/profile下面定义配置文件common_event_config.json(文件名称可由开发者定义)。 - -```json -{ -    "commonEvents": [ -            { -                "name": "abilityName", -                "permission": "string", -                "types": [ -                    "string", -                    "string" -                ], -                "events": [ -                    "string", -                    "string" -                ] -            } -    ] -} -``` - -在module.json的extension组件下面定义metadata信息,如下: - -```json -"extensionAbilities": [ -    { -        "name": "mySubscriber", -        "srcEntrance": "./extension/my_subscriber.js", -        "type": "staticSubscriber", -        "metadata": [ -            { -                "name": "ohos.extability.staticSubscriber", -                "resource": "$profile:common_event_config",  -            } -        ], -    } -] -``` - -#### distroFilter对象内部结构 - -表示应用的分发规则。 - -该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Verion、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。 - -表15 distroFilter对象内部结构 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------- | ------------------------------------------------------------ | -------- | -------------------------- | -| apiVersion | 表示支持的apiVersion范围。参考表16。 | 对象数组 | 该标签可缺省,缺省值为空。 | -| screenShape | 表示屏幕形状的支持策略。 | 对象数组 | 该标签可缺省,缺省值为空。 | -| screenWindow | 表示应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。 | 对象数组 | 该标签可缺省,缺省值为空。 | -| screenDensity | 该标签表示屏幕的像素密度(dpi:Dot Per Inch)。该字段可选,如果配置了该字段,取值必须合法。该标签为字符串数组,字符串范围如下。
sdpi:表示小规模的屏幕密度(Small-scale Dots per Inch),适用于dpi取值为(0,120]的设备。
mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi:表示大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi:表示大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi:表示大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | 对象数组 | 该标签可缺省,缺省值为空。 | -| countryCode | 该标签表示应用需要分发的国家地区码,具体值以ISO-3166-1标准为准。支持多个国家和地区枚举定义。该字段可选,如果配置了该字段,取值必须合法。标签值字符串数组,子串表示所支持的国家或地区,由两个大写字母组成。 | 对象数组 | 该标签可缺省,缺省值为空。 | - -表16 apiVersion对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持的取值为API Version存在的整数值,例如4、5、6。场景示例:某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数组 | 可缺省,缺省值为空。 | - -表17 screenShape对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持的取值为circle(圆形)、rect(矩形)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 数组 | 可缺省,缺省值为空。 | - -表18 screenWindow对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 单个字符串的取值格式为:“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 数组 | 可缺省,缺省值为空。 | - -表19 screenDensity对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 该标签表示屏幕的像素密度(dpi:Dot Per Inch)。 | 数组 | 可缺省,缺省值为空。 | - -表20 countryCode对象的内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 该标签表示应用需要分发的国家地区码。 | 数组 | 可缺省,缺省值为空。 | - -distroFilter示例: - -在开发视图的resources/base/profile下面定义配置文件distroFilter_config.json(文件名称可由开发者定义)。 - -```json -"distroFilter": [ - { - "apiVersion": { - "policy": "include", - "value": [4,5] - }, - "screenShape": { - "policy": "include", - "value": ["circle","rect"] - }, - "screenWindow": { - "policy": "include", - "value": ["454*454","466*466"] - } - } -] -``` - -在module.json的extensionAbilities组件下面定义metadata信息,如下: - -```json -"extensionAbilities": [ -    { -        "name": "mySubscriber", -        "srcEntrance": "./extension/my_subscriber.js", -        "type": "staticSubscriber",  -        "metadata": [ -            { -                "name": "ohos.extability.staticSubscriber", -                "resource": "$profile:distroFilter_config",  -            } -        ], -    } -] - -``` - diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index 2ee57571b1031ed0b6efaa5f9a8fc228408846a2..bea3f988e3f4098caad06dd53a19f7affb937636 100644 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -1,6 +1,6 @@ -# 包结构说明 +# 应用包结构配置文件的说明 在应用开发的工程中,需要在config.json配置文件中对应用的包结构进行声明。 @@ -38,7 +38,7 @@ config.json示例: "package": "com.example.myapplication.entrymodule", "name": ".MyApplication", "deviceType": [ - "phone" + "default" ], "distro": { "moduleName": "entry", @@ -129,29 +129,28 @@ app实例: ### deviceConfig对象的内部结构 -deviceConfig包含设备上的应用配置信息,可以包含default,phone,tv,car,wearable,liteWearable等属性。default标签内的配置是适用于所有通用设备,其他设备类型如果有特殊的需求,则需要在该设备类型的标签下进行配置。内部结构说明参见表5。 +deviceConfig包含设备上的应用配置信息,可以包含default,tv,car,wearable,liteWearable等属性。default标签内的配置是适用于所有通用设备,其他设备类型如果有特殊的需求,则需要在该设备类型的标签下进行配置。内部结构说明参见表5。 表5 deviceConfig对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------ | ----------------------------------------------- | -------- | ------------------ | | default | 表示所有设备通用的应用配置信息。参考表6。 | 对象 | 否 | -| phone | 表示手机类设备的应用信息配置。参考表6。 | 对象 | 可缺省,缺省值为空 | | tablet | 表示平板的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | | tv | 表示智慧屏特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | | car | 表示车机特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | | wearable | 表示智能穿戴特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | | liteWearable | 表示轻量级智能穿戴特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | -default、phone、tablet、tv、car、wearable、liteWearble等对象的内部结构说明,可参见表6。 +default、tablet、tv、car、wearable、liteWearble等对象的内部结构说明,可参见表6。 表6 不同设备的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------ | ------------------------------------------------------------ | -------- | ----------------------- | -| process | 表示应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于手机、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 是 | -| supportBackup | 表示应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"false" | -| compressNativeLibs | 表示libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"true" | +| process | 表示应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于默认设备、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 是 | +| supportBackup | 表示应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"false" | +| compressNativeLibs | 表示libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"true" | | directLaunch | 指定设备被锁定时是否可以启动应用程序。如果要在不解锁设备的情况下启动应用程序,请将此设备设置为"true"。运行OHOS的设备不支持此属性。 | 布尔值 | 可缺省,缺省值为"false" | | ark | 标识maple配置信息。参考表7。 | 对象 | 是缺省为空 | | network | 表示网络安全性配置。该标签允许应用通过配置文件的安全声明来自定义其网络安全,无需修改应用代码。参考表9。 | 对象 | 可缺省,缺省值为空 | @@ -219,18 +218,18 @@ module对象包含HAP包的配置信息,内部结构说明参见表11。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | | mainAbility | 服务中心图标露出的ability,常驻进程拉起时会启动mainAbility。 | 字符串 | 如果存在page类型的ability,则该字段不可缺省。 | -| package | 表示HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度不超过127字节。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 否 | -| name | 表示HAP的类名。采用反向域名 方式表示,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 否 | -| description | 表示HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空 | +| package | 表示HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度不超过127字节。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 否 | +| name | 表示HAP的类名。采用反向域名 方式表示,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 否 | +| description | 表示HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空 | | supportedModes | 表示应用支持的运行模式,当前只定义了驾驶模式(drive)。该标签只适用于车机。 | 字符串数组 | 可缺省,缺省值为空 | -| deviceType | 表示允许Ability运行的设备类型。系统预定义的设备类型包括:phone(手机)、tablet(平板)、tv(智慧屏)、car(车机)、wearable(智能穿戴)、liteWearable(轻量级智能穿戴)等。 | 字符串数组 | 否 | -| distro | 表示HAP发布的具体描述。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。参考表12。 | 对象 | 否 | +| deviceType | 表示允许Ability运行的设备类型。系统预定义的设备类型包括:tablet(平板)、tv(智慧屏)、car(车机)、wearable(智能穿戴)、liteWearable(轻量级智能穿戴)等。 | 字符串数组 | 否 | +| distro | 表示HAP发布的具体描述。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表12。 | 对象 | 否 | | metaData | 表示HAP的元信息。参考表13。 | 对象 | 可缺省,缺省值为空 | | abilities | 表示当前模块内的所有Ability。采用对象数据格式。其中的每个元素表示一个快捷方式对象。参考表17。 | 对象数组 | 可缺省,缺省值为空 | | js | 表示基于ArkUI框架开发的JS模块集合,其中的每个元素代表一个JS模块的信息。参考表22。 | 对象数组 | 可缺省,缺省值为空 | | shortcuts | 表示应用的快捷方式信息。采用对象数组格式,其中的每个元素表示一个快捷方式对象。参考表25。 | 对象数组 | 可缺省,缺省值为空 | | reqPermissions | 表示应用运行时向系统申请的权限。参考表21。 | 对象数组 | 可缺省,缺省值为空 | -| colorMode | 表示应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto" | +| colorMode | 表示应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto" | | distroFilter | 表示应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Verion、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表29。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | | reqCapabilities | 表示运行应用程序所需的设备能力 | 字符串数组 | 可缺省,缺省为空 | | commonEvents | 静态广播,参考表35。 | 对象数组 | 可缺省,缺省为空 | @@ -348,12 +347,12 @@ metaData示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | | process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。运行OHOS的设备不支持此属性。 | 字符串 | 可缺省,缺省值为空。 | -| name | 表示Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,包括生成“MainAbility.java”文件,及“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 否 | +| name | 表示Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,包括生成“MainAbility.java”文件,及“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 否 | | description | 表示对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | icon | 表示Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。
说明:应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | | label | 表示Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | uri | 表示Ability的统一资源标识符。该标签最大长度为255。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | -| launchType | 表示Ability的启动模式,支持“standard”、“singleMission”和“singleton”三种模式:
standard:表示该Ability可以有多实例。
“standard”模式适用于大多数应用场景。
singleMission:表示此Ability在每个任务栈中只能有一个实例。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“standard”。 | +| launchType | 表示Ability的启动模式,支持“standard”、“singleMission”和“singleton”三种模式:
standard:表示该Ability可以有多实例。
“standard”模式适用于大多数应用场景。
singleMission:表示此Ability在每个任务栈中只能有一个实例。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“standard”。 | | visible | 表示Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为“false”。 | | permissions | 表示其他应用的Ability调用此Ability时需要申请的权限。通常采用反向域名格式,取值可以是系统预定义的权限,也可以是开发者自定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | | skills | 表示Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 | @@ -363,13 +362,13 @@ metaData示例: | orientation | 表示该Ability的显示模式。该标签仅适用于page类型的Ability。取值范围如下:
unspecified:由系统自动判断显示方向。
landscape:横屏模式。
portrait:竖屏模式。
followRecent:跟随栈中最近的应用。 | 字符串 | 可缺省,缺省值为“unspecified”。 | | backgroundModes | 表示后台服务的类型,可以为一个服务配置多个后台服务类型。该标签仅适用于service类型的Ability。取值范围如下:
dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback:音频输出业务。
audioRecording:音频输入业务。
pictureInPicture:画中画、小窗口播放视频业务。
voip:音视频电话、VOIP业务。
location:定位、导航业务。
bluetoothInteraction:蓝牙扫描、连接、传输业务。
wifiInteraction:WLAN扫描、连接、传输业务。
screenFetch:录屏、截屏业务。
multiDeviceConnection:多设备互联业务 | 字符串数组 | 可缺省,缺省值为空。 | | grantPermission | 指定是否可以向Ability内任何数据授予权限。 | 布尔值 | 可缺省,缺省值为空。 | -| readPermission | 表示读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | -| writePermission | 表示向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | +| readPermission | 表示读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | +| writePermission | 表示向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | | configChanges | 表示Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:
mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。
mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。
locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。
layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。
fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。
orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。
density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。
size:显示窗口大小发生变更。
smallestSize:显示窗口较短边的边长发生变更。
colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省为空。 | -| mission | 表示Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为应用的包名。 | -| targetAbility | 表示当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其它属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | -| multiUserShared | 表示Ability是否支持多用户状态进行共享,该标签仅适用于data类型的Ability。配置为“true”时,表示在多用户下只有一份存储数据。需要注意的是,该属性会使visible属性失效。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔类型 | 可缺省,缺省值为“false”。 | -| supportPipMode | 表示Ability是否支持用户进入PIP模式(用于在页面最上层悬浮小窗口,俗称“画中画”,常见于视频播放等场景)。该标签仅适用于page类型的Ability。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 布尔类型 | 可缺省,缺省值为“false”。 | +| mission | 表示Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为应用的包名。 | +| targetAbility | 表示当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其它属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | +| multiUserShared | 表示Ability是否支持多用户状态进行共享,该标签仅适用于data类型的Ability。配置为“true”时,表示在多用户下只有一份存储数据。需要注意的是,该属性会使visible属性失效。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔类型 | 可缺省,缺省值为“false”。 | +| supportPipMode | 表示Ability是否支持用户进入PIP模式(用于在页面最上层悬浮小窗口,俗称“画中画”,常见于视频播放等场景)。该标签仅适用于page类型的Ability。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔类型 | 可缺省,缺省值为“false”。 | | formsEnabled | 表示Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。
true:支持卡片能力。
false:不支持卡片能力。 | 布尔类型 | 可缺省,缺省值为“false”。 | | forms | 表示服务卡片的属性。该标签仅当formsEnabled为“true”时,才能生效。参考表27。 | 对象数组 | 可缺省,缺省值为空。 | | srcLanguage | Ability开发语言的类型。 | 字符串 | 取值为java、js或ets | @@ -506,7 +505,7 @@ skills示例: | -------- | ------------------------------------------------------------ | -------- | ------------------------ | | name | 表示JS Component的名字。该标签不可缺省,默认值为default。 | 字符串 | 否 | | pages | 表示JS Component的页面用于列举JS Component中每个页面的路由信息[页面路径+页面名称]。该标签不可缺省,取值为数组,数组第一个元素代表JS FA首页。 | 数组 | 否 | -| window | 用于定义与显示窗口相关的配置。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。参考表23。 | 对象 | 可缺省 | +| window | 用于定义与显示窗口相关的配置。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表23。 | 对象 | 可缺省 | | type | 表示JS应用的类型。取值范围如下:
normal:标识该JS Component为应用实例。
form:标识该JS Component为卡片实例。 | 字符串 | 可缺省,缺省值为“normal” | | mode | 定义JS组件的开发模式。参考表24。 | 对象 | 可缺省,缺省值为空 | diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index 0e64bf3f7cd7f1fe2e0f4b10934ed259f7efaea3..9f1168568595c1de577bfb64a0c4273006970f6f 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -1,5 +1,4 @@ -# 前言 - +# 开发准备 本文档适用于OpenHarmony应用开发的初学者。通过构建一个简单的具有页面跳转/返回功能的应用(如下图所示),快速了解工程目录的主要文件,熟悉OpenHarmony应用开发流程。 @@ -15,33 +14,33 @@ ### UI框架 -OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架)。方舟开发框架可为开发者提供进行应用UI开发时所必须的能力,比如多种组件、布局计算、动画能力、UI交互、绘制等等。 +OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架)。方舟开发框架可为开发者提供应用UI开发所必须的能力,比如多种组件、布局计算、动画能力、UI交互、绘制等等。 方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于JS扩展的类Web开发范式(简称“类Web开发范式”)和基于TS扩展的声明式开发范式(简称“声明式开发范式”)。以下是两种开发范式的简单对比。 - | **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** | +| **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** | | -------- | -------- | -------- | -------- | -------- | -| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的类小程序应用和卡片 | Web前端开发人员 | -| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | +| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 | +| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | -对于DevEco Studio V2.2 Beta1及更高版本,在使用JS语言开发时,除传统代码方式外,还支持使用低代码方式。OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS开发规范](../reference/apis),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 +对于DevEco Studio V2.2 Beta1及更高版本,在使用JS语言开发时,除传统代码方式外,还支持使用低代码方式。OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循JS开发规范,通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 ### Ability -[Ability](../ability/ability-brief.md)是应用所具备能力的抽象,也是应用程序的重要组成部分。一个应用可以具备多种能力(即可以包含多个Ability)。OpenHarmony支持应用以Ability为单位进行部署。 +Ability是应用所具备能力的抽象,也是应用程序的重要组成部分。一个应用可以具备多种能力(即可以包含多个Ability)。OpenHarmony支持应用以Ability为单位进行部署。 -Ability可以分为[FA(Feature Ability)](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/glossary/glossary.md#f)和[PA(Particle Ability)](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/glossary/glossary.md#p)两种类型,每种类型为开发者提供了不同的模板,以便实现不同的业务功能。其中,FA支持[Page Ability](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-pageability.md)模板,以提供与用户交互的能力。一个Page Ability可以含有一个或多个页面(即Page),Page Ability与Page的关系如下图所示: +Ability可以分为[FA(Feature Ability)](../../glossary.md#f)和[PA(Particle Ability)](../../glossary.md#p)两种类型,每种类型为开发者提供了不同的模板,以便实现不同的业务功能。其中,FA支持[Page Ability](../ability/fa-pageability.md)模板,以提供与用户交互的能力。一个Page Ability可以含有一个或多个页面(即Page),Page Ability与Page的关系如下图所示: ![zh-cn_image_0000001215206886](figures/zh-cn_image_0000001215206886.png) -快速入门提供了一个含有两个页面的Page Ability实例。更多Ability的开发内容及指导,请参见[Ability开发](../ability/Readme-CN.md)。 +快速入门提供了一个含有两个页面的Page Ability实例。更多Ability的开发内容及指导,请参见[Ability开发](../ability/fa-brief.md)。 ## 工具准备 -1. 安装最新版[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)。 +1. 安装最新版[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)。 -2. 请参考[配置OpenHarmony SDK](configuring-openharmony-sdk.md),完成**DevEco Studio**的安装和开发环境配置。 +2. 请参考[配置OpenHarmony SDK](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443),完成**DevEco Studio**的安装和开发环境配置。 完成上述操作及基本概念的理解后,可参照[使用eTS语言开发](start-with-ets.md)、[使用JS语言开发(传统代码方式)](start-with-js.md)、[使用JS语言开发(低代码方式)](start-with-js-low-code.md)中的任一章节进行下一步体验和学习。 diff --git a/zh-cn/application-dev/quick-start/start-with-ets.md b/zh-cn/application-dev/quick-start/start-with-ets.md index 4bde32525058164ae9d6a6f869d064794f7116fb..cd5fc9e97a5f3576a84586b536762c44846df498 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets.md +++ b/zh-cn/application-dev/quick-start/start-with-ets.md @@ -4,16 +4,16 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 请使用**DevEco Studio V3.0.0.601 Beta1**及更高版本。 > -> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获取下载链接。 ## 创建eTS工程 1. 打开**DevEco Studio**,点击**File** > **New > Create Project**,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![zh-cn_image_0000001260189591](figures/zh-cn_image_0000001260189591.png) + ![zh-cn_image_0000001223556342](figures/zh-cn_image_0000001223556342.png) 2. 进入配置工程界面,**UI Syntax**选择“**eTS**”,其他参数保持默认设置即可。 - ![zh-cn_image_0000001217063248](figures/zh-cn_image_0000001217063248.png) + ![zh-cn_image_0000001223716826](figures/zh-cn_image_0000001223716826.png) 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 @@ -22,20 +22,22 @@ - **entry** :OpenHarmony工程模块,编译构建生成一个Hap包。 - **src > main > ets** :用于存放ets源码。 - - **src > main > ets > MainAbility** :应用/服务的入口。 - - **src > main > ets > MainAbility > pages** :MainAbility包含的页面。 - - **src > main > ets > MainAbility > app.ets** :承载Ability生命周期。 + - **src > main > ets > MainAbility** :应用/服务的入口。 + - **src > main > ets > MainAbility > pages** :MainAbility包含的页面。 + - **src > main > ets > MainAbility > app.ets** :承载Ability生命周期。 - **src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - - **src > main >config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 + - **src > main > config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。 - **build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 + - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 + - **hvigorfile.js** :应用级编译构建任务脚本。 ## 构建第一个页面 -1. **文本组件。** +1. **使用文本组件。** 工程同步完成后,在“**Project**”窗口,点击“**entry > src > main > ets > MainAbility > pages**”,打开“**index.ets**”文件,可以看到页面由Text组件组成。“**index.ets**”文件的示例如下: @@ -76,13 +78,14 @@ .fontSize(50) .fontWeight(FontWeight.Bold) // 添加按钮,以接受用户点击 - Button(){ + Button() { Text('Next') - .fontSize(30) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) .margin({ - top:20 + top: 20 }) .backgroundColor('#0D9FFB') .width('40%') @@ -105,39 +108,41 @@ 1. **创建第二个页面。** 在“**Project**”窗口,打开“**entry > src > main > ets > MainAbility**”,右键点击“**pages**”文件夹,选择“**New > Page**”,命名为“**second**”,点击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下: - ![zh-cn_image_0000001261233671](figures/zh-cn_image_0000001261233671.png) + ![zh-cn_image_0000001223397122](figures/zh-cn_image_0000001223397122.png) 2. **添加文本及按钮。** 参照第一个页面,在第二个页面添加Text组件、Button组件等,并设置其样式。“**second.ets**”文件的示例如下: - + ``` @Entry @Component struct Second { @State message: string = 'Hi there' - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('Back') - .fontSize(25) + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('40%') - .height('5%') + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') } - .width('100%') + .height('100%') } - .height('100%') - } } ``` @@ -165,20 +170,21 @@ .fontSize(50) .fontWeight(FontWeight.Bold) // 添加按钮,以接受用户点击 - Button(){ + Button() { Text('Next') - .fontSize(30) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) .margin({ - top:20 + top: 20 }) .backgroundColor('#0D9FFB') .width('40%') .height('5%') - // 跳转按钮绑定onClick事件,点击按钮时跳转到第二页 - .onClick(()=>{ - router.push({uri:'pages/second'}) + // 跳转按钮绑定onClick事件,点击时跳转到第二页 + .onClick(() => { + router.push({ uri: 'pages/second' }) }) } .width('100%') @@ -198,37 +204,40 @@ @Entry @Component struct Second { - @State message: string = 'Hi there' - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('Back') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('40%') - .height('5%') - // 返回按钮绑定onClick事件,点击按钮时返回到第一页 - .onClick(()=>{ - router.back() - }) - } - .width('100%') + @State message: string = 'Hi there' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) } - .height('100%') + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // 返回按钮绑定onClick事件,点击按钮时返回到第一页 + .onClick(() => { + router.back() + }) + } + .width('100%') } + .height('100%') + } } ``` 3. **打开index.ets文件,点击预览器中的** ![zh-cn_image_0000001262219043](figures/zh-cn_image_0000001262219043.png) **按钮进行刷新。** 效果如下图所示: + ![zh-cn_image_0000001260684127](figures/zh-cn_image_0000001260684127.png) @@ -236,10 +245,11 @@ 1. 将搭载OpenHarmony标准系统的开发板与电脑连接。 -2. 点击**File >Project Structure** > **Project > Signing**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![zh-cn_image_0000001217365030](figures/zh-cn_image_0000001217365030.png) +2. 点击**File > Project Structure** > **Project > SigningConfigs**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: + ![zh-cn_image_0000001268077317](figures/zh-cn_image_0000001268077317.png) + +3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262206247](figures/zh-cn_image_0000001262206247.png)按钮运行。效果如下图所示: -3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262206247](figures/zh-cn_image_0000001262206247.png) 按钮运行。效果如下图所示: ![zh-cn_image_0000001217526428](figures/zh-cn_image_0000001217526428.png) -恭喜您已经使用eTS语言开发完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 +恭喜您已经使用eTS语言开发完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/start-with-js-low-code.md b/zh-cn/application-dev/quick-start/start-with-js-low-code.md index f3f4c70be5f618800c89a8a1bc717ae782415fe9..f71d5896cfe54230e2787acf633d512d005f4485 100644 --- a/zh-cn/application-dev/quick-start/start-with-js-low-code.md +++ b/zh-cn/application-dev/quick-start/start-with-js-low-code.md @@ -4,10 +4,10 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 该特性在**DevEco Studio V2.2 Beta1**及更高版本中支持。 > -> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获取下载链接。 -OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS开发规范](../reference/apis/),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 +OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循JS开发规范,通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 使用低代码开发应用或服务有以下两种开发方式: @@ -24,10 +24,10 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS > 该功能在DevEco Studio 3.0 Beta2及更高版本中支持,且compileSdkVersion必须为7或以上。 1. 打开**DevEco Studio**,点击**File** > **New > Create Project**,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![zh-cn_image_0000001259949659](figures/zh-cn_image_0000001259949659.png) + ![zh-cn_image_0000001268198893](figures/zh-cn_image_0000001268198893.png) -2. 进入配置工程界面,打开“**Super Visual Enable**”开关, **UI Syntax** 选择“**JS**”,其他参数保持默认设置即可。 - ![zh-cn_image_0000001261786055](figures/zh-cn_image_0000001261786055.png) +2. 进入配置工程界面,打开“**Enable Super Visual**”开关,**UI Syntax**选择“**JS**”,其他参数保持默认设置即可。 + ![zh-cn_image_0000001223717294](figures/zh-cn_image_0000001223717294.png) 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 @@ -36,14 +36,14 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS 工程同步完成后,自动生成以下目录结构: -![zh-cn_image_0000001216753776](figures/zh-cn_image_0000001216753776.png) +![zh-cn_image_0000001223558810](figures/zh-cn_image_0000001223558810.png) -- **pages > index > index.js**:低代码页面的逻辑描述文件,定义了页面里所用到的所有的逻辑关系,比如数据、事件等,详情请参考[JS语法参考](../ui/js-framework-syntax-js.md)。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的js文件。 +- **entry > src > main > js > MainAbility > pages > index > index.js** :低代码页面的逻辑描述文件,定义了页面里所用到的所有的逻辑关系,比如数据、事件等,详情请参考[JS语法参考](../ui/js-framework-syntax-js.md)。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的js文件。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 使用低代码页面开发时,其关联js文件的同级目录中不能包含hml和css页面,例如上图中的**js > MainAbility > pages > index**目录下不能包含hml与css文件,否则会出现编译报错。 + > 使用低代码页面开发时,其关联js文件的同级目录中不能包含hml和css页面,例如上图中的 **js > MainAbility > pages > index** 目录下不能包含hml与css文件,否则会出现编译报错。 -- **pages > index > index.visual**:visual文件存储低代码页面的数据模型,双击该文件即可打开低代码页面,进行可视化开发设计。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的visual文件。 +- **entry > src > main > supervisual > MainAbility > pages > index > index.visual** :visual文件存储低代码页面的数据模型,双击该文件即可打开低代码页面,进行可视化开发设计。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的visual文件。 ## 构建第一个页面 @@ -58,7 +58,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS ![zh-cn_image_0000001216600980](figures/zh-cn_image_0000001216600980.gif) 2. **添加容器,设置Div容器的样式和属性。** - 选中UI Control中的Div组件,将其拖至画布。点击右侧属性样式栏中的样式图标![zh-cn_image_0000001260226691](figures/zh-cn_image_0000001260226691.png)(General),设置Div组件的高度Height为100%,使其占满屏幕;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001215226858](figures/zh-cn_image_0000001215226858.png)(Flex),设置Div组件的FlexDirection样式为column,使Div的主轴垂直;设置Div组件的JustifyContent样式为center,使得其子组件在主轴上居中显示;设置Div组件的AlignItems样式为center,使得其子组件在交叉轴上居中显示。操作如下所示: + 选中UI Control中的Div组件,将其拖至画布。点击右侧属性样式栏中的样式图标![zh-cn_image_0000001260226691](figures/zh-cn_image_0000001260226691.png)(General),设置Div组件的高度Height为100%,使其占满屏幕;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001215226858](figures/zh-cn_image_0000001215226858.png)(Flex),设置Div组件的FlexDirection样式为column,使Div的主轴垂直;设置Div组件的JustifyContent样式为center,使得其子组件在主轴上居中显示;设置Div组件的AlignItems样式为center,使得其子组件在交叉轴上居中显示。操作如下所示: ![zh-cn_image_0000001216448880](figures/zh-cn_image_0000001216448880.gif) @@ -81,11 +81,11 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS 1. **创建第二个页面。** 在“**Project**”窗口,打开“**entry > src > main > js > MainAbility**”,右键点击“**pages**”文件夹,选择“**New > Visual**”,命名为“**second**”,单击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下: - ![zh-cn_image_0000001261129245](figures/zh-cn_image_0000001261129245.png) + ![zh-cn_image_0000001223882030](figures/zh-cn_image_0000001223882030.png) 2. **[删除画布原有模板组件。](#delete_origin_content)** -3. **[添加容器,设置Div容器的样式和属性](#add_container)** +3. **[添加容器,设置Div容器的样式和属性。](#add_container)** 4. **添加文本。** 选中Text组件,拖至Div组件的中央区域。点击右侧属性样式栏中的属性图标![zh-cn_image_0000001260227453](figures/zh-cn_image_0000001260227453.png)(Properties),设置Text组件的Content属性为“Hi there”;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001260107497](figures/zh-cn_image_0000001260107497.png)(Feature),设置组件的FontSize样式为60px;设置组件的TextAlign样式为center。再选中画布上的Text组件,拖动放大。操作如下所示: @@ -104,7 +104,6 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS 1. **第一个页面跳转到第二个页面。** 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理js文件及visual文件。 - - “**index.js**”示例如下: ``` @@ -112,17 +111,17 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS export default { onclick() { - router.push ({ + router.push({ uri:'pages/second/second', // 指定要跳转的页面 }) } } ``` - - “**index.viusal**”: 打开index.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388136](figures/zh-cn_image_0000001215388136.png)(Events),鼠标点击Click事件的输入框,选择onclick,如下所示: - - ![zh-cn_image_0000001261137889](figures/zh-cn_image_0000001261137889.png) - + - “**index.visual**”: 打开index.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388136](figures/zh-cn_image_0000001215388136.png)(Events),鼠标点击Click事件的输入框,选择onclick,如下所示: + + ![zh-cn_image_0000001223722586](figures/zh-cn_image_0000001223722586.png) + 2. **第二个页面返回到第一个页面。** 在第二个页面中,返回按钮绑定back方法,点击按钮时返回到第一页。 @@ -135,15 +134,16 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS export default { back() { - router.back () + router.back() } } ``` - - “**second.viusal**”: 打开second.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388262](figures/zh-cn_image_0000001215388262.png)(Events),鼠标点击Click事件的输入框,选择back,如下所示: + - “**second.visual**”: 打开second.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388262](figures/zh-cn_image_0000001215388262.png)(Events),鼠标点击Click事件的输入框,选择back,如下所示: - ![zh-cn_image_0000001216618320](figures/zh-cn_image_0000001216618320.png) + ![zh-cn_image_0000001268082945](figures/zh-cn_image_0000001268082945.png) 3. **打开index.visual或index.js文件,点击预览器中的** ![zh-cn_image_0000001261979271](figures/zh-cn_image_0000001261979271.png) **按钮进行刷新。** 效果如下图所示: + ![zh-cn_image_0000001261142799](figures/zh-cn_image_0000001261142799.png) @@ -151,11 +151,11 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循[JS 1. 将搭载OpenHarmony标准系统的开发板与电脑连接。 -2. 点击**File >Project Structure** > **Project > Signing**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![zh-cn_image_0000001217527948](figures/zh-cn_image_0000001217527948.png) +2. 点击**File > Project Structure** > **Project > Signing Configs**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: + ![zh-cn_image_0000001268283201](figures/zh-cn_image_0000001268283201.png) -3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262207811](figures/zh-cn_image_0000001262207811.png)按钮运行效果如下图所示: +3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262207811](figures/zh-cn_image_0000001262207811.png)按钮运行。效果如下图所示: ![zh-cn_image_0000001262127855](figures/zh-cn_image_0000001262127855.png) -恭喜您已经使用JS语言开发(低代码方式)完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 +恭喜您已经使用JS语言开发(低代码方式)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/start-with-js.md b/zh-cn/application-dev/quick-start/start-with-js.md index 4586c04052e9237fbc6406985c346da1bd4f9c9d..f97c7892294f6a3abefde03c4fb5e730d4acd58b 100644 --- a/zh-cn/application-dev/quick-start/start-with-js.md +++ b/zh-cn/application-dev/quick-start/start-with-js.md @@ -2,40 +2,43 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获取下载链接。 ## 创建JS工程 1. 打开**DevEco Studio**,点击**File** > **New > Create Project**,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![zh-cn_image_0000001215029852](figures/zh-cn_image_0000001215029852.png) + ![zh-cn_image_0000001223558814](figures/zh-cn_image_0000001223558814.png) 2. 进入配置工程界面,**UI Syntax**选择“**JS**”,其他参数保持默认设置即可。 - ![zh-cn_image_0000001217384890](figures/zh-cn_image_0000001217384890.png) + ![zh-cn_image_0000001223877162](figures/zh-cn_image_0000001223877162.png) 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 ## JS工程项目文件 -- **entry:** OpenHarmony工程模块,编译构建生成一个Hap包。 +- **entry**:OpenHarmony工程模块,编译构建生成一个Hap包。 - **src > main > js** :用于存放js源码。 - - **src > main > js > MainAbility** :应用/服务的入口。 - - **src > main > js > MainAbility > i18n** :用于配置不同语言场景资源内容,比如应用文本词条、图片路径资源等。 - - **src > main > js > MainAbility > pages** :MainAbility包含的页面。 - - **src > main > js > MainAbility > app.js** :承载Ability生命周期。 + - **src > main > js > MainAbility** :应用/服务的入口。 + - **src > main > js > MainAbility > i18n** :用于配置不同语言场景资源内容,比如应用文本词条、图片路径等资源。 + - **src > main > js > MainAbility > pages** :MainAbility包含的页面。 + - **src > main > js > MainAbility > app.js** :承载Ability生命周期。 + - **src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - - **src > main > config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 + - **src > main > config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。 - **build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 + - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 + - **hvigorfile.js** :应用级编译构建任务脚本。 ## 构建第一个页面 -1. **文本组件。** - 工程同步完成后,在“**Project**”窗口,点击“**entry > src >main > js > MainAbility > pages> index**”,打开“**index.hml**”文件,设置Text组件内容。“**index.hml**”文件的示例如下: +1. **使用文本组件。** + 工程同步完成后,在“**Project**”窗口,点击“**entry > src > main > js > MainAbility > pages> index**”,打开“**index.hml**”文件,设置Text组件内容。“**index.hml**”文件的示例如下: ``` @@ -55,13 +58,14 @@ Hello World - + + ``` 3. **设置页面样式。** - 在“**Project**”窗口,点击“**entry > src >main > js > MainAbility > pages> index**”,打开“**index.css**”文件,可以对页面中文本、按钮设置宽高、字体大小、间距等样式。“**index.css**”文件的示例如下: + 在“**Project**”窗口,点击“**entry > src > main > js > MainAbility > pages> index**”,打开“**index.css**”文件,可以对页面中文本、按钮设置宽高、字体大小、间距等样式。“**index.css**”文件的示例如下: ``` @@ -83,7 +87,8 @@ width: 100%; margin: 10px; } - .btn{ + + .btn { font-size: 60px; font-weight: bold; text-align: center; @@ -95,6 +100,7 @@ 4. **在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。** 第一个页面效果如下图所示: + ![zh-cn_image_0000001216084724](figures/zh-cn_image_0000001216084724.png) @@ -103,7 +109,7 @@ 1. **创建第二个页面。** 在“**Project**”窗口,打开“**entry > src > main > js > MainAbility**”,右键点击“**pages**”文件夹,选择“**New > Page**”,命名为“**second**”,点击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下: - ![zh-cn_image_0000001261233695](figures/zh-cn_image_0000001261233695.png) + ![zh-cn_image_0000001223877210](figures/zh-cn_image_0000001223877210.png) 2. **添加文本及按钮。** 参照第一个页面,在第二个页面添加文本、按钮及点击按钮绑定页面返回等。“**second.hml**”文件的示例如下: @@ -111,11 +117,12 @@ ```
- - Hi there - - - + + Hi there + + + +
``` @@ -123,44 +130,45 @@ ``` .container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; } .title { - font-size: 100px; - font-weight: bold; - text-align: center; - width: 100%; - margin: 10px; + font-size: 100px; + font-weight: bold; + text-align: center; + width: 100%; + margin: 10px; } - .btn{ - font-size: 60px; - font-weight: bold; - text-align: center; - width: 40%; - height: 5%; - margin-top: 20px; + + .btn { + font-size: 60px; + font-weight: bold; + text-align: center; + width: 40%; + height: 5%; + margin-top: 20px; } ``` ## 实现页面间的跳转 -页面间的导航可以通过[页面路由router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 +页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 1. **第一个页面跳转到第二个页面。** 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。“**index.js**”示例如下: ``` - import router from '@system.router' + import router from '@system.router'; export default { onclick: function () { @@ -176,7 +184,7 @@ ``` - import router from '@system.router' + import router from '@system.router'; export default { back: function () { @@ -186,6 +194,7 @@ ``` 3. **打开index文件夹下的任意一个文件,点击预览器中的** ![zh-cn_image_0000001262339067](figures/zh-cn_image_0000001262339067.png) **按钮进行刷新。** 效果如下图所示: + ![zh-cn_image_0000001216269940](figures/zh-cn_image_0000001216269940.png) @@ -193,10 +202,11 @@ 1. 将搭载OpenHarmony标准系统的开发板与电脑连接。 -2. 点击**File >Project Structure** > **Project > Signing**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![zh-cn_image_0000001262327095](figures/zh-cn_image_0000001262327095.png) +2. 点击**File > Project Structure** > **Project > Signing Configs**界面勾选“**Automatically generate signing**”,等待自动签名完成即可,点击“**OK**”。如下图所示: + ![zh-cn_image_0000001223557290](figures/zh-cn_image_0000001223557290.png) + +3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001217047316](figures/zh-cn_image_0000001217047316.png)按钮运行。效果如下图所示: -3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001217047316](figures/zh-cn_image_0000001217047316.png) 按钮运行。效果如下图所示: ![zh-cn_image_0000001217527892](figures/zh-cn_image_0000001217527892.png) -恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 +恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/syscap.md b/zh-cn/application-dev/quick-start/syscap.md new file mode 100644 index 0000000000000000000000000000000000000000..ffc32b4c5dd621115eda2b2e2bf39da0c758be8e --- /dev/null +++ b/zh-cn/application-dev/quick-start/syscap.md @@ -0,0 +1,180 @@ +# SysCap使用指南 + +## 概述 + +### 系统能力与 API + +SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性,如蓝牙,WIFI,NFC,摄像头等,都是系统能力之一。每个系统能力对应多个 API,这些 API 绑定在一起,随着目标设备是否支持该系统能力共同存在或消失,也会随着 IDE 一起提供给开发者做联想。 + +![image-20220326064841782](figures/image-20220326064841782.png) + + + +### 支持能力集,联想能力集与要求能力集 + +支持能力集,联想能力集与要求能力集都是系统能力的集合。 +支持能力集描述的是设备能力,要求能力集描述的是应用能力。若应用A的要求能力集是设备N的支持能力集的子集,则应用A可分发到设备N上安装运行,否则不能分发。 +联想能力集是该应用开发时,IDE 可联想的 API 所在的系统能力集合。 + +![image-20220326064913834](figures/image-20220326064913834.png) + + + +### 设备与支持能力集 + +每个设备根据其硬件能力,对应不同的支持能力集。 +SDK 将设备分为两组,爆款设备和自定义设备,爆款设备的支持能力集由 OpenHarmony 来定义,自定义设备由设备厂商给出。 + +![image-20220326064955505](figures/image-20220326064955505.png) + + + +### 设备与SDK能力的对应 + +SDK 提供全量的 API 给 IDE,IDE 通过开发者的项目支持的设备,找到该设备的支持能力集,筛选支持能力集包含的 API 提供给开发者做联想。 + +![image-20220326065043006](figures/image-20220326065043006.png) + + + +## SysCap开发指导 + +### PCID导入 + +DevEco Studio 工程支持 PCID 的导入。导入的 PCID 文件解码后输出的 syscap 会被写入 syscap.json 文件中。 + +在工程目录右键后选择 Import Product Compatibility ID,即可上传 PCID 文件并导入至 syscap.json 中。 + +![20220329-103626](figures/20220329-103626.gif) + + + +### 配置联想能力集和要求能力集 + +IDE 会根据创建的工程所支持的设置自动配置联想能力集和要求能力集,开发者也可以自行修改。 +对于联想能力集,开发者通过添加更多的系统能力,在 IDE 中可以使用更多的 API,但要注意这些 API 可能在设备上不支持,使用前需要判断。 +对于要求能力集,开发者修改时要十分慎重,修改不当会导致应用无法分发到目标设备上。 + +``` +/* syscap.json */ +{ + devices: { + general: [ /*每一个爆款设备对应一个syscap支持能力集,可配置多个爆款设备*/ + “phone”, + "car, + "pc", + ... + ], + custom: [ /*厂家自定义设备*/ + { + "某自定义设备": [ + "SystemCapability.Communication.SoftBus.Core", + ... + ] + }, + ... + ] + }, + development: { /*addedSysCaps内的sycap集合与devices中配置的各设备支持的syscap集合的并集共同构成联想能力集*/ + addedSysCaps: [ + "SystemCapability.Location.Location.Lite", + ... + ] + }, + production: { /*用于生成rpcid,慎重添加,可能导致应用无法分发到目标设备上*/ + addedSysCaps: [], //devices中配置的各设备支持的syscap集合的交集,添加addedSysCaps集合再除去removedSysCaps集合,共同构成要求能力集 + removedSysCaps: [] //当该要求能力集为某设备的子集时,应用才可被分发到该设备上 + } +} +``` + + + +### 单设备应用开发 + +默认应用的联想能力集、要求系统能力集和设备的支持系统能力集相等,开发者修改要求能力集需要慎重。 + +![image-20220326065124911](figures/image-20220326065124911.png) + + + +### 跨设备应用开发 + +默认应用的联想能力集是多个设备支持能力集的并集,要求能力集则是交集。 + +![image-20220326065201867](figures/image-20220326065201867.png) + + + +### 判断 API 是否可以使用 + +首先我们定义了 API canIUse 帮助开发者来判断该工程是否支持某个特定的syscap。 + +``` +if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { + console.log("该应用支持SystemCapability.ArkUI.ArkUI.Full"); +} else { + console.log("该应用不支持SystemCapability.ArkUI.ArkUI.Full"); +} +``` + +开发者可通过 import 的方式将模块导入,若当前设备不支持该模块,import 的结果为 undefined,开发者在使用其 API 时,需要判断其是否存在。 + +``` +import geolocation from '@ohos.geolocation'; + +if (geolocation) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitude); + }); +} else { + console.log('该设备不支持位置信息'); +} +``` + + + +### 不同设备相同能力的差异检查 + +即使是相同的系统能力,在不同的设备下,也会有能力的差异。比如同是摄像头的能力,平板设备优于智能穿戴设备。 + +``` +import userAuth from '@ohos.userIAM.userAuth'; + +const authenticator = userAuth.getAuthenticator(); +const result = authenticator.checkAbility('FACE_ONLY', 'S1'); + +if (result == authenticator.CheckAvailabilityResult.AUTH_NOT_SUPPORT) { + console.log('该设备不支持人脸识别'); +} +//强行调用不支持的 API 会返回错误信息,但不会出现语法错误。 +authenticator.execute('FACE_ONLY', 'S1', (err, result) => { + if (err) { + console.log(err.message); + return; + } +}) +``` + + +### 设备间的SysCap差异如何产生的 + +设备的SysCap因产品解决方案厂商拼装的部件组合不同而不同,整体流程如下图: + +![image-20220326072448840](figures/image-20220326072448840.png) + +1. 一套 OpenHarmony 源码由可选和必选部件集组成,不同的部件为对外体现的系统能力不同,即部件与 SysCap 之间映射关系。 + +2. 发布归一化的 SDK,API 与 SysCap 之间存在映射关系。 + +3. 产品解决方案厂商按硬件能力和产品诉求,可按需拼装部件。 + +4. 产品配置的部件可以是 OpenHarmony 的部件,也可以是三方开发的私有部件,由于部件与SysCap间存在映射,所有拼装后即可得到该产品的SysCap集合。 + +5. SysCap集编码生成 PCID (Product Compatibility ID, 产品兼容性标识),应用开发者可将 PCID 导入 IDE解码成SysCap ,开发时对设备的SysCap差异做兼容性处理。 + +6. 部署到设备上的系统参数中包含了 SysCap 集,系统提供了native的接口和应用接口,可供系统内的部件和应用查询某个 SysCap 是否存在。 + +7. 应用开发过程中,应用必要的 SysCap 将被编码成 RPCID(Required Product Compatibility ID),并写入应用安装包中。应用安装时,包管理器将解码 RPCID 得到应用需要的 SysCap,与设备当前具备的 SysCap 比较,若应用要求的 SysCap 都被满足,则安装成功。 + +8. 应用运行时,可通过 canIUse 接口查询设备的 SysCap,保证在不同设备上的兼容性。 diff --git a/zh-cn/application-dev/quick-start/use-wizard-to-create-project.md b/zh-cn/application-dev/quick-start/use-wizard-to-create-project.md deleted file mode 100644 index ad1015d2e9e6804037ce14f8938860ab22106547..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/use-wizard-to-create-project.md +++ /dev/null @@ -1,47 +0,0 @@ -# 使用工程向导创建新工程 - -- [前提条件](#前提条件) -- [操作步骤](#操作步骤) - -通过工程向导创建一个OpenHarmony工程,该功能只有DevEco Studio 2.2 Beta1及以上版本支持。如果是DevEco Studio 2.1 Release版本,请根据[通过导入Sample方式创建新工程](../quick-start/import-sample-to-create-project.md)进行操作。 - - -## 前提条件 - -已安装OpenHarmony SDK,具体请参考[配置OpenHarmony SDK](../quick-start/configuring-openharmony-sdk.md)。 - - -## 操作步骤 - -1. 通过如下两种方式,打开工程创建向导界面。 - - 如果当前未打开任何工程,可以在DevEco Studio的欢迎页,选择**Create Project**开始创建一个新工程。 - - 如果已经打开了工程,可以在菜单栏选择**File > New > New Project**来创建一个新工程。 - -2. 根据工程创建向导,选择“[Standard]Empty Ability”模板,点击**Next**。 - ![zh-cn_image_0000001162463400](figures/zh-cn_image_0000001162463400.png) - -3. 点击**Next**,进入到工程配置阶段,需要根据向导配置工程的基本信息。 - - **Project name**:工程的名称,可以自定义。 - - **Project type**:工程的类型,标识该工程是一个[原子化服务](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/atomic-service-definition-0000001090840664)(Service)或传统方式的需要安装的应用(Application)。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果是创建的原子化服务,则: - > - > - 原子化服务调试、运行时,在设备桌面上没有应用图标,请使用DevEco Studio的调试和运行功能,来启动原子化服务。 - > - > - 原子化服务是免安装的,config.json中自动添加**installationFree**字段,取值为“true”。 - > - > - 如果entry模块的**installationFree**字段为true,则其相关的所有hap模块的**installationFree**字段都默认为true;如果entry模块的**installationFree**字段为false,则其相关的所有hap模块可以配置为true或false。 - > - > - 编译构建App时,每个hap包大小不能超过10MB。 - - **Bundle name**:软件包名称,默认情况下,应用ID也会使用该名称,应用发布时,应用ID需要唯一。如果“Project Type”选择了Atomic Service,则Bundle Name的后缀名必须是.hmservice。 - - **Save Location**:工程文件本地存储路径。 - - **Development mode**:选择开发模式,部分模板支持低代码开发,可选择Super Visual。 - - **Language**:支持的开发语言。 - - **Compatible API Version**:兼容的SDK最低版本。 - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > OpenHarmony工程如果配置了compileSdkVersion 7以上,对应模块默认使用方舟编译器进行编译,如果要修改编译方式为非方舟编译,在模块级build.gradle的**ohos**闭包中添加**arkEnable false**字段。 - - **Device Type**:该工程模板支持的设备类型。 - ![zh-cn_image_0000001196050928](figures/zh-cn_image_0000001196050928.png) - -4. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 7631ad19140ff57217b51b3f94fc825f1f611a51..08593677a5fa5ce02018dc74e77a2d97e655622e 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,134 +1,207 @@ # 接口 - Ability框架 - - [FeatureAbility模块](js-apis-featureAbility.md) - - [ParticleAbility模块](js-apis-particleAbility.md) - - [DataAbilityHelper模块](js-apis-dataAbilityHelper.md) - - [DataUriUtils模块](js-apis-DataUriUtils.md) - - [Bundle模块](js-apis-Bundle.md) - - [Context模块](js-apis-Context.md) -- 事件与通知 - - [CommonEvent模块](js-apis-commonEvent.md) - - [Notification模块](js-apis-notification.md) - - [后台代理提醒](js-apis-reminderAgent.md) -- 资源管理 - - [资源管理](js-apis-resource-manager.md) - - [国际化-Intl](js-apis-intl.md) - - [国际化-I18n](js-apis-i18n.md) + + - [@ohos.ability.dataUriUtils (DataUriUtils模块)](js-apis-DataUriUtils.md) + - [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md) + - [@ohos.ability.wantConstant (wantConstant)](js-apis-ability-wantConstant.md) + - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](js-apis-abilityDelegatorRegistry.md) + - [@ohos.application.appManager (appManager)](js-apis-appmanager.md) + - [@ohos.application.Configuration (Configuration)](js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-configurationconstant.md) + - [@ohos.ability.featureAbility (FeatureAbility模块)](js-apis-featureAbility.md) + - [@ohos.application.formBindingData (卡片数据绑定类)](js-apis-formbindingdata.md) + - [@ohos.application.formError (FormError)](js-apis-formerror.md) + - [@ohos.application.formHost (FormHost)](js-apis-formhost.md) + - [@ohos.application.formInfo (FormInfo)](js-apis-formInfo.md) + - [@ohos.application.missionManager (missionManager)](js-apis-missionManager.md) + - [@ohos.application.formProvider (FormProvider)](js-apis-formprovider.md) + - [@ohos.ability.particleAbility (particleAbility模块)](js-apis-particleAbility.md) + - [@ohos.application.Want (Want)](js-apis-application-Want.md) + - [@ohos.wantAgent (WantAgent模块)](js-apis-wantAgent.md) + - ability/[dataAbilityHelper (DataAbilityHelper模块)](js-apis-dataAbilityHelper.md) + - app/[context (Context模块)](js-apis-Context.md) + - application/[abilityDelegator (AbilityDelegator)](js-apis-application-abilityDelegator.md) + - application/[abilityDelegatorArgs (AbilityDelegatorArgs)](js-apis-application-abilityDelegatorArgs.md) + - application/[AbilityRunningInfo (AbilityRunningInfo)](js-apis-abilityrunninginfo.md) + - application/[ExtensionContext (ExtensionContext)](js-apis-extension-context.md) + - application/[ExtensionRunningInfo (ExtensionRunningInfo)](js-apis-extensionrunninginfo.md) + - application/[FormExtensionContext (FormExtensionContext)](js-apis-formextensioncontext.md) + - application/[MissionSnapshot (MissionSnapshot)](js-apis-application-MissionSnapshot.md) + - application/[ProcessRunningInfo (ProcessRunningInfo)](js-apis-processrunninginfo.md) + - application/[ServiceExtensionContext (ServiceExtensionContext)](js-apis-service-extension-context.md) + - application/[shellCmdResult (ShellCmdResult)](js-apis-application-shellCmdResult.md) +- 公共事件与通知 + + - [@ohos.commonEvent (公共事件模块)](js-apis-commonEvent.md) + - [@ohos.events.emitter (Emitter)](js-apis-emitter.md) + - [@ohos.notification (Notification模块)](js-apis-notification.md) + - [@ohos.reminderAgent (后台代理提醒)](js-apis-reminderAgent.md) +- 应用程序包管理 + + - [@ohos.bundle (Bundle模块)](js-apis-Bundle.md) + - [@ohos.bundleState (设备使用信息统计)](js-apis-deviceUsageStatistics.md) + - [@ohos.zlib (Zip模块)](js-apis-zlib.md) +- UI界面 + + - [@ohos.animator (动画)](js-apis-animator.md) + - [@ohos.mediaquery (媒体查询)](js-apis-mediaquery.md) + - [@ohos.prompt (弹窗)](js-apis-prompt.md) + - [@ohos.router (页面路由)](js-apis-router.md) +- 图形图像 + + - [@ohos.display (屏幕属性)](js-apis-display.md) + - [@ohos.screenshot (屏幕截图)](js-apis-screenshot.md) + - [@ohos.window (窗口)](js-apis-window.md) + - [webgl (WebGL)](js-apis-webgl.md) + - [webgl2 (WebGL2)](js-apis-webgl2.md) - 媒体 - - [音频管理](js-apis-audio.md) - - [媒体服务](js-apis-media.md) - - [图片处理](js-apis-image.md) - - [相机管理](js-apis-camera.md) + + - [@ohos.multimedia.audio (音频管理)](js-apis-audio.md) + - [@ohos.multimedia.image (图片处理)](js-apis-image.md) + - [@ohos.multimedia.media (媒体服务)](js-apis-media.md) + - [@ohos.multimedia.medialibrary (媒体库管理)](js-apis-medialibrary.md) +- 资源管理 + - [@ohos.i18n (国际化-I18n)](js-apis-i18n.md) + - [@ohos.intl (国际化-Intl)](js-apis-intl.md) + - [@ohos.resourceManager (资源管理)](js-apis-resource-manager.md) +- 资源调度 + + - [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md) +- 定制管理 + + - [@ohos.configPolicy (配置策略)](js-apis-config-policy.md) - 安全 - - [用户认证](js-apis-useriam-userauth.md) - - [访问控制](js-apis-abilityAccessCtrl.md) - - [通用密钥库系统](js-apis-huks.md) + + - [@ohos.abilityAccessCtrl (访问控制管理)](js-apis-abilityAccessCtrl.md) + - [@ohos.security.huks (通用密钥库系统)](js-apis-huks.md) + - [@ohos.userIAM.userAuth (用户认证)](js-apis-useriam-userauth.md) + - [@system.cipher (加密算法)](js-apis-system-cipher.md) - 数据管理 - - [轻量级存储9+](js-apis-data-preferences.md) - - [轻量级存储](js-apis-data-storage.md) - - [分布式数据管理](js-apis-distributed-data.md) - - [分布式数据对象](js-apis-data-distributedobject.md) - - [关系型数据库](js-apis-data-rdb.md) - - [结果集](js-apis-data-resultset.md) - - [DataAbility 谓词](js-apis-data-ability.md) - - [设置数据项名称](js-apis-settings.md) + + - [@ohos.data.dataAbility (DataAbility谓词)](js-apis-data-ability.md) + - [@ohos.data.distributedData (分布式数据管理)](js-apis-distributed-data.md) + - [@ohos.data.distributedDataObject (分布式数据对象)](js-apis-data-distributedobject.md) + - [@ohos.data.rdb (关系型数据库)](js-apis-data-rdb.md) + - [@ohos.settings (设置数据项名称)](js-apis-settings.md) + - [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md) + - data/rdb/[resultSet (结果集)](js-apis-data-resultset.md) - 文件管理 - - [文件管理](js-apis-fileio.md) - - [Statfs](js-apis-statfs.md) - - [目录环境](js-apis-environment.md) - - [公共文件访问与管理](js-apis-filemanager.md) - - [应用空间统计](js-apis-storage-statistics.md) - - [卷管理](js-apis-volumemanager.md) -- 账号管理 - - [系统帐号管理](js-apis-osAccount.md) - - [分布式帐号管理](js-apis-distributed-account.md) - - [应用帐号管理](js-apis-appAccount.md) + + - [@ohos.environment (目录环境能力)](js-apis-environment.md) + - [@ohos.fileio (文件管理)](js-apis-fileio.md) + - [@ohos.fileManager (公共文件访问与管理)](js-apis-filemanager.md) + - [@ohos.statfs (statfs)](js-apis-statfs.md) + - [@ohos.storageStatistics (应用空间统计)](js-apis-storage-statistics.md) - 电话服务 - - [拨打电话](js-apis-call.md) - - [短信服务](js-apis-sms.md) - - [SIM卡管理](js-apis-sim.md) - - [网络搜索](js-apis-radio.md) - - [observer](js-apis-observer.md) - - [蜂窝数据](js-apis-telephony-data.md) + + - [@ohos.contact (联系人)](js-apis-contact.md) + - [@ohos.telephony.call (拨打电话)](js-apis-call.md) + - [@ohos.telephony.observer (observer)](js-apis-observer.md) + - [@ohos.telephony.radio (网络搜索)](js-apis-radio.md) + - [@ohos.telephony.sim (SIM卡管理)](js-apis-sim.md) + - [@ohos.telephony.sms (短信服务)](js-apis-sms.md) + - [@ohos.telephony.data (蜂窝数据)](js-apis-telephony-data.md) - 网络管理 - - [网络连接管理](js-apis-net-connection.md) - - [Socket连接](js-apis-socket.md) - - [WebSocket连接](js-apis-webSocket.md) - - [数据请求](js-apis-http.md) - - [上传下载](js-apis-request.md) + - [@ohos.net.connection (网络连接管理)](js-apis-net-connection.md) + - [@ohos.net.http (数据请求)](js-apis-http.md) + - [@ohos.request (上传下载)](js-apis-request.md) + - [@ohos.net.socket (Socket连接)](js-apis-socket.md) + - [@ohos.net.webSocket (WebSocket连接)](js-apis-webSocket.md) - 通信与连接 - - [WLAN](js-apis-wifi.md) - - [Bluetooth](js-apis-bluetooth.md) - - [RPC通信](js-apis-rpc.md) + + - [@ohos.bluetooth (蓝牙)](js-apis-bluetooth.md) + - [@ohos.connectedTag (有源标签)](js-apis-connectedTag.md) + - [@ohos.rpc (RPC通信)](js-apis-rpc.md) + - [@ohos.wifi (WLAN)](js-apis-wifi.md) + - [@ohos.wifiext (WLAN)](js-apis-wifiext.md) +- 系统基础能力 + + - [@ohos.accessibility (辅助功能)](js-apis-accessibility.md) + - [@ohos.faultLogger (故障日志获取)](js-apis-faultLogger.md) + - [@ohos.hiAppEvent (应用打点)](js-apis-hiappevent.md) + - [@ohos.hichecker (检测模式)](js-apis-hichecker.md) + - [@ohos.hidebug (Debug调试)](js-apis-hidebug.md) + - [@ohos.hilog (日志打印)](js-apis-hilog.md) + - [@ohos.hiTraceChain (分布式跟踪)](js-apis-hitracechain.md) + - [@ohos.hiTraceMeter (性能打点)](js-apis-hitracemeter.md) + - [@ohos.inputMethod (输入法框架)](js-apis-inputmethod.md) + - [@ohos.inputMethodEngine (输入法服务)](js-apis-inputmethodengine.md) + - [@ohos.pasteboard (剪贴板)](js-apis-pasteboard.md) + - [@ohos.screenLock (锁屏管理)](js-apis-screen-lock.md) + - [@ohos.systemTime (设置系统时间)](js-apis-system-time.md) + - [@ohos.wallpaper (壁纸)](js-apis-wallpaper.md) + - [Timer (定时器)](js-apis-timer.md) - 设备管理 - - [传感器](js-apis-sensor.md) - - [振动](js-apis-vibrator.md) - - [屏幕亮度](js-apis-brightness.md) - - [电量信息](js-apis-battery-info.md) - - [系统电源管理](js-apis-power.md) - - [热管理](js-apis-thermal.md) - - [Runninglock锁](js-apis-runninglock.md) - - [设备信息](js-apis-device-info.md) - - [系统属性](js-apis-system-parameter.md) - - [设备管理](js-apis-device-manager.md) - - [窗口](js-apis-window.md) - - [屏幕属性](js-apis-display.md) - - [升级](js-apis-update.md) - - [USB管理](js-apis-usb.md) - - [位置服务](js-apis-geolocation.md) - - [输入设备](js-apis-inputdevice.md) - - [组合按键](js-apis-inputconsumer.md) - - [输入监听](js-apis-inputmonitor.md) - - [事件注入](js-apis-inputeventclient.md) -- 基本功能 - - [应用上下文](js-apis-system-app.md) - - [日志打印](js-apis-logs.md) - - [页面路由](js-apis-router.md) - - [弹窗](js-apis-prompt.md) - - [应用配置](js-apis-system-configuration.md) - - [定时器](js-apis-timer.md) - - [锁屏管理](js-apis-screen-lock.md) - - [设置系统时间](js-apis-system-time.md) - - [壁纸](js-apis-wallpaper.md) - - [剪贴板](js-apis-pasteboard.md) - - [动画](js-apis-animator.md) - - [WebGL](js-apis-webgl.md) - - [WebGL2](js-apis-webgl2.md) - - [屏幕截图](js-apis-screenshot.md) - - [输入法框架](js-apis-inputmethod.md) - - [输入法服务](js-apis-inputmethodengine.md) - - [辅助功能](js-apis-accessibility.md) -- DFX - - [应用打点](js-apis-hiappevent.md) - - [性能打点](js-apis-hitracemeter.md) - - [故障日志获取](js-apis-faultLogger.md) - - [分布式跟踪](js-apis-hitracechain.md) - - [日志打印](js-apis-hilog.md) - - [检测模式](js-apis-hichecker.md) - - [Debug调试](js-apis-hidebug.md) + + - [@ohos.batteryInfo (电量信息)](js-apis-battery-info.md) + - [@ohos.brightness (屏幕亮度)](js-apis-brightness.md) + - [@ohos.deviceInfo (设备信息)](js-apis-device-info.md) + - [@ohos.distributedHardware.deviceManager (设备管理)](js-apis-device-manager.md) + - [@ohos.geolocation (位置服务)](js-apis-geolocation.md) + - [@ohos.multimodalInput.inputConsumer (组合按键)](js-apis-inputconsumer.md) + - [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputEventClient (注入按键)](js-apis-inputeventclient.md) + - [@ohos.multimodalInput.inputMonitor (输入监听)](js-apis-inputmonitor.md) + - [@ohos.power (系统电源管理)](js-apis-power.md) + - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) + - [@ohos.sensor (传感器)](js-apis-sensor.md) + - [@ohos.systemParameter (系统属性)](js-apis-system-parameter.md) + - [@ohos.thermal (热管理)](js-apis-thermal.md) + - [@ohos.update (升级)](js-apis-update.md) + - [@ohos.usb (USB管理)](js-apis-usb.md) + - [@ohos.vibrator (振动)](js-apis-vibrator.md) +- 帐号管理 + + - [@ohos.account.appAccount (应用帐号管理)](js-apis-appAccount.md) + - [@ohos.account.distributedAccount (分布式帐号管理)](js-apis-distributed-account.md) + - [@ohos.account.osAccount (系统帐号管理)](js-apis-osAccount.md) - 语言基础类库 - - [获取进程相关的信息](js-apis-process.md) - - [URL字符串解析](js-apis-url.md) - - [URI字符串解析](js-apis-uri.md) - - [util工具函数](js-apis-util.md) - - [xml解析与生成](js-apis-xml.md) - - [xml转换JavaScript](js-apis-convertxml.md) - - [启动一个worker](js-apis-worker.md) - - [线性容器ArrayList](js-apis-arraylist.md) - - [线性容器Deque](js-apis-deque.md) - - [线性容器List](js-apis-list.md) - - [线性容器LinkedList](js-apis-linkedlist.md) - - [线性容器Queue](js-apis-queue.md) - - [线性容器Stack](js-apis-stack.md) - - [线性容器Vector](js-apis-vector.md) - - [非线性容器HashSet](js-apis-hashset.md) - - [非线性容器HashMap](js-apis-hashmap.md) - - [非线性容器PlainArray](js-apis-plainarray.md) - - [非线性容器TreeMap](js-apis-treemap.md) - - [非线性容器TreeSet](js-apis-treeset.md) - - [非线性容器LightWeightMap](js-apis-lightweightmap.md) - - [非线性容器LightWeightSet](js-apis-lightweightset.md) -- 定制管理 - - [配置策略](js-apis-config-policy.md) - - [企业设备管理](js-apis-enterprise-device-manager.md) + + - [@ohos.convertxml (xml转换JavaScript)](js-apis-convertxml.md) + - [@ohos.process (获取进程相关的信息)](js-apis-process.md) + - [@ohos.uri (URI字符串解析)](js-apis-uri.md) + - [@ohos.url (URL字符串解析)](js-apis-url.md) + - [@ohos.util (util工具函数)](js-apis-util.md) + - [@ohos.util.ArrayList (线性容器ArrayList)](js-apis-arraylist.md) + - [@ohos.util.Deque (线性容器Deque)](js-apis-deque.md) + - [@ohos.util.HashMap (非线性容器HashMap)](js-apis-hashmap.md) + - [@ohos.util.HashSet (非线性容器HashSet)](js-apis-hashset.md) + - [@ohos.util.LightWeightMap (非线性容器LightWeightMap)](js-apis-lightweightmap.md) + - [@ohos.util.LightWeightSet (非线性容器LightWeightSet)](js-apis-lightweightset.md) + - [@ohos.util.LinkedList (线性容器LinkedList)](js-apis-linkedlist.md) + - [@ohos.util.List (线性容器List)](js-apis-list.md) + - [@ohos.util.PlainArray (非线性容器PlainArray)](js-apis-plainarray.md) + - [@ohos.util.Queue (线性容器Queue)](js-apis-queue.md) + - [@ohos.util.Stack (线性容器Stack)](js-apis-stack.md) + - [@ohos.util.TreeMap (非线性容器TreeMap)](js-apis-treemap.md) + - [@ohos.util.TreeSet (非线性容器TreeSet)](js-apis-treeset.md) + - [@ohos.util.Vector (线性容器Vector)](js-apis-vector.md) + - [@ohos.worker (启动一个Worker)](js-apis-worker.md) + - [@ohos.xml (xml解析与生成)](js-apis-xml.md) +- 测试 + - [@ohos.application.testRunner (TestRunner)](js-apis-testRunner.md) + - [@ohos.uitest (UiTest)](js-apis-uitest.md) +- 已停止维护的接口 + + - [@ohos.bytrace (性能打点)](js-apis-bytrace.md) + - [@system.app (应用上下文)](js-apis-system-app.md) + - [@system.battery (电量信息)](js-apis-system-battery.md) + - [@system.bluetooth (蓝牙)](js-apis-system-bluetooth.md) + - [@system.brightness (屏幕亮度)](js-apis-system-brightness.md) + - [@system.configuration (应用配置)](js-apis-system-configuration.md) + - [@system.device (设备信息)](js-apis-system-device.md) + - [@system.fetch (数据请求)](js-apis-system-fetch.md) + - [@system.file (文件存储)](js-apis-system-file.md) + - [@system.geolocation (地理位置)](js-apis-system-location.md) + - [@system.mediaquery (媒体查询)](js-apis-system-mediaquery.md) + - [@system.network (网络状态)](js-apis-system-network.md) + - [@system.notification (通知消息)](js-apis-system-notification.md) + - [@system.package (应用管理)](js-apis-system-package.md) + - [@system.prompt (弹窗)](js-apis-system-prompt.md) + - [@system.request (上传下载)](js-apis-system-request.md) + - [@system.router (页面路由)](js-apis-system-router.md) + - [@system.sensor (传感器)](js-apis-system-sensor.md) + - [@system.storage (数据存储)](js-apis-system-storage.md) + - [@system.vibrator (振动)](js-apis-system-vibrate.md) + - [console (日志打印)](js-apis-logs.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md deleted file mode 100644 index 0ce945b4cce417c96b7bc92e4870ce6c7fe17afa..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ /dev/null @@ -1,60 +0,0 @@ -# 延迟任务调度回调 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## 导入模块 - -``` -import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' -``` - -## WorkSchedulerExtensionAbility.onWorkStart - -onWorkStart(work: workScheduler.WorkInfo): void - -延迟任务调度开始回调。 - -**系统能力:** SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | --------------------- | ---- | -------------- | -| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示要添加到执行队列的工作。 | - -**示例:** - - ``` - export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { - onWorkStart(workInfo) { - console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); - } - } - ``` - -## WorkSchedulerExtensionAbility.onWorkStop - -onWorkStop(work: workScheduler.WorkInfo) - -延迟任务调度结束回调。 - -**系统能力:** SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | --------------------- | ---- | -------------- | -| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示要添加到执行队列的工作。 | - - -**示例:** - - ``` - export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { - onWorkStop(workInfo) { - console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); - } - } - ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md deleted file mode 100644 index 0be308776eb084cbd3e93d9cdf4c1e1321394ef7..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ /dev/null @@ -1,498 +0,0 @@ -# AbilityContext - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -Ability的上下文环境,继承自Context。 - - -## 使用说明 - - -在使用AbilityContext的功能前,需要通过Ability子类实例获取。 - - - -```js -import Ability from '@ohos.application.Ability' -class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - let context = this.context; - } -} -``` - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| abilityInfo | AbilityInfo | 是 | 否 | Abilityinfo相关信息 | -| currentHapModuleInfo | HapModuleInfo | 是 | 否 | 当前hap包的信息 | - - -## AbilityContext.startAbility - -startAbility(want: Want, callback: AsyncCallback<void>): void - -启动Ability。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | - -**示例:** - - ```js - var want = { - "deviceId": "", - "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" - }; - this.context.startAbility(want, (error) => { - console.log("error.code = " + error.code) - }) - ``` - - -## AbilityContext.startAbility - -startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void - -启动Ability。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果。 | - -**示例:** - - ```js - var want = { - "deviceId": "", - "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" - }; - var options = { - windowMode: 0, - }; - this.context.startAbility(want, options, (error) => { - console.log("error.code = " + error.code) - }) - ``` - - -## AbilityContext.startAbility - -startAbility(want: Want, options?: StartOptions): Promise<void>; - -启动Ability。通过Promise返回结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 否 | 启动Ability所携带的参数。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise形式返回启动结果。 | - -**示例:** - - ```js - var want = { - "deviceId": "", - "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" - }; - var options = { - windowMode: 0, - }; - this.context.startAbility(want, options) - .then((data) => { - console.log('Operation successful.') - }).catch((error) => { - console.log('Operation failed.'); - }) - ``` - - -## AbilityContext.startAbilityForResult - -startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; - -启动Ability并在结束的时候返回执行结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | - - -**示例:** - - ```js - this.context.startAbilityForResult( - {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, - (error, result) => { - console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) - console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) - } - ); - ``` - -## AbilityContext.startAbilityForResult - -startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; - -启动Ability并在结束的时候返回执行结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | - - -**示例:** - - ```js - var options = { - windowMode: 0, - }; - this.context.startAbilityForResult( - {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options, - (error, result) => { - console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) - console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) - } - ); - ``` - - -## AbilityContext.startAbilityForResult - -startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>; - -启动Ability并在结束的时候返回执行结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 否 | 启动Ability所携带的参数。 | - - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise形式返回执行结果。 | - -**示例:** - - ```js - var options = { - windowMode: 0, - }; - this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => { - console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode) - }, (error) => { - console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code) - }) - ``` - - -## AbilityContext.terminateSelf - -terminateSelf(callback: AsyncCallback<void>): void; - -停止Ability自身。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数,返回接口调用是否成功的结果。 | - -**示例:** - - ```js - this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringify(err)); - }); - ``` - - -## AbilityContext.terminateSelf - -terminateSelf(): Promise<void>; - -停止Ability自身。通过Promise返回结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果。 | - -**示例:** - - ```js - this.context.terminateSelf(want).then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - ``` - - -## AbilityContext.terminateSelfWithResult - -terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; - -停止Ability,并返回给调用startAbilityForResult 接口调用方的相关信息。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | 是 | 返回给调用startAbilityForResult 接口调用方的相关信息。 | - | callback | AsyncCallback<void> | 是 | callback形式返回停止结果。 | - -**示例:** - - ```js - this.context.terminateSelfWithResult( - { - want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"}, - resultCode: 100 - }, (error) => { - console.log("terminateSelfWithResult is called = " + error.code) - } - ); - ``` - - -## AbilityContext.terminateSelfWithResult - -terminateSelfWithResult(parameter: AbilityResult): Promise<void>; - -停止Ability,并返回给调用startAbilityForResult 接口相关信息。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | 是 | 返回给startAbilityForResult 调用方的信息。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | promise形式返回停止结果。 | - -**示例:** - - ```js - this.context.terminateSelfWithResult( - { - want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"}, - resultCode: 100 - }).then((result) => { - console.log("terminateSelfWithResult") - } - ) - ``` - - -## AbilityContext.startAbilityByCall - -startAbilityByCall(want: Want): Promise<Caller>; - -获取指定通用组件服务端的caller通信接口, 并且将指定通用组件服务端拉起并切换到后台。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<Caller> | 获取要通讯的caller对象。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - console.log('Caller GetCaller Get ' + call); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); - } - } - ``` - - -## AbilityContext.requestPermissionsFromUser - -requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; - -拉起弹窗请求用户授权。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | permissions | Array<string> | 是 | 权限列表。 | - | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | 是 | 回调函数,返回接口调用是否成功的结果。 | - -**示例:** - - ``` - this.context.requestPermissionsFromUser(permissions,(result) => { - console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); - }); - ``` - - -## AbilityContext.requestPermissionsFromUser - -requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>; - -拉起弹窗请求用户授权。通过Promise返回结果。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | permissions | Array<string> | 是 | 权限列表。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | 返回一个Promise,包含接口的结果。 | - -**示例:** - - ``` - this.context.requestPermissionsFromUser(permissions).then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - ``` - - -## AbilityContext.setMissionLabel - -setMissionLabel(label: string, callback:AsyncCallback<void>): void; - -设置ability在任务中显示的名称。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | label | string | 是 | 显示名称。 | - | callback | AsyncCallback<void> | 是 | 回调函数,返回接口调用是否成功的结果。 | - -**示例:** - - ```js - this.context.setMissionLabel("test",(result) => { - console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); - }); - ``` - - -## AbilityContext.setMissionLabel - -setMissionLabel(label: string): Promise<void> - -设置ability在任务中显示的名称。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | label | string | 是 | 显示名称。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 返回一个Promise,包含接口的结果。 | - -**示例:** - - ```js - this.context.setMissionLabel("test").then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - ``` - diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md deleted file mode 100644 index 5bf1ffba7de3ded2a797be4db301ae7452aa96af..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ /dev/null @@ -1,34 +0,0 @@ -# AbilityStageContext - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -AbilityStage的上下文环境,继承自[Context](js-apis-application-context.md)。 - - -## 使用说明 - - -通过AbilityStage实例来获取。 - - - -```js -import AbilityStage from '@ohos.application.AbilityStage'; -class MyAbilityStage extends AbilityStage { - onCreate() { - let abilityStageContext = this.context; - } -} -``` - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | 是 | 否 | AbilityStage对应的ModuleInfo对象。 | -| config | [Configuration](js-apis-configuration.md) | 是 | 否 | 环境变化对象。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md deleted file mode 100644 index 108dc8e016b3df2a7815089a11b079c30d5e47f2..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md +++ /dev/null @@ -1,352 +0,0 @@ -# DataShareExtensionAbility - -- [导入模块](#导入模块) -- [属性](#属性) - - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -类的数据共享扩展能力。 - - -## 导入模块 - - -``` -import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; -``` - -## 属性 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -------- | -| context | 是 | 否 | ExtensionContext | 否 | 指示数据共享扩展能力上下文。| - - -## DataShareExtensionAbility.onCreate - -onCreate?(want: Want): void; - -在启动数据共享扩展功能进行初始化时回调。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | Want | 是 | want表示有关数据共享扩展功能的连接信息。| - -**示例:** - - ```js - class myAbility extends DataShareExtensionAbility { - onCreate(want) { - console.log('onCreate, want:' + want.abilityName); - } - } - ``` - -## DataShareExtensionAbility.getFileTypes - -getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void - -获取支持的文件的MIME类型(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------------- | ------------------------------ | ---- | ---------------------------------- | -| uri | string | 是 | 指示要获取的文件的路径。 | -| mimeTypeFilter | string | 是 | 指示要获取的文件的MIME类型。 | -| callback | AsyncCallback\> | 是 | 回调方法,返回匹配的MIME类型数组。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -DAHelper.getFileTypes( - "dataability:///com.example.DataAbility", - "image/*", - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.insert - -insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void - -将单个数据记录插入数据库(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ------------ | ---------------------- | ---- | ------------------------------------------------------ | -| uri | string | 是 | 指示要插入的数据的路径。 | -| valuesBucket | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | -| callback | AsyncCallback\ | 是 | 回调方法,返回插入数据记录的索引。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -const valueBucket = { - "name": "rose", - "age": 22, - "salary": 200.5, - "blobType": u8, -} -DAHelper.insert( - "dataability:///com.example.DataAbility", - valueBucket, - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.update - -update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - -更新数据库中的数据记录(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ------------ | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指示要更新的数据的路径。 | -| valuesBucket | rdb.ValuesBucket | 是 | 指示要更新的数据。 | -| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | -| callback | AsyncCallback\ | 是 | 回调方法,返回更新的数据记录数。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -const va = { - "name": "roe1", - "age": 21, - "salary": 20.5, - "blobType": u8, -} -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.update( - "dataability:///com.example.DataAbility", - va, - da, - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.delete - -delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - -从数据库中删除一个或多个数据记录(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ------------ | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指示要删除的数据的路径。 | -| valuesBucket | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | -| callback | AsyncCallback\ | 是 | 回调方法。返回已删除的数据记录数。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.delete( - "dataability:///com.example.DataAbility", - da, - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.query - -query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - -查询数据库中的数据(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指示要查询的数据的路径。 | -| columns | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | -| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | -| callback | AsyncCallback\ | 是 | 回调方法,返回查询结果。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -var cars=new Array("value1", "value2", "value3", "value4"); -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.query( - "dataability:///com.example.DataAbility", - cars, - da, - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.getType - -getType?(uri: string, callback: AsyncCallback\): void - -获取给定URI指定数据的MIME类型(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | --------------------------------------------- | -| uri | string | 是 | 指示要操作的数据的路径。 | -| callback | AsyncCallback\ | 是 | 回调方法,返回与uri指定的数据匹配的MIME类型。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -DAHelper.getType( - "dataability:///com.example.DataAbility", - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.batchInsert - -batchInsert?(uri: string, valueBuckets: Array, callback: AsyncCallback\): void - -插入数据库(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ------------ | ----------------------- | ---- | -------------------------------- | -| uri | string | 是 | 指示要插入的数据的路径。 | -| valuesBucket | Array | 是 | 指示要插入的数据记录。 | -| callback | AsyncCallback\ | 是 | 回调方法。返回插入的数据记录数。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) -DAHelper.batchInsert( - "dataability:///com.example.DataAbility", - cars, - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.normalizeUri - -normalizeUri?(uri: string, callback: AsyncCallback\): void - -将引用数据功能的给定uri转换为规范化uri(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| uri | string | 是 | 指示要规范化的uri对象。 | -| callback | AsyncCallback\ | 是 | 回调方法。如果数据功能支持uri规范化,则返回规范化uri对象;否则返回null。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -DAHelper.normalizeUri( - "dataability:///com.example.DataAbility", - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` - -## DataShareExtensionAbility.denormalizeUri - -denormalizeUri?(uri: string, callback: AsyncCallback\): void - -将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(callback形式)。 - -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | --------------------------------------------------- | -| uri | string | 是 | 指示要规范化的uri对象。 | -| callback | AsyncCallback\ | 是 | 回调方法。如果反规范化成功,则返回反规范化uri对象。 | - -**示例:** - -```js -import featureAbility from '@ohos.ability.featureAbility' -var DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" -); -DAHelper.denormalizeUri( - "dataability:///com.example.DataAbility", - (err, data) => { - console.info("==========================>Called=======================>"); -}); -``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md b/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md deleted file mode 100644 index 8fb0784a21090472913730f5f8f9d55eed813e2b..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md +++ /dev/null @@ -1,35 +0,0 @@ -# StartOptions - -- [导入模块](#导入模块) -- [属性](#属性) - - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -StartOptions是系统的基本通信组件。 - - -## 导入模块 - - -``` -import StartOptions from '@ohos.application.StartOptions'; -``` - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.AbilityCore - -| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -------- | -| windowMode | 是 | 否 | number | 否 | 窗口模式。 | -| displayId | 是 | 否 | number | 否 | 显示ID。 | - - - - - - diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md deleted file mode 100644 index d173d00937f118756fa31164934a758f535890c9..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ /dev/null @@ -1,591 +0,0 @@ -# Ability - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -Ability模块,提供对Ability生命周期、上下文环境等调用管理。 - - -## 导入模块 - - -``` -import Ability from '@ohos.application.Ability'; -``` - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.AbilityCore - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| context | [AbilityContext](js-apis-ability-context.md) | 是 | 否 | 上下文。 | -| launchWant | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 否 | Ability启动时的参数。 | -| lastRequestWant | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 否 | Ability最后请求时的参数。| - - -## Ability.onCreate - -onCreate(want: Want, param: AbilityConstant.LaunchParam): void; - -Ability创建时回调,执行初始化业务逻辑操作。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 当前Ability的Want类型信息,包括ability名称、bundle名称等。 | - | param | AbilityConstant.LaunchParam | 是 | 创建 ability、上次异常退出的原因信息。 | - -**示例:** - - ```js - class myAbility extends Ability { - onCreate(want, param) { - console.log('onCreate, want:' + want.abilityName); - } - } - ``` - - -## Ability.onWindowStageCreate - -onWindowStageCreate(windowStage: window.WindowStage): void - -当WindowStage创建后调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | 是 | WindowStage相关信息。 | - -**示例:** - - ```js - class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - } - } - ``` - - -## Ability.onWindowStageDestroy - -onWindowStageDestroy(): void - -当WindowStage销毁后调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**示例:** - - ```js - class myAbility extends Ability { - onWindowStageDestroy() { - console.log('onWindowStageDestroy'); - } - } - ``` - - -## Ability.onWindowStageRestore - -onWindowStageRestore(windowStage: window.WindowStage): void - -当迁移多实例ability时,恢复WindowStage后调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | 是 | WindowStage相关信息。 | - -**示例:** - - ```js - class myAbility extends Ability { - onWindowStageRestore(windowStage) { - console.log('onWindowStageRestore'); - } - } - ``` - - -## Ability.onDestroy - -onDestroy(): void; - -Ability生命周期回调,在销毁时回调,执行资源清理等操作。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**示例:** - - ```js - class myAbility extends Ability { - onDestroy() { - console.log('onDestroy'); - } - } - ``` - - -## Ability.onForeground - -onForeground(): void; - -Ability生命周期回调,当应用处于前台时触发。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**示例:** - - ```js - class myAbility extends Ability { - onForeground() { - console.log('onForeground'); - } - } - ``` - - -## Ability.onBackground - -onBackground(): void; - -Ability生命周期回调,当应用处于后台时触发。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**示例:** - - ```js - class myAbility extends Ability { - onBackground() { - console.log('onBackground'); - } - } - ``` - - -## Ability.onContinue - -onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult; - -当ability迁移准备迁移时触发,保存数据。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | wantParam | {[key: string]: any} | 是 | want相关参数。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | AbilityConstant.OnContinueResult | 继续的结果。 | - -**示例:** - - ```js - class myAbility extends Ability { - onContinue(wantParams) { - console.log('onContinue'); - wantParams["myData"] = "my1234567"; - return true; - } - } - ``` - - -## Ability.onNewWant - -onNewWant(want: Want): void; - -当ability的启动模式设置为单例时回调会被调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | Want类型参数,如ability名称,包名等。 | - -**示例:** - - ```js - class myAbility extends Ability { - onNewWant(want) { - console.log('onNewWant, want:' + want.abilityName); - } - } - ``` - - -## Ability.onConfigurationUpdated - -onConfigurationUpdated(config: Configuration): void; - -当系统配置更新时调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 | - -**示例:** - - ```js - class myAbility extends Ability { - onConfigurationUpdated(config) { - console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); - } - } - ``` - - -## Caller - -通用组件Caller通信客户端调用接口, 用来向通用组件服务端发送约定数据。 - - -## Caller.call - -call(method: string, data: rpc.Sequenceable): Promise<void>; - -向通用组件服务端发送约定序列化数据。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | method | string | 是 | 约定的服务端注册事件字符串。 | - | data | rpc.Sequenceable | 是 | 由开发者实现的Sequenceable可序列化数据。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise形式返回应答。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - class MyMessageAble{ // 自定义的Sequenceable数据结构 - constructor(name, str) { - this.name = name; - this.str = str; - } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); - console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); - console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - }; - var method = 'call_Function'; // 约定的通知消息字符串 - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - let msg = new MyMessageAble(1, "world"); // 参考Sequenceable数据定义 - caller.call(method, msg) - .then(() => { - console.log('Caller call() called'); - }).catch((e) => { - console.log('Caller call() catch error ' + e); - }); - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); - } - - } - ``` - - -## Caller.callWithResult - -callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>; - -向通用组件服务端发送约定序列化数据, 并将服务端返回的约定序列化数据带回。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | method | string | 是 | 约定的服务端注册事件字符串。 | - | data | rpc.Sequenceable | 是 | 由开发者实现的Sequenceable可序列化数据。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<rpc.MessageParcel> | Promise形式返回通用组件服务端应答数据。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - class MyMessageAble{ - constructor(name, str) { - this.name = name; - this.str = str; - } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); - console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); - console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - }; - var method = 'call_Function'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - let msg = new MyMessageAble(1, "world"); - caller.callWithResult(method, msg) - .then((data) => { - console.log('Caller callWithResult() called'); - let retmsg = new MyMessageAble(0, ""); - data.readSequenceable(retmsg); - }).catch((e) => { - console.log('Caller callWithResult() catch error ' + e); - }); - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); - } - } - ``` - - -## Caller.release - -release(): void; - -主动释放通用组件服务端的通信接口。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - try { - caller.release(); - } catch (e) { - console.log('Caller Release error ' + e); - } - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); - } - } - ``` - - -## Caller.onRelease - -onRelease(callback: OnReleaseCallBack): void; - -注册通用组件服务端Stub断开监听通知。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | OnReleaseCallBack | 是 | 返回onRelease回调结果。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - var caller; - export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", - deviceId: "" - }).then((obj) => { - caller = obj; - try { - caller.onRelease((str) => { - console.log(' Caller OnRelease CallBack is called ' + str); - }); - } catch (e) { - console.log('Caller Release error ' + e); - } - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); - } - } - ``` - - -## Callee - -通用组件服务端注册和解除客户端caller通知送信的callback接口。 - - -## Callee.on - -on(method: string, callback: CaleeCallBack): void; - -通用组件服务端注册消息通知callback。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | method | string | 是 | 与客户端约定的通知消息字符串。 | - | callback | CaleeCallBack | 是 | 一个rpc.MessageParcel类型入参的js通知同步回调函数, 回调函数至少要返回一个空的rpc.Sequenceable数据对象, 其他视为函数执行错误。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - class MyMessageAble{ - constructor(name, str) { - this.name = name; - this.str = str; - } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); - console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); - console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); - return true; - } - }; - var method = 'call_Function'; - function funcCallBack(pdata) { - console.log('Callee funcCallBack is called ' + pdata); - let msg = new MyMessageAble(0, ""); - pdata.readSequenceable(msg); - return new MyMessageAble(10, "Callee test"); - } - export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log('Callee onCreate is called'); - this.callee.on(method, funcCallBack); - } - } - ``` - - -## Callee.off - -off(method: string): void; - -解除通用组件服务端注册消息通知callback。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | method | string | 是 | 已注册的通知事件字符串。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability'; - var method = 'call_Function'; - export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log('Callee onCreate is called'); - this.callee.off(method); - } - } - ``` - -## OnReleaseCallBack - -(msg: string): void; - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| (msg: string) | function | 是 | 否 | 调用者注册的侦听器函数接口的原型。 | - - - ## CaleeCallBack - -(indata: rpc.MessageParcel): rpc.Sequenceable; - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| (indata: rpc.MessageParcel) | rpc.Sequenceable | 是 | 否 | 被调用方注册的消息侦听器函数接口的原型。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md deleted file mode 100644 index ba0648207f6ad5088be237852424a972f4b8d0c1..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md +++ /dev/null @@ -1,68 +0,0 @@ -# AbilityConstant - -- [导入模块](#导入模块) -- [属性](#属性) - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -启动参数的接口. - - -## 导入模块 - - -```js -import AbilityConstant from '@ohos.application.AbilityConstant'; -``` - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| launchReason | LaunchReason| 是 | 是 | 指示启动原因。 | -| lastExitReason | LastExitReason | 是 | 是 | 表示最后退出原因。 | - -## AbilityConstant.LaunchReason - -初次开始原因的类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 变量 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| UNKNOWN | 0 | 未知的状态。 | -| START_ABILITY | 1 | 启动能力。 | -| CALL | 2 | 呼叫。 | -| CONTINUATION | 3 | 继续。 | - - -## AbilityConstant.LastExitReason - -上次退出原因的类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 变量 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| UNKNOWN | 0 | 未知的状态。 | -| ABILITY_NOT_RESPONDING | 1 | 能力没有反应 | -| NORMAL | 2 | 正常的状态。 | - - -## AbilityConstant.OnContinueResult - -继续结果的类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 变量 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------------------------------------ | -| AGREE | 0 | 同意。 | -| REJECT | 1 | 拒绝。 | -| MISMATCH | 2 | 不匹配。| diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md deleted file mode 100644 index 9557e0367f59794d2fcb8e8361bcc01cdd6582fe..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md +++ /dev/null @@ -1,31 +0,0 @@ -# AbilityMonitor - -> **说明** -> -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## 导入模块 - -```js -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -``` - - - -## AbilityMonitor - -Ability监听器 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | -| abilityName | string | 是 | 是 | 当前AbilityMonitor绑定的ability名称。 | -| onAbilityCreate | function | 是 | 是 | ability被启动初始化时的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onAbilityForeground | function | 是 | 是 | ability状态变成前台时的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onAbilityBackground | function | 是 | 是 | ability状态变成后台时的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onAbilityDestroy | function | 是 | 是 | ability被销毁前的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onWindowStageCreate | function | 是 | 是 | window stage被创建时的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onWindowStageRestore | function | 是 | 是 | window stage被重载时的回调函数。
不设置该属性则不能收到该生命周期回调。 | -| onWindowStageDestroy | function | 是 | 是 | window stage被销毁前的回调函数。
不设置该属性则不能收到该生命周期回调。 | - diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md deleted file mode 100644 index 286747b62b09e1d401213068a9de04c03c51ce80..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ /dev/null @@ -1,101 +0,0 @@ -# AbilityStage - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -AbilityStage是HAP包的运行时类。在HAP加载的时候,通知开发者,开发者可以在此进行该HAP的初始化(如资源预加载,线程创建等)。 - - -## 导入模块 - - -```js -import AbilityStage from '@ohos.application.AbilityStage'; -``` - -## AbilityStage.onCreate - -onCreate(): void - -当应用创建时调用。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - - - -**示例:** - - ```js - class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage.onCreate is called") - } - } - ``` - - -## AbilityStage.onAcceptWant - -onAcceptWant(want: Want): string; - -启动一个specified ability时触发的事件。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | Want类型参数,传入需要启动的ability的信息,如ability名称,包名等。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | string | 用户返回一个ability标识,如果之前启动过次标识的ability,不创建新的实例并拉回栈顶,否则创建新的实例并启动。 | - -**示例:** - - ```js - class MyAbilityStage extends AbilityStage { - onAcceptWant(want) { - console.log("MyAbilityStage.onAcceptWant called"); - return "com.example.test"; - } - } - ``` - - -## AbilityStage.onConfigurationUpdated - -onConfigurationUpdated(config: Configuration): void; - -环境变化通知接口,发生全局配置变更时回调。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | 是 | 发生全局配置变更时触发回调,当前全局配置包括系统语言、深浅色模式。 | - -**示例:** - - ```js - class MyAbilityStage extends AbilityStage { - onConfigurationUpdated(config) { - console.log('onConfigurationUpdated, language:' + config.language); - } - } - ``` -## AbilityStage.context - -指示有关上下文的配置信息。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -| 属性名 | 类型 | 说明 | -| ----------- | --------------------------- | ------------------------------------------------------------ | -| context | [AbilityStageContext](js-apis-featureAbility.md) | 在启动能力阶段进行初始化时回调。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md deleted file mode 100644 index 4fa6b87cffc617ec1ed7562389fee67aa32bcced..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ /dev/null @@ -1,81 +0,0 @@ -# Context - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 - - -## 使用说明 - - -通过AbilityContext等继承实现。 - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - - | 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 | -| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 | -| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 | -| tempDir | string | 是 | 否 | 应用的临时文件路径。 | -| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 | -| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 | -| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 | -| bundleCodeDir | string | 是 | 否 | 应用安装路径。 | -| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 | -| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。| - - -## Context.createBundleContext - -createBundleContext(bundleName: string): Context; - -创建指定应用上下文。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 应用bundle名。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Context | 对应创建应用的上下文context。 | - -**示例:** - - ```js - let test = "com.example.test"; - let context = this.context.createBundleContext(test); - ``` - - -## Context.getApplicationContext - -getApplicationContext(): Context; - -获取当前context。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Context | 当前Context 信息。 | - -**示例:** - - ```js - // 必选项。 - let context = this.context.getApplicationContext(); - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md deleted file mode 100644 index 0c7017eea3fb3ff13259354ccb2983aa22622a62..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ /dev/null @@ -1,38 +0,0 @@ -# StaticSubscriberExtensionAbility - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## 导入模块 - -``` -import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' -``` - -## StaticSubscriberExtensionAbility.onReceiveEvent - -onReceiveEvent(event: CommonEventData): void; - -静态订阅者通用事件回调。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | CommonEventData | 是 | 静态订阅者通用事件回调。 | - -**示例:** - - ```js - var StaticSubscriberExtensionAbility = requireNapi("application.StaticSubscriberExtensionAbility") - { - onReceiveEvent(event){ - console.log('onReceiveEvent,event:' + event.code); - } - } - export default MyStaticSubscriberExtensionAbility - - ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index da2ba881771d1be9002e9f4e180454aa9b45c9bf..e54f2d0d04bb3e4c5a6d3eea36dc0131fb87478d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -435,17 +435,6 @@ audio.createAudioRenderer(audioCapturerOptions).then((data) => { | INTERRUPT_TYPE_BEGIN | 1 | 音频播放中断事件开始。 | | INTERRUPT_TYPE_END | 2 | 音频播放中断事件结束。 | -## InterruptForceType9+ - -枚举,强制打断类型。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer - -| 名称 | 默认值 | 描述 | -| --------------- | ------ | ------------------------------------ | -| INTERRUPT_FORCE | 0 | 由系统进行操作,强制打断音频播放。 | -| INTERRUPT_SHARE | 1 | 由应用进行操作,可以选择打断或忽略。 | - ## InterruptHint 枚举,中断提示。 @@ -510,18 +499,6 @@ audio.createAudioRenderer(audioCapturerOptions).then((data) => { | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 | | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 | -## InterruptEvent9+ - -播放中断时,应用接收的中断事件。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------------------------------------------ | ---- | ------------------------------------ | -| eventType | [InterruptType](#interrupttype) | 是 | 中断事件类型,开始或是结束。 | -| forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 | -| hintType | [InterruptHint](#interrupthint) | 是 | 中断提示。 | - ## AudioInterrupt 音频监听事件传入的参数。 @@ -2498,51 +2475,6 @@ audioRenderer.getRenderRate().then((renderRate) => { }); ``` -### on('interrupt')9+ - -on(type: 'interrupt', callback: Callback\): void - -监听音频中断事件。使用callback获取中断事件。 - -**系统能力**: SystemCapability.Multimedia.Audio.Renderer - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 事件回调类型,支持的事件为:'interrupt'(中断事件被触发,音频播放被中断。) | -| callback | Callback<[InterruptEvent](#interruptevent9)> | 是 | 被监听的中断事件的回调。 | - -**示例:** - -``` -audioRenderer.on('interrupt', (interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.log('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.log('Resume force paused renderer or ignore'); - startRenderer(); - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.log('Choose to pause or ignore'); - pauseRenderer(); - break; - } - } -}); -``` - ### on('markReach')8+ on(type: 'markReach', frame: number, callback: (position: number) => {}): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 1a3c7a2dc2ebc6b8f571e28484d01b885dfc3a71..806aa7447d361c98c624457fd9336f90f2a66de9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -22,15 +22,15 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | reason | string | 是 | 延迟挂起申请的原因。 | - | callback | Callback<void> | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------ | +| reason | string | 是 | 延迟挂起申请的原因。 | +| callback | Callback<void> | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 | **返回值**: - | 类型 | 说明 | - | -------- | -------- | - | [DelaySuspendInfo](#delaysuspendinfo) | 返回延迟挂起信息。 | +| 类型 | 说明 | +| ------------------------------------- | --------- | +| [DelaySuspendInfo](#delaysuspendinfo) | 返回延迟挂起信息。 | **示例**: ```js @@ -50,10 +50,10 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | requestId | number | 是 | 延迟挂起的请求ID。 | - | callback | AsyncCallback<number> | 是 | 指定的callback回调方法。用于返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------------------------- | ---- | ---------------------------------------- | +| requestId | number | 是 | 延迟挂起的请求ID。 | +| callback | AsyncCallback<number> | 是 | 指定的callback回调方法。用于返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | **示例**: @@ -78,14 +78,14 @@ getRemainingDelayTime(requestId: number): Promise<number> **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | requestId | number | 是 | 延迟挂起的请求ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------- | +| requestId | number | 是 | 延迟挂起的请求ID。 | **返回值**: - | 类型 | 说明 | - | -------- | -------- | - | Promise<number> | 指定的Promise回调方法。返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | +| 类型 | 说明 | +| --------------------- | ---------------------------------------- | +| Promise<number> | 指定的Promise回调方法。返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | **示例**: ```js @@ -107,9 +107,9 @@ cancelSuspendDelay(requestId: number): void **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | requestId | number | 是 | 延迟挂起的请求ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------- | +| requestId | number | 是 | 延迟挂起的请求ID。 | **示例**: ```js @@ -128,12 +128,12 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | -| bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。| -| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知参数,用于指定长时任务通知点击后跳转的界面。 | -| callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---------------------------------- | ---- | ------------------------ | +| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | +| bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知参数,用于指定长时任务通知点击后跳转的界面。 | +| callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | **示例**: ```js @@ -180,16 +180,16 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | -| bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | -| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---------------------------------- | ---- | ----------------------- | +| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | +| bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。 | **返回值** - | 类型 | 说明 | - | -------------- | ------------------------- | - | Promise\ | 使用Promise形式返回结果。 | +| 类型 | 说明 | +| -------------- | ---------------- | +| Promise\ | 使用Promise形式返回结果。 | **示例**: ```js @@ -229,10 +229,10 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------- | ---- | ---------------------- | +| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | +| callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | **示例**: ```js @@ -260,14 +260,14 @@ stopBackgroundRunning(context: Context): Promise<void> **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **参数**: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------- | ---- | --------- | +| context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | **返回值** - | 类型 | 说明 | - | -------------- | ------------------------- | - | Promise\ | 使用Promise形式返回结果。 | +| 类型 | 说明 | +| -------------- | ---------------- | +| Promise\ | 使用Promise形式返回结果。 | **示例**: ```js @@ -288,24 +288,24 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() **系统能力:** 以下各项对应的系统能力均为SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| requestId | number | 是 | 延迟挂起的请求ID。 | -| actualDelayTime | number | 是 | 应用的实际挂起延迟时间,以毫秒为单位。
一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------ | ---- | ---------------------------------------- | +| requestId | number | 是 | 延迟挂起的请求ID。 | +| actualDelayTime | number | 是 | 应用的实际挂起延迟时间,以毫秒为单位。
一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 | ## BackgroundMode8+ **系统能力:** 以下各项对应的系统能力均为SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| 参数名 | 参数值 | 描述 | -| ----------------------- | -------- | -------- | -| DATA_TRANSFER | 1 | 数据传输 | -| AUDIO_PLAYBACK | 2 | 音频播放 | -| AUDIO_RECORDING | 3 | 录音 | -| LOCATION | 4 | 定位导航 | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | -| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | -| VOIP | 8 | 音视频通话(系统保留) | -| TASK_KEEPING | 9 | 计算任务(仅供PC使用) | \ No newline at end of file +| 参数名 | 参数值 | 描述 | +| ----------------------- | ---- | ------------ | +| DATA_TRANSFER | 1 | 数据传输 | +| AUDIO_PLAYBACK | 2 | 音频播放 | +| AUDIO_RECORDING | 3 | 录音 | +| LOCATION | 4 | 定位导航 | +| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | +| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | +| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | +| VOIP | 8 | 音视频通话(系统保留) | +| TASK_KEEPING | 9 | 计算任务 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md index fb607412758baa1198fe07390914fed0fae16d7f..9133a70b86e343e5a90b2b716f341d409ab8ad68 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md @@ -1,7 +1,7 @@ # 性能打点 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 8开始,该接口不再维护,推荐使用新接口[hiTraceMeter](js-apis-hitracemeter.md)。 +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[`@ohos.hiTraceMeter`](js-apis-hitracemeter.md)。 > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index 30fdfb0abfbb4b5c388ea08ad13f1d4e98f3fe4f..87292d1fb7776837bfaeded57c2a7376bd7c2e9c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -314,7 +314,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca | 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | | phoneNumber | string | 是 | 电话号码。 | -| options | EmergencyNumberOptions | 是 | 手机参数,参考[EmergencyNumberOptions](#emergencynumberoptions7)。 | +| options | EmergencyNumberOptions | 是 | 电话号码参数,参考[EmergencyNumberOptions](#emergencynumberoptions7)。 | | callback | AsyncCallback<boolean> | 是 | 回调函数,返回判断是否是紧急电话号码的结果:
- true:是紧急电话号码。
- false:不是紧急电话号码。 | **示例:** @@ -339,7 +339,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): | 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------- | ---- | ------------------------------------------------------------ | | phoneNumber | string | 是 | 电话号码。 | -| options | EmergencyNumberOptions | 是 | 手机参数,参考[EmergencyNumberOptions](#emergencynumberoptions7)。 | +| options | EmergencyNumberOptions | 是 | 电话号码参数,参考[EmergencyNumberOptions](#emergencynumberoptions7)。 | **返回值:** @@ -449,7 +449,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: Asy 将电话号码格式化为E.164表示形式,使用callback方式作为异步方法。 -需要格式化的电话号码需要与传入国家码相匹配,如中国手机号需要传入国家码CN,否则格式化后的手机号为null。 +需要格式化的电话号码需要与传入国家码相匹配,如中国电话号码需要传入国家码CN,否则格式化后的电话号码为null。 支持所有国家码。 @@ -480,7 +480,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## 导入模块 - -``` -import camera from '@ohos.multimedia.camera'; -``` - -## 权限 - -ohos.permission.CAMERA - -## camera.getCameraManager - -getCameraManager(context: Context, callback: AsyncCallback): void - -获取相机管理器实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ---------------------------------- | -| context | Context | 是 | 应用上下文。 | -| callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获取相机管理器实例。 | - -**示例:** - -``` -camera.getCameraManager(context, (err, cameraManager) => { - if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); - return; - } - console.log('Callback returned with the CameraManager instance'); -}); -``` - -## camera.getCameraManager - -getCameraManager(context: Context): Promise - -获取相机管理器实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------- | ------- | ---- | ------------ | -| context | Context | 是 | 应用上下文。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------------- | -| Promise<[CameraManager](#cameramanager)\> | 使用Promise的方式获取一个相机管理器实例。 | - -**示例:** - -``` -camera.getCameraManager(context).then((cameraManger) => { - console.log('Promise returned with the CameraManager instance.'); -}) -``` - -## CameraStatus - -枚举,相机状态。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| ------------------------- | ------ | ------------ | -| CAMERA_STATUS_APPEAR | 0 | 相机存在。 | -| CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。 | -| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。 | -| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。 | - - -## CameraPosition - -枚举,相机方向。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| --------------------------- | ------ | ---------------- | -| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。 | -| CAMERA_POSITION_BACK | 1 | 后置相机。 | -| CAMERA_POSITION_FRONT | 2 | 前置相机。 | - -## CameraType - -枚举,相机类型。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| ----------------------- | ------ | ---------------- | -| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。 | -| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | -| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。 | -| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | -| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。 | - - -## ConnectionType - -枚举,相机连接类型。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| ---------------------------- | ------ | ------------- | -| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。 | -| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。 | - - -## CameraManager - -相机管理器类,使用前需要通过getCameraManager获取相机管理实例。 - -### getCameras - -getCameras(callback: AsyncCallback\>): void - -异步获取设备支持的相机列表,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback\> | 是 | 使用callback方式获取支持的相机列表。 | - -**示例:** - -``` -cameraManager.getCameras((err, cameras) => { - if (err) { - console.error('Failed to get the cameras. ${err.message}'); - return; - } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); -}) -``` - -### getCameras - -getCameras(): Promise\> - -异步获取设备支持的相机列表,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------- | ----------------------------- | -| Promise\> | 使用promise获取支持相机列表。 | - - -**示例:** - -``` -cameraManager.getCameras().then((cameraArray) => { - console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); -}) -``` - -### createCameraInput - -createCameraInput(cameraId: string, callback: AsyncCallback): void - -使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 默认值 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| cameraId | string | 是 | 指定相机ID。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | - -**示例:** - -``` -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance.'); -}) -``` - -### createCameraInput - -createCameraInput(cameraId: string): Promise - -使用相机ID异步创建CameraInput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 默认值 | 必填 | 说明 | -| -------- | ------ | ---- | ------------ | -| cameraId | string | 是 | 指定相机ID。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | - -**示例:** - -``` -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); -}) -``` - -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void - -使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | - -**示例:** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { - if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback returned with the CameraInput instance'); -}) -``` - -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType): Promise - -使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------- | ---- | ---------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | - -**示例:** - -``` -cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); -}) -``` - -### on('cameraStatus') - -on(type: 'cameraStatus', callback: AsyncCallback): void - -监听相机的状态变化,通过注册回调函数获取相机的状态变化。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'cameraStatus',即相机状态变化事件。 | -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取相机状态变化信息。 | - -**示例:** - -``` -cameraManager.on('cameraStatus', (cameraStatusInfo) => { - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); -}) -``` - -## Camera - -调用[camera.getCameraManager](#cameragetcameramanager)后,将返回Camera实例,包括相机ID、位置、类型、连接类型等相机相关的元数据。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 类型 | 只读 | 说明 | -| -------------- | --------------------------------- | ---- | -------------- | -| cameraId | string | 是 | 相机ID。 | -| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | -| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。 | - -**示例:** - -``` -async function getCameraInfo() { - var cameraManager = await camera.getCameraManager(); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var cameraId = cameraObj.connectionType; -} - -``` - -## CameraStatusInfo - -相机管理器回调返回的接口实例,表示相机状态信息。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 类型 | 说明 | -| ------ | ----------------------------- | ---------- | -| camera | [Camera](#camera) | 相机信息。 | -| status | [CameraStatus](#camerastatus) | 相机状态。 | - - -## CameraInput - -相机输入类。在使用该类的方法前,需要先构建一个CameraInput实例。 - -### getCameraId - -getCameraId(callback: AsyncCallback\): void - -异步获取该CameraInput实例的相机ID,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取相机ID。 | - -**示例:** - -``` -cameraInput.getCameraId((err, cameraId) => { - if (err) { - console.error('Failed to get the camera ID. ${err.message}'); - return; - } - console.log('Callback returned with the camera ID: ' + cameraId); -}) -``` - -### getCameraId - -getCameraId(): Promise - -异步获取该CameraInput实例的相机ID,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ---------------- | ----------------------------- | -| Promise | 使用Promise的方式获取相机ID。 | - -**示例:** - -``` -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); -}) -``` - - -### hasFlash - -hasFlash(callback: AsyncCallback): void - -判断设备是否支持闪光灯,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback | 是 | 回调函数,返回true表示设备支持闪光灯。 | - -**示例:** - -``` -cameraInput.hasFlash((err, status) => { - if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); - return; - } - console.log('Callback returned with flash light support status: ' + status); -}) -``` - -### hasFlash - -hasFlash(): Promise - -判断设备是否支持闪光灯,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------- | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | - -**示例:** - -``` -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); -}) -``` - -### isFlashModeSupported - -isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void - -判断设备是否支持指定闪光灯模式,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------------------------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该闪光灯模式。 | - -**示例:** - -``` -cameraInput.isFlashModeSupported(flashMode, (err, status) => { - if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the flash mode support status: ' + status); -}) -``` - -### isFlashModeSupported - -isFlashModeSupported(flashMode: FlashMode): Promise - -判断设备是否支持指定闪光灯模式,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------------ | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | - -**示例:** - -``` -cameraInput.isFlashModeSupported(flashMode).then((status) => { - console.log('Promise returned with flash mode support status.' + status); -}) -``` - -### setFlashMode - -setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void - -设置闪光灯模式,通过注册回调函数获取结果。 - -进行设置之前,需要先检查: - -1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 -2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ------------------------ | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.setFlashMode(flashMode, (err) => { - if (err) { - console.error('Failed to set the flash mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFlashMode.'); -}) -``` - -### setFlashMode - -setFlashMode(flashMode: FlashMode): Promise - -设置闪光灯模式,通过Promise获取结果。 - -进行设置之前,需要先检查: - -1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 -2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -cameraInput.setFlashMode(flashMode).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); -}) -``` - -### getFlashMode - -getFlashMode(callback: AsyncCallback): void - -获取当前设备的闪光灯模式,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 | - -**示例:** - -``` -cameraInput.getFlashMode((err, flashMode) => { - if (err) { - console.error('Failed to get the flash mode ${err.message}'); - return; - } - console.log('Callback returned with current flash mode: ' + flashMode); -}) -``` - -### getFlashMode - -getFlashMode(): Promise - -获取当前设备的闪光灯模式,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| --------------------------------- | --------------------------------------- | -| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 | - -**示例:** - -``` -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); -}) -``` - -### isFocusModeSupported - -isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void - -判断设备是否支持指定的焦距模式,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该焦距模式。 | - -**示例:** - -``` -cameraInput.isFocusModeSupported(afMode, (err, status) => { - if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); - return; - } - console.log('Callback returned with the focus mode support status: ' + status); -}) -``` - -### isFocusModeSupported - -isFocusModeSupported(afMode: FocusMode): Promise - -判断设备是否支持指定的焦距模式,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ----------------------------------------------------------- | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | - -**示例:** - -``` -cameraInput.isFocusModeSupported(afMode).then((status) => { - console.log('Promise returned with focus mode support status.' + status); -}) -``` - -### setFocusMode - -setFocusMode(afMode: FocusMode, callback: AsyncCallback): void - -设置焦距模式,通过注册回调函数获取结果。 - -进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | ------------------------ | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.setFocusMode(afMode, (err) => { - if (err) { - console.error('Failed to set the focus mode ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setFocusMode.'); -}) -``` - -### setFocusMode - -setFocusMode(afMode: FocusMode): Promise - -设置焦距模式,通过Promise获取结果。 - -进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -cameraInput.setFocusMode(afMode).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); -}) -``` - -### getFocusMode - -getFocusMode(callback: AsyncCallback): void - -获取当前设备的焦距模式,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 | - -**示例:** - -``` -cameraInput.getFocusMode((err, afMode) => { - if (err) { - console.error('Failed to get the focus mode ${err.message}'); - return; - } - console.log('Callback returned with current focus mode: ' + afMode); -}) -``` - -### getFocusMode - -getFocusMode(): Promise - -获取当前设备的焦距模式,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------------------- | -| Promise | 使用Promise的方式获取当前的焦距模式。 | - -**示例:** - -``` -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); -}) -``` - -### getZoomRatioRange - -getZoomRatioRange\(callback: AsyncCallback\>\): void - -获取可变焦距比范围,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------ | ---- | ------------------------ | -| callback | AsyncCallback\> | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { - if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); - return; - } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### getZoomRatioRange - -getZoomRatioRange\(\): Promise\> - -获取可变焦距比范围,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ------------------------ | ------------------------------------------- | -| Promise\> | 使用Promise的方式获取当前的可变焦距比范围。 | - -**示例:** - -``` -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` - -### setZoomRatio - -setZoomRatio(zoomRatio: number, callback: AsyncCallback): void - -设置可变焦距比,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | -------------------- | ---- | ------------------------ | -| zoomRatio | number | 是 | 可变焦距比。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.setZoomRatio(zoomRatio, (err) => { - if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); - return; - } - console.log('Callback returned with the successful execution of setZoomRatio.'); -}) -``` - -### setZoomRatio - -setZoomRatio(zoomRatio: number): Promise - -设置可变焦距比,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ------------ | -| zoomRatio | number | 是 | 可变焦距比。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -cameraInput.setZoomRatio(zoomRatio).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); -}) -``` - -### getZoomRatio - -getZoomRatio(callback: AsyncCallback): void - -获取当前的可变焦距比,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.getZoomRatio((err, zoomRatio) => { - if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); - return; - } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); -}) -``` - -### getZoomRatio - -getZoomRatio(): Promise - -获取当前的可变焦距比,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ---------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); -}) -``` - -### release - -release\(callback: AsyncCallback\): void - -释放相机实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -camera.release((err) => { - if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); -``` - -### release - -release(): Promise - -释放相机实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); -}) -``` - -### on('focusStateChange') - -on(type: 'focusStateChange', callback: AsyncCallback): void - -监听焦距的状态变化,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'focusStateChange',即焦距状态变化事件。 | -| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取焦距状态。 | - -**示例:** - -``` -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -监听CameraInput的错误事件,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------------------- | :--- | :---------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即CamerInput错误事件。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); -}) -``` - - -## FlashMode - -枚举,闪光灯模式。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| ---------------------- | ------ | ------------ | -| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 | -| FLASH_MODE_OPEN | 1 | 闪光灯开启。 | -| FLASH_MODE_AUTO | 2 | 自动闪光灯。 | -| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 | - -## FocusMode - -枚举,焦距模式。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| -------------------------- | ------ | ------------------ | -| FOCUS_MODE_MANUAL | 0 | 手动变焦模式。 | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。 | -| FOCUS_MODE_AUTO | 2 | 自动变焦模式。 | -| FOCUS_MODE_LOCKED | 3 | 定焦模式。 | - -## FocusState - -枚举,焦距状态。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| --------------------- | ------ | ------------ | -| FOCUS_STATE_SCAN | 0 | 扫描状态。 | -| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。 | -| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。 | - -## camera.createCaptureSession - -createCaptureSession\(context: Context, callback: AsyncCallback\): void - -获取CaptureSession实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------- | ---- | -------------------------------------- | -| context | Context | 是 | 应用上下文。 | -| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取CaptureSession实例。 | - -**示例:** - -``` -camera.createCaptureSession((context), (err, captureSession) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); -``` - -## camera.createCaptureSession - -createCaptureSession(context: Context\): Promise; - -获取CaptureSession实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------- | ------- | ---- | ------------ | -| context | Context | 是 | 应用上下文。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------------- | ----------------------------------------- | -| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession实例。 | - -**示例:** - -``` -camera.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); -}) -``` - -## CaptureSession - -拍照会话类。 - -### beginConfig - -beginConfig\(callback: AsyncCallback\): void - -开始配置会话,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.beginConfig((err) => { - if (err) { - console.error('Failed to start the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the begin config success.'); -}); -``` - -### beginConfig - -beginConfig\(\): Promise - -开始配置会话,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -captureSession.beginConfig().then(() => { - console.log('Promise returned to indicate the begin config success.'); -}) -``` - -### commitConfig - -commitConfig\(callback: AsyncCallback\): void - -提交会话配置,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.commitConfig((err) => { - if (err) { - console.error('Failed to commit the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the commit config success.'); -}); -``` - -### commitConfig - -commitConfig\(\): Promise - -提交会话配置,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.commitConfig().then(() => { - console.log('Promise returned to indicate the commit config success.'); -}) -``` - -### addInput - -addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void - -在当前会话中,添加一个CameraInput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.addInput(cameraInput, (err) => { - if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); -``` - -### addInput - -addInput\(cameraInput: CameraInput\): Promise - -在当前会话中,添加一个CameraInput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); -}) -``` - -### addOutput - -addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void - -在当前会话中,添加一个PreviewOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.addOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); -}); -``` - -### addOutput - -addOutput\(previewOutput: PreviewOutput\): Promise - -在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); -}) -``` - -### addOutput - -addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void - -在当前会话中,添加一个PhotoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.addOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); -}); -``` - -### addOutput - -addOutput\(photoOutput: PhotoOutput\): Promise - -在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); -}) -``` - -### addOutput - -addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void - -在当前会话中,添加一个VideoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.addOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); -``` - -### addOutput - -addOutput\(videoOutput: VideoOutput\): Promise - -在当前会话中,添加一个VideoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); -}) -``` - -### removeInput - -removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void - -在当前会话中,移除一个CameraInput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.removeInput(cameraInput, (err) => { - if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the cameraInput instance is removed.'); -}); -``` - -### removeInput - -removeInput\(cameraInput: CameraInput\): Promise - -在当前会话中,移除一个CameraInput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.removeInput(cameraInput).then(() => { - console.log('Promise returned to indicate that the cameraInput instance is removed.'); -}) -``` - -### removeOutput - -removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void - -在当前会话中,移除一个PreviewOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.removeOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); -}); -``` - -### removeOutput - -removeOutput(previewOutput: PreviewOutput): Promise - -在当前会话中,移除一个PreviewOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | - - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); -}) -``` - -### removeOutput - -removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void - -在当前会话中,移除一个PhotoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.removeOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); -}); -``` - -### removeOutput - -removeOutput(photoOutput: PhotoOutput): Promise - -在当前会话中,移除一个PhotoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | - - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); -}) -``` - -### removeOutput - -removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void - -在当前会话中,移除一个VideoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.removeOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); -}); -``` - -### removeOutput - -removeOutput(videoOutput: VideoOutput): Promise - -在当前会话中,移除一个VideoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | - - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); -}) -``` - -### start - -start\(callback: AsyncCallback\): void - -启动拍照会话,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.start((err) => { - if (err) { - console.error('Failed to start the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session start success.'); -}); -``` - -### start - -start\(\): Promise - -启动拍照会话,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); -}) -``` - -### stop - -stop\(callback: AsyncCallback\): void - -停止拍照会话,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.stop((err) => { - if (err) { - console.error('Failed to stop the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session stop success.'); -}); -``` - -### stop - -stop(): Promise - -停止拍照会话,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.stop().then(() => { - console.log('Promise returned to indicate the session stop success.'); -}) -``` - -### release - -release\(callback: AsyncCallback\): void - -释放CaptureSession实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -captureSession.release((err) => { - if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); -}); -``` - -### release - -release(): Promise - -释放CaptureSession实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -captureSession.release().then(() => { - console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -监听拍照会话的错误事件,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | - -**示例:** - -``` -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); -}) -``` - -## camera.createPreviewOutput - -createPreviewOutput(surfaceId: string, callback: AsyncCallback): void - -获取PreviewOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------------------------------- | ---- | ------------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | -| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。 | - -**示例:** - -``` -camera.createPreviewOutput((surfaceId), (err, previewOutput) => { - if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with previewOutput instance'); -}); -``` - -## camera.createPreviewOutput - -createPreviewOutput(surfaceId: string): Promise\ - -获取PreviewOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ---------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------------- | --------------------------- | -| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取结果。 | - -**示例:** - -``` -camera.createPreviewOutput(surfaceId).then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); -}) -``` - -## PreviewOutput - -预览输出类。 - -### release - -release(callback: AsyncCallback): void - -释放PreviewOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -previewOutput.release((err) => { - if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); -``` - -### release - -release(): Promise - -释放PreviewOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); -}) -``` - -### on('frameStart') - -on(type: 'frameStart', callback: AsyncCallback): void - -监听预览帧启动,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameStart',即帧启动事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -previewOutput.on('frameStart', () => { - console.log('Preview frame started'); -}) -``` - -### on('frameEnd') - -on(type: 'frameEnd', callback: AsyncCallback): void - -监听预览帧结束,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameEnd',即帧结束事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -previewOutput.on('frameEnd', () => { - console.log('Preview frame ended'); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -监听预览输出的错误事件,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :--------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | - -**示例:** - -``` -previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); -}) -``` - -## camera.createPhotoOutput - -createPhotoOutput(surfaceId: string, callback: AsyncCallback): void - -获取PhotoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | -| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 | - -**示例:** - -``` -camera.createPhotoOutput((surfaceId), (err, photoOutput) => { - if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the PhotoOutput instance.'); -}); -``` - -## camera.createPhotoOutput - -createPhotoOutput(surfaceId: string): Promise - -获取PhotoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput实例。 | - -**示例:** - -``` -camera.createPhotoOutput(surfaceId).then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); -}) -``` -## ImageRotation - -枚举,图片旋转角度。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| ------------ | ------ | --------------- | -| ROTATION_0 | 0 | 图片旋转0度。 | -| ROTATION_90 | 90 | 图片旋转90度。 | -| ROTATION_180 | 180 | 图片旋转180度。 | -| ROTATION_270 | 270 | 图片旋转270度。 | - - - -## QualityLevel - -枚举,图片质量。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 默认值 | 说明 | -| -------------------- | ------ | -------------- | -| QUALITY_LEVEL_HIGH | 0 | 图片质量高。 | -| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。 | -| QUALITY_LEVEL_LOW | 2 | 图片质量差。 | - - -## PhotoCaptureSetting - -拍摄照片的设置。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------- | ---- | -------------- | -| quality | [QualityLevel](#qualitylevel) | 否 | 图片质量。 | -| rotation | [ImageRotation](#imagerotation) | 否 | 图片旋转角度。 | - - -## PhotoOutput - -照片输出类。 - -### capture - -capture(callback: AsyncCallback): void - -拍照,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -photoOutput.capture((err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture - -capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void - -根据拍照设置拍照,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ------------------------ | -| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -photoOutput.capture(settings, (err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` - -### capture - -capture(setting?: PhotoCaptureSetting): Promise - -根据拍照设置拍照,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------- | ------------------------------------------- | ---- | ---------- | -| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); -}) -``` - -### release - -release(callback: AsyncCallback): void - -释放PhotoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -photoOutput.release((err) => { - if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); -``` - -### release - -release(): Promise - -释放PhotoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); -}) -``` - -### on('captureStart') - -on(type: 'captureStart', callback: AsyncCallback): void - -监听拍照启动,通过注册回调函数获取Capture ID。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :--------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监听事件,固定为'captureStart',即拍照启动事件。 | -| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | - -**示例:** - -``` -photoOutput.on('captureStart', (captureId) => { - console.log('photo capture stated, captureId : ' + captureId); -}) -``` - -### on('frameShutter') - -on(type: 'frameShutter', callback: AsyncCallback): void - -监听帧刷新,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | - -**示例:** - -``` -photoOutput.on('frameShutter', (frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); -}) -``` - -### on('captureEnd') - -on(type: 'captureEnd', callback: AsyncCallback): void - -监听拍照停止,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :----------------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | - -**示例:** - -``` -photoOutput.on('captureEnd', (captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -监听拍照的错误事件,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------------------- | :--- | :---------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | - -**示例:** - -``` -photoOutput.on('error', (photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); -}) -``` - -## camera.createVideoOutput - -createVideoOutput(surfaceId: string, callback: AsyncCallback): void - -获取VideoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | -| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获取VideoOutput实例。 | - -**示例:** - -``` -camera.createVideoOutput((surfaceId), (err, videoOutput) => { - if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the VideoOutput instance'); -}); -``` - -## camera.createVideoOutput - -createVideoOutput(surfaceId: string): Promise - -获取VideoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[VideoOutput](#videooutput)\> | 使用Promise的方式获取VideoOutput实例。 | - -**示例:** - -``` -camera.createVideoOutput(surfaceId).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); -}) -``` - -## VideoOutput - -视频输出类。 - -### start - -start(callback: AsyncCallback): void - -开始拍摄视频,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -videoOutput.start((err) => { - if (err) { - console.error('Failed to start the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output start success.'); -}); -``` - -### start - -start(): Promise - -开始拍摄视频,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); -}) -``` - -### stop - -stop(callback: AsyncCallback): void - -停止拍摄视频,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -videoOutput.stop((err) => { - if (err) { - console.error('Failed to stop the video output ${err.message}'); - return; - } - console.log('Callback invoked to indicate the video output stop success.'); -}); -``` - -### stop - -stop(): Promise - -停止拍摄视频,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - -**示例:** - -``` -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); -}) -``` - -### release - -release(callback: AsyncCallback): void - -释放VideoOutput实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -videoOutput.release((err) => { - if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); -``` - -### release - -release(): Promise - -释放VideoOutput实例,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - - -**示例:** - -``` -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); -}) -``` - -### on('frameStart') - -on(type: 'frameStart', callback: AsyncCallback): void - -监听视频帧开启,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameStart',即视频帧开启事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -videoOutput.on('frameStart', () => { - console.log('Video frame started'); -}) -``` - -### on('frameEnd') - -on(type: 'frameEnd', callback: AsyncCallback): void - -监听视频帧结束,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameEnd',即视频帧结束事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | - -**示例:** - -``` -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -监听视频输出的错误事件,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| :------- | :-------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 | -| callback | Callback | 是 | 回调函数,用于获取错误信息。 | - -**示例:** - -``` -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); -}) -``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index f5b10f70be03b535e00f2100b8069efc00e7d79b..0888b9f9a0339168512f0958abd4c46f5e07290d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -537,7 +537,7 @@ getCode(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取有序公共事件的结果代码回调 function getCodeCallback(err, Code) { if (err.code) { console.error("getCode failed " + JSON.stringify(err)); @@ -594,7 +594,7 @@ setCode(code: number, callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//设置有序公共事件的结果代码回调 function setCodeCallback(err) { if (err.code) { console.error("setCode failed " + JSON.stringify(err)); @@ -656,7 +656,7 @@ getData(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取有序公共事件的结果数据回调 function getDataCallback(err, Data) { if (err.code) { console.error("getData failed " + JSON.stringify(err)); @@ -777,7 +777,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//设置有序公共事件的结果代码和结果数据回调 function setCodeDataCallback(err) { if (err.code) { console.error("setCodeAndData failed " + JSON.stringify(err)); @@ -842,7 +842,7 @@ isOrderedCommonEvent(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取当前公共事件是否为有序事件的回调 function isOrderedCallback(err, isOrdered) { if (err.code) { console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); @@ -902,7 +902,7 @@ isStickyCommonEvent(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取当前公共事件是否为粘性事件的回调 function isStickyCallback(err, isSticky) { if (err.code) { console.error("isStickyCommonEvent failed " + JSON.stringify(err)); @@ -917,7 +917,7 @@ subscriber.isStickyCommonEvent(isStickyCallback); isStickyCommonEvent(): Promise\ -检查当前公共事件是否为一个粘性事件(callback形式)。 +检查当前公共事件是否为一个粘性事件(Promise形式)。 返回true代表是粘性公共事件,false代表不是粘性公共事件。 @@ -960,7 +960,7 @@ abortCommonEvent(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//取消当前有序公共事件的回调 function abortCallback(err) { if (err.code) { console.error("abortCommonEvent failed " + JSON.stringify(err)); @@ -1016,7 +1016,7 @@ clearAbortCommonEvent(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//清除当前公共事件取消状态的回调 function clearAbortCallback(err) { if (err.code) { console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); @@ -1072,7 +1072,7 @@ getAbortCommonEvent(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取当前有序公共事件是否取消的回调 function getAbortCallback(err, AbortCommonEvent) { if (err.code) { console.error("getAbortCommonEvent failed " + JSON.stringify(err)); @@ -1128,7 +1128,7 @@ getSubscribeInfo(callback: AsyncCallback\): void ```js var subscriber; //创建成功的订阅者对象 -//设置有序公共事件的结果数据回调 +//获取订阅者信息回调 function getSubscribeInfoCallback(err, SubscribeInfo) { if (err.code) { console.error("getSubscribeInfo failed " + JSON.stringify(err)); @@ -1165,57 +1165,6 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => { }); ``` -### finishCommonEvent - -finishCommonEvent(callback: AsyncCallback\): void - -结束当前已排序的公共事件(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 表示排序的公共事件结束后的回调函数。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -function finishCommonEventCallback() { - console.log("--------- finishCommonEventCallback ----------"); -} - -subscriber.finishCommonEvent(finishCommonEventCallback); -``` - -### finishCommonEvent - -finishCommonEvent(): Promise\ - -结束当前已排序的公共事件(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ---------------- | -------------------- | -| Promise\ | 返回一个Promise的结果。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.finishCommonEvent() - .then(() => { - console.info("--------- finishCommonEventCallback ----------"); - }) -``` - ## CommonEventData **系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md index 8bd6606682050634708fe3c820a85dd2190766f9..d58bd4d28df434a77775d14bf5acaccc82a442e8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -63,6 +63,7 @@ genSessionId(): string ## DistributedObject 表示一个分布式对象。 + ### setSessionId setSessionId(sessionId?: string): boolean @@ -72,16 +73,19 @@ setSessionId(sessionId?: string): boolean **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | sessionId | string | 否 | 分布式对象在可信组网中的标识ID。如果要退出分布式组网,设置为""或不设置均可。 | **返回值:** + | 类型 | 说明 | | -------- | -------- | | boolean | true:标识设置sessionId成功;
false:标识设置sessionId失败。 | **示例:** + ```js import distributedObject from '@ohos.data.distributedDataObject' var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md deleted file mode 100644 index 84d4426f00f65412b4c8d53cf282eb7fd07239e7..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ /dev/null @@ -1,623 +0,0 @@ -# 轻量级存储 - -轻量级存储为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## 导入模块 - -``` -import data_Preferences from '@ohos.data.preferences' -``` - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。 | -| MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。 | - - -## data_Preferences.getPreferences - -getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void - -读取指定文件,将数据加载到Preferences实例,用于数据操作,使用callback形式返回结果。 - - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - | callback | AsyncCallback<[Preferences](#preferences)> | 是 | 回调函数。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - var path = this.context.getDataBaseDir() - data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, path: " + path + '/mystore') - return; - } - preferences.putSync('startup', 'auto') - preferences.flushSync() - }) - ``` - - -## data_Preferences.getPreferences - -getPreferences(context: Context, name: string): Promise<Preferences> - -读取指定文件,将数据加载到Preferences实例,用于数据操作,使用Promise方式作为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[Preferences](#preferences)> | Promise实例,用于异步获取结果。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - var path = this.context.getDataBaseDir() - let promisePre = data_Preferences.getPreferences(this.context, 'mystore') - promisePre.then((preferences) => { - preferences.putSync('startup', 'auto') - preferences.flushSync() - }).catch((err) => { - console.info("Get the preferences failed, path: " + path + '/mystore') - }) - ``` - - -## data_Preferences.deletePreferences - -deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void - -从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - data_Preferences.deletePreferences(this.context, 'mystore', function (err) { - if (err) { - console.info("Deleted failed with err: " + err) - return - } - console.info("Deleted successfully.") - }) - ``` - - -## data_Preferences.deletePreferences - -deletePreferences(context: Context, name: string): Promise<void> - -从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步获取结果。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - let promisedelPre = data_Preferences.deletePreferences(this.context, 'mystore') - promisedelPre.then(() => { - console.info("Deleted successfully.") - }).catch((err) => { - console.info("Deleted failed with err: " + err) - }) - ``` - - -## data_Preferences.removePreferencesFromCache - -removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<void>): void - -从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - data_Preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { - if (err) { - console.info("Removed preferences from cache failed with err: " + err) - return - } - console.info("Removed preferences from cache successfully.") - }) - ``` - - -## data_Preferences.removePreferencesFromCache - -removePreferencesFromCache(context: Context, name: string): Promise<void> - -从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context | Context | 是 | 应用程序或功能的上下文 | - | name | string | 是 | 应用程序内部数据存储名称。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步获取结果。 | - -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_Preferences from '@ohos.data.preferences' - let promiserevPre = data_Preferences.removePreferencesFromCache(this.context, 'mystore') - promiserevPre.then(() => { - console.info("Removed preferences from cache successfully.") - }).catch((err) => { - console.info("Removed preferences from cache failed with err: " + err) - }) - ``` - - -## Preferences - -提供获取和修改存储数据的接口。 - - -### get - -get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void - -获取键对应的值,如果值为null或者非默认值类型,返回默认数据。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称。它不能为空。 | - | defValue | ValueType | 是 | 默认返回值。支持number、string、boolean。 | - | callback | AsyncCallback<ValueType> | 是 | 回调函数。 | - -- 示例: - ``` - preferences.get('startup', 'default', function(err, value) { - if (err) { - console.info("Get the value of startup failed with err: " + err) - return - } - console.info("The value of startup is " + value) - }) - ``` - - -### get - -get(key: string, defValue: ValueType): Promise<ValueType> - -获取键对应的值,如果值为null或者非默认值类型,返默认数据。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称。它不能为空。 | - | defValue | ValueType | 是 | 默认返回值。支持number、string、boolean。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<ValueType> | Promise实例,用于异步获取结果。 | - -- 示例: - ``` - let promiseget = preferences.get('startup', 'default') - promiseget.then((value) => { - console.info("The value of startup is " + value) - }).catch((err) => { - console.info("Get the value of startup failed with err: " + err) - }) - ``` - - -### put - -put(key: string, value: ValueType, callback: AsyncCallback<void>): void - -首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要修改的存储的key。它不能为空。 | - | value | ValueType | 是 | 存储的新值。支持number、string、boolean。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed with err: " + err) - return - } - console.info("Put the value of startup successfully.") - }) - ``` - - -### put - -put(key: string, value: ValueType): Promise<void> - -首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要修改的存储的key。它不能为空。 | - | value | ValueType | 是 | 存储的新值。支持number、string、boolean。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步处理。 | - -- 示例: - ``` - let promiseput = preferences.put('startup', 'auto') - promiseput.then(() => { - console.info("Put the value of startup successfully.") - }).catch((err) => { - console.info("Put the value of startup failed with err: " + err) - }) - ``` - - -### has - -has(key: string, callback: AsyncCallback<boolean>): boolean - -检查存储对象是否包含名为给定key的存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称,不能为空。 | - | callback | AsyncCallback<boolean> | 是 | 回调函数。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | true表示存在,false表示不存在。 | - -- 示例: - ``` - preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Check the key of startup failed with err: " + err) - return - } - if (isExist) { - console.info("The key of startup is contained.") - } - }) - ``` - - -### has - -has(key: string): Promise<boolean> - -检查存储对象是否包含名为给定key的存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称。它不能为空。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<boolean> | Promise实例,用于异步处理。 | - -- 示例: - ``` - let promisehas = preferences.has('startup') - promisehas.then((isExist) => { - if (isExist) { - console.info("The key of startup is contained.") - } - }).catch((err) => { - console.info("Check the key of startup failed with err: " + err) - }) - ``` - - -### delete - -delete(key: string, callback: AsyncCallback<void>): void - -从存储对象中删除名为给定key的存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称,不能为空。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - preferences.delete('startup', function (err) { - if (err) { - console.info("Delete startup key failed with err: " + err) - return - } - console.info("Deleted startup key successfully.") - }) - ``` - - -### delete - -delete(key: string): Promise<void> - -从存储对象删除名为给定key的存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | key | string | 是 | 要获取的存储key名称。 | - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步处理。 | - -- 示例: - ``` - let promisedel = preferences.delete('startup') - promisedel.then(() => { - console.info("Deleted startup key successfully.") - }).catch((err) => { - console.info("Delete startup key failed with err: " + err) - }) - ``` - - -### flush - -flush(callback: AsyncCallback<void>): void - -将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed with err: " + err) - return - } - console.info("Flushed to file successfully.") - }) - ``` - - -### flush - -flush(): Promise<void> - -将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步处理。 | - -- 示例: - ``` - let promiseflush = preferences.flush() - promiseflush.then(() => { - console.info("Flushed to file successfully.") - }).catch((err) => { - console.info("Flush to file failed with err: " + err) - }) - ``` - - -### clear - -clear(callback: AsyncCallback<void>): void - -清除此存储对象中的所有存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例: - ``` - preferences.clear(function (err) { - if (err) { - console.info("Clear to file failed with err: " + err) - return - } - console.info("Cleared to file successfully.") - }) - ``` - - -### clear - -clear(): Promise<void> - -清除此存储对象中的所有存储。 - -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | Promise实例,用于异步处理。 | - -- 示例: - ``` - let promiseclear = preferences.clear() - promiseclear.then(() => { - console.info("Cleared to file successfully.") - }).catch((err) => { - console.info("Clear to file failed with err: " + err) - }) - ``` - - -### on('change') - -on(type: 'change', callback: Callback<{ key : string }>): void - -订阅数据变更者类,订阅的key的值发生变更后,在执行flush方法后,callback方法会被回调。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | type | string | 事件类型,固定值'change',表示数据变更。 | - | callback | Callback<{ key : string }> | 回调对象实例。 | - -- 示例: - ``` - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - preferences.on('change', observer) - preferences.put('startup', 'auto') - preferences.flush() // observer will be called. - ``` - - -### off('change') - -off(type: 'change', callback: Callback<{ key : string }>): void - -当不再进行订阅数据变更时,使用此接口取消订阅。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core - -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | type | string | 事件类型,固定值'change',表示数据变更。 | - | callback | Callback<{ key : string }> | 需要取消的回调对象实例。 | - -- 示例: - ``` - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - preferences.off('change', observer) - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index 7cc705e0c15b771d3ac84b1ada795c843335f704..88689d5ef7d51af66b46b47c69346d548688103a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -40,21 +40,6 @@ data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { }) ``` -API9的示例请参考如下代码: - -``` -import Ability from '@ohos.application.Ability' -import data_rdb from '@ohos.data.rdb' -export default class MainAbility extends Ability { - const STORE_CONFIG = { name: "RdbTest.db"} - const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" - data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) - console.info('create table done.') - }) -} -``` - ## data_rdb.getRdbStore getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> @@ -96,28 +81,6 @@ promisegetRdb.then(async (rdbStore) => { }) ``` -API9的示例请参考如下代码: - -``` -import Ability from '@ohos.application.Ability' -import data_rdb from '@ohos.data.rdb' -export default class MainAbility extends Ability { - const STORE_CONFIG = { name: "RdbTest.db" } - const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" - let promisegetRdb = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); - promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) - }).catch((err) => { - console.log("getRdbStore err.") - }) -} -``` - ## data_rdb.deleteRdbStore deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void @@ -141,18 +104,6 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void&g }) ``` -API9的示例请参考如下代码: - -``` -import Ability from '@ohos.application.Ability' -import data_rdb from '@ohos.data.rdb' -export default class MainAbility extends Ability { - data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) -} -``` - ## data_rdb.deleteRdbStore deleteRdbStore(context: Context, name: string): Promise<void> @@ -183,21 +134,6 @@ deleteRdbStore(context: Context, name: string): Promise<void> }) ``` -API9的示例请参考如下代码: - -``` -import Ability from '@ohos.application.Ability' -import data_rdb from '@ohos.data.rdb' -export default class MainAbility extends Ability { - let promisedeleteRdb = data_rdb.deleteRdbStore(this.context, "RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) -} -``` - ## RdbPredicates 表示关系型数据库(RDB)的谓词。该类确定RDB中条件表达式的值是true还是false。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index f39822ce4d2108c30849bfe2047780541b293aef..cc576515fd14e25d148657ecab0e38d01b36f659 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -4,7 +4,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
从API Version 9开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md) +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -45,7 +45,7 @@ getStorageSync(path: string): Storage ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() context.getFilesDir((err, path) => { if (err) { @@ -78,7 +78,7 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() context.getFilesDir((err, path) => { if (err) { @@ -120,7 +120,7 @@ getStorage(path: string): Promise<Storage> ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() context.getFilesDir((err, path) => { if (err) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index a0d79407b301532f666c2f96d1821721b169778d..857ccaca928b03edc6ef727a0e0febc858921baa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -38,7 +38,7 @@ import display from '@ohos.display'; | id | number | 是 | 否 | 显示设备的id号。| | name | string | 是 | 否 | 显示设备的名称。| | alive | boolean | 是 | 否 | 显示设备是否启用。| -| state | [DisplayState](#DisplayState) | 是 | 否 | 显示设备的状态。| +| state | [DisplayState](#displaystate) | 是 | 否 | 显示设备的状态。| | refreshRate | number | 是 | 否 | 显示设备的刷新率。| | rotation | number | 是 | 否 | 显示设备的屏幕旋转角度。| | width | number | 是 | 否 | 显示设备的宽度,单位为像素。| @@ -61,7 +61,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void - 参数 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Display](#Display)> | 是 | 回调返回当前默认的display对象。 | + | callback | AsyncCallback<[Display](#display)> | 是 | 回调返回当前默认的display对象。 | - 示例 ``` @@ -88,7 +88,7 @@ getDefaultDisplay(): Promise<Display> | 类型 | 说明 | | ---------------------------------- | ---------------------------------------------- | - | Promise<[Display](#Display)> | 以Promise形式返回结果,返回默认的display对象。 | + | Promise<[Display](#display)> | 以Promise形式返回结果,返回默认的display对象。 | - 示例 @@ -113,7 +113,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | ------------------------------- | - | callback | AsyncCallback<Array<[Display](Display)>> | 是 | 回调返回当前所有的display对象。 | + | callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调返回当前所有的display对象。 | - 示例 diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index 37c7ab69629d4e71c9034415023dfbd4472fe1b1..bb08288d6aa9cf405c61b34aa13c9bbd02501421 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -27,27 +27,28 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> | callback | AsyncCallback<[KVManager](#kvmanager)> | 是 | KVManager实例创建时调用的回调,返回KVManager对象实例。 | **示例**: - - let kvManager; - try { - const kvManagerConfig = { - bundleName : 'com.example.datamanagertest', - userInfo : { - userId : '0', - userType : distributedData.UserType.SAME_USER_ID - } +``` +let kvManager; +try { + const kvManagerConfig = { + bundleName : 'com.example.datamanagertest', + userInfo : { + userId : '0', + userType : distributedData.UserType.SAME_USER_ID } - distributedData.createKVManager(kvManagerConfig, function (err, manager) { - if (err) { - console.log("createKVManager err: " + JSON.stringify(err)); - return; - } - console.log("createKVManager success"); - kvManager = manager; - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("createKVManager err: " + JSON.stringify(err)); + return; + } + console.log("createKVManager success"); + kvManager = manager; + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ## distributedData.createKVManager @@ -71,25 +72,26 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> **示例**: - let kvManager; - try { - const kvManagerConfig = { - bundleName : 'com.example.datamanagertest', - userInfo : { - userId : '0', - userType : distributedData.UserType.SAME_USER_ID - } +``` +let kvManager; +try { + const kvManagerConfig = { + bundleName : 'com.example.datamanagertest', + userInfo : { + userId : '0', + userType : distributedData.UserType.SAME_USER_ID } - distributedData.createKVManager(kvManagerConfig).then((manager) => { - console.log("createKVManager success"); - kvManager = manager; - }).catch((err) => { - console.log("createKVManager err: " + JSON.stringify(err)); - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); } - + distributedData.createKVManager(kvManagerConfig).then((manager) => { + console.log("createKVManager success"); + kvManager = manager; + }).catch((err) => { + console.log("createKVManager err: " + JSON.stringify(err)); + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ## KVManagerConfig @@ -102,8 +104,6 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> | userInfo | [UserInfo](#userinfo) | 是 | 调用方的用户信息。 | | bundleName | string | 是 | 调用方的包名。 | - - ## UserInfo 用户信息。 @@ -131,8 +131,6 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> 数据管理实例,用于获取KVStore的相关信息。在调用KVManager的方法前,需要先通过createKVManager构建一个KVManager实例。 - - ### getKVStore getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void @@ -151,30 +149,30 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: **示例**: - ``` - let kvStore; - let kvManager; - try { - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - securityLevel : distributedData.SecurityLevel.S2, - }; - kvManager.getKVStore('storeId', options, function (err, store) { - if (err) { - console.log("getKVStore err: " + JSON.stringify(err)); - return; - } - console.log("getKVStore success"); - kvStore = store; - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` +``` +let kvStore; +let kvManager; +try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options, function (err, store) { + if (err) { + console.log("getKVStore err: " + JSON.stringify(err)); + return; + } + console.log("getKVStore success"); + kvStore = store; + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### getKVStore @@ -199,31 +197,30 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& | -------------------------------------- | ------------------------ | | Promise<T> <T extends KVStore> | 指定的Promise回调方法,返回创建的KVStore数据库实例。 | - **示例**: - ``` - let kvStore; - let kvManager; - try { - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - securityLevel : distributedData.SecurityLevel.S2, - }; - kvManager.getKVStore('storeId', options).then((store) => { - console.log("getKVStore success"); - kvStore = store; - }).catch((err) => { - console.log("getKVStore err: " + JSON.stringify(err)); - }); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` +``` +let kvStore; +let kvManager; +try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options).then((store) => { + console.log("getKVStore success"); + kvStore = store; + }).catch((err) => { + console.log("getKVStore err: " + JSON.stringify(err)); + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### closeKVStore8+ ### @@ -243,33 +240,33 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa | kvStore | [KVStore](#kvstore) | 是 | 要关闭的KvStore数据库。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果数据库关闭成功则返回true,否则返回false。 | - **示例**: - ``` - let kvStore; - let kvManager; - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { - kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('getKVStore success'); - kvStore = store; - await kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { - console.log('closeKVStore success'); - }); - }); - } catch (e) { - console.log('closeKVStore e ' + e); - } - ``` +``` +let kvStore; +let kvManager; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } + try { + kvManager.getKVStore('storeId', options, async function (err, store) { + console.log('getKVStore success'); + kvStore = store; + await kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { + console.log('closeKVStore success'); + }); + }); +} catch (e) { + console.log('closeKVStore e ' + e); +} +``` + ### closeKVStore8+ ### @@ -295,34 +292,34 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& **示例**: - ``` - let kvManager; - let kvStore; - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { - kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('getKVStore success'); - kvStore = store; - await kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { - console.log('closeKVStore success'); - }).catch((err) => { - console.log('closeKVStore err ' + JSON.stringify(err)); - }); - }).catch((err) => { - console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); - }); - } catch (e) { - console.log('closeKVStore e ' + e); - } - ``` +``` +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} + try { + kvManager.getKVStore('storeId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + await kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { + console.log('closeKVStore success'); + }).catch((err) => { + console.log('closeKVStore err ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('closeKVStore e ' + e); +} +``` ### deleteKVStore8+ ### @@ -341,33 +338,32 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果成功返回true,否则返回false。 | - **示例**: - ``` - let kvManager; - let kvStore; - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { - kvManager.getKVStore('store', options, async function (err, store) { - console.log('getKVStore success'); - kvStore = store; - await kvManager.deleteKVStore('appId', 'storeId', function (err, data) { - console.log('deleteKVStore success'); - }); +``` +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} +try { + kvManager.getKVStore('store', options, async function (err, store) { + console.log('getKVStore success'); + kvStore = store; + await kvManager.deleteKVStore('appId', 'storeId', function (err, data) { + console.log('deleteKVStore success'); }); - } catch (e) { - console.log('DeleteKVStore e ' + e); - } - ``` + }); +} catch (e) { + console.log('DeleteKVStore e ' + e); +} +``` ### deleteKVStore8+ ### @@ -393,34 +389,34 @@ deleteKVStore(appId: string, storeId: string): Promise<void> **示例**: - ``` - let kvManager; - let kvStore; - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', - securityLevel : distributedData.SecurityLevel.S2, - } - try { - kvManager.getKVStore('storId', options).then(async (store) => { - console.log('getKVStore success'); - kvStore = store; - await kvManager.deleteKVStore('appId', 'storeId').then(() => { - console.log('deleteKVStore success'); - }).catch((err) => { - console.log('deleteKVStore err ' + JSON.stringify(err)); - }); +``` +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} +try { + kvManager.getKVStore('storId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + await kvManager.deleteKVStore('appId', 'storeId').then(() => { + console.log('deleteKVStore success'); }).catch((err) => { - console.log('getKVStore err ' + JSON.stringify(err)); + console.log('deleteKVStore err ' + JSON.stringify(err)); }); - } catch (e) { - console.log('deleteKVStore e ' + e); - } - ``` + }).catch((err) => { + console.log('getKVStore err ' + JSON.stringify(err)); + }); +} catch (e) { + console.log('deleteKVStore e ' + e); +} +``` ### getAllKVStoreId8+ ### @@ -440,17 +436,17 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void **示例**: - ``` - let kvManager; - try { - kvManager.getAllKVStoreId('appId', function (err, data) { - console.log('GetAllKVStoreId success'); - console.log('GetAllKVStoreId size = ' + data.length); - }); - } catch (e) { - console.log('GetAllKVStoreId e ' + e); - } - ``` +``` +let kvManager; +try { + kvManager.getAllKVStoreId('appId', function (err, data) { + console.log('GetAllKVStoreId success'); + console.log('GetAllKVStoreId size = ' + data.length); + }); +} catch (e) { + console.log('GetAllKVStoreId e ' + e); +} +``` ### getAllKVStoreId8+ ### @@ -476,20 +472,20 @@ getAllKVStoreId(appId: string): Promise<string[]> **示例**: - ``` - let kvManager; - try { - console.log('GetAllKVStoreId'); - kvManager.getAllKVStoreId('apppId').then((data) => { - console.log('getAllKVStoreId success'); - console.log('size = ' + data.length); - }).catch((err) => { - console.log('getAllKVStoreId err ' + JSON.stringify(err)); - }); - } catch(e) { - console.log('getAllKVStoreId e ' + e); - } - ``` +``` +let kvManager; +try { + console.log('GetAllKVStoreId'); + kvManager.getAllKVStoreId('apppId').then((data) => { + console.log('getAllKVStoreId success'); + console.log('size = ' + data.length); + }).catch((err) => { + console.log('getAllKVStoreId err ' + JSON.stringify(err)); + }); +} catch(e) { + console.log('getAllKVStoreId e ' + e); +} +``` ### on8+ ### @@ -507,23 +503,21 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi | event | 'distributedDataServiceDie' | 是 | 服务状态改变时触发的事件名。 | | deathCallback | Callback<void> | 是 | 回调函数,在设备状态改变时获取通知。 | - - **示例** - ``` - let kvManager; - try { - - console.log('KVManagerOn'); - const deathCallback = function () { - console.log('death callback call'); - } - kvManager.on('distributedDataServiceDie', deathCallback); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); +``` +let kvManager; +try { + + console.log('KVManagerOn'); + const deathCallback = function () { + console.log('death callback call'); } - ``` + kvManager.on('distributedDataServiceDie', deathCallback); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### off8+ ### @@ -544,19 +538,19 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v **示例** - ``` - let kvManager; - try { - console.log('KVManagerOff'); - const deathCallback = function () { - console.log('death callback call'); - } - kvManager.off('distributedDataServiceDie', deathCallback); - } catch (e) { - console.log("An unexpected error occurred. Error:" + e); +``` +let kvManager; +try { + console.log('KVManagerOff'); + const deathCallback = function () { + console.log('death callback call'); } + kvManager.off('distributedDataServiceDie', deathCallback); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} - ``` +``` ## Options @@ -569,7 +563,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v | createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认创建。 | | encrypt | boolean | 否 |设置数据库文件是否加密,默认不加密。 | | backup | boolean | 否 |设置数据库文件是否备份,默认备份。 | -| autoSync | boolean | 否 |设置数据库文件是否自动同步,默认不自动同步。 | +| autoSync | boolean | 否 |设置数据库文件是否自动同步,默认不自动同步。**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 | | kvStoreType | [KVStoreType](#kvstoretype) | 否 |设置要创建的数据库类型,默认为多设备协同数据库。 | | securityLevel | [SecurityLevel](#securitylevel) | 否 |设置数据库安全级别,默认不设置安全级别。 | | schema8+ | [Schema](#schema8) | 否 | 设置定义存储在数据库中的值。 | @@ -588,7 +582,6 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v | MULTI_VERSION | 2 | 表示多版本数据库。此类型当前不允许使用。 | - ## SecurityLevel 用于指定创建的数据库的安全级别。 @@ -629,7 +622,7 @@ KVStore常量。 | 名称 | 类型 | 说明 | | --- | ---- | ----------------------- | | root8+ | [FieldNode](#fieldnode8) | 表示json根对象 | -| indexes8+ | Array | 表示json类型的字符串数组。 | +| indexes8+ | Array\ | 表示json类型的字符串数组。 | | mode8+ | number | 表示Schema的模式。 | | skip8+ | number | Schema的跳跃大小。 | @@ -690,27 +683,25 @@ appendChild(child: FieldNode): boolean **示例** - ``` - import ddm from '@ohos.data.distributedData'; - try { - let node = new ddm.FieldNode("root"); - let child1 = new ddm.FieldNode("child1"); - let child2 = new ddm.FieldNode("child2"); - let child3 = new ddm.FieldNode("child3"); - node.appendChild(child1); - node.appendChild(child2); - node.appendChild(child3); - console.log("appendNode " + node.toJson()); - child1 = null; - child2 = null; - child3 = null; - node = null; - } catch (e) { - console.log("AppendChild " + e); - } - ``` - - +``` +import ddm from '@ohos.data.distributedData'; +try { + let node = new ddm.FieldNode("root"); + let child1 = new ddm.FieldNode("child1"); + let child2 = new ddm.FieldNode("child2"); + let child3 = new ddm.FieldNode("child3"); + node.appendChild(child1); + node.appendChild(child2); + node.appendChild(child3); + console.log("appendNode " + node.toJson()); + child1 = null; + child2 = null; + child3 = null; + node = null; +} catch (e) { + console.log("AppendChild " + e); +} +``` ## KvStoreResultSet8+ ## @@ -734,23 +725,22 @@ getCount(): number **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const count = resultSet.getCount(); - console.log("GetCount " + count); - } catch (e) { - console.log("GetCount fail " + e); - } - ``` - +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const count = resultSet.getCount(); + console.log("GetCount " + count); +} catch (e) { + console.log("GetCount fail " + e); +} +``` ### getPosition8+ ### @@ -768,22 +758,22 @@ getPosition(): number **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const position = resultSet.getPosition(); - console.log("getPosition " + position); - } catch (e) { - console.log("GetPosition fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const position = resultSet.getPosition(); + console.log("getPosition " + position); +} catch (e) { + console.log("GetPosition fail " + e); +} +``` ### moveToFirst8+ ### @@ -802,22 +792,22 @@ moveToFirst(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToFirst(); - console.log("moveToFirst " + moved); - } catch (e) { - console.log("MoveToFirst fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToFirst(); + console.log("moveToFirst " + moved); +} catch (e) { + console.log("MoveToFirst fail " + e); +} +``` ### moveToLast8+ ### @@ -836,22 +826,22 @@ moveToLast(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToLast(); - console.log("moveToLast " + moved); - } catch (e) { - console.log("moveToLast fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToLast(); + console.log("moveToLast " + moved); +} catch (e) { + console.log("moveToLast fail " + e); +} +``` ### moveToNext8+ ### @@ -870,22 +860,22 @@ moveToNext(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToNext(); - console.log("moveToNext " + moved); - } catch (e) { - console.log("moveToNext fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToNext(); + console.log("moveToNext " + moved); +} catch (e) { + console.log("moveToNext fail " + e); +} +``` ### moveToPrevious8+ ### @@ -904,22 +894,22 @@ moveToPrevious(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToPrevious(); - console.log("moveToPrevious " + moved); - } catch (e) { - console.log("moveToPrevious fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToPrevious(); + console.log("moveToPrevious " + moved); +} catch (e) { + console.log("moveToPrevious fail " + e); +} +``` ### move8+ ### @@ -944,22 +934,22 @@ move(offset: number): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.move(); - console.log("move " + moved); - } catch (e) { - console.log("move fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.move(); + console.log("move " + moved); +} catch (e) { + console.log("move fail " + e); +} +``` ### moveToPosition8+ ### @@ -984,22 +974,22 @@ moveToPosition(position: number): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToPosition(); - console.log("moveToPosition " + moved); - } catch (e) { - console.log("moveToPosition fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToPosition(); + console.log("moveToPosition " + moved); +} catch (e) { + console.log("moveToPosition fail " + e); +} +``` ### isFirst8+ ### @@ -1018,22 +1008,22 @@ isFirst(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.isFirst(); - console.log("isFirst " + moved); - } catch (e) { - console.log("isFirst fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isFirst(); + console.log("isFirst " + moved); +} catch (e) { + console.log("isFirst fail " + e); +} +``` ### isLast8+ ### @@ -1052,23 +1042,22 @@ isLast(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.isLast(); - console.log("isLast " + moved); - } catch (e) { - console.log("isLast fail " + e); - } - ``` - +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isLast(); + console.log("isLast " + moved); +} catch (e) { + console.log("isLast fail " + e); +} +``` ### isBeforeFirst8+ ### @@ -1086,22 +1075,22 @@ isBeforeFirst(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.isBeforeFirst(); - console.log("isBeforeFirst " + moved); - } catch (e) { - console.log("isBeforeFirst fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isBeforeFirst(); + console.log("isBeforeFirst " + moved); +} catch (e) { + console.log("isBeforeFirst fail " + e); +} +``` ### isAfterLast8+ ### @@ -1120,22 +1109,22 @@ isAfterLast(): boolean **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.isAfterLast(); - console.log("isAfterLast " + moved); - } catch (e) { - console.log("isAfterLast fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isAfterLast(); + console.log("isAfterLast " + moved); +} catch (e) { + console.log("isAfterLast fail " + e); +} +``` ### getEntry8+ ### @@ -1154,23 +1143,23 @@ getEntry(): Entry **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + err); - }); - const moved = resultSet.moveToNext(); - const entry = resultSet.getEntry(); - console.log("getEntry " + JSON.stringify(entry)); - } catch (e) { - console.log("getEntry fail " + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToNext(); + const entry = resultSet.getEntry(); + console.log("getEntry " + JSON.stringify(entry)); +} catch (e) { + console.log("getEntry fail " + e); +} +``` ## Query8+ ## @@ -1205,18 +1194,18 @@ reset(): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.equalTo("key", "value"); - console.log("query is " + query.getSqlLike()); - query.reset(); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("simply calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.equalTo("key", "value"); + console.log("query is " + query.getSqlLike()); + query.reset(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("simply calls should be ok :" + e); +} +``` ### equalTo8+ ### @@ -1242,16 +1231,16 @@ equalTo(field: string, value: number|string|boolean): Query; **示例** - ``` - try { - let query = new distributedData.Query(); - query.equalTo("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.equalTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### notEqualTo8+ ### @@ -1277,16 +1266,16 @@ notEqualTo(field: string, value: number|string|boolean): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### greaterThan8+ ### @@ -1302,7 +1291,7 @@ greaterThan(field: string, value: number|string|boolean): Query | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| value | number/string/boolean | 是 | 表示指定的值。| +| value | number\|string\|boolean | 是 | 表示指定的值。| **返回值**: @@ -1312,16 +1301,16 @@ greaterThan(field: string, value: number|string|boolean): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.greaterThan("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.greaterThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### lessThan8+ ### @@ -1337,7 +1326,7 @@ lessThan(field: string, value: number|string): Query | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| value | number/string/boolean | 是 | 表示指定的值。| +| value | number\|string\|boolean | 是 | 表示指定的值。| **返回值**: @@ -1347,16 +1336,16 @@ lessThan(field: string, value: number|string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.lessThan("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.lessThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### greaterThanOrEqualTo8+ ### @@ -1372,7 +1361,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| value | number/string/boolean | 是 | 表示指定的值。| +| value | number\|string\|boolean | 是 | 表示指定的值。| **返回值**: @@ -1382,17 +1371,17 @@ greaterThanOrEqualTo(field: string, value: number|string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.greaterThanOrEqualTo("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` - +``` +try { + let query = new distributedData.Query(); + query.greaterThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` + ### lessThanOrEqualTo8+ ### @@ -1407,7 +1396,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| value | number/string/boolean | 是 | 表示指定的值。| +| value | number\|string\|boolean | 是 | 表示指定的值。| **返回值**: @@ -1417,16 +1406,16 @@ lessThanOrEqualTo(field: string, value: number|string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.lessThanOrEqualTo("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.lessThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### isNull8+ ### @@ -1452,16 +1441,16 @@ isNull(field: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.isNull("field"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.isNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### inNumber8+ ### @@ -1486,19 +1475,18 @@ inNumber(field: string, valueList: number[]): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| - **示例** - ``` - try { - let query = new distributedData.Query(); - query.inNumber("field", [0, 1]); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.inNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### inString8+ ### @@ -1524,16 +1512,16 @@ inString(field: string, valueList: string[]): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.inString("field", ['test1', 'test2']); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.inString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### notInNumber8+ ### @@ -1559,16 +1547,16 @@ notInNumber(field: string, valueList: number[]): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notInNumber("field", [0, 1]); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notInNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### notInString8+ ### @@ -1594,16 +1582,16 @@ notInString(field: string, valueList: string[]): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notInString("field", ['test1', 'test2']); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notInString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### like8+ ### @@ -1629,16 +1617,16 @@ like(field: string, value: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.like("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.like("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### unlike8+ ### @@ -1664,16 +1652,16 @@ unlike(field: string, value: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.unlike("field", "value"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.unlike("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### and8+ ### @@ -1692,18 +1680,18 @@ and(): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value1"); - query.and(); - query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.and(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### or8+ ### @@ -1722,18 +1710,18 @@ or(): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value1"); - query.or(); - query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.or(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### orderByAsc8+ ### @@ -1758,17 +1746,17 @@ orderByAsc(field: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value"); - query.orderByAsc("field"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByAsc("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### orderByDesc8+ ### @@ -1791,20 +1779,19 @@ orderByDesc(field: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| - **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value"); - query.orderByDesc("field"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByDesc("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### limit8+ ### @@ -1830,17 +1817,17 @@ limit(total: number, offset: number): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.notEqualTo("field", "value"); - query.limit("total", "offset"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.limit("total", "offset"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### isNotNull8+ ### @@ -1865,16 +1852,16 @@ isNotNull(field: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.isNotNull("field"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.isNotNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### beginGroup8+ ### @@ -1893,18 +1880,18 @@ beginGroup(): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.beginGroup(); - query.isNotNull("field"); - query.endGroup(); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### endGroup8+ ### @@ -1923,18 +1910,18 @@ endGroup(): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.beginGroup(); - query.isNotNull("field"); - query.endGroup(); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### prefixKey8+ ### @@ -1959,17 +1946,17 @@ prefixKey(prefix: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.prefixKey("$.name"); - query.prefixKey("0"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.prefixKey("$.name"); + query.prefixKey("0"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### setSuggestIndex8+ ### @@ -1994,17 +1981,17 @@ setSuggestIndex(index: string): Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.setSuggestIndex("$.name"); - query.setSuggestIndex("0"); - console.log("query is " + query.getSqlLike()); - query = null; - } catch (e) { - console.log("dumplicated calls should be ok :" + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.setSuggestIndex("$.name"); + query.setSuggestIndex("0"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("dumplicated calls should be ok :" + e); +} +``` ### deviceId8+ ### @@ -2030,15 +2017,15 @@ deviceId(deviceId:string):Query **示例** - ``` - try { - let query = new distributedData.Query(); - query.deviceId("deviceId"); - console.log("query is " + query.getSqlLike()); - } catch (e) { - console.log("should be ok on Method Chaining : " + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + query.deviceId("deviceId"); + console.log("query is " + query.getSqlLike()); +} catch (e) { + console.log("should be ok on Method Chaining : " + e); +} +``` ### getSqlLike8+ ### @@ -2057,15 +2044,15 @@ getSqlLike():string **示例** - ``` - try { - let query = new distributedData.Query(); - let sql1 = query.getSqlLike(); - console.log("GetSqlLike sql=" + sql1); - } catch (e) { - console.log("dumplicated calls should be ok : " + e); - } - ``` +``` +try { + let query = new distributedData.Query(); + let sql1 = query.getSqlLike(); + console.log("GetSqlLike sql=" + sql1); +} catch (e) { + console.log("dumplicated calls should be ok : " + e); +} +``` ## KVStore @@ -2092,22 +2079,22 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### put @@ -2131,23 +2118,22 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| - **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); - }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); - }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### delete @@ -2167,29 +2153,29 @@ delete(key: string, callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); + console.log("delete err: " + JSON.stringify(err)); return; } - console.log("put success"); - kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("delete err: " + JSON.stringify(err)); - return; - } - console.log("delete success"); - }); + console.log("delete success"); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### delete @@ -2214,25 +2200,25 @@ delete(key: string): Promise<void> **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); - kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log("delete success"); - }).catch((err) => { - console.log("delete err: " + JSON.stringify(err)); - }); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("delete success"); }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); + console.log("delete err: " + JSON.stringify(err)); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### on @@ -2251,15 +2237,14 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific | type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 | | observer |Callback<[ChangeNotification](#changenotification)> | 是 |回调函数。 | - **示例** - ``` - let kvStore; - kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { - console.log("dataChange callback call data: " + JSON.stringify(data)); - }); - ``` +``` +let kvStore; +kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); +}); +``` ### on @@ -2277,15 +2262,14 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> | event |'syncComplete' | 是 |回调函数名称。 | | syncCallback |Callback<Array<[string, number]>> | 是 |回调函数。 | - **示例** - ``` - let kvStore; - kvStore.on('syncComplete', function (data) { - console.log("syncComplete callback call data: " + data); - }); - ``` +``` +let kvStore; +kvStore.on('syncComplete', function (data) { + console.log("syncComplete callback call data: " + data); +}); +``` ### off8+ @@ -2304,15 +2288,15 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void **示例** - ``` - let kvStore; - kvStore.on('dataChange', function (data) { - console.log("syncComplete callback call data: " + data); - }); - kvStore.off('dataChange', function (data) { - console.log("syncComplete callback call data: " + data); - }); - ``` +``` +let kvStore; +kvStore.on('dataChange', function (data) { + console.log("syncComplete callback call data: " + data); +}); +kvStore.off('dataChange', function (data) { + console.log("syncComplete callback call data: " + data); +}); +``` ### putBatch8+ @@ -2332,35 +2316,34 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - await kvStore.getEntries('batch_test_string_key', function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }); - }); - }catch(e) { - console.log('PutBatch e ' + e); + entries.push(entry); } - - ``` + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### putBatch8+ @@ -2385,37 +2368,37 @@ putBatch(entries: Entry[]): Promise<void> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - await kvStore.getEntries('batch_test_string_key').then((entrys) => { - console.log('getEntries success'); - console.log('PutBatch ' + JSON.stringify(entries)); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('PutBatch ' + JSON.stringify(entries)); }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); + console.log('getEntries fail ' + JSON.stringify(err)); }); - }catch(e) { - console.log('PutBatch e ' + e); - } - ``` + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### deleteBatch8+ @@ -2435,34 +2418,34 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - try { - let entries = []; - let keys = []; - for (var i = 0; i < 5; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); - keys.push(key + i); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - await kvStore.deleteBatch(keys, async function (err,data) { - console.log('deleteBatch success'); - }); - }); - }catch(e) { - console.log('DeleteBatch e ' + e); + entries.push(entry); + keys.push(key + i); } - ``` + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.deleteBatch(keys, async function (err,data) { + console.log('deleteBatch success'); + }); + }); +}catch(e) { + console.log('DeleteBatch e ' + e); +} +``` ### deleteBatch8+ ### @@ -2487,38 +2470,38 @@ deleteBatch(keys: string[]): Promise<void> **示例** - ``` - let kvStore; - try { - let entries = []; - let keys = []; - for (var i = 0; i < 5; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); - keys.push(key + i); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - await kvStore.deleteBatch(keys).then((err) => { - console.log('deleteBatch success'); - }).catch((err) => { - console.log('deleteBatch fail ' + JSON.stringify(err)); - }); + entries.push(entry); + keys.push(key + i); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.deleteBatch(keys).then((err) => { + console.log('deleteBatch success'); }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); + console.log('deleteBatch fail ' + JSON.stringify(err)); }); - }catch(e) { - console.log('DeleteBatch e ' + e); - } - ``` + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('DeleteBatch e ' + e); +} +``` ### startTransaction8+ ### @@ -2537,40 +2520,40 @@ startTransaction(callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - function putBatchString(len, prefix) { - let entries = []; - for (var i = 0; i < len; i++) { - var entry = { - key : prefix + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +function putBatchString(len, prefix) { + let entries = []; + for (var i = 0; i < len; i++) { + var entry = { + key : prefix + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - return entries; + entries.push(entry); } - try { - var count = 0; - kvStore.on('dataChange', 0, function (data) { - console.log('startTransaction 0' + data) - count++; - }); - kvStore.startTransaction(async function (err,data) { - console.log('startTransaction success'); - let entries = putBatchString(10, 'batch_test_string_key'); - console.log('entries: ' + JSON.stringify(entries)); - await kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - }); + return entries; +} +try { + var count = 0; + kvStore.on('dataChange', 0, function (data) { + console.log('startTransaction 0' + data) + count++; + }); + kvStore.startTransaction(async function (err,data) { + console.log('startTransaction success'); + let entries = putBatchString(10, 'batch_test_string_key'); + console.log('entries: ' + JSON.stringify(entries)); + await kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); }); - }catch(e) { - console.log('startTransaction e ' + e); - } - ``` + }); +}catch(e) { + console.log('startTransaction e ' + e); +} +``` ### startTransaction8+ ### @@ -2589,23 +2572,23 @@ startTransaction(): Promise<void> **示例** - ``` - let kvStore; - try { - var count = 0; - kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { - console.log('startTransaction ' + JSON.stringify(data)); - count++; - }); - kvStore.startTransaction().then(async (err) => { - console.log('startTransaction success'); - }).catch((err) => { - console.log('startTransaction fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('startTransaction e ' + e); - } - ``` +``` +let kvStore; +try { + var count = 0; + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { + console.log('startTransaction ' + JSON.stringify(data)); + count++; + }); + kvStore.startTransaction().then(async (err) => { + console.log('startTransaction success'); + }).catch((err) => { + console.log('startTransaction fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('startTransaction e ' + e); +} +``` ### commit8+ ### @@ -2624,20 +2607,20 @@ commit(callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - try { - kvStore.commit(function (err,data) { - if (err == undefined) { - console.log('commit success'); - } else { - console.log('commit fail'); - } - }); - }catch(e) { - console.log('Commit e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.commit(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); +}catch(e) { + console.log('Commit e ' + e); +} +``` ### commit8+ ### @@ -2656,18 +2639,18 @@ commit(): Promise<void> **示例** - ``` - let kvStore; - try { - kvStore.commit().then(async (err) => { - console.log('commit success'); - }).catch((err) => { - console.log('commit fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('Commit e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.commit().then(async (err) => { + console.log('commit success'); + }).catch((err) => { + console.log('commit fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('Commit e ' + e); +} +``` ### rollback8+ ### @@ -2686,20 +2669,20 @@ rollback(callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - try { - kvStore.rollback(function (err,data) { - if (err == undefined) { - console.log('commit success'); - } else { - console.log('commit fail'); - } - }); - }catch(e) { - console.log('Rollback e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.rollback(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); +}catch(e) { + console.log('Rollback e ' + e); +} +``` ### rollback8+ ### @@ -2718,18 +2701,18 @@ rollback(): Promise<void> **示例** - ``` - let kvStore; - try { - kvStore.rollback().then(async (err) => { - console.log('rollback success'); - }).catch((err) => { - console.log('rollback fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('Rollback e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.rollback().then(async (err) => { + console.log('rollback success'); + }).catch((err) => { + console.log('rollback fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('Rollback e ' + e); +} +``` ### enableSync8+ ### @@ -2749,20 +2732,20 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - try { - kvStore.enableSync(true, function (err,data) { - if (err == undefined) { - console.log('enableSync success'); - } else { - console.log('enableSync fail'); - } - }); - }catch(e) { - console.log('EnableSync e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.enableSync(true, function (err,data) { + if (err == undefined) { + console.log('enableSync success'); + } else { + console.log('enableSync fail'); + } + }); +}catch(e) { + console.log('EnableSync e ' + e); +} +``` ### enableSync8+ ### @@ -2787,18 +2770,18 @@ enableSync(enabled: boolean): Promise<void> **示例** - ``` - let kvStore; - try { - kvStore.enableSync(true).then((err) => { - console.log('enableSync success'); - }).catch((err) => { - console.log('enableSync fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('EnableSync e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.enableSync(true).then((err) => { + console.log('enableSync success'); + }).catch((err) => { + console.log('enableSync fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('EnableSync e ' + e); +} +``` ### setSyncRange8+ ### @@ -2819,18 +2802,18 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy **示例** - ``` - let kvStore; - try { - const localLabels = ['A', 'B']; - const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) { - console.log('SetSyncRange put success'); - }); - }catch(e) { - console.log('SetSyncRange e ' + e); - } - ``` +``` +let kvStore; +try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) { + console.log('SetSyncRange put success'); + }); +}catch(e) { + console.log('SetSyncRange e ' + e); +} +``` ### setSyncRange8+ ### @@ -2857,20 +2840,20 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v **示例** - ``` - let kvStore; - try { - const localLabels = ['A', 'B']; - const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { - console.log('setSyncRange success'); - }).catch((err) => { - console.log('delete fail ' + err); - }); - }catch(e) { - console.log('SetSyncRange e ' + e); - } - ``` +``` +let kvStore; +try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { + console.log('setSyncRange success'); + }).catch((err) => { + console.log('delete fail ' + err); + }); +}catch(e) { + console.log('SetSyncRange e ' + e); +} +``` ## SubscribeType @@ -2957,29 +2940,29 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| callback |AsyncCallback<Uint8Array / string / boolean / number>) | 是 |回调函数,获取查询的值。 | +| callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | 是 |回调函数,获取查询的值。 | **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { - console.log("get success data: " + data); - }); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log("get success data: " + data); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### get @@ -3001,30 +2984,29 @@ get(key: string): Promise<Uint8Array | string | boolean | number> | 类型 | 说明 | | ------ | ------- | -|Promise<Uint8Array / string / boolean / number> |Promise实例,用于获取异步返回结果。| - +|Promise<Uint8Array \| string \| boolean \| number> |Promise实例,用于获取异步返回结果。| **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); - kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log("get success data: " + data); - }).catch((err) => { - console.log("get err: " + JSON.stringify(err)); - }); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("get success data: " + data); }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); + console.log("get err: " + JSON.stringify(err)); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); - } - ``` + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` ### getEntries8+ ### @@ -3039,37 +3021,37 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -| callback |AsyncCallback<Entry[]> | 是 |回调函数,获取指定前缀的键值对列表。 | +| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,获取指定前缀的键值对列表。 | **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_number_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.INTEGER, - value : 222 - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_number_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.INTEGER, + value : 222 } - entries.push(entry); } - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - await kvStore.getEntries('batch_test_number_key', function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }); - }); - }catch(e) { - console.log('PutBatch e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_number_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### getEntries8+ ### @@ -3094,40 +3076,40 @@ getEntries(keyPrefix: string): Promise<Entry[]> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - console.log('entries: ' + entries); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - await kvStore.getEntries('batch_test_string_key').then((entrys) => { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); + console.log('entrys[0].value.value: ' + entrys[0].value.value); }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); + console.log('getEntries fail ' + JSON.stringify(err)); }); - }catch(e) { - console.log('PutBatch e ' + e); - } - ``` + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### getEntries8+ ### @@ -3143,42 +3125,42 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示要匹配的键前缀。 | -| callback |AsyncCallback<Entry[]> | 是 |回调函数,获取指定前缀的键值对列表。 | +| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,获取指定前缀的键值对列表。 | **示例** - ``` - let kvStore; - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getEntries(query, function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }); - }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); + entries.push(entry); } - ``` + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getEntries8+ ### @@ -3203,39 +3185,39 @@ getEntries(query: Query): Promise<Entry[]> **示例** - ``` - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getEntries(query).then((entrys) => { - console.log('getEntries success'); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query).then((entrys) => { + console.log('getEntries success'); }).catch((err) => { - console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + console.log('getEntries fail ' + JSON.stringify(err)); }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); - } - ``` + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getResultSet8+ ### @@ -3255,36 +3237,36 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>) **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('GetResultSet putBatch success'); - await kvStore.getResultSet('batch_test_string_key', async function (err, result) { - console.log('GetResultSet getResultSet success'); - resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { - console.log('GetResultSet closeResultSet success'); - }) - }); - }); - }catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('GetResultSet putBatch success'); + await kvStore.getResultSet('batch_test_string_key', async function (err, result) { + console.log('GetResultSet getResultSet success'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('GetResultSet closeResultSet success'); + }) + }); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -3309,42 +3291,42 @@ getResultSet(keyPrefix: string): Promise<KvStoreResultSet> **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('PutBatch putBatch fail ' + JSON.stringify(err)); - }); - kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('GetResult getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('GetResult closeResultSet success'); - }).catch((err) => { - console.log('closeResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResult e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('GetResult getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResult closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResult e ' + e); +} +``` ### getResultSet8+ ### @@ -3364,35 +3346,35 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getResultSet(query, async function (err, result) { - console.log('getResultSet success'); - resultSet = result; - }); - }); - } catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -3417,39 +3399,39 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); - }); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSet(query).then((result) => { - console.log(' getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query).then((result) => { + console.log(' getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### closeResultSet8+ ### @@ -3468,21 +3450,21 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **示例** - ``` - let kvStore; - try { - let resultSet = null; - kvStore.closeResultSet(resultSet, function (err, data) { - if (err == undefined) { - console.log('closeResultSet success'); - } else { - console.log('closeResultSet fail'); - } - }); - }catch(e) { - console.log('CloseResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` ### closeResultSet8+ ### @@ -3507,19 +3489,19 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **示例** - ``` - let kvStore; - try { - let resultSet = null; - kvStore.closeResultSet(resultSet).then(() => { - console.log('closeResultSet success'); - }).catch((err) => { - console.log('closeResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('CloseResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` ### getResultSize8+ ### @@ -3539,33 +3521,33 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getResultSize(query, async function (err, resultSize) { - console.log('getResultSet success'); - }); - }); - } catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### getResultSize8+ ### @@ -3590,37 +3572,37 @@ getResultSize(query: Query): Promise<number> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); - }); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSize(query).then((resultSize) => { - console.log('getResultSet success'); - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### removeDeviceData8+ ### @@ -3640,29 +3622,29 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { - console.log('put success'); - const deviceid = 'no_exist_device_id'; - await kvStore.removeDeviceData(deviceid, async function (err,data) { - if (err == undefined) { - console.log('removeDeviceData success'); - } else { - console.log('removeDeviceData fail'); - await kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err,data) { - console.log('RemoveDeviceData get success'); - }); - } - }); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + const deviceid = 'no_exist_device_id'; + await kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + await kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } }); - }catch(e) { - console.log('RemoveDeviceData e ' + e); - } - ``` + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` ### removeDeviceData8+ ### @@ -3687,31 +3669,31 @@ removeDeviceData(deviceId: string): Promise<void> **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { - console.log('removeDeviceData put success'); - }).catch((err) => { - console.log('put fail ' + JSON.stringify(err)); - }); - const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid).then((err) => { - console.log('removeDeviceData success'); - }).catch((err) => { - console.log('removeDeviceData fail ' + JSON.stringify(err)); - }); - kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('get success data:' + data); - }).catch((err) => { - console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('RemoveDeviceData e ' + e); - } - ``` +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('removeDeviceData put success'); + }).catch((err) => { + console.log('put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` ### on8+ ### @@ -3731,23 +3713,23 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **示例** - ``` - let kvStore; - const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; - const VALUE_TEST_FLOAT_ELEMENT = 321.12; - try { - kvStore.on('syncComplete', function (data) { - console.log('syncComplete ' + data) - }); - kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { - console.log('syncComplete put success'); - }).catch((error) => { - console.log('syncComplete put fail ' + error); - }); - }catch(e) { - console.log('syncComplete put e ' + e); - } - ``` +``` +let kvStore; +const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; +const VALUE_TEST_FLOAT_ELEMENT = 321.12; +try { + kvStore.on('syncComplete', function (data) { + console.log('syncComplete ' + data) + }); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); +}catch(e) { + console.log('syncComplete put e ' + e); +} +``` ### off8+ ### @@ -3765,21 +3747,20 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& | event |'syncComplete' | 是 |同步完成时触发的事件名。 | | syncCallback |Callback<Array<[string, number]>> | 否 |用于向调用方发送同步结果的回调。 | - **示例** - ``` - let kvStore; - try { - const func = function (data) { - console.log('syncComplete ' + data) - }; - kvStore.on('syncComplete', func); - kvStore.off('syncComplete', func); - }catch(e) { - console.log('syncComplete e ' + e); - } - ``` +``` +let kvStore; +try { + const func = function (data) { + console.log('syncComplete ' + data) + }; + kvStore.on('syncComplete', func); + kvStore.off('syncComplete', func); +}catch(e) { + console.log('syncComplete e ' + e); +} +``` ### sync @@ -3787,6 +3768,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void 在手动模式下,触发数据库同步,此方法为同步方法。 +**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 @@ -3800,10 +3782,10 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void **示例**: - ``` - let kvStore; - kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); - ``` +``` +let kvStore; +kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); +``` ### setSyncParam8+ ### @@ -3820,20 +3802,19 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | | callback |AsyncCallback<void> | 是 |回调函数。 | - **示例** - ``` - let kvStore; - try { - const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) { - console.log('SetSyncParam put success'); - }); - }catch(e) { - console.log('testSingleKvStoreSetSyncParam e ' + e); - } - ``` +``` +let kvStore; +try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) { + console.log('SetSyncParam put success'); + }); +}catch(e) { + console.log('testSingleKvStoreSetSyncParam e ' + e); +} +``` ### setSyncParam8+ ### @@ -3859,19 +3840,19 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> **示例** - ``` - let kvStore; - try { - const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { - console.log('SetSyncParam put success'); - }).catch((err) => { - console.log('SetSyncParam put fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('SetSyncParam e ' + e); - } - ``` +``` +let kvStore; +try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { + console.log('SetSyncParam put success'); + }).catch((err) => { + console.log('SetSyncParam put fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('SetSyncParam e ' + e); +} +``` ### getSecurityLevel8+ ### @@ -3890,16 +3871,16 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void **示例** - ``` - let kvStore; - try { - kvStore.getSecurityLevel(function (err,data) { - console.log('getSecurityLevel success'); - }); - }catch(e) { - console.log('GetSecurityLeve e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.getSecurityLevel(function (err,data) { + console.log('getSecurityLevel success'); + }); +}catch(e) { + console.log('GetSecurityLeve e ' + e); +} +``` ### getSecurityLevel8+ ### @@ -3916,21 +3897,20 @@ getSecurityLevel(): Promise<SecurityLevel> | ------ | ------- | |Promise<[SecurityLevel](#securitylevel)> |Promise实例,用于获取异步返回结果。| - **示例** - ``` - let kvStore; - try { - kvStore.getSecurityLevel().then((data) => { - console.log(' getSecurityLevel success'); - }).catch((err) => { - console.log('getSecurityLevel fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetSecurityLeve e ' + e); - } - ``` +``` +let kvStore; +try { + kvStore.getSecurityLevel().then((data) => { + console.log(' getSecurityLevel success'); + }).catch((err) => { + console.log('getSecurityLevel fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetSecurityLeve e ' + e); +} +``` ## DeviceKVStore8+ ## @@ -3953,26 +3933,25 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | key |string | 是 |表示要查询 key 值的键。 | -| callback |AsyncCallback<boolean/string/number/Uint8Array> | 是 |回调函数,返回匹配给定条件的字符串值。 | - +| callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | 是 |回调函数,返回匹配给定条件的字符串值。 | **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; - try{ - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { - console.log('put success'); - kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) { - console.log('get success'); - }); - }) - }catch(e) { - console.log('get e' + e); - } - ``` +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try{ + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log('get success'); + }); + }) +}catch(e) { + console.log('get e' + e); +} +``` ### get8+ ### @@ -3994,29 +3973,29 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& | 类型 | 说明 | | ------ | ------- | -|Promise<boolean/string/number/Uint8Array> |Promise实例,用于获取异步返回结果。| +|Promise<boolean\|string\|number\|Uint8Array> |Promise实例,用于获取异步返回结果。| **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { - console.log(' put success'); - kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('get success'); - }).catch((err) => { - console.log('get fail ' + JSON.stringify(err)); - }); - }).catch((error) => { - console.log('put error' + error); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { + console.log(' put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success'); + }).catch((err) => { + console.log('get fail ' + JSON.stringify(err)); }); - } catch (e) { - console.log('Get e ' + e); - } - ``` + }).catch((error) => { + console.log('put error' + error); + }); +} catch (e) { + console.log('Get e ' + e); +} +``` ### getEntries8+ ### @@ -4037,34 +4016,34 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - console.log('entries: ' + entries); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - await kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }); - }); - }catch(e) { - console.log('PutBatch e ' + e); + entries.push(entry); } - ``` + console.log('entries: ' + entries); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### getEntries8+ ### @@ -4090,40 +4069,40 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - console.log('entries: ' + entries); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - await kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entrys) => { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); + console.log('entrys[0].value.value: ' + entrys[0].value.value); }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); + console.log('getEntries fail ' + JSON.stringify(err)); }); - }catch(e) { - console.log('PutBatch e ' + e); - } - ``` + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` ### getEntries8+ ### @@ -4143,40 +4122,40 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **示例** - ``` - let kvStore; - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - expect(err == undefined).assertTrue(); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - query.deviceId('localDeviceId'); - await kvStore.getEntries(query, function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }); - }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); + entries.push(entry); } - ``` + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + expect(err == undefined).assertTrue(); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getEntries(query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getEntries8+ ### @@ -4201,40 +4180,40 @@ getEntries(query: Query): Promise<Entry[]> **示例** - ``` - let kvStore; - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getEntries(query).then((entrys) => { - console.log('getEntries success'); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query).then((entrys) => { + console.log('getEntries success'); }).catch((err) => { - console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + console.log('getEntries fail ' + JSON.stringify(err)); }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); - } - ``` + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getEntries8+ ### @@ -4255,40 +4234,40 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> **示例** - ``` - let kvStore; - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries, async function (err,data) { - console.log('putBatch success'); - expect(err == undefined).assertTrue(); - var query = new distributedData.Query(); - query.deviceId('localDeviceId'); - query.prefixKey("batch_test"); - await kvStore.getEntries('localDeviceId', query, function (err,entrys) { - console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - }) - }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); + entries.push(entry); } - ``` + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + expect(err == undefined).assertTrue(); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + await kvStore.getEntries('localDeviceId', query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getEntries8+ ### @@ -4314,41 +4293,41 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> **示例** - ``` - let kvStore; - try { - var arr = new Uint8Array([21,31]); - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_bool_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.BYTE_ARRAY, - value : arr - } +``` +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr } - entries.push(entry); } - console.log('entries: ' + JSON.stringify(entries)); - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - var query = new distributedData.Query(); - query.deviceId('localDeviceId'); - query.prefixKey("batch_test"); - await kvStore.getEntries('localDeviceId', query).then((entrys) => { - console.log('getEntries success'); - }).catch((err) => { - console.log('getEntries fail ' + JSON.stringify(err)); - }); + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + await kvStore.getEntries('localDeviceId', query).then((entrys) => { + console.log('getEntries success'); }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); + console.log('getEntries fail ' + JSON.stringify(err)); }); - console.log('GetEntries success'); - }catch(e) { - console.log('GetEntries e ' + e); - } - ``` + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` ### getResultSet8+ ### @@ -4369,21 +4348,21 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { - console.log('getResultSet success'); - resultSet = result; - await kvStore.closeResultSet(resultSet, function (err, data) { - console.log('closeResultSet success'); - }) - }); - }catch(e) { - console.log('GetResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -4409,25 +4388,25 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g **示例** - ``` - let kvStore; - try { - let resultSet; - kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('closeResultSet success'); - }).catch((err) => { - console.log('closeResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -4447,39 +4426,39 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - query.deviceId('localDeviceId'); - await kvStore.getResultSet(query, async function (err, result) { - console.log('getResultSet success'); - resultSet = result; - await kvStore.closeResultSet(resultSet, function (err, data) { - console.log('closeResultSet success'); - }) - }); - }); - } catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -4504,46 +4483,46 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('putBatch fail ' + err); - }); - const query = new distributedData.Query(); - query.deviceId('localDeviceId'); - query.prefixKey("batch_test"); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.getResultSet(query).then((result) => { - console.log('getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('closeResultSet success'); - }).catch((err) => { - console.log('closeResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + err); + }); + const query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.getResultSet(query).then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -4564,38 +4543,38 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getResultSet('localDeviceId', query, async function (err, result) { - console.log('getResultSet success'); - resultSet = result; - await kvStore.closeResultSet(resultSet, function (err, data) { - console.log('closeResultSet success'); - }) - }); - }); - } catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSet('localDeviceId', query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### getResultSet8+ ### @@ -4621,47 +4600,47 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> **示例** - ``` - let kvStore; - try { - let resultSet; - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('GetResultSet putBatch success'); - }).catch((err) => { - console.log('PutBatch putBatch fail ' + JSON.stringify(err)); - }); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('GetResultSet getResultSet success'); - resultSet = result; - }).catch((err) => { - console.log('GetResultSet getResultSet fail ' + JSON.stringify(err)); - }); - query.deviceId('localDeviceId'); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('GetResultSet closeResultSet success'); - }).catch((err) => { - console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err)); - }); - - }catch(e) { - console.log('GetResultSet e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('GetResultSet putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet('localDeviceId', query).then((result) => { + console.log('GetResultSet getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('GetResultSet getResultSet fail ' + JSON.stringify(err)); + }); + query.deviceId('localDeviceId'); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResultSet closeResultSet success'); + }).catch((err) => { + console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err)); + }); + +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` ### closeResultSet8+ ### @@ -4681,22 +4660,22 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **示例** - ``` - let kvStore; - try { - console.log('CloseResultSet success'); - let resultSet = null; - kvStore.closeResultSet(resultSet, function (err, data) { - if (err == undefined) { - console.log('closeResultSet success'); - } else { - console.log('closeResultSet fail'); - } - }); - }catch(e) { - console.log('CloseResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` ### closeResultSet8+ ### @@ -4721,20 +4700,20 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **示例** - ``` - let kvStore; - try { - console.log('CloseResultSet success'); - let resultSet = null; - kvStore.closeResultSet(resultSet).then(() => { - console.log('closeResultSet success'); - }).catch((err) => { - console.log('closeResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('CloseResultSet e ' + e); - } - ``` +``` +let kvStore; +try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` ### getResultSize8+ ### @@ -4754,34 +4733,34 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - query.deviceId('localDeviceId'); - await kvStore.getResultSize(query, async function (err, resultSize) { - console.log('getResultSet success'); - }); - }); - } catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### getResultSize8+ ### @@ -4806,38 +4785,38 @@ getResultSize(query: Query): Promise<number> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); - }); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - query.deviceId('localDeviceId'); - kvStore.getResultSize(query).then((resultSize) => { - console.log('getResultSet success'); - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### getResultSize8+ ### @@ -4858,33 +4837,33 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('putBatch success'); - const query = new distributedData.Query(); - query.prefixKey("batch_test"); - await kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { - console.log('getResultSet success'); - }); - }); - } catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### getResultSize8+ ### @@ -4910,37 +4889,37 @@ getResultSize(deviceId: string, query: Query): Promise<number> **示例** - ``` - let kvStore; - try { - let entries = []; - for (var i = 0; i < 10; i++) { - var key = 'batch_test_string_key'; - var entry = { - key : key + i, - value : { - type : distributedData.ValueType.STRING, - value : 'batch_test_string_value' - } +``` +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' } - entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('putBatch success'); - }).catch((err) => { - console.log('putBatch fail ' + JSON.stringify(err)); - }); - var query = new distributedData.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSize('localDeviceId', query).then((resultSize) => { - console.log('getResultSet success'); - }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('GetResultSize e ' + e); + entries.push(entry); } - ``` + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + var query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize('localDeviceId', query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` ### removeDeviceData8+ ### @@ -4960,29 +4939,29 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { - console.log('RemoveDeviceData put success'); - const deviceid = 'no_exist_device_id'; - await kvStore.removeDeviceData(deviceid, async function (err,data) { - if (err == undefined) { - console.log('removeDeviceData success'); - } else { - console.log('removeDeviceData fail'); - await kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, async function (err,data) { - console.log('RemoveDeviceData get success'); - }); - } - }); +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData put success'); + const deviceid = 'no_exist_device_id'; + await kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + await kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } }); - }catch(e) { - console.log('RemoveDeviceData e ' + e); - } - ``` + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` ### removeDeviceData8+ ### @@ -5007,31 +4986,31 @@ removeDeviceData(deviceId: string): Promise<void> **示例** - ``` - let kvStore; - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; - try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { - console.log('RemoveDeviceData put success'); - }).catch((err) => { - console.log('RemoveDeviceData put fail ' + JSON.stringify(err)); - }); - const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid).then((err) => { - console.log('removeDeviceData success'); - }).catch((err) => { - console.log('removeDeviceData fail ' + JSON.stringify(err)); - }); - kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('RemoveDeviceData get success data:' + data); - }).catch((err) => { - console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); - }); - }catch(e) { - console.log('RemoveDeviceData e ' + e); - } - ``` +``` +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('RemoveDeviceData put success'); + }).catch((err) => { + console.log('RemoveDeviceData put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('RemoveDeviceData get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` ### sync8+ ### @@ -5039,6 +5018,7 @@ removeDeviceData(deviceId: string): Promise<void> sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void 在手动模式下,触发数据库同步,此方法为同步方法。 +**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 @@ -5050,27 +5030,26 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | mode |[SyncMode](#syncmode) | 是 |表示同步方式,PUSH、PULL或PUSH_PULL。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | - **示例** - ``` - let kvStore; - const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; - const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; - try { - kvStore.on('syncComplete', function (data) { - console.log('Sync dataChange'); - }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { - console.log('Sync put success'); - const devices = ['deviceList']; - const mode = distributedData.SyncMode.PULL_ONLY; - kvStore.sync(devices, mode); - }); - }catch(e) { - console.log('Sync e' + e); - } - ``` +``` +let kvStore; +const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; +const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; +try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + console.log('Sync put success'); + const devices = ['deviceList']; + const mode = distributedData.SyncMode.PULL_ONLY; + kvStore.sync(devices, mode); + }); +}catch(e) { + console.log('Sync e' + e); +} +``` ### on8+ ### @@ -5089,22 +5068,22 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **示例** - ``` - const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; - const VALUE_TEST_FLOAT_ELEMENT = 321.12; - try { - kvStore.on('syncComplete', function (data) { - console.log('syncComplete ' + data) - }); - kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { - console.log('syncComplete put success'); - }).catch((error) => { - console.log('syncComplete put fail ' + error); - }); - }catch(e) { - console.log('syncComplete put e ' + e); - } - ``` +``` +const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; +const VALUE_TEST_FLOAT_ELEMENT = 321.12; +try { + kvStore.on('syncComplete', function (data) { + console.log('syncComplete ' + data) + }); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); +}catch(e) { + console.log('syncComplete put e ' + e); +} +``` ### off8+ ### @@ -5122,21 +5101,20 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& | event |'syncComplete' | 是 |同步完成时触发的事件名。 | | syncCallback |Callback ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## 导入模块 - -``` -import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; -``` - - -## enterpriseDeviceManager.activateAdmin - -activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\): void - -以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。 - -**需要权限:** -ohos.permission.MANAGE_ADMIN - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | -| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | - -**示例**: - -``` -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result); -}); -``` - -## enterpriseDeviceManager.activateAdmin - -activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType): Promise\ - -以异步方法根据给定的包名和类名激活设备管理员应用,使用Promise形式返回是否激活成功。 - -**需要权限:** -ohos.permission.MANAGE_ADMIN - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | --------------------------- | -| Promise\ | Promise形式返回是否激活成功 | - -**示例**: - -``` -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL) -.then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.deactivateAdmin - -deactivateAdmin(admin: Want, callback: AsyncCallback\): void - -以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。 - -**需要权限:** -ohos.permission.MANAGE_ADMIN - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ------------------------------ | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 普通设备管理员应用 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | - -**示例**: - -``` -let wantTemp = { - bundleName: elementName.bundleName, - abilityName: elementName.abilityName, -}; -enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result); -}); -``` - - - -## enterpriseDeviceManager.deactivateAdmin - -deactivateAdmin(admin: Want): Promise\ - -以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Promise形式返回是否去激活成功。 - -**需要权限:** -ohos.permission.MANAGE_ADMIN - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------------------------------------- | ---- | ------------------ | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 普通设备管理员应用 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | --------------------------- | -| Promise\ | Promise形式返回是否激活成功 | - -**示例**: - -``` -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.deactivateSuperAdmin - -deactivateSuperAdmin(bundleName: String, callback: AsyncCallback\): void - -以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ----------------------- | ---- | ------------------------------ | -| bundleName | String | 是 | 超级设备管理员应用的包名 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | - -**示例**: - -``` -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result); -}); -``` - -## enterpriseDeviceManager.deactivateSuperAdmin - -deactivateSuperAdmin(bundleName: String): Promise\ - -以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ------------------------ | -| bundleName | String | 是 | 超级设备管理员应用的包名 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | --------------------------- | -| Promise\ | Promise形式返回是否激活成功 | - -**示例**: - -``` -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.isAdminAppActive - -isAdminAppActive(admin: Want, callback: AsyncCallback\): void - -以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Callback形式返回是否处于激活状态。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | -------------------------------- | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | - -**示例**: - -``` -let wantTemp = { - bundleName: elementName.bundleName, - abilityName: elementName.abilityName, -}; -enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result); -}); -``` - - - -## enterpriseDeviceManager.isAdminAppActive - -isAdminAppActive(admin: Want): Promise\ - -以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ------------------------------- | -| Promise\ | Promise形式返回是否处于激活状态 | - -**示例**: - -``` -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.isSuperAdmin - -isSuperAdmin(bundleName: String, callback: AsyncCallback\): void - -以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Callback形式返回是否处于激活状态。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ----------------------- | ---- | -------------------------------- | -| bundleName | String | 是 | 设备管理员应用 | -| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | - -**示例**: - -``` -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result); -}); -``` - - - -## enterpriseDeviceManager.isSuperAdmin - -isSuperAdmin(bundleName: String): Promise\ - -以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ------------------ | -| bundleName | String | 是 | 超级设备管理员应用 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ------------------------------- | -| Promise\ | Promise形式返回是否处于激活状态 | - -**示例**: - -``` -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.getDeviceSettingsManager - -getDeviceSettingsManager(callback: AsyncCallback<DeviceSettingsManager>): void - -获取DeviceSettingsManager对象,使用callback形式返回DeviceSettingsManager对象。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback { - if (error != null) { - console.log("error occurs" + error); - return; - } - mgr.setDateTime(wantTemp, 1526003846000, (error, value) => { - if (error != null) { - console.log(error); - } else { - console.log(value); - } - }); -}); -``` - - -## enterpriseDeviceManager.getDeviceSettingsManager - -getDeviceSettingsManager(): Promise<DeviceSettingsManager> - -获取DeviceSettingsManager对象,使用Promise形式返回DeviceSettingsManager对象。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**返回值:** - -| 类型 | 说明 | -| -------- | -------- | -| Promise<DeviceSettingsManager> | Promise方式返回DeviceSettingsManager对象 | - -**示例:** - -``` -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -mgr.getDeviceSettingsManager().then((mgr) => { - mgr.setDateTime(wantTemp, 1526003846000).then((value) => { - console.log(value); - }).catch((error) => { - console.log(error); - }) -}).catch((error) => { - console.log(error); -}) -``` - -## enterpriseDeviceManager.setEnterpriseInfo - -setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<boolean>): void - -设置设备管理员应用的企业信息,使用callback形式返回是否设置成功。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------------- | ---- | ------------------------------------ | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| callback | AsyncCallback\ { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - - -## enterpriseDeviceManager.setEnterpriseInfo - -setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<boolean> - -设置设备管理员应用的企业信息,使用Promise形式返回是否设置成功。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | - -**返回值:** - -| 类型 | 说明 | -| ------------------ | ----------------------------------- | -| Promise\; | Promise方式返回是否设置企业信息成功 | - -**示例:** - -``` -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) -.then((result) => { - console.log(result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.getEnterpriseInfo - -getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void - -获取设备管理员应用的企业信息,使用callback形式返回设备管理员应用的企业信息。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | -| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | 是 | callback方式返回设备管理员应用的企业信息 | - -**示例:** - -``` -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result.name); - console.log(result.description); -}); -``` - - -## enterpriseDeviceManager.getEnterpriseInfo - -getDeviceSettingsManager(admin: Want): Promise<EnterpriseInfo> - -获取设备管理员应用的企业信息,使用Promise形式返回设备管理员应用的企业信息。 - -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 设备管理员应用 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------------------ | ------------------------------------------- | -| Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise方式返回设备管理员应用的企业信息对象 | - -**示例:** - -``` -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { - console.log(result.name); - console.log(result.description); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## EnterpriseInfo - -设备管理员应用的企业信息 - -**系统能力:** -以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ----------- | -------- | ------ | ---- | ---------------------------------- | -| name | 只读 | string | 是 | 表示设备管理员应用所属企业的名称。 | -| description | 只读 | string | 是 | 表示设备管理员应用所属企业的描述。 | - - -## AdminType - -设备管理员应用的管理员类型。 - -**系统能力:** -以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 | -| ADMIN_TYPE_SUPER | 0x01 | 超级管理员 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md deleted file mode 100644 index 0a1ed1adcc6b998d195a011bd6eccf4bc8ecf7ae..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ /dev/null @@ -1,140 +0,0 @@ -# EventHub - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -事件中心,提供订阅、取消订阅、触发事件能力。 - - -## 使用说明 - - -​在使用eventHub的功能前,需要通过Ability实例的成员变量context获取。 - - - -```js -import Ability from '@ohos.application.Ability' -export default class MainAbility extends Ability { - onForeground() { - this.context.eventHub.on("123", this.func1); - } -} -``` - - -## EventHub.on - -on(event: string, callback: Function): void; - -订阅指定事件。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | string | 是 | 事件名称。 | - | callback | Function | 是 | 事件回调,事件触发后运行。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability' - - export default class MainAbility extends Ability { - onForeground() { - this.context.eventHub.on("123", this.func1); - this.context.eventHub.on("123", () => { - console.log("call anonymous func 1"); - }); - // 结果: - // func1 is called - // call anonymous func 1 - this.context.eventHub.emit("123"); - } - func1() { - console.log("func1 is called"); - } - } - ``` - - -## EventHub.off - -off(event: string, callback?: Function): void; - -取消订阅指定事件。当callback传值时,取消订阅指定的callback;未传值时,取消订阅该事件下所有callback。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | string | 是 | 事件名称。 | - | callback | Function | 否 | 事件回调。如果不传callback,则取消订阅该事件下所有callback。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability' - - export default class MainAbility extends Ability { - onForeground() { - this.context.eventHub.on("123", this.func1); - this.context.eventHub.off("123", this.func1); //取消订阅func1 - this.context.eventHub.on("123", this.func1); - this.context.eventHub.on("123", this.func2); - this.context.eventHub.off("123"); //取消订阅func1和func2 - } - func1() { - console.log("func1 is called"); - } - func2() { - console.log("func2 is called"); - } - } - ``` - - -## EventHub.emit - -emit(event: string, ...args: Object[]): void; - -触发指定事件。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | string | 是 | 事件名称。 | - | ...args | Object[] | 是 | 可变参数,事件触发时,传递给回调函数的参数。 | - -**示例:** - - ```js - import Ability from '@ohos.application.Ability' - - export default class MainAbility extends Ability { - onForeground() { - this.context.eventHub.on("123", this.func1); - // 结果: - // func1 is called,undefined,undefined - this.context.eventHub.emit("123"); - // 结果: - // func1 is called,1,undefined - this.context.eventHub.emit("123", 1); - // 结果: - // func1 is called,1,2 - this.context.eventHub.emit("123", 1, 2); - } - func1(a, b) { - console.log("func1 is called," + a + "," + b); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 36bc2e261e82c3b000d40cb466f54626ff838dec..074f5a954c6c18c569e3d00a76e3f9d484687480 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -1376,9 +1376,9 @@ readTextSync(filePath: string, options?: { | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | --------------------- | ---------- | - | Promise<string> | 返回读取文件的内容。 | + | 类型 | 说明 | + | ------ | -------------------- | + | string | 返回读取文件的内容。 | - 示例: ```js @@ -1532,10 +1532,10 @@ rename(oldPath: string, newPath: string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------------------ | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | - 返回值: | 类型 | 说明 | @@ -1544,7 +1544,7 @@ rename(oldPath: string, newPath: string): Promise<void> - 示例: ```js - fileio.rename(oldPath, Newpath).then(function() { + fileio.rename(oldPath, newPath).then(function() { console.info("rename successfully"); }).catch(function(err){ console.info("rename failed with error:"+ err); @@ -1563,13 +1563,13 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------- | - | oldpath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | | Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | - 示例: ```js - fileio.rename(oldpath, Newpath, function(err){ + fileio.rename(oldPath, newPath, function(err){ }); ``` @@ -1586,11 +1586,11 @@ renameSync(oldPath: string, newPath: string): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ------------ | | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | newPath | String | 是 | 目标文件的新绝对路径。 | - 示例: ```js - fileio.renameSync(oldpath, newpath); + fileio.renameSync(oldPath, newPath); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index 43ab0d49f446b8c94edeb457800dd44cf86e338f..581823d3df733bbe829c68bdad574dc2cfd7ffb7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -21,7 +21,7 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> - 参数 | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | -- | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | - 返回值 @@ -31,17 +31,17 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> - 示例 -```js -filemanager.getRoot().then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}).catch((err) => { - console.log(err) -}); -``` + ```js + filemanager.getRoot().then((fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }).catch((err) => { + console.log(err) + }); + ``` ## filemanager.getRoot @@ -55,20 +55,20 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------------------- | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 示例 -```js -filemanager.getRoot((err, fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}) -``` + ```js + filemanager.getRoot((err, fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }); + ``` ## filemanager.listFile @@ -81,12 +81,10 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num - 参数 | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | -- | - | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | | path | string | 是 | 待查询目录uri | - | dev | [DevInfo](#devinfo) | 是 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | - | offset | number | 否 | 待查询文件偏移 | - | count | number | 否 | 待查询文件个数 | - + | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 | + - 返回值 | 类型 | 说明 | @@ -100,21 +98,24 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 获取目录下所有文件 -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -filemanager.listFile(media_path, "file") -.then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}).catch((err) => { - console.log(err) -}) -``` +- 示例 + + ```js + // 获取目录下所有文件 + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + filemanager.listFile(media_path, "file") + .then((fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }).catch((err) => { + console.log(err) + }); + ``` + ## filemanager.listFile listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback<FileInfo[]>) : void @@ -127,11 +128,9 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | | path | string | 是 | 待查询目录uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | - | offset | number | 否 | 待查询文件偏移 | - | count | number | 否 | 待查询文件个数 | + | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 异常 @@ -141,21 +140,23 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -filemanager.listFile(media_path, "file", (err, fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) - } - } -}) -``` +- 示例 + + ```js + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + filemanager.listFile(media_path, "file", (err, fileInfo) => { + if(Array.isArray(fileInfo)) { + for (var i = 0; i < fileInfo.length; i++) { + console.log(JSON.Stringify(fileInfo)) + } + } + }); + ``` ## filemanager.createFile -filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : promise<string> +filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise<string> 以异步方法创建文件到指定路径,返回文件uri。使用promise形式返回结果。 @@ -166,7 +167,7 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI | --- | --- | --- | -- | | filename | string | 是 | 待创建的文件名 | | path | string | 是 | 待保存目的相册uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | - 返回值 @@ -182,18 +183,20 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 创建文件,返回文件uri -let media_path = file.uri // 通过listFile、getRoot获取的文件uri -let name = "xxx.jpg" // 待保存文件的后缀 -filemanager.createFile(media_path, name) -.then((uri) => { -// 返回uri给应用 -}) -.catch((err) => { - console.log(err) -}) -``` +- 示例 + + ```js + // 创建文件,返回文件uri + let media_path = file.uri // 通过listFile、getRoot获取的文件uri + let name = "xxx.jpg" // 待保存文件的后缀 + filemanager.createFile(media_path, name) + .then((uri) => { + // 返回uri给应用 + }) + .catch((err) => { + console.log(err) + }); + ``` ## filemanager.createFile @@ -209,7 +212,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac | -------- | ------------------------- | ---- | ----------------------------- | | filename | string | 是 | 待创建的文件名 | | path | string | 是 | 待保存目的相册uri | - | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' | + | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' | | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 | - 异常 @@ -221,16 +224,18 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 | | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 | -```js -// 创建文件,返回文件uri -// 通过listFile、getRoot获取的文件uri -let media_path = file.uri -// 待保存文件的后缀 -let name = "xxx.jpg" -filemanager.createFile(media_path, name, (err, uri) => { -// 返回uri给应用 -}) -``` +- 示例 + + ```js + // 创建文件,返回文件uri + // 通过listFile、getRoot获取的文件uri + let media_path = file.uri + // 待保存文件的后缀 + let name = "xxx.jpg" + filemanager.createFile(media_path, name, (err, uri) => { + // 返回uri给应用 + }); + ``` ## FileInfo 文件信息类型,通过getRoot, listFile等接口返回的类型。 @@ -249,12 +254,13 @@ filemanager.createFile(media_path, name, (err, uri) => { | modifiedTime | number | 是 | 否 | 媒体修改时间 | ## DevInfo + 设备类型,配置接口访问的设备类型。 **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.FileManagerService。 ### 属性 - | 参数名 | 类型 | 可读 | 可写 | 说明 | - | --- | -- | -- | -- | -- | - | name | string | 是 | 是 | 设备名称 | \ No newline at end of file +| 参数名 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | -------- | +| name | string | 是 | 是 | 设备名称 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md b/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md index 792d5a022f31915576fcbf608c146479eb901c59..aa0c5ca3acf689555b9fa01aa4e7008ec7466585 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formbindingdata.md @@ -25,7 +25,7 @@ createFormBindingData(obj?: Object | string): FormBindingData | 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| obj | Object或string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。 | +| obj | Object或string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} | **返回值:** @@ -38,7 +38,11 @@ createFormBindingData(obj?: Object | string): FormBindingData **示例:** ```js - let obj = {"temperature": "21°"}; + let fd = fileio.openSync(path); + let obj = { + "temperature": "21°", + "formImages": {"image": fd} + }; let formBindingDataObj = formBindingData.createFormBindingData(obj); ``` @@ -46,10 +50,9 @@ createFormBindingData(obj?: Object | string): FormBindingData FormBindingData相关描述。 -**系统能力**:SystemCapability.Ability.Form +**系统能力**:SystemCapability.Ability.Form -| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | +| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -------- | -------- | -| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。| +| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。| - \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextension.md b/zh-cn/application-dev/reference/apis/js-apis-formextension.md deleted file mode 100644 index d549c1e4651bb39f074ddb6add65c29910626da4..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-formextension.md +++ /dev/null @@ -1,221 +0,0 @@ -# FormExtension - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -提供FormExtension卡片扩展相关接口。 - -## 导入模块 - -``` -import FormExtension from '@ohos.application.FormExtension'; -``` - -## 权限 - -无 - -## 属性 - -**系统能力**:SystemCapability.Ability.Form - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- | -| context | [FormExtensionContext](js-apis-formextensioncontext.md) | 是 | 否 | FormExtension的上下文环境,继承自ExtensionContext。 | - -## onCreate - -onCreate(want: Want): formBindingData.FormBindingData - -卡片提供方接收创建卡片的通知接口。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | - | want | [Want](js-apis-featureAbility.md#want) | 是 | 当前Extension相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 | - -**返回值:** - - | 类型 | 说明 | - | ------------------------------------------------------------ | ----------------------------------------------------------- | - | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 一个formBindingData.FormBindingData对象,卡片要显示的数据。 | - -**示例:** - - ```js - export default class MyFormExtension extends FormExtension { - onCreate(want) { - console.log('FormExtension onCreate, want:' + want.abilityName); - let dataObj1 = { - temperature:"11c", - "time":"11:00" - }; - let obj1 = formBindingData.createFormBindingData(dataObj1); - return obj1; - } - } - ``` - -## FormExtension.onCastToNormal - -onCastToNormal(formId: string): void - -卡片提供方接收临时卡片转常态卡片的通知接口。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------ | - | formId | string | 是 | 请求转换为常态的卡片ID。 | - -**示例:** - - ``` - export default class MyFormExtension extends FormExtension { - onCastToNormal(formId) { - console.log('FormExtension onCastToNormal, formId:' + formId); - } - } - ``` - -## FormExtension.onUpdate - -onUpdate(formId: string): void - -卡片提供方接收更新卡片的通知接口。获取最新数据后调用[FormExtensionContext](js-apis-formextensioncontext.md)的updateForm接口刷新卡片数据。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------ | - | formId | string | 是 | 请求更新的卡片ID。 | - -**示例:** - - ```js - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } - ``` - -## FormExtension.onVisibilityChange - -onVisibilityChange(newStatus: { [key: string]: number }): void - -卡片提供方接收修改可见性的通知接口。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------------- | ---- | ---------------------------- | - | newStatus | { [key: string]: number } | 是 | 请求修改的卡片ID和可见状态。 | - -**示例:** - - ```js - export default class MyFormExtension extends FormExtension { - onVisibilityChange(newStatus) { - console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - - for (let key in newStatus) { - console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); - this.context.updateForm(key, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } - } - ``` - -## FormExtension.onEvent - -onEvent(formId: string, message: string): void - -卡片提供方接收处理卡片事件的通知接口。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ---------------------- | - | formId | string | 是 | 请求触发事件的卡片ID。 | - | message | string | 是 | 事件消息。 | - -**示例:** - - ```js - export default class MyFormExtension extends FormExtension { - onEvent(formId, message) { - console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); - } - } - ``` - -## FormExtension.onDestroy - -onDestroy(formId: string): void - -卡片提供方接收销毁卡片的通知接口。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------ | - | formId | string | 是 | 请求销毁的卡片ID。 | - -**示例:** - - ```js - export default class MyFormExtension extends FormExtension { - onDestroy(formId) { - console.log('FormExtension onDestroy, formId:' + formId); - } - } - ``` - -## FormExtension.onConfigurationUpdated - -onConfigurationUpdated(config: Configuration): void; - -当系统配置更新时调用。 - -**系统能力**:SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | config | [Configuration](#section188911144124715) | 是 | 表示需要更新的配置信息。 | - -**示例:** - - ```js - class MyFormExtension extends MyFormExtension { - onConfigurationUpdated(config) { - console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); - } - } - ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-formhost.md index 987bd8c17e403b86e5a280b73ef3ed4080d06f11..19a314b9bfb27dfef2b964776f1986cd58b1b0b5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formhost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formhost.md @@ -51,15 +51,21 @@ deleteForm(formId: string): Promise<void>; 删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **参数:** @@ -144,6 +150,11 @@ SystemCapability.Ability.Form | formId | string | 是 | 卡片标识 | | isReleaseCache | boolean | 否 | 是否释放缓存 | +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -188,15 +199,21 @@ requestForm(formId: string): Promise<void>; 请求卡片更新。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -241,15 +258,21 @@ castTempForm(formId: string): Promise<void>; 将指定的临时卡片转换为普通卡片。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -294,15 +317,21 @@ notifyVisibleForms(formId: string): Promise<void>; 向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -347,15 +376,21 @@ notifyInvisibleForms(formId: string): Promise<void>; 向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -400,15 +435,21 @@ enableFormsUpdate(formId: string): Promise<void>; 向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -453,15 +494,21 @@ disableFormsUpdate(formId: string): Promise<void>; 向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | formId | string | 是 | 卡片标识 | -**系统能力:** +**返回值:** -SystemCapability.Ability.Form + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | **示例:** @@ -509,6 +556,12 @@ isSystemReady(): Promise<void>; SystemCapability.Ability.Form +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | + **示例:** ```js @@ -627,7 +680,7 @@ SystemCapability.Ability.Form getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<FormInfo>>; -获取设备上所有应用提供的卡片信息。 +获取设备上指定应用程序提供的卡片信息。 **系统能力:** @@ -688,6 +741,10 @@ function deleteInvalidForms(formIds: Array<string>): Promise<number>; 根据列表删除应用程序的无效卡片。 +**系统能力:** + +SystemCapability.Ability.Form + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -700,10 +757,6 @@ function deleteInvalidForms(formIds: Array<string>): Promise<number>; | :------------ | :---------------------------------- | | Promise<number> | Promise实例,用于获取异步返回删除的卡片个数 | -**系统能力:** - -SystemCapability.Ability.Form - **示例:** ```js @@ -747,9 +800,9 @@ SystemCapability.Ability.Form ## acquireFormState -function acquireFormState(formIds: Array<string>): Promise<formInfo.FormStateInfo>; +function acquireFormState(want: Want): Promise<FormStateInfo>; -根据列表删除应用程序的无效卡片。 +获取卡片状态。 **参数:** @@ -784,7 +837,7 @@ SystemCapability.Ability.Form on(type: "formUninstall", callback: Callback<string>): void; -获取卡片状态 +订阅卡片卸载事件。 **系统能力:** @@ -811,7 +864,7 @@ SystemCapability.Ability.Form off(type: "formUninstall", callback: Callback<string>): void; -获取卡片状态 +取消订阅卡片卸载事件。 **系统能力:** @@ -880,6 +933,12 @@ SystemCapability.Ability.Form | formIds | Array<string> | 是 | 卡片标识列表 | | isVisible | boolean | 是 | 是否可见 | +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | + **示例:** ```js @@ -935,6 +994,12 @@ SystemCapability.Ability.Form | formIds | Array<string> | 是 | 卡片标识列表 | | isEnableUpdate | boolean | 是 | 是否使能更新 | +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包含接口的结果 | + **示例:** ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-huks.md b/zh-cn/application-dev/reference/apis/js-apis-huks.md index 8eb5c87bdbe0ea6c41eda444afb5d81c61f23a69..42c0bd644dc50df6c5e86dc74670cffd36552c60 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-huks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-huks.md @@ -91,21 +91,21 @@ import huks from '@ohos.security.huks' ## HuksKeyPurpose -表示密钥(密钥对)用途。 +表示密钥用途。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 -| 名称 | 值 | 说明 | -| ------------------------ | ---- | ------------------------------------------ | -| HUKS_KEY_PURPOSE_ENCRYPT | 1 | 表示密钥(密钥对)用于对明文进行加密操作。 | -| HUKS_KEY_PURPOSE_DECRYPT | 2 | 表示密钥(密钥对)用于对密文进行解密操作。 | -| HUKS_KEY_PURPOSE_SIGN | 4 | 表示密钥对用于对数据进行签名。 | -| HUKS_KEY_PURPOSE_VERIFY | 8 | 表示密钥对用于验证签名后的数据。 | -| HUKS_KEY_PURPOSE_DERIVE | 16 | 表示密钥用于派生密钥。 | -| HUKS_KEY_PURPOSE_WRAP | 32 | 表示密钥用于加密导入。 | -| HUKS_KEY_PURPOSE_UNWRAP | 64 | 表示密钥加密导出。 | -| HUKS_KEY_PURPOSE_MAC | 128 | 表示密钥用于生成mac消息验证码。 | -| HUKS_KEY_PURPOSE_AGREE | 256 | 表示密钥对用于进行密钥协商。 | +| 名称 | 值 | 说明 | +| ------------------------ | ---- | -------------------------------- | +| HUKS_KEY_PURPOSE_ENCRYPT | 1 | 表示密钥用于对明文进行加密操作。 | +| HUKS_KEY_PURPOSE_DECRYPT | 2 | 表示密钥用于对密文进行解密操作。 | +| HUKS_KEY_PURPOSE_SIGN | 4 | 表示密钥用于对数据进行签名。 | +| HUKS_KEY_PURPOSE_VERIFY | 8 | 表示密钥用于验证签名后的数据。 | +| HUKS_KEY_PURPOSE_DERIVE | 16 | 表示密钥用于派生密钥。 | +| HUKS_KEY_PURPOSE_WRAP | 32 | 表示密钥用于加密导入。 | +| HUKS_KEY_PURPOSE_UNWRAP | 64 | 表示密钥加密导出。 | +| HUKS_KEY_PURPOSE_MAC | 128 | 表示密钥用于生成mac消息验证码。 | +| HUKS_KEY_PURPOSE_AGREE | 256 | 表示密钥用于进行密钥协商。 | ## HuksKeyDigest @@ -155,30 +155,30 @@ import huks from '@ohos.security.huks' ## HuksKeySize -表示密钥(密钥对)长度。 +表示密钥长度。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 -| 名称 | 值 | 说明 | -| ---------------------------- | ---- | -------------------------------------------- | -| HUKS_RSA_KEY_SIZE_512 | 512 | 表示使用RSA算法的密钥对长度为512bit。 | -| HUKS_RSA_KEY_SIZE_768 | 768 | 表示使用RSA算法的密钥对长度为768bit。 | -| HUKS_RSA_KEY_SIZE_1024 | 1024 | 表示使用RSA算法的密钥对长度为1024bit。 | -| HUKS_RSA_KEY_SIZE_2048 | 2048 | 表示使用RSA算法的密钥对长度为2048bit。 | -| HUKS_RSA_KEY_SIZE_3072 | 3072 | 表示使用RSA算法的密钥对长度为3072bit。 | -| HUKS_RSA_KEY_SIZE_4096 | 4096 | 表示使用RSA算法的密钥对长度为4096bit。 | -| HUKS_ECC_KEY_SIZE_224 | 224 | 表示使用ECC算法的密钥对长度为224bit。 | -| HUKS_ECC_KEY_SIZE_256 | 256 | 表示使用ECC算法的密钥对长度为256bit。 | -| HUKS_ECC_KEY_SIZE_384 | 384 | 表示使用ECC算法的密钥对长度为384bit。 | -| HUKS_ECC_KEY_SIZE_521 | 521 | 表示使用ECC算法的密钥对长度为521bit。 | -| HUKS_AES_KEY_SIZE_128 | 128 | 表示使用AES算法的密钥长度为128bit。 | -| HUKS_AES_KEY_SIZE_192 | 196 | 表示使用AES算法的密钥长度为196bit。 | -| HUKS_AES_KEY_SIZE_256 | 256 | 表示使用AES算法的密钥长度为256bit。 | -| HUKS_AES_KEY_SIZE_512 | 512 | 表示使用AES算法的密钥长度为512bit。 | -| HUKS_CURVE25519_KEY_SIZE_256 | 256 | 表示使用CURVE25519算法的密钥对长度为256bit。 | -| HUKS_DH_KEY_SIZE_2048 | 2048 | 表示使用DH算法的密钥对长度为2048bit。 | -| HUKS_DH_KEY_SIZE_3072 | 3072 | 表示使用DH算法的密钥对长度为3072bit。 | -| HUKS_DH_KEY_SIZE_4096 | 4096 | 表示使用DH算法的密钥对长度为4096bit。 | +| 名称 | 值 | 说明 | +| ---------------------------- | ---- | ------------------------------------------ | +| HUKS_RSA_KEY_SIZE_512 | 512 | 表示使用RSA算法的密钥长度为512bit。 | +| HUKS_RSA_KEY_SIZE_768 | 768 | 表示使用RSA算法的密钥长度为768bit。 | +| HUKS_RSA_KEY_SIZE_1024 | 1024 | 表示使用RSA算法的密钥长度为1024bit。 | +| HUKS_RSA_KEY_SIZE_2048 | 2048 | 表示使用RSA算法的密钥长度为2048bit。 | +| HUKS_RSA_KEY_SIZE_3072 | 3072 | 表示使用RSA算法的密钥长度为3072bit。 | +| HUKS_RSA_KEY_SIZE_4096 | 4096 | 表示使用RSA算法的密钥长度为4096bit。 | +| HUKS_ECC_KEY_SIZE_224 | 224 | 表示使用ECC算法的密钥长度为224bit。 | +| HUKS_ECC_KEY_SIZE_256 | 256 | 表示使用ECC算法的密钥长度为256bit。 | +| HUKS_ECC_KEY_SIZE_384 | 384 | 表示使用ECC算法的密钥长度为384bit。 | +| HUKS_ECC_KEY_SIZE_521 | 521 | 表示使用ECC算法的密钥长度为521bit。 | +| HUKS_AES_KEY_SIZE_128 | 128 | 表示使用AES算法的密钥长度为128bit。 | +| HUKS_AES_KEY_SIZE_192 | 196 | 表示使用AES算法的密钥长度为196bit。 | +| HUKS_AES_KEY_SIZE_256 | 256 | 表示使用AES算法的密钥长度为256bit。 | +| HUKS_AES_KEY_SIZE_512 | 512 | 表示使用AES算法的密钥长度为512bit。 | +| HUKS_CURVE25519_KEY_SIZE_256 | 256 | 表示使用CURVE25519算法的密钥长度为256bit。 | +| HUKS_DH_KEY_SIZE_2048 | 2048 | 表示使用DH算法的密钥长度为2048bit。 | +| HUKS_DH_KEY_SIZE_3072 | 3072 | 表示使用DH算法的密钥长度为3072bit。 | +| HUKS_DH_KEY_SIZE_4096 | 4096 | 表示使用DH算法的密钥长度为4096bit。 | ## HuksKeyAlg @@ -254,14 +254,14 @@ import huks from '@ohos.security.huks' **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 -| 名称 | 值 | 说明 | -| --------------------- | ------- | --------------------------------- | -| HUKS_TAG_TYPE_INVALID | 0 << 28 | 表示非法的Tag类型。 | -| HUKS_TAG_TYPE_INT | 1 << 28 | 表示该Tag的数据类型为number。 | -| HUKS_TAG_TYPE_UINT | 2 << 28 | 表示该Tag的数据类型为number。 | -| HUKS_TAG_TYPE_ULONG | 3 << 28 | 表示该Tag的数据类型为bigint。 | -| HUKS_TAG_TYPE_BOOL | 4 << 28 | 表示该Tag的数据类型为boolean。 | -| HUKS_TAG_TYPE_BYTES | 5 << 28 | 表示该Tag的数据类型为Uint8Array。 | +| 名称 | 值 | 说明 | +| --------------------- | ------- | --------------------------------------- | +| HUKS_TAG_TYPE_INVALID | 0 << 28 | 表示非法的Tag类型。 | +| HUKS_TAG_TYPE_INT | 1 << 28 | 表示该Tag的数据类型为int类型的number。 | +| HUKS_TAG_TYPE_UINT | 2 << 28 | 表示该Tag的数据类型为uint类型的number。 | +| HUKS_TAG_TYPE_ULONG | 3 << 28 | 表示该Tag的数据类型为bigint。 | +| HUKS_TAG_TYPE_BOOL | 4 << 28 | 表示该Tag的数据类型为boolean。 | +| HUKS_TAG_TYPE_BYTES | 5 << 28 | 表示该Tag的数据类型为Uint8Array。 | ## HuksTag @@ -273,15 +273,15 @@ import huks from '@ohos.security.huks' | -------------------------------------- | ---------------------------------------- | -------------------------------------- | | HUKS_TAG_INVALID | HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | 表示非法的Tag。 | | HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | 表示算法的Tag。 | -| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | 表示密钥(密钥对)用途的Tag。 | -| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | 表示密钥(密钥对)长度的Tag。 | +| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | 表示密钥用途的Tag。 | +| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | 表示密钥长度的Tag。 | | HUKS_TAG_DIGEST | HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | 表示摘要算法的Tag。 | | HUKS_TAG_PADDING | HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | 表示补齐算法的Tag。 | | HUKS_TAG_BLOCK_MODE | HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | 表示加密模式的Tag。 | | HUKS_TAG_KEY_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | 表示密钥类型的Tag。 | -| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | 表示表示附加身份验证数据的Tag。 | -| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | 表示表示密钥偏移量的Tag。 | -| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | 表示表示密钥偏移量的Tag。 | +| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | 表示附加身份验证数据的Tag。 | +| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | 表示密钥加解密的字段。 | +| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | 表示密钥初始化的向量。 | | HUKS_TAG_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | 表示密钥派生时的info。 | | HUKS_TAG_SALT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | 表示密钥派生时的盐值。 | | HUKS_TAG_PWD | HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | 表示密钥派生时的password。 | @@ -352,7 +352,7 @@ import huks from '@ohos.security.huks' generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void -生成密钥(密钥对),使用Callback回调异步返回结果。 +生成密钥,使用Callback回调异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -403,7 +403,7 @@ huks.generateKey(alias, options, function (err, data){}); generateKey(keyAlias: string, options: HuksOptions) : Promise\ -生成密钥(密钥对),使用Promise方式异步返回结果。 +生成密钥,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -528,9 +528,9 @@ getSdkVersion(options: HuksOptions) : string **返回值:** -| 类型 | 说明 | -| ------ | ------------------------------------------------------------ | -| string | 返回sdk版本。
**系统能力**:SystemCapability.Security.Huks | +| 类型 | 说明 | +| ------ | ------------- | +| string | 返回sdk版本。 | **示例:** @@ -545,7 +545,7 @@ var result = huks.getSdkVersion(emptyOptions); importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void -导入密钥对,使用Callback方式回调异步返回结果 。 +导入密钥,使用Callback方式回调异步返回结果 。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -593,7 +593,7 @@ huks.importKey(keyAlias, options, function (err, data){}); importKey(keyAlias: string, options: HuksOptions) : Promise\ -导入密钥对,使用Promise方式异步返回结果。 +导入密钥,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -646,7 +646,7 @@ var result = huks.importKey(keyAlias, options); exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void -导出密钥对,使用Callback方式回调异步返回的结果。 +导出密钥,使用Callback方式回调异步返回的结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -672,7 +672,7 @@ huks.exportKey(keyAlias, emptyOptions, function (err, data){}); exportKey(keyAlias: string, options: HuksOptions) : Promise\ -导出密钥对,使用Promise方式回调异步返回的结果。 +导出密钥,使用Promise方式回调异步返回的结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -687,7 +687,7 @@ exportKey(keyAlias: string, options: HuksOptions) : Promise\ | 类型 | 说明 | | ----------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksresult)> | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。
**系统能力**:SystemCapability.Security.Huks | +| Promise\<[HuksResult](#huksresult)> | 返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | **示例:** @@ -713,7 +713,7 @@ getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误properties:返回值为从生成key时传入的别名。中导出的生成密钥时所需参数。 | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | **示例:** @@ -737,14 +737,14 @@ getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------- | ---- | ------------------------------------------------------------ | -| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。
**系统能力**:SystemCapability.Security.Huks | -| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。
**系统能力**:SystemCapability.Security.Huks | +| keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | +| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | **返回值:** | 类型 | 说明 | | ------------------ | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksoptions)> | errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。properties:返回值为从生成key时传入的别名。中导出的生成密钥时所需参数。
**系统能力**:SystemCapability.Security.Huks | +| Promise\<[HuksResult](#huksoptions)> | errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。properties:返回值为从生成key时传入的别名。中导出的生成密钥时所需参数。 | **示例:** @@ -818,7 +818,7 @@ var result = huks.isKeyExist(keyAlias, emptyOptions); init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void -init操作接口,使用Callback回调异步返回结果 。 +init操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -863,7 +863,7 @@ huks.init(alias, options, function(err, data) { init(keyAlias: string, options: HuksOptions) : Promise\ -init操作接口,使用Promise方式异步返回结果。 +init操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -913,7 +913,7 @@ huks.init(alias, options).then((data) => { update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback\) : void -update操作接口,使用Callback回调异步返回结果 。 +update操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -952,7 +952,7 @@ huks.update(handle, options, function (err, data){}); update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\ -update操作接口,使用Promise方式异步返回结果。 +update操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -991,7 +991,7 @@ var result = huks.update(handle, options) finish(handle: number, options: HuksOptions, callback: AsyncCallback\) : void -finish操作接口,使用Callback回调异步返回结果 。 +finish操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -1029,7 +1029,7 @@ huks.finish(handle, options, function (err, data){}); finish(handle: number, options: HuksOptions) : Promise\ -finish操作接口,使用Promise方式异步返回结果。 +finish操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -1068,7 +1068,7 @@ var result = huks.finish(handle, options) abort(handle: number, options: HuksOptions, callback: AsyncCallback\) : void -abort操作接口,使用Callback回调异步返回结果 。 +abort操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 @@ -1106,7 +1106,7 @@ huks.abort(handle, options, function (err, data){}); abort(handle: number, options: HuksOptions) : Promise\; -abort操作接口,使用Promise方式异步返回结果。 +abort操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Security.Huks。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 394f072cad66ee11f4c0c31c1b74df6b71bdd72f..288224034f0ceb866bc5f3d979bd0bf40c2a4471 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -990,40 +990,14 @@ release(): Promise\ | RGBA_8888 | 3 | 格式为RGBA_8888。 | | RGB_565 | 2 | 格式为RGB_565。 | -## AlphaType9+ - -枚举,透明度。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image - -| 名称 | 默认值 | 描述 | -| -------- | ------ | ----------------------- | -| UNKNOWN | 0 | 未知透明度。 | -| OPAQUE | 1 | 没有alpha或图片全透明。 | -| PREMUL | 2 | RGB前乘alpha。 | -| UNPREMUL | 3 | RGB不前乘alpha。 | - -## ScaleMode9+ - -枚举,缩略值。 - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image - -| 名称 | 默认值 | 描述 | -| --------------- | ------ | -------------------------------------------------- | -| CENTER_CROP | 1 | 缩放图像以填充目标图像区域并居中裁剪区域外的效果。 | -| FIT_TARGET_SIZE | 2 | 图像适合目标尺寸的效果。 | - ## InitializationOptions8+ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image | 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ---------------------------------- | ---- | ---- | -------------- | -| alphaType9+ | [AlphaType](#alphatype9) | 是 | 是 | 透明度。 | | editable | boolean | 是 | 是 | 是否可编辑。 | | pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 像素格式。 | -| scaleMode9+ | [ScaleMode](#scalemode9) | 是 | 是 | 缩略值。 | | size | [Size](#size) | 是 | 是 | 创建图片大小。 | ## DecodingOptions7+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index f1918f7ba4a8292824d5530977bd4df62b193dc2..0ecd9b3257546692b81781d2d41ee55897e7ae56 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -27,7 +27,7 @@ import inputMethodEngine from '@ohos.inputMethodEngine'; | PATTERN_NULL | number | 是 | 否 | 无特殊性编辑框。 | | PATTERN_TEXT | number | 是 | 否 | 文本编辑框。 | | PATTERN_NUMBER | number | 是 | 否 | 数字编辑框。 | -| PATTERN_PHONE | number | 是 | 否 | 电话编辑框。 | +| PATTERN_PHONE | number | 是 | 否 | 电话号码编辑框。 | | PATTERN_DATETIME | number | 是 | 否 | 日期编辑框。 | | PATTERN_EMAIL | number | 是 | 否 | 邮件编辑框。 | | PATTERN_URI | number | 是 | 否 | 超链接编辑框。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-logs.md b/zh-cn/application-dev/reference/apis/js-apis-logs.md index 7d674cff693aca7487a509296c378803051e5d8a..ed92b8b2c47d6826c1ba0c90178046cca60678ba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-logs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-logs.md @@ -1,5 +1,8 @@ # 日志打印 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.hilog`](js-apis-hilog.md)'。 + ## console.debug debug(message: string): void @@ -7,9 +10,9 @@ debug(message: string): void 打印debug级别的日志信息。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 表示要打印的文本信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ----------- | + | message | string | 是 | 表示要打印的文本信息。 | ## console.log @@ -19,9 +22,9 @@ log(message: string): void 打印debug级别的日志信息。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 表示要打印的文本信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ----------- | + | message | string | 是 | 表示要打印的文本信息。 | ## console.info @@ -31,9 +34,9 @@ info(message: string): void 打印info级别的日志信息。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 表示要打印的文本信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ----------- | + | message | string | 是 | 表示要打印的文本信息。 | ## console.warn @@ -43,9 +46,9 @@ warn(message: string): void 打印warn级别的日志信息。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 表示要打印的文本信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ----------- | + | message | string | 是 | 表示要打印的文本信息。 | ## console.error @@ -55,9 +58,9 @@ error(message: string): void 打印error级别的日志信息。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 表示要打印的文本信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ----------- | + | message | string | 是 | 表示要打印的文本信息。 | ## 示例 diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index e9d157b0c6fc7efdc439193399c90d544281dbd8..d06ccedc0a1ff197c4dc756097a3affa1ad597b9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -10,7 +10,6 @@ - 音频播放([AudioPlayer](#audioplayer)) - 视频播放([VideoPlayer](#videoplayer8)) - 音频录制([AudioRecorder](#audiorecorder)) -- 视频录制([VideoRecorder](#videorecorder9)) 后续将提供以下功能:DataSource音视频播放、音视频编解码、容器封装解封装、媒体能力查询等功能。 @@ -125,73 +124,6 @@ createAudioRecorder(): AudioRecorder let audiorecorder = media.createAudioRecorder(); ``` -## media.createVideoRecorder9+ - -createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void - -异步方式创建视频录制实例。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | 是 | 异步创建视频录制实例回调方法。 | - -**示例:** - -```js -let videoRecorder - -media.createVideoRecorder((error, video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info(`video createVideoRecorder fail, error:${error.message}`); - } -}); -``` - -## media.createVideoRecorder9+ - -createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> - -异步方式创建视频录制实例。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | 异步创建视频录制实例Promise返回值。 | - -**示例:** - -```js -let videoRecorder - -function failureCallback(error) { - console.info(`video failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`video catchCallback, error:${error.message}`); -} - -await media.createVideoRecorder.then((video) => { - if (typeof(video) != 'undefined') { - videoRecorder = video; - console.info('video createVideoRecorder success'); - } else { - console.info('video createVideoRecorder fail'); - } -}, failureCallback).catch(catchCallback); -``` - - - ## MediaErrorCode8+ 媒体服务错误类型枚举。 @@ -1842,662 +1774,6 @@ audioRecorder.prepare(); // pre | AMR_WB | 4 | 封装为AMR_WB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | | AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。 | -## VideoRecorder9+ - -视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#mediacreatevideorecorder9)构建一个[VideoRecorder](#videorecorder9)实例。 - -视频录制demo可参考:[视频录制开发指导](../../media/video-recorder.md) - -### 属性 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------------ | -------------------------------------- | ---- | ---- | ---------------- | -| state8+ | [VideoRecordState](#videorecordstate9) | 是 | 否 | 视频录制的状态。 | - -### prepare9+ - -prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; - -异步方式进行视频录制的参数设置。通过注册回调函数获取返回值。 - -**需要权限:** ohos.permission.MICROPHONE - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------------- | ---- | ----------------------------------- | -| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | -| callback | AsyncCallback\ | 是 | 异步视频录制prepare方法的回调方法。 | - -**示例:** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// asyncallback -let videoRecorder = null; -let events = require('events'); -let eventEmitter = new events.EventEmitter(); - -eventEmitter.on('prepare', () => { - videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { - console.info('prepare success'); - } else { - console.info('prepare failed and error is ' + err.message); - } - }); -}); - -media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined' && typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - eventEmitter.emit('prepare'); // prepare事件触发 - } else { - console.info('createVideoRecorder failed and error is ' + err.message); - } -}); -``` - -### prepare9+ - -prepare(config: VideoRecorderConfig): Promise\; - -异步方式进行视频录制的参数设置。通过Promise获取返回值。 - -**需要权限:** ohos.permission.MICROPHONE,ohos.permission.CAMERA - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------------------------------------- | ---- | ------------------------ | -| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | - -**返回值:** - -| 类型 | 说明 | -| -------------- | ---------------------------------------- | -| Promise\ | 异步视频录制prepare方法的Promise返回值。 | - -**示例:** - -```js -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} - -let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// promise -let videoRecorder = null; -await media.createVideoRecorder().then((recorder) => { - if (typeof (recorder) != 'undefined') { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - } else { - console.info('createVideoRecorder failed'); - } -}, (err) => { - console.info('error hanppend message is ' + err.message); -}).catch((err) => { - console.info('catch err error message is ' + err.message); -}); - -await videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); -}, (err) => { - console.info('prepare failed and error is ' + err.message); -}).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); -}); -``` - -### getInputSurface9+ - -getInputSurface(callback: AsyncCallback\): void; - -异步方式获得录制需要的surface。此surface提供给调用者,调用者从此surface中获取surfaceBuffer,填入相应的数据。 - -应当注意,填入的视频数据需要携带时间戳(单位ns),buffersize。时间戳的起始时间请以系统启动时间为基准。 - -只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | --------------------------- | -| callback | AsyncCallback\ | 是 | 异步获得surface的回调方法。 | - -**示例:** - -```js -// asyncallback -let surfaceID = null; // 传递给外界的surfaceID -videoRecorder.getInputSurface((err, surfaceId) => { - if (typeof (err) == 'undefined') { - console.info('getInputSurface success'); - surfaceID = surfaceId; - } else { - console.info('getInputSurface failed and error is ' + err.message); - } -}); -``` - -### getInputSurface9+ - -getInputSurface(): Promise\; - - 异步方式获得录制需要的surface。此surface提供给调用者,调用者从此surface中获取surfaceBuffer,填入相应的数据。 - -应当注意,填入的视频数据需要携带时间戳(单位ns),buffersize。时间戳的起始时间请以系统启动时间为基准。 - -只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| ---------------- | -------------------------------- | -| Promise\ | 异步获得surface的Promise返回值。 | - -**示例:** - -```js -// promise -let surfaceID = null; // 传递给外界的surfaceID -await videoRecorder.getInputSurface().then((surfaceId) => { - console.info('getInputSurface success'); - surfaceID = surfaceId; -}, (err) => { - console.info('getInputSurface failed and error is ' + err.message); -}).catch((err) => { - console.info('getInputSurface failed and catch error is ' + err.message); -}); -``` - -### start9+ - -start(callback: AsyncCallback\): void; - -异步方式开始视频录制。通过注册回调函数获取返回值。 - -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步开始视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { - console.info('start videorecorder success'); - } else { - console.info('start videorecorder failed and error is ' + err.message); - } -}); -``` - -### start9+ - -start(): Promise\; - -异步方式开始视频录制。通过Promise获取返回值。 - -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步开始视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.start().then(() => { - console.info('start videorecorder success'); -}, (err) => { - console.info('start videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('start videorecorder failed and catch error is ' + err.message); -}); -``` - -### pause9+ - -pause(callback: AsyncCallback\): void; - -异步方式暂停视频录制。通过注册回调函数获取返回值。 - -在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步暂停视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { - console.info('pause videorecorder success'); - } else { - console.info('pause videorecorder failed and error is ' + err.message); - } -}); -``` - -### pause9+ - -pause(): Promise\; - -异步方式暂停视频录制。通过Promise获取返回值。 - -在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步暂停视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.pause().then(() => { - console.info('pause videorecorder success'); -}, (err) => { - console.info('pause videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('pause videorecorder failed and catch error is ' + err.message); -}); -``` - -### resume9+ - -resume(callback: AsyncCallback\): void; - -异步方式恢复视频录制。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步恢复视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { - console.info('resume videorecorder success'); - } else { - console.info('resume videorecorder failed and error is ' + err.message); - } -}); -``` - -### resume9+ - -resume(): Promise\; - -异步方式恢复视频录制。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步恢复视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.resume().then(() => { - console.info('resume videorecorder success'); -}, (err) => { - console.info('resume videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('resume videorecorder failed and catch error is ' + err.message); -}); -``` - -### stop9+ - -stop(callback: AsyncCallback\): void; - -异步方式停止视频录制。通过注册回调函数获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步停止视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { - console.info('stop videorecorder success'); - } else { - console.info('stop videorecorder failed and error is ' + err.message); - } -}); -``` - -### stop9+ - -stop(): Promise\; - -异步方式停止视频录制。通过Promise获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步停止视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.stop().then(() => { - console.info('stop videorecorder success'); -}, (err) => { - console.info('stop videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('stop videorecorder failed and catch error is ' + err.message); -}); -``` - -### release9+ - -release(callback: AsyncCallback\): void; - -异步方式释放视频录制资源。通过注册回调函数获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 异步释放视频录制资源的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { - console.info('release videorecorder success'); - } else { - console.info('release videorecorder failed and error is ' + err.message); - } -}); -``` - -### release9+ - -release(): Promise\; - -异步方式释放视频录制资源。通过Promise获取返回值。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ----------------------------------------- | -| Promise\ | 异步释放视频录制资源方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.release().then(() => { - console.info('release videorecorder success'); -}, (err) => { - console.info('release videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('release videorecorder failed and catch error is ' + err.message); -}); -``` - -### reset9+ - -reset(callback: AsyncCallback\): void; - -异步方式重置视频录制。通过注册回调函数获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------- | -| callback | AsyncCallback\ | 是 | 异步重置视频录制的回调方法。 | - -**示例:** - -```js -// asyncallback -videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { - console.info('reset videorecorder success'); - } else { - console.info('reset videorecorder failed and error is ' + err.message); - } -}); -``` - -### reset9+ - -reset(): Promise\; - -异步方式重置视频录制。通过Promise获取返回值。 - -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**返回值:** - -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 异步重置视频录制方法的Promise返回值。 | - -**示例:** - -```js -// promise -await videoRecorder.reset().then(() => { - console.info('reset videorecorder success'); -}, (err) => { - console.info('reset videorecorder failed and error is ' + err.message); -}).catch((err) => { - console.info('reset videorecorder failed and catch error is ' + err.message); -}); -``` - -### on('error')9+ - -on(type: 'error', callback: ErrorCallback): void - -开始订阅视频录制错误事件。 - -**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 录制错误事件回调类型'error'。
- 'error':视频录制过程中发生错误,触发该事件。 | -| callback | ErrorCallback | 是 | 录制错误事件回调方法。 | - -**示例:** - -```js -videoRecorder.on('error', (error) => { // 设置'error'事件回调 - console.info(`audio error called, errName is ${error.name}`); // 打印错误类型名称 - console.info(`audio error called, errCode is ${error.code}`); // 打印错误码 - console.info(`audio error called, errMessage is ${error.message}`); // 打印错误类型详细描述 -}); -// 当获取videoRecordState接口出错时通过此订阅事件上报 -``` - -## VideoRecordState9+ - -视频录制的状态机。可通过state属性获取当前状态。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 类型 | 描述 | -| -------- | ------ | ---------------------- | -| idle | string | 视频录制空闲。 | -| prepared | string | 视频录制参数设置完成。 | -| playing | string | 视频正在录制。 | -| paused | string | 视频暂停录制。 | -| stopped | string | 视频录制停止。 | -| error | string | 错误状态。 | - -## VideoRecorderConfig9+ - -表示视频录制的参数设置。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 参数类型 | 必填 | 说明 | -| --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype9) | 是 | 视频录制的音频源类型。 | -| videoSourceType | [VideoSourceType](#videosourcetype9) | 是 | 视频录制的视频源类型。 | -| profile | [VideoRecorderProfile](#videorecorderprofile9) | 是 | 视频录制的profile。 | -| rotation | number | 否 | 录制视频的旋转角度。 | -| location | [Location](#location) | 否 | 录制视频的地理位置。 | -| url | string | 是 | 视频输出URL:fd://xx (fd number)
![](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | - -## AudioSourceType9+ - -表示视频录制中音频源类型的枚举。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 值 | 说明 | -| ------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT | 0 | 默认的音频输入源类型。 | -| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | - -## VideoSourceType9+ - -表示视频录制中视频源类型的枚举。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------- | -| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。 | -| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | 输入surface中携带的是ES data。 | - -## VideoRecorderProfile9+ - -视频录制的配置文件。 - -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 - -| 名称 | 参数类型 | 必填 | 说明 | -| ---------------- | -------------------------------------------- | ---- | ---------------- | -| audioBitrate | number | 是 | 音频编码比特率。 | -| audioChannels | number | 是 | 音频采集声道数。 | -| audioCodec | [CodecMimeType](#codecmimetype8) | 是 | 音频编码格式。 | -| audioSampleRate | number | 是 | 音频采样率。 | -| fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式。 | -| videoBitrate | number | 是 | 视频编码比特率。 | -| videoCodec | [CodecMimeType](#codecmimetype8) | 是 | 视频编码格式。 | -| videoFrameWidth | number | 是 | 录制视频帧的宽。 | -| videoFrameHeight | number | 是 | 录制视频帧的高。 | -| videoFrameRate | number | 是 | 录制视频帧率。 | - ## ContainerFormatType8+ 表示容器格式类型的枚举,缩写为CFT。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index f0ce12ad547ef80ba0287d4d02257ff77b528c1e..4fa7c3841d39ff0f9830de2bea197f0bcc6ac87c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -1149,15 +1149,19 @@ getThumbnail(size?: Size): Promise<image.PixelMap> async function example() { let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], - order: fileKeyObj.DATE_ADDED + " DESC", - extendArgs: "", + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.getThumbnail(size, (err, pixelmap) => { + asset.getThumbnail(size) + .then((pixelmap) => { console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }) + .catch((err) => { + console.info('mediaLibraryTest : getThumbnail fail'+ err); }); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index 29b2b81af235e6e1d14b5a6611b0e4de46fee058..d62301a861d579430bf1505663dda5e8926b02e5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -684,83 +684,14 @@ netConnection.unregister(function (error) { | ------ | ------ | ------------------------- | | netId | number | 网络ID,必须大于等于100。 | -### bindSocket - -bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void - -将TCPSocket或UDPSocket绑定到当前网络,使用callback方式作为异步方法。 - -**系统能力**:SystemCapability.Communication.NetManager.Core - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | ---------------- | -| socketParam | TCPSocket \| UDPSocket | 是 | TCPSocket或UDPSocket对象。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -``` -// 绑定TCPSocket -connection.getDefaultNet().then(function (netHandle) { - let tcpSocket = socket.constructTCPSocketInstance() - netHandle.bindSocket(tcpSocket, (function (error) { - console.log(JSON.stringify(error)) - })) -}) -// 绑定UDPSocket -connection.getDefaultNet().then(function (netHandle) { - let udpSocket = socket.constructUDPSocketInstance() - netHandle.bindSocket(udpSocket, (function (error) { - console.log(JSON.stringify(error)) - })) -}) -``` - - -### bindSocket - -bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void> - -将TCPSocket或UDPSocket绑定到当前网络,使用promise方式作为异步方法。 - -**系统能力**:SystemCapability.Communication.NetManager.Core - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| socketParam | TCPSocket \| UDPSocket | 是 | TCPSocket或UDPSocket对象。 | - -**返回值:** -| 类型 | 说明 | -| ------------------- | --------------------------- | -| Promise<void> | 以Promise形式返回执行结果。 | - -**示例:** - -``` -// 绑定TCPSocket -connection.getDefaultNet().then(function (netHandle) { - let tcpSocket = socket.constructTCPSocketInstance() - netHandle.bindSocket(tcpSocket).then(function () { - console.log("bind socket success") - }) -}) -// 绑定UDPSocket -connection.getDefaultNet().then(function (netHandle) { - let udpSocket = socket.constructUDPSocketInstance() - netHandle.bindSocket(udpSocket).then(function () { - console.log("bind socket success") - }) -}) -``` - ### getAddressesByName getAddressesByName(host: string, callback: AsyncCallback\>): void 使用对应网络解析主机名以获取所有IP地址,使用callback方式作为异步方法。 +**需要权限**:ohos.permission.GET_NETWORK_INFO + **系统能力**:SystemCapability.Communication.NetManager.Core **参数:** @@ -788,6 +719,8 @@ getAddressesByName(host: string): Promise\> 使用对应网络解析主机名以获取所有IP地址,使用Promise方式作为异步方法。 +**需要权限**:ohos.permission.GET_NETWORK_INFO + **系统能力**:SystemCapability.Communication.NetManager.Core **参数:** @@ -819,6 +752,8 @@ getAddressByName(host: string, callback: AsyncCallback\): void 使用对应网络解析主机名以获取第一个IP地址,使用callback方式作为异步方法。 +**需要权限**:ohos.permission.GET_NETWORK_INFO + **系统能力**:SystemCapability.Communication.NetManager.Core **参数:** @@ -846,6 +781,8 @@ getAddressByName(host: string): Promise\ 使用对应网络解析主机名以获取第一个IP地址,使用Promise方式作为异步方法。 +**需要权限**:ohos.permission.GET_NETWORK_INFO + **系统能力**:SystemCapability.Communication.NetManager.Core **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index b4cae9b30cec783dd4ae362f52311c30ed48c29a..95379aa8e493b38cfb95651ebd38610324dbe478 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -185,7 +185,7 @@ Notification.cancel(0, "label", cancelCallback) ## Notification.cancel -cancel(id:number, label?:string): Promise\ +cancel(id:number, label?: string): Promise\ 取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 @@ -2109,7 +2109,7 @@ Notification.supportDoNotDisturbMode().then((data) => { isSupportTemplate(templateName: string, callback: AsyncCallback\): void -查询模板是否存在。 +查询模板是否存在(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2137,7 +2137,7 @@ Notification.isSupportTemplate(templateName, isSupportTemplateCallback); isSupportTemplate(templateName: string): Promise\ -查询模板是否存在。 +查询模板是否存在(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2169,7 +2169,7 @@ Notification.isSupportTemplate(templateName).then((data) => { requestEnableNotification(callback: AsyncCallback\): void -应用请求通知使能。 +应用请求通知使能(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2195,7 +2195,7 @@ Notification.requestEnabledNotification(requestEnabledNotificationCallback); requestEnableNotification(): Promise\ -应用请求通知使能。 +应用请求通知使能(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2213,7 +2213,7 @@ Notification.requestEnableNotification() enableDistributed(enable: boolean, callback: AsyncCallback\): void -设置设备是否支持分布式通知。 +设置设备是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2242,7 +2242,7 @@ Notification.enableDistributed(enable, enabledNotificationCallback); enableDistributed(enable: boolean): Promise\ -设置设备是否支持分布式通知。 +设置设备是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2268,7 +2268,7 @@ Notification.enableDistributed(enable) isDistributedEnabled(callback: AsyncCallback\): void -获取设备是否支持分布式通知。 +获取设备是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2294,7 +2294,7 @@ Notification.enableDistributed(isDistributedEnabledCallback); isDistributedEnabled(): Promise\ -获取设备是否支持分布式通知。 +获取设备是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2318,7 +2318,7 @@ Notification.isDistributedEnabled() enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -根据应用的包设置应用程序是否支持分布式通知。 +根据应用的包设置应用程序是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2352,7 +2352,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle 根据bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise -根据应用的包设置应用程序是否支持分布式通知。 +根据应用的包设置应用程序是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2382,7 +2382,7 @@ Notification.enableDistributedByBundle(bundle, enable) isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\): void -根据应用的包获取应用程序是否支持分布式通知。 +根据应用的包获取应用程序是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2413,7 +2413,7 @@ Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallb isDistributedEnabledByBundle(bundle: BundleOption): Promise\ -根据应用的包获取应用程序是否支持分布式通知。 +根据应用的包获取应用程序是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2447,7 +2447,7 @@ Notification.isDistributedEnabledByBundle(bundle) getDeviceRemindType(callback: AsyncCallback\): void -获取通知的提醒方式。 +获取通知的提醒方式(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2455,7 +2455,7 @@ getDeviceRemindType(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtypesup8sup)\> | 是 | 获取通知的提醒方式的回调函数。 | +| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是 | 获取通知的提醒方式的回调函数。 | **示例:** @@ -2473,7 +2473,7 @@ Notification.getDeviceRemindType(getDeviceRemindTypeCallback); getDeviceRemindType(): Promise\ -获取通知的提醒方式。 +获取通知的提醒方式(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2481,7 +2481,7 @@ getDeviceRemindType(): Promise\ | 类型 | 说明 | | ------------------ | --------------- | -| Promise\<[DeviceRemindType](#deviceremindtypesup8sup)\> | Promise方式返回通知的提醒方式的结果。 | +| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回通知的提醒方式的结果。 | **示例:** @@ -2743,7 +2743,7 @@ Notification.subscribe(subscriber, subscribeCallback); ### onEnabledNotificationChanged8+ -onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup)) +onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) 监听应用通知使能变化。 @@ -2753,7 +2753,7 @@ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](# | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup)\> | 是 | 回调返回监听到的应用信息。 | +| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | 是 | 回调返回监听到的应用信息。 | **示例:** @@ -2851,10 +2851,10 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 值 | 说明 | | --------------------------------- | ----------- | ------------------ | | LEVEL_NONE | 0 | 表示关闭通知功能。 | -| LEVEL_MIN | 1 | 启用通知功能,但通知不启用。 | -| LEVEL_LOW | 2 | 通知和通止功能都启用。 | -| LEVEL_DEFAULT | 3 | 通知和通止功能都启用。 | -| LEVEL_HIGH | 4 | 通知和通止功能都启用。 | +| LEVEL_MIN | 1 | 指示通知功能已启用,但状态栏中不显示通知图标,且没有横幅或提示音。 | +| LEVEL_LOW | 2 | 指示通知功能已启用,且状态栏中显示通知图标,但没有横幅或提示音。 | +| LEVEL_DEFAULT | 3 | 指示通知功能已启用,状态栏中显示通知图标,没有横幅但有提示音。 | +| LEVEL_HIGH | 4 | 指示通知功能已启用,状态栏中显示通知图标,有横幅和提示音。 | ## BundleOption @@ -2900,7 +2900,7 @@ Notification.subscribe(subscriber, subscribeCallback); | title | 是 | 是 | string | 是 | 按钮标题。 | | wantAgent | 是 | 是 | WantAgent | 是 | 点击按钮时触发的WantAgent。 | | extras | 是 | 是 | { [key: string]: any } | 否 | 按钮扩展信息。 | -| userInput9+ | 是 | 是 | [NotificationUserInput](#notificationuserinputsup8sup) | 否 | 用户输入对象实例。 | +| userInput9+ | 是 | 是 | [NotificationUserInput](#notificationuserinput8) | 否 | 用户输入对象实例。 | ## NotificationBasicContent @@ -3025,12 +3025,12 @@ Notification.subscribe(subscriber, subscribeCallback); | hashCode | 是 | 否 | string | 否 | 通知唯一标识。 | | classification | 是 | 是 | string | 否 | 通知分类。 | | groupName8+| 是 | 是 | string | 否 | 组通知名称。 | -| template8+ | 是 | 是 | [NotificationTemplate](#notificationtemplatesup8sup) | 否 | 通知模板。 | +| template8+ | 是 | 是 | [NotificationTemplate](#notificationtemplate8) | 否 | 通知模板。 | | isRemoveAllowed8+ | 是 | 否 | boolean | 否 | 通知是否能被移除。 | | source8+ | 是 | 否 | number | 否 | 通知源。 | -| distributedOption8+ | 是 | 是 | [DistributedOptions](#distributedoptionssup8sup) | 否 | 分布式通知的选项。 | +| distributedOption8+ | 是 | 是 | [DistributedOptions](#distributedoptions8) | 否 | 分布式通知的选项。 | | deviceId8+ | 是 | 否 | string | 否 | 通知源的deviceId。 | -| notificationFlags8+ | 是 | 否 | [NotificationFlags](#notificationflagssup8sup) | 否 | 获取NotificationFlags。 | +| notificationFlags8+ | 是 | 否 | [NotificationFlags](#notificationflags8) | 否 | 获取NotificationFlags。 | ## DistributedOptions8+ @@ -3097,8 +3097,6 @@ Notification.subscribe(subscriber, subscribeCallback); ## NotificationTemplate8+ -模板信息 - **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification | 名称 | 参数类型 | 可读 | 可写 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md deleted file mode 100644 index c61ec7613803479d2ea83ebe04acdbc0ec73ad9d..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ /dev/null @@ -1,17 +0,0 @@ -# PermissionRequestResult - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -权限请求结果。 - - -## 属性 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core - - | 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| permissions | Array<string> | 是 | 否 | 用户传入的权限。| -| authResults | Array<number> | 是 | 否 | 相应请求权限的结果。0表示授权成功,-1表示失败。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-prompt.md index 6e68ded1857dbf1ca84c240ea5e7e14833c1d7f5..1523a09d8b4ad3ec3f9c76387a818d9df12ec130 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-prompt.md @@ -21,9 +21,9 @@ showToast(options: ShowToastOptions): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | options | [ShowToastOptions](#showtoastoptions) | 是 | 文本弹窗选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------- | ---- | ------- | +| options | [ShowToastOptions](#showtoastoptions) | 是 | 文本弹窗选项。 | **示例:** ``` @@ -42,11 +42,11 @@ showToast(options: ShowToastOptions): void **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| message | string | 是 | 显示的文本信息。 | -| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms,若小于1500ms则取默认值。 | -| bottom | <length> | 否 | 设置弹窗边框距离屏幕底部的位置,仅手机和平板设备支持。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------- | ---- | ---------------------------------------- | +| message | string | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms,若小于1500ms则取默认值。 | +| bottom | <length> | 否 | 设置弹窗边框距离屏幕底部的位置。 | ## prompt.showDialog @@ -57,15 +57,15 @@ showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse> **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | options | [ShowDialogOptions](#showdialogoptions) | 是 | 对话框选项。| +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 对话框选项。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 对话框响应结果。| +| 类型 | 说明 | +| ---------------------------------------- | -------- | +| Promise<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 对话框响应结果。 | **示例:** @@ -106,10 +106,10 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | options | [ShowDialogOptions](#showdialogoptions) | 是 | 页面显示对话框信息描述。| - | callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 是 | 对话框响应结果回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 页面显示对话框信息描述。 | +| callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 是 | 对话框响应结果回调。 | **示例:** ``` @@ -146,11 +146,11 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| message | string | 否 | 内容文本。 | -| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------------------------------------- | +| title | string | 否 | 标题文本。 | +| message | string | 否 | 内容文本。 | +| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | ## ShowDialogSuccessResponse @@ -158,8 +158,8 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 -| 名称 | 类型 | 说明 | -| -------- | -------- | -------- | +| 名称 | 类型 | 说明 | +| ----- | ------ | ------------------- | | index | number | 选中按钮在buttons数组中的索引。 | @@ -172,10 +172,10 @@ showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenu **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | - | callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 是 | 菜单响应结果回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | +| callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 是 | 菜单响应结果回调。 | **示例:** @@ -215,14 +215,14 @@ showActionMenu(options: ActionMenuOptions): Promise **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 菜单响应结果。| +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 菜单响应结果。 | **示例:** ``` @@ -256,10 +256,10 @@ showActionMenu(options: ActionMenuOptions): Promise **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| buttons | Array | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------------------------------------- | +| title | string | 否 | 标题文本。 | +| buttons | Array | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | ## ActionMenuSuccessResponse @@ -267,7 +267,7 @@ showActionMenu(options: ActionMenuOptions): Promise **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full。 -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| index | number | 否 | 选中按钮在buttons数组中的索引,从0开始。 | +| 名称 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------------------------ | +| index | number | 否 | 选中按钮在buttons数组中的索引,从0开始。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index cf3ab73eaede52789829d052bfe2700b75aed253..dc79f5a2c50fa91e57e256c2b247b40de14358ef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,4 +1,4 @@ -资源管理 +#资源管理 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -671,10 +671,10 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor& **系统能力**:SystemCapability.Global.ResourceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| path | string | 是 | rawfile文件路径 | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | **示例:** ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index f6407d49f7a715eec6f5f0b20a1fc7f27a7a2ca7..3e06326e131d8473a7c9b92e6283aca41dfe4c8a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -18,8 +18,8 @@ import screenshot from '@ohos.screenshot'; | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------- | ---- | ------------------------------------------------------------ | -| screenRect | [Rect](#Rect) | 否 | 表示截取图像的区域,不传值默认为全屏。| -| imageSize | [Size](#Size) | 否 | 表示截取图像的大小,不传值默认为全屏。| +| screenRect | [Rect](#rect) | 否 | 表示截取图像的区域,不传值默认为全屏。| +| imageSize | [Size](#size) | 否 | 表示截取图像的大小,不传值默认为全屏。| | rotation | number | 否 | 表示截取图像的旋转角度,当前仅支持输入值为0,默认值为0。| @@ -62,7 +62,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#ScreenshotOptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation三个参数,需要分别设置这三个参数。 | + | options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation三个参数,需要分别设置这三个参数。 | | callback | AsyncCallback<image.PixelMap> | 是 | 回调返回一个PixelMap对象。 | - 示例 @@ -102,7 +102,7 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> | 参数名 | 类型 | 必填 | 说明 | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#ScreenshotOptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation三个参数,需要分别设置这三个参数。 | + | options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation三个参数,需要分别设置这三个参数。 | - 返回值 diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md deleted file mode 100644 index cfed484d339397af5e80a8db5cc62d91b323534a..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md +++ /dev/null @@ -1,163 +0,0 @@ -# ServiceExtensionAbility - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -提供ServiceExtension服务扩展相关接口。 - - -## 导入模块 - -``` -import ServiceExtension from '@ohos.application.ServiceExtensionAbility'; -``` - - -## 权限 - -无 - - -## 属性 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | 是 | 否 | ServiceExtension的上下文环境,继承自ExtensionContext。 | - - -## ServiceExtensionAbility.onCreate - -onCreate(want: Want): void; - -Extension生命周期回调,在创建时回调,执行初始化业务逻辑操作。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | - -**示例:** - - ```js - class ServiceExt extends ServiceExtension { - onCreate(want) { - console.log('onCreate, want:' + want.abilityName); - } - } - ``` - - -## ServiceExtensionAbility.onDestroy - -onDestroy(): void; - -Extension生命周期回调,在销毁时回调,执行资源清理等操作。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**示例:** - - ```js - class ServiceExt extends ServiceExtension { - onDestroy() { - console.log('onDestroy'); - } - } - ``` - - -## ServiceExtensionAbility.onRequest - -onRequest(want: Want, startId: number): void; - -Extension生命周期回调,如果是startAbility拉起的服务,会在onCreate之后回调。每次拉起服务都会回调,startId会递增。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | - | startId | number | 是 | 返回拉起次数。首次拉起初始值返回1,多次之后自动递增。 | - -**示例:** - - ```js - class ServiceExt extends ServiceExtension { - onRequest(want, startId) { - console.log('onRequest, want:' + want.abilityName); - } - } - ``` - - -## ServiceExtensionAbility.onConnect - -onConnect(want: Want): rpc.RemoteObject; - -Extension生命周期回调,如果是connectAbility拉起的服务,会在onCreate之后回调。返回一个RemoteObject对象,用于和客户端进行通信。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明)| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | rpc.RemoteObject | 一个RemoteObject对象,用于和客户端进行通信。 | - -**示例:** - - ```js - import rpc from '@ohos.rpc' - class StubTest extends rpc.RemoteObject{ - constructor(des) { - super(des); - } - onRemoteRequest(code, data, reply, option) { - } - } - class ServiceExt extends ServiceExtension { - onConnect(want) { - console.log('onConnect , want:' + want.abilityName); - return new StubTest("test"); - } - } - ``` - - -## ServiceExtensionAbility.onDisconnect - -onDisconnect(want: Want): void; - -Extension的生命周期,断开服务连接时回调。 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-featureAbility.md#Want类型说明)| 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | - -**示例:** - - ```js - class ServiceExt extends ServiceExtension { - onDisconnect(want) { - console.log('onDisconnect, want:' + want.abilityName); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index eebc4cde7bdd52a56c2a81b5fc8496f72d0dea1c..fe6843e020b1c0993bbb485432ae494370720a47 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -67,7 +67,6 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v }); ``` - ## storagestatistics.getFreeSizeOfVolume @@ -125,71 +124,3 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` - -## storagestatistics.getBundleStats9+ - -getBundleStats(packageName: string): Promise<BundleStats> - -异步获取应用存储状态,以promise方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------ | ---- | -------- | - | packageName | string | 是 | 应用包名 | - -- 返回值 - - | 类型 | 说明 | - | ------------------------------------------ | -------------------------- | - | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 | - -- 示例 - - ```js - let packageName = ""; - storagestatistics.getBundleStats(packageName).then(function(BundleStats){ - console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); - }).catch(function(err){ - console.info("getBundleStats failed with error:"+ err); - }); - ``` - -## storagestatistics.getBundleStats9+ - -getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void - -异步获取应用存储状态,以callback方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | packageName | string | 是 | 应用包名 | - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | - -- 示例 - - ```js - let packageName = ""; - storagestatistics.getBundleStats(packageName, function(error, BundleStats){ - // do something - console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); - }); - ``` - -## BundleStats9+ - -**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。 - -### 属性 - -| 名称 | 类型 | 说明 | -| --------- | ------ | -------------- | -| appSize9+ | number | app数据大小 | -| cacheSize9+ | number | 缓存数据大小 | -| dataSize9+ | number | 应用总数据大小 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-app.md b/zh-cn/application-dev/reference/apis/js-apis-system-app.md index 51e89b3ca7d9d4fecb8011c2eb560d067c9e7108..a1b7d04658ec0e7a54a68af988da1294bac6b996 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-app.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-app.md @@ -1,7 +1,7 @@ # 应用上下文 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口。具体新接口在接口描述中说明。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -79,7 +79,7 @@ requestFullWindow(options?: RequestFullWindowOptions): void duration: 200}); } } - ``` + ``` ## app.setImageCacheCount7+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md index 0370a7b99e3d4ca3127f3dcaf2583861da416a58..2f9e575a01de78fc69b6371162bb602c0a68db39 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md @@ -1,7 +1,7 @@ # 电量信息 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.batteryInfo'](js-apis-battery-info.md)。 +> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.batteryInfo`](js-apis-battery-info.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md index 495ffd660c805171ebbae2bedb0e4d20bc303755..d5f03b7975526b2eea54a8bead528bf6a3a29340 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @@ -2,7 +2,10 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.bluetooth`](js-apis-bluetooth.md)。 +> +> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md index eadac91a5945fcedb9cd37bf9b17746f32b21438..b8e3a07ba1cfbd0ba2e65854bb2db8acb32c0ff1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @@ -1,7 +1,7 @@ # 屏幕亮度 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.brightness'](js-apis-brightness.md)。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.brightness`](js-apis-brightness.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md index 7d434d3c98c0aee4fc813b56899448136a1ad920..dd1b1d13f725cbf0c9faf3527c9731d029d582bc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @@ -2,7 +2,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本接口在OpenHarmony 3.1 Release版本仅为接口定义。接口将在OpenHarmony 3.1 MR版本提供使用支持。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md index d7543663552ae46b61a584e939b6a426253e5795..43e368c28dfdc243d130baf5ddec151ab3bec5c3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @@ -1,7 +1,7 @@ # 应用配置 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](js-apis-i18n.md)和['@ohos.intl'](js-apis-intl.md)。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.i18n`](js-apis-i18n.md)和[`@ohos.intl`](js-apis-intl.md)。 > > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-device.md b/zh-cn/application-dev/reference/apis/js-apis-system-device.md new file mode 100644 index 0000000000000000000000000000000000000000..dec8bf99b4096f9680bdc3027d47dc035d7c4e1c --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-device.md @@ -0,0 +1,75 @@ +# 设备信息 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.deviceInfo`](js-apis-device-info.md)进行设备信息查询。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import device from '@system.device'; +``` + + +## device.getInfo + +getInfo(Object): void + +获取当前设备的信息。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 在首页的onShow生命周期之前不建议调用device.getInfo接口。 + +**系统能力:** SystemCapability.Startup.SysInfo + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| brand | string | 品牌。 | +| manufacturer | string | 生产商。 | +| model | string | 型号。 | +| product | string | 代号。 | +| language4+ | string | 系统语言。 | +| region4+ | string | 系统地区。 | +| windowWidth | number | 可使用的窗口宽度。 | +| windowHeight | number | 可使用的窗口高度。 | +| screenDensity4+ | number | 屏幕密度。 | +| screenShape4+ | string | 屏幕形状。可取值:
- rect:方形屏;
- circle:圆形屏。 | +| apiVersion4+ | number | 系统API版本号。 | +| releaseType4+ | string | 版本发布类型,值为类型+版本号,如Beta1。
类型可能值有:
- Canary:同一apiVersion下,canary版本之间保持API兼容,beta版本不对canary版本兼容。
- Beta:同一apiVersion下,beta版本之间保持API兼容,release版本不对beta版本兼容。
- Release:release版本会保持5个API版本兼容。 | +| deviceType4+ | string | 设备类型。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 200 | 返回结果中存在无法获得的信息。 | + +**示例:** + +``` +export default { + getInfo() { + device.getInfo({ + success: function(data) { + console.log('Device information obtained successfully. Device brand:' + data.brand); + }, + fail: function(data, code) { + console.log('Failed to obtain device information. Error code:'+ code + '; Error information: ' + data); + }, + }); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md b/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md deleted file mode 100644 index 7deaf91a5aff0bb44547b14ed282159dd7a36697..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md +++ /dev/null @@ -1,75 +0,0 @@ -# 设备信息 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.deviceInfo'](js-apis-device-info.md)进行设备信息查询。 -> -> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## 导入模块 - - -``` -import device from '@system.device'; -``` - - -## device.getInfo - -getInfo(Object): void - -获取当前设备的信息。 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 在首页的onShow生命周期之前不建议调用device.getInfo接口。 - -**系统能力:** SystemCapability.Startup.SysInfo - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | - -success返回值: - -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| brand | string | 品牌。 | -| manufacturer | string | 生产商。 | -| model | string | 型号。 | -| product | string | 代号。 | -| language4+ | string | 系统语言。 | -| region4+ | string | 系统地区。 | -| windowWidth | number | 可使用的窗口宽度。 | -| windowHeight | number | 可使用的窗口高度。 | -| screenDensity4+ | number | 屏幕密度。 | -| screenShape4+ | string | 屏幕形状。可取值:
- rect:方形屏;
- circle:圆形屏。 | -| apiVersion4+ | number | 系统API版本号。 | -| releaseType4+ | string | 版本发布类型,值为类型+版本号,如Beta1。
类型可能值有:
- Canary:同一apiVersion下,canary版本之间保持API兼容,beta版本不对canary版本兼容。
- Beta:同一apiVersion下,beta版本之间保持API兼容,release版本不对beta版本兼容。
- Release:release版本会保持5个API版本兼容。 | -| deviceType4+ | string | 设备类型,可能值有:
- phone:智能手机
- tablet:平板
- tv:智慧屏
- wearable:智能穿戴
- liteWearable:轻量级智能穿戴
- ar:增强现实
- vr:虚拟现实
- earphones:耳机
- pc:个人计算机
- speaker:音箱
- smartVision:智能视觉设备
- linkIoT:联接类模组 | - -fail返回错误代码: - -| 错误码 | 说明 | -| -------- | -------- | -| 200 | 返回结果中存在无法获得的信息。 | - -**示例:** - -``` -export default { - getInfo() { - device.getInfo({ - success: function(data) { - console.log('Device information obtained successfully. Device brand:' + data.brand); - }, - fail: function(data, code) { - console.log('Failed to obtain device information. Error code:'+ code + '; Error information: ' + data); - }, - }); - }, -} -``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md index 678ead5ffacc1f0d304197f0256f4ca5e80ff671..ae92b2f606e1295196d6d75b607f89be73f0167a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @@ -1,7 +1,7 @@ # 数据请求 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.net.http'](js-apis-http.md)。 +> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.net.http`](js-apis-http.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-file.md b/zh-cn/application-dev/reference/apis/js-apis-system-file.md index f43e669498d9835069440988fa646b8560a4d7f2..a54f28518195eca0fbe95c243cbb86df74d2b81c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-file.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-file.md @@ -1,7 +1,7 @@ # 文件存储 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.fileio'](js-apis-fileio.md)。 +> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.fileio`](js-apis-fileio.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-location.md b/zh-cn/application-dev/reference/apis/js-apis-system-location.md index 0c5e8bde4c074f0ad3c43eeb86f53b8cb6286521..2443d76ceabbf54ef932fa2b3736b69106824cbe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-location.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-location.md @@ -1,7 +1,7 @@ # 地理位置 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.geolocation'](js-apis-geolocation.md)。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.geolocation`](js-apis-geolocation.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md index 29a7a02c3d111dc386a769351083af1b6a9b8b50..20f90a9b04e1f3fb47c4d1cf70ae2a53433b414d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md @@ -2,7 +2,9 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.mediaquery`](js-apis-mediaquery.md)。 +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -23,14 +25,14 @@ matchMedia(condition: string): MediaQueryList **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| condition | string | 是 | 用于查询的条件。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | -------- | +| condition | string | 是 | 用于查询的条件。 | **返回值:** -| 参数类型 | 说明 | -| -------- | -------- | +| 参数类型 | 说明 | +| -------------- | ---------------------------------------- | | MediaQueryList | 表示创建MediaQueryList对象的属性,详情见下表 MediaQueryList说明。 | **示例:** @@ -49,9 +51,9 @@ export default { **系统能力:** SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| matches | boolean | 是 | 匹配结果。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------- | ------- | ---- | ----- | +| matches | boolean | 是 | 匹配结果。 | ## MediaQueryList @@ -61,10 +63,10 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| media | string | 否 | 序列化媒体查询条件,该参数为只读。 | -| matches | boolean | 是 | 匹配结果。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------- | ------- | ---- | ----------------- | +| media | string | 否 | 序列化媒体查询条件,该参数为只读。 | +| matches | boolean | 是 | 匹配结果。 | ### onchange @@ -76,9 +78,9 @@ matches状态变化时的执行函数。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| matches | boolean | 是 | matches状态变化时值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | -------------- | +| matches | boolean | 是 | matches状态变化时值。 | ### MediaQueryList.addListener @@ -91,9 +93,9 @@ addListener(callback: (event: MediaQueryEvent) => void): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | (event: MediaQueryEvent) => void | 是 | 匹配条件发生变化的响应函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | -------------- | +| callback | (event: MediaQueryEvent) => void | 是 | 匹配条件发生变化的响应函数。 | **示例:** @@ -112,9 +114,9 @@ removeListener(callback: (event: MediaQueryEvent) => void): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | (event: MediaQueryEvent) => void) | 是 | 匹配条件发生变化的响应函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | -------------- | +| callback | (event: MediaQueryEvent) => void) | 是 | 匹配条件发生变化的响应函数。 | **示例:** @@ -124,4 +126,3 @@ mMediaQueryList.removeListener(maxWidthMatch); - diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-network.md b/zh-cn/application-dev/reference/apis/js-apis-system-network.md index fa0b34f7a17543ffc32bbedfb21ac56445a2c113..731bd4d85ff13b25c1f3dcb02717790d4265e6fd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-network.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-network.md @@ -1,7 +1,7 @@ # 网络状态 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.telephony.observer'](js-apis-observer.md)。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.telephony.observer`](js-apis-observer.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md index dd4b4c6c9cde639d8cf66f92d4b77b1deab7f5c9..54fa874345392ddeeedfd19d9921dfe2530a974f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md @@ -1,7 +1,7 @@ # 通知消息 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.notification'](js-apis-notification.md)。 +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.notification`](js-apis-notification.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-package.md b/zh-cn/application-dev/reference/apis/js-apis-system-package.md index 5572556897c3208026f16fc57c2b8175e67c48e4..b8138d9d985f899aa02592ae330f9e195e7008cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-package.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-package.md @@ -2,7 +2,10 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.bundle`](js-apis-Bundle.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md index 1af2112068693034bbb2bf6381f3299026b16c07..c400fc338712c9c6062342f984fe8cee24115ac5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md @@ -1,8 +1,11 @@ # 弹窗 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API Version 8 开始,该接口不再维护,推荐使用新接口[`@ohos.prompt`](js-apis-prompt.md)。 +> +> > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 从API Version 8 开始,该接口不再维护,推荐使用新接口['@ohos.prompt](js-apis-prompt.md)'。 ## 导入模块 @@ -22,9 +25,9 @@ showToast(options: ShowToastOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [ShowToastOptions](#showtoastoptions) | 是 | 定义ShowToast的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------- | ---- | --------------- | +| options | [ShowToastOptions](#showtoastoptions) | 是 | 定义ShowToast的选项。 | **示例:** @@ -50,9 +53,9 @@ showDialog(options: ShowDialogOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [ShowDialogOptions](#showdialogoptions) | 是 | 定义显示对话框的选项。| +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ----------- | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 定义显示对话框的选项。 | **示例:** @@ -90,9 +93,9 @@ showActionMenu(options: ShowActionMenuOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [ShowActionMenuOptions](#showactionmenuoptions) | 是 | 定义ShowActionMenu的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | -------------------- | +| options | [ShowActionMenuOptions](#showactionmenuoptions) | 是 | 定义ShowActionMenu的选项。 | **示例:** @@ -128,11 +131,11 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| message | string | 是 | 显示的文本信息。 | -| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。若小于1500ms则取默认值,最大取值为10000ms。 | -| bottom5+ | string\|number| 否 | 设置弹窗边框距离屏幕底部的位置,仅手机和平板设备支持。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------------------- | -------------- | ---- | ---------------------------------------- | +| message | string | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。若小于1500ms则取默认值,最大取值为10000ms。 | +| bottom5+ | string\|number | 否 | 设置弹窗边框距离屏幕底部的位置。 | ## Button @@ -140,10 +143,10 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | 定义按钮信息。 | -| color | string | 是 | 定义按钮颜色。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------- | +| text | string | 是 | 定义按钮信息。 | +| color | string | 是 | 定义按钮颜色。 | ## ShowDialogSuccessResponse @@ -151,9 +154,9 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| index | number | 是 | 定义数据的索引信息。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------- | +| index | number | 是 | 定义数据的索引信息。 | ## ShowDialogOptions @@ -161,14 +164,14 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| message | string | 否 | 文本内容。 | -| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | -| success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | 否 | 接口调用成功的回调函数。 | -| cancel | (data: string, code: string) => void | 否 | 接口调用失败的回调函数。 | -| complete | (data: string) => void | 否 | 接口调用结束的回调函数。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string | 否 | 标题文本。 | +| message | string | 否 | 文本内容。 | +| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | +| success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | 否 | 接口调用成功的回调函数。 | +| cancel | (data: string, code: string) => void | 否 | 接口调用失败的回调函数。 | +| complete | (data: string) => void | 否 | 接口调用结束的回调函数。 | ## ShowActionMenuOptions6+ @@ -176,10 +179,10 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。| -| success | (tapIndex: number, errMsg: string) => void | 否 | 弹出对话框时调用。 | -| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数。 | -| complete | (data: string) => void | 否 | 关闭对话框时调用。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string | 否 | 标题文本。 | +| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。 | +| success | (tapIndex: number, errMsg: string) => void | 否 | 弹出对话框时调用。 | +| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数。 | +| complete | (data: string) => void | 否 | 关闭对话框时调用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-request.md b/zh-cn/application-dev/reference/apis/js-apis-system-request.md index 685237bb568944f90a50488dd027c33ba951ab24..6763edf39c9be01187a9e921a7bc280b48884525 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-request.md @@ -1,7 +1,7 @@ # 上传下载 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.request'](js-apis-request.md)。 +> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.request`](js-apis-request.md)。 > > - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-router.md b/zh-cn/application-dev/reference/apis/js-apis-system-router.md index 00aad57b6366c6692b361ef20f11850be8519748..7085a61e8a100f2d9464e058f8f443b91b3787dc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-router.md @@ -1,8 +1,11 @@ # 页面路由 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API Version 8 开始,该接口不再维护,推荐使用新接口[`@ohos.router`](js-apis-router.md)。 +> +> > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 从API Version 8 开始,该接口不再维护,推荐使用新接口['@ohos.router'](js-apis-router.md)。 ## 导入模块 @@ -22,9 +25,9 @@ push(options: RouterOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。| +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | -------------------------- | +| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。 | **示例:** @@ -76,9 +79,9 @@ replace(options: RouterOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。| +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | -------------------------- | +| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。 | **示例:** @@ -119,9 +122,9 @@ back(options?: BackRouterOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [BackRouterOptions](#backrouteroptions) | 是 | 详细请参考BackRouterOptions。| +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ----------------------- | +| options | [BackRouterOptions](#backrouteroptions) | 是 | 详细请参考BackRouterOptions。 | **示例:** @@ -191,9 +194,9 @@ getParams(): ParamsInterface **返回值:** -| 类型 | 说明 | -| -------- | -------- | -| [ParamsInterface](#paramsinterface) | 详细请参见ParamsInterface。| +| 类型 | 说明 | +| ----------------------------------- | --------------------- | +| [ParamsInterface](#paramsinterface) | 详细请参见ParamsInterface。 | ## router.clear @@ -223,8 +226,8 @@ getLength(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------------ | | string | 页面数量,页面栈支持最大数值是32。 | **示例:** @@ -248,9 +251,9 @@ getState(): RouterState **返回值:** -| 参数类型 | 说明 | -| -------- | -------- | -| [RouterState](#routerstate) | 详细请参见RouterState。| +| 参数类型 | 说明 | +| --------------------------- | ----------------- | +| [RouterState](#routerstate) | 详细请参见RouterState。 | **示例:** @@ -275,9 +278,9 @@ enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [EnableAlertBeforeBackPageOptions](#enableAlertbeforebackpageoptions6) | 是 | 详细请参见EnableAlertBeforeBackPageOptions。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | -------------------------------------- | +| options | [EnableAlertBeforeBackPageOptions](#enableAlertbeforebackpageoptions6) | 是 | 详细请参见EnableAlertBeforeBackPageOptions。 | **示例:** @@ -307,9 +310,9 @@ disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| options | [DisableAlertBeforeBackPageOptions](#disablealertbeforebackpageoptions6) | 否 | 详细请参见DisableAlertBeforeBackPageOptions。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | --------------------------------------- | +| options | [DisableAlertBeforeBackPageOptions](#disablealertbeforebackpageoptions6) | 否 | 详细请参见DisableAlertBeforeBackPageOptions。 | **示例:** @@ -334,10 +337,10 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Lite -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | -| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | +| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | ## BackRouterOptions @@ -346,10 +349,10 @@ export default { **系统能力:** 以下各项对应的系统能力有所不同,详见下表。 -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full| -| params | Object | 否 | 跳转时要同时传递到目标页面的数据。
**系统能力:** SystemCapability.ArkUI.ArkUI.Lite| +| 名称 | 参数类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full | +| params | Object | 否 | 跳转时要同时传递到目标页面的数据。
**系统能力:** SystemCapability.ArkUI.ArkUI.Lite | ## RouterState @@ -357,11 +360,11 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- |-------- | -| index | number | 是 | 表示当前页面在页面栈中的索引。从栈底到栈顶,index从1开始递增。 | -| name | string | 是 | 表示当前页面的名称,即对应文件名。 | -| path | string | 是 | 表示当前页面的路径。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------------------------------- | +| index | number | 是 | 表示当前页面在页面栈中的索引。从栈底到栈顶,index从1开始递增。 | +| name | string | 是 | 表示当前页面的名称,即对应文件名。 | +| path | string | 是 | 表示当前页面的路径。 | ## EnableAlertBeforeBackPageOptions6+ @@ -369,12 +372,12 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| message | string | 是 | 询问对话框内容。 | -| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 | -| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。 | -| complete | () => void | 否 | 接口调用结束的回调函数。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ------------------------- | +| message | string | 是 | 询问对话框内容。 | +| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 | +| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。 | +| complete | () => void | 否 | 接口调用结束的回调函数。 | ## DisableAlertBeforeBackPageOptions6+ @@ -382,14 +385,14 @@ export default { **系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 | -| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。| -| complete | () => void | 否 | 接口调用结束的回调函数。 | +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ------------------------- | +| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 | +| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。 | +| complete | () => void | 否 | 接口调用结束的回调函数。 | ## ParamsInterface -| 名称 | 参数类型 | 说明 | -| -------- | -------- | -------- | -| [key: string] | Object| 路由参数列表。 | +| 名称 | 参数类型 | 说明 | +| ------------- | ------ | ------- | +| [key: string] | Object | 路由参数列表。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md index cfa19710dfbd77dd6840c00902c3543965acdd8e..69fd17f9c8f6db70281893c895b2241d27d239c3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @@ -2,8 +2,9 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[`@ohos.sensor`](js-apis-sensor.md)。 > - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 从API Version 8开始,该接口不再维护,推荐使用新接口[sensor](js-apis-sensor.md)。 > - 该功能使用需要对应硬件支持,仅支持真机调试。 @@ -17,9 +18,9 @@ import sensor from '@system.sensor'; ## 传感器错误码列表 - | 错误码 | 说明 | -| -------- | -------- | -| 900 | 当前设备不支持相应的传感器。 | +| 错误码 | 说明 | +| ---- | -------------- | +| 900 | 当前设备不支持相应的传感器。 | ## sensor.subscribeAccelerometer @@ -33,19 +34,19 @@ subscribeAccelerometer(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| interval | string | 是 | 频率参数,加速度的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | -| success | Function | 是 | 感应到加速度数据变化后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | ---------------------------------------- | +| interval | string | 是 | 频率参数,加速度的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到加速度数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| x | number | x轴的加速度。 | -| y | number | y轴的加速度。 | -| z | number | z轴的加速度。 | +| 参数名 | 类型 | 说明 | +| ---- | ------ | ------- | +| x | number | x轴的加速度。 | +| y | number | y轴的加速度。 | +| z | number | z轴的加速度。 | **示例:** @@ -92,16 +93,16 @@ subscribeCompass(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 罗盘数据改变后触发的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | --------------- | +| success | Function | 是 | 罗盘数据改变后触发的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| direction | number | 设备面对的方向度数。 | +| 参数名 | 类型 | 说明 | +| --------- | ------ | ---------- | +| direction | number | 设备面对的方向度数。 | **示例:** @@ -143,16 +144,16 @@ subscribeProximity(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 距离感应数据改变后调用的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ----------------- | +| success | Function | 是 | 距离感应数据改变后调用的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| distance | number | 可见物体相对于设备显示屏的接近或远离状态。 | +| 参数名 | 类型 | 说明 | +| -------- | ------ | --------------------- | +| distance | number | 可见物体相对于设备显示屏的接近或远离状态。 | **示例:** @@ -194,16 +195,16 @@ sensor.subscribeLight(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 光线感应数据改变后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | --------------- | +| success | Function | 是 | 光线感应数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| intensity | number | 光线强度,单位为lux。 | +| 参数名 | 类型 | 说明 | +| --------- | ------ | ------------ | +| intensity | number | 光线强度,单位为lux。 | **示例:** @@ -247,16 +248,16 @@ subscribeStepCounter(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 计步传感器数据改变后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ---------------- | +| success | Function | 是 | 计步传感器数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| steps | number | 计步传感器重启后累计记录的步数。
| +| 参数名 | 类型 | 说明 | +| ----- | ------ | --------------------- | +| steps | number | 计步传感器重启后累计记录的步数。
| **示例:** @@ -301,16 +302,16 @@ subcribeBarometer(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 气压传感器数据改变后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ---------------- | +| success | Function | 是 | 气压传感器数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| pressure | number | 气压值,单位:帕斯卡。 | +| 参数名 | 类型 | 说明 | +| -------- | ------ | ----------- | +| pressure | number | 气压值,单位:帕斯卡。 | **示例:** @@ -356,16 +357,16 @@ subscribeHeartRate(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 心率传感器数据改变后的回调函数,默认频率5s/次。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ------------------------- | +| success | Function | 是 | 心率传感器数据改变后的回调函数,默认频率5s/次。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| heartRate | number | 心率值。 | +| 参数名 | 类型 | 说明 | +| --------- | ------ | ---- | +| heartRate | number | 心率值。 | **示例:** @@ -410,16 +411,16 @@ subscribeOnBodyState(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 是 | 穿戴状态改变后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ------------- | +| success | Function | 是 | 穿戴状态改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| value | boolean | 是否已佩戴。 | +| 参数名 | 类型 | 说明 | +| ----- | ------- | ------ | +| value | boolean | 是否已佩戴。 | **示例:** @@ -461,17 +462,17 @@ getOnBodyState(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | ------------ | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| value | boolean | 是否已佩戴。 | +| 参数名 | 类型 | 说明 | +| ----- | ------- | ------ | +| value | boolean | 是否已佩戴。 | **示例:** @@ -498,18 +499,18 @@ subscribeDeviceOrientation(interval: string, success: (data: DeviceOrientationRe **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| interval | string | 是 | 频率参数,设备方向传感器的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | -| success | Function | 是 | 感应到设备方向传感器数据变化后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | ---------------------------------------- | +| interval | string | 是 | 频率参数,设备方向传感器的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到设备方向传感器数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| alpha | number | 当手机坐标 X/Y 和地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha。 | -| beta | number | 当手机坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。 | -| gamma | number | 当手机 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。 | +| 参数名 | 类型 | 说明 | +| ----- | ------ | ---------------------------------------- | +| alpha | number | 当设备坐标 X/Y 和地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha。 | +| beta | number | 当设备坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。 | +| gamma | number | 当设备 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。 | **示例:** @@ -558,19 +559,19 @@ subscribeGyroscope(interval: string, success: (data: GyroscopeResponse), fail?: **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| interval | string | 是 | 频率参数,陀螺仪的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | -| success | Function | 是 | 感应到陀螺仪数据变化后的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | ---------------------------------------- | +| interval | string | 是 | 频率参数,陀螺仪的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到陀螺仪数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | success返回值: - | 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| x | number | x轴的旋转角速度。 | -| y | number | y轴的旋转角速度。 | -| z | number | z轴的旋转角速度。 | +| 参数名 | 类型 | 说明 | +| ---- | ------ | --------- | +| x | number | x轴的旋转角速度。 | +| y | number | y轴的旋转角速度。 | +| z | number | z轴的旋转角速度。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md index eed952738cdff3a792fe7a86c5f3f94d4f523832..b91e0314d04358544d03a3e6492a6792ae86166c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md @@ -2,7 +2,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> - 从API Version 6开始,该接口不再维护,可以使用接口['@ohos.data.storage'](js-apis-data-storage.md)。在API Version 9后,推荐使用新接口 ['@ohos.data.preferences'](js-apis-data-preferences.md)。 +> - 从API Version 6开始,该接口不再维护,可以使用接口[`@ohos.data.storage`](js-apis-data-storage.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md b/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md index 67ab27690a460b15d277385af4259e01a86dbd13..156a728a3bdac0712e9859d24b71f13b01243faf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @@ -3,7 +3,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 从API Version 8开始,该接口不再维护,推荐使用新接口[vibrator](js-apis-vibrator.md)。 +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[`@ohos.vibrator`](js-apis-vibrator.md)。 > - 该功能使用需要对应硬件支持,仅支持真机调试。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index d5cb631df90fda9bfd7300f7460fa8441ecf0e73..3ec708af81564e20e8ac812d8ce4c9efebaf77c2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -1,4 +1,4 @@ -# 升级 +升级 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -8,7 +8,7 @@ 升级依赖:升级分为SD卡升级和在线升级两种。 - SD卡升级依赖升级包和SD卡安装。 -- 在线升级依赖手机厂商部署的用于管理升级包的服务器。服务器由手机厂商部署,IP由调用者传入,请求的request接口是固定的,由手机厂商开发。 +- 在线升级依赖设备厂商部署的用于管理升级包的服务器。服务器由设备厂商部署,IP由调用者传入,请求的request接口是固定的,由设备厂商开发。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md b/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md deleted file mode 100644 index 81ef347078ea19d4c2585031a3abccd7ccd84e72..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ /dev/null @@ -1,82 +0,0 @@ -# uriPermissionManager - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -Uri权限管理。 - - -## 导入模块 - - -``` -import uriPermissionManager from '@ohos.application.uriPermissionManager'; -``` - - -## uriPermissionManager.verifyUriPermission - -verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback<number>): void - -检验某个应用是否对指定的uri有flag指定的权限。 - -**系统能力:** - -SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uri | string | 是 | 指向文件的uri,例如fileshare:///com.samples.filesharetest.FileShare/person/10。 | - | flag | wantConstant.Flags | 是 | uri的读权限或写权限。 | - | accessTokenId | number | 是 | 每个应用的唯一标识ID,开发者通过包管理接口自行获取。 | - | callback | AsyncCallback<number> | 是 | callback形式返回检验结果,返回0表示有权限,返回-1表示无权限。 | - -**示例:** - - ``` - let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => { - console.log("result.code = " + result.code) - }) // accessTokenId开发者通过包管理接口自行获取 - ``` - - -## uriPermissionManager.verifyUriPermission - -verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise<number> - -检验某个应用是否对指定的uri有flag指定的权限。 - -**系统能力:** - -SystemCapability.Ability.AbilityRuntime.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uri | string | 是 | 指向文件的uri,例如fileshare:///com.samples.filesharetest.FileShare/person/10。 | - | flag | wantConstant.Flags | 是 | uri的读权限或写权限。 | - | accessTokenId | number | 是 | 每个应用的唯一标识ID,开发者通过包管理接口自行获取。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | Promise<number> | 返回0表示有权限,返回-1表示无权限。 | - -**示例:** - - ``` - let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId) - .then((data) => { - console.log('Verification succeeded.' + data) - }).catch((error) => { - console.log('Verification failed.'); - }) - ``` - diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md deleted file mode 100644 index c644344a1efaacae2939a6828fa27714b1a56c1a..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ /dev/null @@ -1,179 +0,0 @@ -# 卷管理 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> -> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 此接口为系统接口,三方应用不支持调用。 - -## 导入模块 - -```js -import volumemanager from "@ohos.volumeManager"; -``` - -## volumemanager.getAllVolumes9+ - -getAllVolumes(): Promise<Array<Volume>> - -异步获取当前所有可获得的卷信息,以promise方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 返回值 - - | 类型 | 说明 | - | ---------------------------------- | -------------------------- | - | Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷信息 | - -- 示例 - - ```js - volumemanager.getAllVolumes().then(function(volumes){ - // do something - }); - ``` - -## volumemanager.getAllVolumes9+ - -getAllVolumes(callback: AsyncCallback<Array<Volume>>): void - -异步获取当前所有可获得的卷信息,以callback方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback:AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | - -- 示例 - - ```js - let uuid = ""; - volumemanager.getAllVolumes(uuid, function(error, volumes){ - // do something - }); - ``` - - -## volumemanager.mount9+ - -mount(volumeId: string): Promise<boolean> - -异步挂载指定卷,以promise方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | - -- 返回值 - - | 类型 | 说明 | - | ---------------------- | ---------- | - | Promise<boolean> | 挂载指定卷 | - -- 示例 - - ```js - let volumeId = ""; - volumemanager.mount(volumeId).then(function(flag){ - // do something - }); - ``` - -## volumemanager.mount9+ - -mount(volumeId: string, callback:AsyncCallback<boolean>):void - -异步获取指定卷的可用空间大小,以callback方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | 是 | 卷id | - | callback | callback:AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | - -- 示例 - - ```js - let volumeId = ""; - volumemanager.mount(volumeId, function(error, flag){ - // do something - }); - ``` - -## volumemanager.unmount9+ - -unmount(volumeId: string): Promise<boolean> - -异步卸载指定卷,以promise方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | - -- 返回值 - - | 类型 | 说明 | - | ---------------------- | ---------- | - | Promise<boolean> | 卸载指定卷 | - -- 示例 - - ```js - let volumeId = ""; - volumemanager.unmount(volumeId).then(function(flag){ - // do something - }); - ``` - -## volumemanager.unmount9+ - -unmount(volumeId: string, callback:AsyncCallback<boolean>):void - -异步卸载指定卷,以callback方式返回。 - -**系统能力**:SystemCapability.FileManagement.StorageService.Volume - -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | 是 | 卷id | - | callback | callback:AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | - -- 示例 - - ```js - let volumeId = ""; - volumemanager.unmount(volumeId, function(error, flag){ - // do something - }); - ``` - -## Volume9+ - -**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.Volume。 - -### 属性 - -| 名称 | 类型 | 说明 | -| ----------- | ------- | -------------------- | -| id9+ | number | 卷id | -| uuid9+ | string | 卷uuid | -| description9+ | string | 卷相关描述 | -| removable9+ | boolean | 是否为可移动存储设备 | -| state9+ | int | 当前卷状态 | -| path9+ | string | 卷的挂载地址 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index ede1e6649366ac24d915e1109e955f6b49ca8909..b542ff5ff6493bb84fea27b73a81783ea05d1a1c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -503,6 +503,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); }); ``` + ## wallpaper.getFile8+ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void @@ -530,6 +531,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo console.log(`success to getFile: ` + JSON.stringify(data)); }); ``` + ## wallpaper.getFile8+ getFile(wallpaperType: WallpaperType): Promise<number> diff --git a/zh-cn/application-dev/reference/apis/js-apis-wifi.md b/zh-cn/application-dev/reference/apis/js-apis-wifi.md index 889b4504b5fbc055aa555e367e05339ea71c151a..c2854482f4e93b7dc03a395859fb5ea36b9cae7d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wifi.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wifi.md @@ -235,7 +235,7 @@ removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -添加不可信网络配置,使用callback方式作为异步方法。 +移除不可信网络配置,使用callback方式作为异步方法。 - 需要权限: ohos.permission.SET_WIFI_INFO @@ -589,7 +589,7 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void | deviceAddress | string | 只读 | 设备MAC地址。 | | primaryDeviceType | string | 只读 | 主设备类型。 | | deviceStatus | [P2pDeviceStatus](#P2pDeviceStatus) | 只读 | 设备状态。 | -| groupCapabilitys | number | 只读 | 群组能力。 | +| groupCapabilities | number | 只读 | 群组能力。 | ## P2pDeviceStatus8+ @@ -668,7 +668,7 @@ createGroup(config: WifiP2PConfig): boolean; | 参数名 | 类型 | 读写属性 | 说明 | | -------- | -------- | -------- | -------- | -| deviceAddress | string | 只读 | 设备名称。 | +| deviceAddress | string | 只读 | 设备地址。 | | netId | number | 只读 | 网络ID。创建群组时-1表示创建临时组,-2表示创建永久组。 | | passphrase | string | 只读 | 群组密钥。 | | groupName | string | 只读 | 群组名称。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 6202965ca408f1598e08c8a5fc10177ab8e44e93..546ef489e8d341b0abd05b1c73020836c3fadd31 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -233,18 +233,18 @@ create(id: string, type: WindowType): Promise<Window> create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void -当Context为[ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md)时,创建系统窗口,使用callback方式作为异步方法。 +当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback方式作为异步方法。 **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | - | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息, 为ServiceExtensionContext的基类。 | - | id | string | 是 | 窗口id。 | - | type | [WindowType](#windowtype) | 是 | 窗口类型。 | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ----------------------------------------------- | ---- | ---------------------- | + | ctx | [Context](js-apis-service-extension-context.md) | 是 | 当前应用上下文信息。 | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | - 示例 @@ -265,17 +265,17 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi create(ctx: Context, id: string, type: WindowType): Promise<Window> -当Context为[ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md)时,创建系统窗口,使用Promise方式作为异步方法。 +当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise方式作为异步方法。 **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | - | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息, 为ServiceExtensionContext的基类。 | - | id | string | 是 | 窗口id。 | - | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------------------------- | ---- | -------------------- | + | ctx | [Context](js-apis-service-extension-context.md) | 是 | 当前应用上下文信息。 | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | - 返回值 @@ -423,10 +423,10 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | - | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息。 | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | + | ctx | Context | 是 | 当前应用上下文信息。API8的Context定义见[Context](js-apis-Context.md)。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 | - 示例 @@ -452,9 +452,9 @@ getTopWindow(ctx: Context): Promise<Window> - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------------------------------------------------------------ | ---- | -------------------- | - | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------- | ---- | ------------------------------------------------------------ | + | ctx | Context | 是 | 当前应用上下文信息。API8的Context定义见[Context](js-apis-Context.md)。 | - 返回值 diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md deleted file mode 100644 index 626bd01dff25af4e8739a87fc57ac90ba32d07bc..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md +++ /dev/null @@ -1,340 +0,0 @@ -# 延迟任务调度 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## 导入模块 - -``` -import workScheduler from '@ohos.workScheduler' -``` - -## workScheduler.startWork -startWork(work: WorkInfo): boolean - -通知WorkSchedulerService将工作添加到执行队列。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | --------------------- | ---- | -------------- | -| work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | - -**返回值**: - -| 类型 | 说明 | -| ------- | -------------------------------- | -| boolean | 如果工作成功添加到执行队列,则返回true,否则返回false。 | - -**示例**: - -``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.startWork(workInfo); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.stopWork -stopWork(work: WorkInfo, needCancel?: boolean): boolean - -通知WorkSchedulerService停止指定工作。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | --------------------- | ---- | ---------- | -| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | -| needCancel | boolean | 是 | 是否需要取消的工作。 | - -**返回值**: - -| 类型 | 说明 | -| ------- | ----------------------- | -| boolean | 如果成功,则返回true,否则返回false。 | - -**示例**: - -``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.stopWork(workInfo, false); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.getWorkStatus -getWorkStatus(workId: number, callback : AsyncCallback\): void - -获取工作的最新状态,使用Callback形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------- | ---- | ---------------------------------------- | -| workId | number | 是 | work的id。 | -| callback | AsyncCallback\<[WorkInfo](#workinfo)> | 是 | 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | - -**示例**: - -``` - workScheduler.getWorkStatus(50, (err, res) => { - if (err) { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - } else { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } - } - }); -``` - -## workScheduler.getWorkStatus -getWorkStatus(workId: number): Promise\ - -获取工作的最新状态,使用Promise形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------- | -| workId | number | 是 | work的id。 | - -**返回值**: - -| 类型 | 说明 | -| ------------------------------- | ---------------------------------------- | -| Promise\<[WorkInfo](#workinfo)> | 指定的Promise回调方法。如果指定的工作ID有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | - -**示例**: - -``` - workScheduler.getWorkStatus(50).then((res) => { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } - }).catch((err) => { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - }) -``` - -## workScheduler.obtainAllWorks -obtainAllWorks(callback : AsyncCallback\): Array\ - -获取与当前应用程序关联的所有工作,使用Callback形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------------- | -| callback | AsyncCallback\ | 是 | 指定的callback回调方法。返回与应用程序关联的所有工作。 | - -**返回值**: - -| 类型 | 说明 | -| ----------------------------- | --------------- | -| Array\<[WorkInfo](#workinfo)> | 返回与应用程序关联的所有工作。 | - -**示例**: - -``` - workScheduler.obtainAllWorks((err, res) =>{ - if (err) { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - } else { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - } - }); -``` - -## workScheduler.obtainAllWorks -obtainAllWorks(): Promise> - -获取与当前应用程序关联的所有工作,使用Promise形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**返回值**: - -| 类型 | 说明 | -| -------------------------------------- | ------------------------------ | -| Promise> | 指定的Promise回调方法。返回与应用程序关联的所有工作。 | - -**示例**: - -``` - workScheduler.obtainAllWorks().then((res) => { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - }).catch((err) => { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - }) -``` - -## workScheduler.stopAndClearWorks -stopAndClearWorks(): boolean - -停止和取消与当前应用程序关联的所有工作。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**示例**: - -``` - let res = workScheduler.stopAndClearWorks(); - console.info("workschedulerLog res:" + res); -``` - -## workScheduler.isLastWorkTimeOut -isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean - -检查指定工作的最后一次执行是否为超时操作,使用Callback形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------------------------------------- | -| workId | number | 是 | work的id。 | -| callback | AsyncCallback\ | 是 | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | - -**返回值**: - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | - -**示例**: - -``` - workScheduler.isLastWorkTimeOut(500, (err, res) =>{ - if (err) { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - } else { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - } - }); -``` - -## workScheduler.isLastWorkTimeOut -isLastWorkTimeOut(workId: number): Promise\ - -检查指定工作的最后一次执行是否为超时操作,使用Promise形式返回。 - -**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------- | -| workId | number | 是 | work的id。 | - -**返回值**: - -| 类型 | 说明 | -| ----------------- | ---------------------------------------- | -| Promise\ | 指定的Promise回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | - -**示例**: - -``` - workScheduler.isLastWorkTimeOut(500) - .then(res => { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - }) - .catch(err => { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - }); -``` - -## WorkInfo -提供工作的具体信息。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - -| 参数名 | 类型 | 必填 | 说明 | -| --------------- | --------------------------------- | ---- | ---------------- | -| workId | number | 是 | 当前工作的ID | -| bundleName | string | 是 | 延迟任务包名 | -| abilityName | string | 是 | 延迟任务回调通知的组件名(必填) | -| networkType | [NetworkType](#networktype) | 否 | 网络类型 | -| isCharging | boolean | 否 | 是否充电 | -| chargerType | [ChargingType](#chargingtype) | 否 | 充电类型 | -| batteryLevel | number | 否 | 电量 | -| batteryStatus | [BatteryStatus](#batterystatus) | 否 | 电池状态 | -| storageRequest | [StorageRequest](#storagerequest) | 否 | 存储状态 | -| isRepeat | boolean | 否 | 是否循环任务 | -| repeatCycleTime | number | 否 | 循环间隔 | -| repeatCount | number | 否 | 循环次数 | - -## NetworkType -触发工作的网络类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - -| 名称 | 默认值 | 说明 | -| ---------------------- | ---- | ----------------------- | -| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | -| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | -| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | -| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | -| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | -| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | - -## ChargingType -触发工作的充电类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - -| 名称 | 默认值 | 说明 | -| ------------------------- | ---- | -------------------- | -| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | -| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | -| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | -| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | - -## BatteryStatus -触发工作的电池状态。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - -| 名称 | 默认值 | 说明 | -| -------------------------- | ---- | -------------------------- | -| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | -| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | -| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | - -## StorageRequest -触发工作的存储状态。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - - |名称 |默认值 |说明| - | -------- | -------- | -------- | - |STORAGE_LEVEL_LOW |0 |表示这个触发条件是存储空间不足。 - |STORAGE_LEVEL_OKAY |1 |表示这个触发条件是从存储空间不足恢复到正常。 - |STORAGE_LEVEL_LOW_OR_OKAY |2 |表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index 558973a2905db88133a48f9e16b731603ffbe7fd..b78a86e5703cf9afef70a14f3276580d7e9472c5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -25,10 +25,10 @@ XmlSerializer的构造函数。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | -| encoding | string | 否 | 编码格式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ----------------------------------- | +| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | +| encoding | string | 否 | 编码格式。 | **示例:** @@ -47,10 +47,10 @@ setAttributes(name: string, value: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 属性的key值。 | -| value | string | 是 | 属性的value值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------- | +| name | string | 是 | 属性的key值。 | +| value | string | 是 | 属性的value值。 | **示例:** @@ -68,9 +68,9 @@ addEmptyElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 该空元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 该空元素的元素名。 | **示例:** @@ -102,9 +102,9 @@ startElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 当前元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 当前元素的元素名。 | **示例:** @@ -142,10 +142,10 @@ setNamespace(prefix: string, namespace: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| prefix | string | 是 | 当前元素及其子元素的前缀。 | -| namespace | string | 是 | 当前元素及其子元素的命名空间。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | --------------- | +| prefix | string | 是 | 当前元素及其子元素的前缀。 | +| namespace | string | 是 | 当前元素及其子元素的命名空间。 | **示例:** @@ -166,9 +166,9 @@ setComment(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | 当前元素的注释内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ---------- | +| text | string | 是 | 当前元素的注释内容。 | **示例:** @@ -189,9 +189,9 @@ setCDATA(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | CDATA属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| text | string | 是 | CDATA属性的内容。 | **示例:** @@ -210,9 +210,9 @@ setText(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | text属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ---------- | +| text | string | 是 | text属性的内容。 | **示例:** @@ -234,9 +234,9 @@ setDocType(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | DocType属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ------------- | +| text | string | 是 | DocType属性的内容。 | **示例:** @@ -258,10 +258,10 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | -| encoding | string | 否 | 编码格式(仅支持utf-8)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | -------------------------------- | +| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | +| encoding | string | 否 | 编码格式(仅支持utf-8)。 | **示例:** @@ -291,9 +291,9 @@ parse(option: ParseOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | ---------------- | +| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | **示例:** @@ -330,13 +330,13 @@ that.parse(options); xml解析选项。 -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | -| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | -| tagValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取tagValue回调函数。 | -| attributeValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取attributeValue回调函数。 | -| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | 否 | 获取tokenValue回调函数。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------------------------ | ---------------------------------------- | ---- | -------------------------------- | +| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | +| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | +| tagValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取tagValue回调函数。 | +| attributeValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取attributeValue回调函数。 | +| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | 否 | 获取tokenValue回调函数。 | ## ParseInfo @@ -351,8 +351,8 @@ getColumnNumber(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------- | | number | 返回当前列号。 | @@ -364,8 +364,8 @@ getDepth(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ---------- | | number | 返回元素的当前深度。 | @@ -377,8 +377,8 @@ getLineNumber(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------- | | number | 返回当前行号。 | @@ -390,8 +390,8 @@ getName(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | --------- | | string | 返回当前元素名称。 | @@ -403,8 +403,8 @@ getNamespace(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------ | | string | 返回当前元素的命名空间。 | @@ -416,8 +416,8 @@ getPrefix(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | --------- | | string | 返回当前元素前缀。 | @@ -429,8 +429,8 @@ getText(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------ | | string | 返回当前事件的文本内容。 | @@ -442,8 +442,8 @@ isEmptyElementTag(): boolean **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ---------------- | | boolean | 返回true,当前元素为空元素。 | @@ -455,8 +455,8 @@ isWhitespace(): boolean **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | --------------------- | | boolean | 返回true,当前文本事件仅包含空格字符。 | @@ -467,8 +467,8 @@ getAttributeCount(): number 获取当前开始标记的属性数。 **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ----------- | | number | 当前开始标记的属性数。 | @@ -476,16 +476,16 @@ getAttributeCount(): number 事件枚举。 -| 名称 | 枚举值 | 说明 | -| -------- | -------- | -------- | -| START_DOCUMENT | 0 | 启动文件事件。 | -| END_DOCUMENT | 1 | 结束文件事件。 | -| START_TAG | 2 | 启动标签事件。 | -| END_TAG | 3 | 结束标签事件。 | -| TEXT | 4 | 文本事件。 | -| CDSECT | 5 | CDATA事件。 | -| COMMENT | 6 | XML注释事件。 | -| DOCDECL | 7 | XML文档类型声明事件。 | -| INSTRUCTION | 8 | XML处理指令声明事件。 | -| ENTITY_REFERENCE | 9 | 实体引用事件。 | -| WHITESPACE | 10 | 空白事件。 | +| 名称 | 枚举值 | 说明 | +| ---------------- | ---- | ------------ | +| START_DOCUMENT | 0 | 启动文件事件。 | +| END_DOCUMENT | 1 | 结束文件事件。 | +| START_TAG | 2 | 启动标签事件。 | +| END_TAG | 3 | 结束标签事件。 | +| TEXT | 4 | 文本事件。 | +| CDSECT | 5 | CDATA事件。 | +| COMMENT | 6 | XML注释事件。 | +| DOCDECL | 7 | XML文档类型声明事件。 | +| INSTRUCTION | 8 | XML处理指令声明事件。 | +| ENTITY_REFERENCE | 9 | 实体引用事件。 | +| WHITESPACE | 10 | 空白事件。 | diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif index 98bf461673a8f11366755e99b8f59baf7cc282e8..00f9ce6746501edad918bda726b3e143991189fc 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152773860.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152773860.png deleted file mode 100644 index dca96aeb057ba12dc63365e613007e54dd268a40..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152773860.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png index b370937f36a472829e7a08a4439b4025721b0437..495f967777f91ce6e654c278683807ef6560809c 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png index 5e7bc3dec11daa00059d3ec93d77ac15ce357a14..3d74a346c8d9d41efbef3f0f2feb12b19fc90a94 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif deleted file mode 100644 index e64a81a267d1cb0f6f216caa7cefe75020850e75..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md index c6551400e9cd3f1f99f2489a9c36ac9dbbdc0029..c2ada666a38d33b17859157647e18847d7b49495 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md @@ -75,9 +75,9 @@ ```
- + - <select class="selects" onchange="change_fit"><option for="{{fits}}" value="{{$item}}">{{$item}}</option></select> +
``` @@ -87,12 +87,11 @@ justify-content: center; align-items: center; flex-direction: column; - } .selects{ margin-top: 20px; width:300px; - border:1px solid \#808080; + border:1px solid #808080; border-radius: 10px; } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md index 0d9575bb3f714aed9f084bc3ae2f8a6e74bb7d16..15a1e89ddca0b91a2fe9716e2037010f63738fa6 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md @@ -15,68 +15,68 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| type | string | text | 否 | 设置滑动选择器的类型,该属性不支持动态修改,可选项有:
- text:文本选择器。
- time:时间选择器。
- date:日期选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| type | string | text | 否 | 设置滑动选择器的类型,该属性不支持动态修改,可选项有:
- text:文本选择器。
- time:时间选择器。
- date:日期选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | 文本选择器:type=text -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| range | Array | - | 否 | 设置文本选择器的取值范围。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | -| selected | string | 0 | 否 | 设置文本选择器的默认选择值,该值需要为range的索引。 | -| indicatorprefix | string | - | 否 | 文本选择器选定值增加的前缀字段。 | -| indicatorsuffix | string | - | 否 | 文本选择器选定值增加的后缀字段。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| --------------- | ------ | ---- | ---- | ---------------------------------------- | +| range | Array | - | 否 | 设置文本选择器的取值范围。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | +| selected | string | 0 | 否 | 设置文本选择器的默认选择值,该值需要为range的索引。 | +| indicatorprefix | string | - | 否 | 文本选择器选定值增加的前缀字段。 | +| indicatorsuffix | string | - | 否 | 文本选择器选定值增加的后缀字段。 | 时间选择器:type=time -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| containsecond | boolean | false | 否 | 时间选择器是否包含秒。 | -| selected | string | 当前时间 | 否 | 设置时间选择器的默认取值,格式为 HH:mm;
当包含秒时,格式为HH:mm:ss。 | -| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------- | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| containsecond | boolean | false | 否 | 时间选择器是否包含秒。 | +| selected | string | 当前时间 | 否 | 设置时间选择器的默认取值,格式为 HH:mm;
当包含秒时,格式为HH:mm:ss。 | +| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | 日期选择器:type=date -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | -| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | -| selected | string | 当前日期 | 否 | 设置日期选择器的默认选择值,格式为 YYYY-MM-DD。 | -| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | -| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------------ | ------------ | ---------- | ---- | ---------------------------------------- | +| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | +| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | +| selected | string | 当前日期 | 否 | 设置日期选择器的默认选择值,格式为 YYYY-MM-DD。 | +| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。 | 日期时间选择器:type=datetime,日期的选择范围为本年的日月。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| selected | string | 当前日期时间 | 否 | 设置日期时间选择器的默认取值,格式有两种,为月日时分MM-DD-HH-mm或者年月日时分YYYY-MM-DD-HH-mm,不设置年时,默认使用当前年,该取值表示选择器弹窗时弹窗界面的默认选择值。 | -| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | -| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | -| lunarswitch | boolean | false | 否 | 设置日期时间选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------------ | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| selected | string | 当前日期时间 | 否 | 设置日期时间选择器的默认取值,格式有两种,为月日时分MM-DD-HH-mm或者年月日时分YYYY-MM-DD-HH-mm,不设置年时,默认使用当前年,该取值表示选择器弹窗时弹窗界面的默认选择值。 | +| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期时间选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。 | 多列文本选择器:type=multi-text -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| columns | number | - | 是 | 设置多列文本选择器的列数。 | -| range | 二维Array | - | 否 | 设置多列文本选择器的选择值,该值为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | -| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗时弹窗界面的默认选择值。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | ------- | --------- | ---- | ---------------------------------------- | +| columns | number | - | 是 | 设置多列文本选择器的列数。 | +| range | 二维Array | - | 否 | 设置多列文本选择器的选择值,该值为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | +| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗时弹窗界面的默认选择值。 | ## 样式 除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| color | <color> | \#ffffff | 否 | 候选项字体颜色。 | -| font-size | <length> | 16px | 否 | 候选项字体尺寸,类型length,单位px。 | -| selected-color | <color> | #ff0a69f7 | 否 | 选中项字体颜色。 | -| selected-font-size | <length> | 20px | 否 | 选中项字体尺寸,类型length,单位px。 | -| disappear-color5+ | <color> | \#ffffff | 否 | 渐变消失项的字体颜色。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | -| disappear-font-size5+ | <length> | 14px | 否 | 渐变消失项的字体尺寸。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | -| font-family | string | sans-serif | 否 | 选项字体类型。字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------------------------------- | -------------- | ---------- | ---- | ---------------------------------------- | +| color | <color> | \#ffffff | 否 | 候选项字体颜色。 | +| font-size | <length> | 16px | 否 | 候选项字体尺寸,类型length,单位px。 | +| selected-color | <color> | #ff0a69f7 | 否 | 选中项字体颜色。 | +| selected-font-size | <length> | 20px | 否 | 选中项字体尺寸,类型length,单位px。 | +| disappear-color5+ | <color> | \#ffffff | 否 | 渐变消失项的字体颜色。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | +| disappear-font-size5+ | <length> | 14px | 否 | 渐变消失项的字体尺寸。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | +| font-family | string | sans-serif | 否 | 选项字体类型。字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | ## 事件 @@ -85,32 +85,32 @@ type=text: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | --------------- | | change | { newValue: newValue, newSelected: newSelected } | 文本选择器选定值后触发该事件。 | type=time: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ------------------------------- | | change | { hour: hour, minute: minute, [second:second]} | 时间选择器选定值后触发该事件。
包含秒时,返回时分秒。 | type=date: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | --------------- | | change | { year:year, month:month, day:day } | 日期选择器选择值后触发该事件。 | type=datetime: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ----------------- | | change | { year:year, month:month, day:day,  hour:hour, minute:minute } | 日期时间选择器选择值后触发该事件。 | type=multi-text: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------------ | ---------------------------------------- | ---------------------------------------- | | columnchange | { column:column, newValue:newValue, newSelected:newSelected } | 多列文本选择器某一列的值改变时触发该事件,column:第几列修改,newValue:选中的值,newSelected:选中值对应的索引。 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md index aae0f7e0c51f613d8f0bc597b4c68e1eb525e717..45652c36949000bb41f628ec4d1cdc36c6e8f689 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md @@ -20,89 +20,89 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:↵ -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| type | string | - | 否 | 该属性值不支持动态修改。可选择项有:
- text:文本选择器。
- date:日期选择器。
- time:时间选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| type | string | - | 否 | 该属性值不支持动态修改。可选择项有:
- text:文本选择器。
- date:日期选择器。
- time:时间选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | ### 普通选择器 滑动选择器类型设置为text时表示普通选择器。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| range | Array | - | 否 | 设置普通选择器的取值范围,如["15", "20", "25"]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | -| selected | string | 0 | 否 | 设置普通选择器弹窗的默认取值,取值需要是 range 的索引值,该取值表示选择器弹窗界面的默认选择值。 | -| value | string | - | 否 | 设置普通选择器的值。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | ------ | ---- | ---- | ---------------------------------------- | +| range | Array | - | 否 | 设置普通选择器的取值范围,如["15", "20", "25"]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | +| selected | string | 0 | 否 | 设置普通选择器弹窗的默认取值,取值需要是 range 的索引值,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 否 | 设置普通选择器的值。 | ### 日期选择器 滑动选择器类型设置为date时表示日期选择器。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | -| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | -| selected | string | 当前日期 | 否 | 设置日期选择器弹窗的默认取值,格式为 YYYY-MM-DD,该取值表示选择器弹窗界面的默认选择值。 | -| value | string | - | 是 | 设置日期选择器的值。 | -| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | -| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------------ | ------------ | ---------- | ---- | ---------------------------------------- | +| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | +| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | +| selected | string | 当前日期 | 否 | 设置日期选择器弹窗的默认取值,格式为 YYYY-MM-DD,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 是 | 设置日期选择器的值。 | +| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | ### 时间选择器 滑动选择器类型设置为time时表示时间选择器。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| containsecond | boolean | false | 否 | 设置时间选择器是否包含秒。 | -| selected | string | 当前时间 | 否 | 设置时间选择器弹窗的默认取值,格式为 HH:mm;当包含秒时,格式为HH:mm:ss,
该取值表示选择器弹窗界面的默认选择值。 | -| value | string | - | 否 | 设置时间选择器的值。 | -| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------- | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| containsecond | boolean | false | 否 | 设置时间选择器是否包含秒。 | +| selected | string | 当前时间 | 否 | 设置时间选择器弹窗的默认取值,格式为 HH:mm;当包含秒时,格式为HH:mm:ss,
该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 否 | 设置时间选择器的值。 | +| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | ### 日期时间选择器 滑动选择器类型设置为datetime时表示日期时间选择器,日期的选择范围为本年的日月。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| selected | string | 当前日期时间 | 否 | 设置日期时间选择器弹窗的默认取值,有两种可选格式。
- 月日时分:MM-DD-HH-mm
- 年月日时分:YYYY-MM-DD-HH-mm
不设置年时,默认使用当前年,该取值表示选择器弹窗界面的默认选择值。 | -| value | string | - | 是 | 设置日期时间选择器的值。 | -| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | -| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | -| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ------------------ | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| selected | string | 当前日期时间 | 否 | 设置日期时间选择器弹窗的默认取值,有两种可选格式。
- 月日时分:MM-DD-HH-mm
- 年月日时分:YYYY-MM-DD-HH-mm
不设置年时,默认使用当前年,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 是 | 设置日期时间选择器的值。 | +| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | ### 多列文本选择器 滑动选择器类型设置为multi-text时表示多列文本选择器。 -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| columns | number | - | 是 | 设置多列文本选择器的列数。 | -| range | 二维Array | - | 否 | 设置多列文本选择器的选择项,其中range 为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | -| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器弹窗的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗界面的默认选择值。 | -| value | Array | - | 否 | 设置多列文本选择器的值,每一列被选中项对应的值构成的数组。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | ------- | --------- | ---- | ---------------------------------------- | +| columns | number | - | 是 | 设置多列文本选择器的列数。 | +| range | 二维Array | - | 否 | 设置多列文本选择器的选择项,其中range 为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | +| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器弹窗的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗界面的默认选择值。 | +| value | Array | - | 否 | 设置多列文本选择器的值,每一列被选中项对应的值构成的数组。 | ## 样式 除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| text-color | <color> | - | 否 | 选择器的文本颜色。 | -| font-size | <length> | - | 否 | 选择器的文本尺寸。 | -| allow-scale | boolean | true | 否 | 选择器的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | -| letter-spacing | <length> | 0 | 否 | 选择器的字符间距。见[text组件的letter-spacing样式属性](../arkui-js/js-components-basic-text.md#样式)。 | -| text-decoration | string | - | 否 | 选择器的文本修饰。见[text组件的text-decoration样式属性](../arkui-js/js-components-basic-text.md#样式)。 | -| font-style | string | normal | 否 | 选择器的字体样式。见[text组件的font-style样式属性](../arkui-js/js-components-basic-text.md#样式)。 | -| font-weight | number \| string | normal | 否 | 选择器的字体粗细。见[text组件的font-weight样式属性](../arkui-js/js-components-basic-text.md#样式)。 | -| font-family | string | sans-serif | 否 | 选择器的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | -| line-height | <length> | 0px | 否 | 选择器的文本行高。 | -| column-height5+ | <length> | - | 否 | 选择器的选择项列表高度。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------------------------- | -------------------------- | ---------- | ---- | ---------------------------------------- | +| text-color | <color> | - | 否 | 选择器的文本颜色。 | +| font-size | <length> | - | 否 | 选择器的文本尺寸。 | +| allow-scale | boolean | true | 否 | 选择器的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| letter-spacing | <length> | 0 | 否 | 选择器的字符间距。见[text组件的letter-spacing样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| text-decoration | string | - | 否 | 选择器的文本修饰。见[text组件的text-decoration样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-style | string | normal | 否 | 选择器的字体样式。见[text组件的font-style样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-weight | number \| string | normal | 否 | 选择器的字体粗细。见[text组件的font-weight样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 选择器的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| line-height | <length> | 0px | 否 | 选择器的文本行高。 | +| column-height5+ | <length> | - | 否 | 选择器的选择项列表高度。 | ## 事件 @@ -112,52 +112,52 @@ ### 普通选择器 -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ---------------------------------------- | | change | { newValue: newValue, newSelected: newSelected } | 普通选择器选择值后点击弹窗中的确定按钮时触发该事件(newSelected为索引)。 | -| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | ### 日期选择器 -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ---------------------------------------- | | change | { year: year, month: month, day: day } | 日期选择器选择值后点击弹窗中的确认按钮时触发该事件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> month值范围为: 0(1月)~11(12月)。5+ | -| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | ### 日期时间选择器 -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ---------------------------- | | change | { year: year, month: month, day: day,  hour: hour, minute: minute} | 日期时间选择器选择值后点击弹窗中的确认按钮时触发该事件。 | -| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | ### 时间选择器 -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | +| 名称 | 参数 | 描述 | +| ------ | ---------------------------------------- | ---------------------------------------- | | change | { hour: hour, minute: minute, [second: second] } | 时间选择器选择值后点击弹窗中的确认按钮时触发该事件,当使用时分秒时,还包含秒数据。 | -| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | ### 多列文本选择器 -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | -| change | { newValue: [newValue1, newValue2, newValue3, …], newSelected:[newSelected1, newSelected2, newSelected3, …] } | 多列文本选择器选择值后点击弹窗中的确认按钮时触发该事件,其中:
- newValue:被选中项对应的值构成的数组。
- newSelected:被选中项对应的索引构成的数组,两者的长度和range的长度一致。 | +| 名称 | 参数 | 描述 | +| ------------ | ---------------------------------------- | ---------------------------------------- | +| change | { newValue: [newValue1, newValue2, newValue3, …], newSelected:[newSelected1, newSelected2, newSelected3, …] } | 多列文本选择器选择值后点击弹窗中的确认按钮时触发该事件,其中:
- newValue:被选中项对应的值构成的数组。
- newSelected:被选中项对应的索引构成的数组,两者的长度和range的长度一致。 | | columnchange | { column: column, newValue: newValue, newSelected: newSelected } | 多列文本选择器中某一列的值改变时触发该事件,其中:
- column:第几列修改。
- newValue:选中的值。
- newSelected:选中值对应的索引。 | -| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | ## 方法 除支持[通用方法](../arkui-js/js-components-common-methods.md)外,支持如下方法: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | -| show | - | 显示 picker。 | +| 名称 | 参数 | 描述 | +| ---- | ---- | --------------- | +| show | - | 显示 picker。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md index d2975d0745deaf8be7f5e632ceaff68b80b410fd..c25ba6285163c57c5bfc9e76828baf0b9fd1daa2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md @@ -99,11 +99,6 @@ width: 400px; height: 400px; border: 20px; - border-image-source: url("/common/images/landscape.jpg"); - border-image-slice: 20px; - border-image-width: 30px; - border-image-outset: 10px; - border-image-repeat: round; } .title { font-size: 80px; diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index be29b6d2c188431ecc74b254a745882553b282b8..c3e72b293f1c67d72d7e25e76192568ebdb7802b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -12,7 +12,7 @@
- <input type="button" style="width: 180px; height: 60px;" value="fillStyle" onclick="antialias" />
+ ; ``` ``` @@ -27,9 +27,14 @@ }, antialias() { const el = this.$refs.canvas1; - const ctx = el.getContext('2d', { antialias: true }); ctx.beginPath(); ctx.arc(100, 75, 50, 0, 6.28); ctx.stroke(); }} + const ctx = el.getContext('2d', { antialias: true }); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + } + } ``` - + - 示意图(关闭抗锯齿) ![zh-cn_image_0000001214837333](figures/zh-cn_image_0000001214837333.png) @@ -260,10 +265,8 @@ export default { ctx.moveTo(140, 10); ctx.lineTo(140, 160); ctx.stroke(); - ctx.font = '18px sans-serif'; - - // Show the different textAlign values + // Show the different textAlign values ctx.textAlign = 'start'; ctx.fillText('textAlign=start', 140, 60); ctx.textAlign = 'end'; @@ -300,9 +303,7 @@ export default { ctx.moveTo(0, 120); ctx.lineTo(400, 120); ctx.stroke(); - ctx.font = '20px sans-serif'; - ctx.textBaseline = 'top'; ctx.fillText('Top', 10, 120); ctx.textBaseline = 'bottom'; @@ -339,7 +340,6 @@ export default { ctx.globalAlpha = 0.4; ctx.fillStyle = 'rgb(0,0,255)'; ctx.fillRect(50, 50, 50, 50); - } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md index 973948bf46b9df774fb2db3fe1ee0b54e86042e7..d83a0cba9ca04fac1627ed87739b9fbe05c7e02e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md @@ -13,29 +13,29 @@ 相对于私有事件,大部分组件都可以绑定如下事件。 -| 名称 | 参数 | 描述 | 是否支持冒泡 | -| -------- | -------- | -------- | -------- | -| touchstart | TouchEvent | 手指刚触摸屏幕时触发该事件。
> **说明:**TouchEvent具体可参考表2 TouchEvent对象属性列表 | 是5+ | -| touchmove | TouchEvent | 手指触摸屏幕后移动时触发该事件。 | 是5+ | -| touchcancel | TouchEvent | 手指触摸屏幕中动作被打断时触发该事件。 | 是5+ | -| touchend | TouchEvent | 手指触摸结束离开屏幕时触发该事件。 | 是5+ | -| click | - | 点击动作触发该事件。 | 是6+ | -| doubleclick7+ | - | 双击动作触发该事件 | 否 | -| longpress | - | 长按动作触发该事件。 | 否 | -| swipe5+ | SwipeEvent | 组件上快速滑动后触发该事件。
> **说明:**SwipeEvent具体可参考表6 SwipeEvent 基础事件对象属性列表 | 否 | -| attached6+ | - | 当前组件节点挂载在渲染树后触发。 | 否 | -| detached6+ | - | 当前组件节点从渲染树中移除后触发。 | 否 | -| pinchstart7+ | PinchEvent | 手指开始执行捏合操作时触发该事件。
> **说明:**PinchEvent具体可参考表7 PinchEvent 对象属性列表 | 否 | -| pinchupdate7+ | PinchEvent | 手指执行捏合操作过程中触发该事件。 | 否 | -| pinchend7+ | PinchEvent | 手指捏合操作结束离开屏幕时触发该事件。 | 否 | -| pinchcancel7+ | PinchEvent | 手指捏合操作被打断时触发该事件。 | 否 | -| dragstart7+ | DragEvent | 用户开始拖拽时触发该事件。
> **说明:**DragEvent具体可参考表8 DragEvent对象属性列表 | 否 | -| drag7+ | DragEvent | 拖拽过程中触发该事件。 | 否 | -| dragend7+ | DragEvent | 用户拖拽完成后触发。 | 否 | -| dragenter7+ | DragEvent | 进入释放目标时触发该事件。 | 否 | -| dragover7+ | DragEvent | 在释放目标内拖动时触发。 | 否 | -| dragleave7+ | DragEvent | 离开释放目标区域时触发。 | 否 | -| drop7+ | DragEvent | 在可释放目标区域内释放时触发。 | 否 | +| 名称 | 参数 | 描述 | 是否支持冒泡 | +| ------------------------ | ---------- | ---------------------------------------- | -------------- | +| touchstart | TouchEvent | 手指刚触摸屏幕时触发该事件。
> **说明:** TouchEvent具体可参考表2 TouchEvent对象属性列表 | 是5+ | +| touchmove | TouchEvent | 手指触摸屏幕后移动时触发该事件。 | 是5+ | +| touchcancel | TouchEvent | 手指触摸屏幕中动作被打断时触发该事件。 | 是5+ | +| touchend | TouchEvent | 手指触摸结束离开屏幕时触发该事件。 | 是5+ | +| click | - | 点击动作触发该事件。 | 是6+ | +| doubleclick7+ | - | 双击动作触发该事件 | 否 | +| longpress | - | 长按动作触发该事件。 | 否 | +| swipe5+ | SwipeEvent | 组件上快速滑动后触发该事件。
> **说明:** SwipeEvent具体可参考表6 SwipeEvent 基础事件对象属性列表 | 否 | +| attached6+ | - | 当前组件节点挂载在渲染树后触发。 | 否 | +| detached6+ | - | 当前组件节点从渲染树中移除后触发。 | 否 | +| pinchstart7+ | PinchEvent | 手指开始执行捏合操作时触发该事件。
> **说明:** PinchEvent具体可参考表7 PinchEvent 对象属性列表 | 否 | +| pinchupdate7+ | PinchEvent | 手指执行捏合操作过程中触发该事件。 | 否 | +| pinchend7+ | PinchEvent | 手指捏合操作结束离开屏幕时触发该事件。 | 否 | +| pinchcancel7+ | PinchEvent | 手指捏合操作被打断时触发该事件。 | 否 | +| dragstart7+ | DragEvent | 用户开始拖拽时触发该事件。
> **说明:** DragEvent具体可参考表8 DragEvent对象属性列表 | 否 | +| drag7+ | DragEvent | 拖拽过程中触发该事件。 | 否 | +| dragend7+ | DragEvent | 用户拖拽完成后触发。 | 否 | +| dragenter7+ | DragEvent | 进入释放目标时触发该事件。 | 否 | +| dragover7+ | DragEvent | 在释放目标内拖动时触发。 | 否 | +| dragleave7+ | DragEvent | 离开释放目标区域时触发。 | 否 | +| drop7+ | DragEvent | 在可释放目标区域内释放时触发。 | 否 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** @@ -43,52 +43,52 @@ **表1** BaseEvent对象属性列表 -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| type | string | 当前事件的类型,比如click、longpress等。 | -| timestamp | number | 该事件触发时的时间戳。 | +| 属性 | 类型 | 说明 | +| --------- | ------ | --------------------------- | +| type | string | 当前事件的类型,比如click、longpress等。 | +| timestamp | number | 该事件触发时的时间戳。 | **表2** TouchEvent对象属性列表(继承BaseEvent) -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| touches | Array<TouchInfo> | 触摸事件时的属性集合,包含屏幕触摸点的信息数组。 | +| 属性 | 类型 | 说明 | +| -------------- | ---------------------- | ---------------------------------------- | +| touches | Array<TouchInfo> | 触摸事件时的属性集合,包含屏幕触摸点的信息数组。 | | changedTouches | Array<TouchInfo> | 触摸事件时的属性集合,包括产生变化的屏幕触摸点的信息数组。数据格式和touches一样。该属性表示有变化的触摸点,如从无变有,位置变化,从有变无。例如用户手指刚接触屏幕时,touches数组中有数据,但changedTouches无数据。 | **表3** TouchInfo -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| globalX | number | 距离屏幕左上角(不包括状态栏)横向距离。屏幕的左上角为原点。 | -| globalY | number | 距离屏幕左上角(不包括状态栏)纵向距离。屏幕的左上角为原点。 | -| localX | number | 距离被触摸组件左上角横向距离。组件的左上角为原点。 | -| localY | number | 距离被触摸组件左上角纵向距离。组件的左上角为原点。 | -| size | number | 触摸接触面积。 | -| force6+ | number | 接触力信息。 | +| 属性 | 类型 | 说明 | +| ------------------ | ------ | ------------------------------ | +| globalX | number | 距离屏幕左上角(不包括状态栏)横向距离。屏幕的左上角为原点。 | +| globalY | number | 距离屏幕左上角(不包括状态栏)纵向距离。屏幕的左上角为原点。 | +| localX | number | 距离被触摸组件左上角横向距离。组件的左上角为原点。 | +| localY | number | 距离被触摸组件左上角纵向距离。组件的左上角为原点。 | +| size | number | 触摸接触面积。 | +| force6+ | number | 接触力信息。 | **表6** SwipeEvent 基础事件对象属性列表(继承BaseEvent) -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| direction | string | 滑动方向,可能值有:
1. left:向左滑动;
2. right:向右滑动;
3. up:向上滑动;
4. down:向下滑动。 | -| distance6+ | number | 在滑动方向上的滑动距离。 | +| 属性 | 类型 | 说明 | +| --------------------- | ------ | ---------------------------------------- | +| direction | string | 滑动方向,可能值有:
1. left:向左滑动;
2. right:向右滑动;
3. up:向上滑动;
4. down:向下滑动。 | +| distance6+ | number | 在滑动方向上的滑动距离。 | **表7** PinchEvent 对象属性列表7+ -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| scale | number | 缩放比例 | +| 属性 | 类型 | 说明 | +| ------------ | ------ | -------------- | +| scale | number | 缩放比例 | | pinchCenterX | number | 捏合中心点X轴坐标,单位px | | pinchCenterY | number | 捏合中心点Y轴坐标,单位px | **表8** DragEvent对象属性列表(继承BaseEvent)7+ -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | -| type | string | 事件名称。 | -| globalX | number | 距离屏幕左上角坐标原点横向距离。 | -| globalY | number | 距离屏幕左上角坐标原点纵向距离。 | -| timestamp | number | 时间戳。 | +| 属性 | 类型 | 说明 | +| --------- | ------ | ---------------- | +| type | string | 事件名称。 | +| globalX | number | 距离屏幕左上角坐标原点横向距离。 | +| globalY | number | 距离屏幕左上角坐标原点纵向距离。 | +| timestamp | number | 时间戳。 | ## 事件对象 @@ -96,8 +96,8 @@ **target对象:** -| 属性 | 类型 | 说明 | -| -------- | -------- | -------- | +| 属性 | 类型 | 说明 | +| -------------------- | ------ | ---------------------------------------- | | dataSet6+ | Object | 组件上通过通用属性设置的[data-*](../arkui-js/js-components-common-attributes.md)的自定义属性组成的集合。 | **示例:** 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 395c073392a4752667b6f61f42752d6173a17f9b..0c59395b6ff772d622eb280c1699979c916cf4c4 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 @@ -6,63 +6,63 @@ 组件普遍支持的可以在style或css中设置组件外观样式。 -| 名称 | 类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| width | <length> \| <percentage> | - | 设置组件自身的宽度。
缺省时使用元素自身内容需要的宽度。
| -| height | <length> \| <percentage> | - | 设置组件自身的高度。
缺省时使用元素自身内容需要的高度。
| -| min-width5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小宽度。 | -| min-height5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小高度。 | -| max-width5+ | <length> \| <percentage>6+ | - | 设置元素的最大宽度。默认无限制。 | -| max-height5+ | <length> \| <percentage>6+ | - | 设置元素的最大高度。默认无限制。 | -| padding | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的内边距属性。
该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | -| padding-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下内边距属性。 | -| padding-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端内边距属性。 | -| margin | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | -| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下外边距属性。 | -| margin-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端外边距属性。 | -| border | - | 0 | 使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。 | -| border-style | string | solid | 使用简写属性设置所有边框的样式,可选值为:
- dotted:显示为一系列圆点,圆点半径为border-width的一半。
- dashed:显示为一系列短的方形虚线。
- solid:显示为一条实线。 | -| border-[left\|top\|right\|bottom]-style | string | solid | 分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。 | -| border-[left\|top\|right\|bottom] | - | - | 使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。 | -| border-width | <length> | 0 | 使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度。 | -| border-[left\|top\|right\|bottom]-width | <length> | 0 | 分别设置左、上、右、下四个边框的宽度。 | -| border-color | <color> | black | 使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色。 | -| border-[left\|top\|right\|bottom]-color | <color> | black | 分别设置左、上、右、下四个边框的颜色。 | -| border-radius | <length> | - | border-radius属性设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left\|top\|right\|bottom]-width,border-[left\|top\|right\|bottom]-color ,border-[left\|top\|right\|bottom]-style,如果要设置color、width和style,需要将四个方向一起设置(border-width、border-color、border-style)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 顺序为左下、右下、左上和右上。 | -| border-[top\|bottom]-[left\|right]-radius | <length> | - | 分别设置左上,右上,右下和左下四个角的圆角半径。 | -| background | <linear-gradient> | - | 仅支持设置[渐变样式](../arkui-js/js-components-common-gradient.md),与background-color、background-image不兼容。 | -| background-color | <color> | - | 设置背景颜色。 | -| background-image | string | - | 设置背景图片。与background-color、background不兼容,支持网络图片资源和本地图片资源地址。
示例:
- background-image: url("/common/background.png")
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 不支持svg格式图片。 | -| background-size | - string
- <length> <length>
- <percentage> <percentage> | auto | 设置背景图片的大小。
- string可选值:
  - contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  - cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。
  - auto:保持原图的比例不变。
- length值参数方式:
  设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
- 百分比参数方式:
  以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | -| background-repeat | string | repeat | 针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。
- repeat:在水平轴和竖直轴上同时重复绘制图片。
- repeat-x:只在水平轴上重复绘制图片。
- repeat-y:只在竖直轴上重复绘制图片。
- no-repeat:不会重复绘制图片。 | -| background-position | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | - 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
  - left:水平方向上最左侧。
  - right:水平方向上最右侧。
  - top:竖直方向上最顶部。
  - bottom:竖直方向上最底部。
  - center:水平方向或竖直方向上中间位置。
- length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
- 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
- 可以混合使用<percentage>和<length>。 | -| box-shadow5+ | string | 0 | 语法:box-shadow: h-shadow v-shadow blur spread color
通过这个样式可以设置当前组件的阴影样式,包括水平位置(必填)、垂直位置(必填)、模糊半径(可选,默认值为0)、阴影延展距离(可选,默认值为0)、阴影颜色(可选,默认值为黑色)。
示例:
- box-shadow :10px 20px 5px 10px \#888888
- box-shadow :100px 100px 30px red
- box-shadow :-100px -100px 0px 40px | -| filter5+ | string | - | 语法:filter: blur(px)
通过这个样式可以设置当前组件布局范围的内容模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- filter: blur(10px) | -| backdrop-filter5+ | string | - | 语法:backdrop-filter: blur(px)
通过这个样式可以设置当前组件布局范围的背景模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- backdrop-filter: blur(10px) | -| window-filter5+ | string | - | 语法:window-filter: blur(percent), style5+
通过这个样式可以设置当前组件布局范围的窗口模糊程度和模糊样式,如果没有设置值,则默认是0%(不模糊),多块模糊区域时不支持设置不同的模糊值和模糊样式。style可选值:small_light(默认值), medium_light, large_light, xlarge_light, small_dark, medium_dark, large_dark, xlarge_dark。
示例:
- window-filter: blur(50%)
- window-filter: blur(10%), large_light
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 | -| opacity | number | 1 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | -| display | string | flex | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | -| visibility | string | visible | 是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:
- visible:元素正常显示。
- hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> visibility和display样式都设置时,仅display生效。 | -| flex | number \| string | - | 规定当前组件如何适应父组件中的可用空间。
flex可以指定1个、2个5+或3个5+值。
单值语法:
- 一个无单位数:用来设置组件的flex-grow。
- 一个有效的宽度值5+:用来设置组件的flex-basis。
双值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow。第二个值是以下之一:
- 一个无单位数:用来设置组件的flex-shrink。
- 一个有效的宽度值:用来设置组件的flex-basis。
三值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow;第二个值必须是无单位数,用来设置组件的flex-shrink;第三个值必须是一个有效的宽度值,用来设置组件的flex-basis。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | -| flex-grow | number | 0 | 设置组件的拉伸样式,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex子元素占用的大小)的分配权重。0为不伸展。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | -| flex-shrink | number | 1 | 设置组件的收缩样式,元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | -| flex-basis | <length> | - | 设置组件在主轴方向上的初始大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | -| align-self6+ | string | - | 设置自身在父元素交叉轴上的对齐方式,该样式会覆盖父元素的align-items样式,仅在父容器为div、list。可选值为:
- stretch 弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start 元素向交叉轴起点对齐。
- flex-end 元素向交叉轴终点对齐。
- center 元素在交叉轴居中。
- baseline 元素在交叉轴基线对齐。 | -| position | string | relative | 设置元素的定位类型,不支持动态变更。
- fixed:相对与整个界面进行定位。
- absolute:相对于父元素进行定位。
- relative:相对于其正常位置进行定位。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> absolute属性仅在父容器为<div>、<stack>时生效。 | -| [left\|top\|right\|bottom] | <length> \| <percentage>6+ | - | left\|top\|right\|bottom需要配合position样式使用,来确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。
- right属性规定元素的右边缘。该属性定义了定位元素右外边距边界与其包含块右边界之间的偏移。
- bottom属性规定元素的底部边缘。该属性定义了一个定位元素的下外边距边界与其包含块下边界之间的偏移。 | -| [start \| end]6+ | <length> \| <percentage> | - | start \| end需要配合position样式使用,来确定元素的偏移位置。
- start属性规定元素的起始边缘。该属性定义了定位元素起始外边距边界与其包含块起始边界之间的偏移。
- end属性规定元素的结尾边缘。该属性定义了一个定位元素的结尾边距边界与其包含块结尾边界之间的偏移。 | -| z-index6+ | number | - | 表示对于同一父节点其子节点的渲染顺序。数值越大,渲染数据越靠后。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> z-index不支持auto,并且opacity等其他样式不会影响z-index的渲染顺序。 | -| image-fill6+ | <color> | - | 为svg图片填充颜色,支持组件范围(与设置图片资源的属性):button(icon属性)、piece(icon属性)、search(icon属性)、input(headericon属性)、textarea(headericon属性)、image(src属性)、toolbar-item(icon属性)。
svg图片文件内的fill属性颜色值在渲染时将被替换为image-fill所配的颜色值,且仅对svg图片内显示声明的fill属性生效。 | -| clip-path6+ | [ <geometry-box> \|\| <basic-shape> ] \| none | - | 设置组件的裁剪区域。区域内的部分显示,区域外的不显示。
<geometry-box>:表示裁剪区域的作用范围,默认为border-box。可选值为:
- margin-box:margin计算入长宽尺寸内。
- border-box:border计算入长宽尺寸内。
- padding-box:padding计算入长宽尺寸内。
- content-box:margin/border/padding不计算入长宽尺寸内。
<basic-shape>:表示裁剪的形状。包含以下类型:
- inset,格式为:inset( <percentage>{1,4} [ round <'border-radius'> ]? )。
- circle,格式为:circle( [ <percentage> ]? [ at <percentage> <percentage> ]? )。
- ellipse,格式为:ellipse( [ <percentage>{2} ]? [ at <percentage> <percentage> ]? )。
- polygon,格式为:polygon( [ <percentage> <percentage> ]\# )
- path,格式为:path( <string> )。 | -| mask-image6+ | - <linear-gradient>
- string | - | 设置渐变色遮罩或本地图片设置。
设置渐变色遮罩,示例:
linear-gradient(to left, black, white)
设置纯色遮罩,示例:
linear-gradient(to right, grey , grey)
设置本地svg图片为遮罩,示例:url(common/mask.svg) | -| mask-size6+ | - string
- <length><length>
- <percentage> <percentage> | auto | 设置遮罩图片显示大小,仅当mask-image为图片资源时有效。
string可选值:
- contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
- cover:把图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
- auto:保持原图的比例不变。
length值参数方式:设置图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
百分比参数方式:以原图宽高的百分比来设置图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | -| mask-position6+ | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | 设置遮罩图片显示位置,仅当mask-image为图片资源时有效。关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
string可选值:
- left:水平方向上最左侧。
- right:水平方向上最右侧。
- top:竖直方向上最顶部。
- bottom:竖直方向上最底部。
- center:水平方向或竖直方向上中间位置。
length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
可以混合使用<percentage>和<length>。 | -| border-image-source7+ | string | - | 指定元素的边框图片。
示例:
border-image-source: url("/common/images/border.png") | -| border-image-slice7+ | <length> \| <percentage> | 0 | 指定图片的边界内向偏移。
该属性可以有1到4个值:
指定一个值时,该值指定四个边的内偏移。
指定两个值时,第一个值指定上下两边的内偏移,第二个指定左右两边的内偏移。
指定三个值时,第一个指定上边的内偏移,第二个指定左右两边的内偏移,第三个指定下边的内偏移。
指定四个值时分别为上、右、下、左边的内偏移(顺时针顺序)。 | -| border-image-width7+ | <length> \| <percentage> | 0 | 指定图片边界的宽度。
指定一个值时,该值指定四个边的宽度。
指定两个值时,第一个值指定上下两边的宽度 ,第二个指定左右两边的宽度。
指定三个值时,第一个指定上边的宽度 ,第二个指定左右两边的宽度 ,第三个指定下边的宽度。
指定四个值时分别为上、右、下、左边的宽度 (顺时针顺序)。 | -| border-image-outset7+ | <length> \| <percentage> | 0 | 指定边框图像可超出边框的大小。
指定一个值时,边框图像在四个方向超出边框的距离。
指定两个值时,第一个值指定上下两边的边框图像超出边框的距离,第二个指定左右两边的 。
指定三个值时,第一个指定上边的边框图像超出边框的距离 ,第二个指定左右两边的边框图像超出边框的距离 ,第三个指定下边的边框图像超出边框的距离 。
指定四个值时分别为上、右、下、左边的边框图像超出边框的距离 (顺时针顺序)。 | -| border-image-repeat7+ | string | stretch | 定义图片如何填充边框。
stretch: 拉伸图片以填充边框。
repeat:平铺图片以填充边框。
round:平铺图像。当不能整数次平铺时,根据情况放大或缩小图像。
| -| border-image7+ | string | - | 简写属性,可以选择以下两种设置方式:
- 设置图片边框的每个属性。包含图像的边界向内偏移,图像边界的宽度,边框图像可超出边框盒的大小,图片如何填充边框,顺序设置为 border-image-source ,border-image-slice,border-image-width,border-image-outset,border-image-repeat,不设置的值为默认值。
- 渐变色边框
  示例:
  border-image: linear-gradient(red, yellow) 10px | +| 名称 | 类型 | 默认值 | 描述 | +| ---------------------------------------- | ---------------------------------------- | ------------ | ---------------------------------------- | +| width | <length> \| <percentage> | - | 设置组件自身的宽度。
缺省时使用元素自身内容需要的宽度。
| +| height | <length> \| <percentage> | - | 设置组件自身的高度。
缺省时使用元素自身内容需要的高度。
| +| min-width5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小宽度。 | +| min-height5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小高度。 | +| max-width5+ | <length> \| <percentage>6+ | - | 设置元素的最大宽度。默认无限制。 | +| max-height5+ | <length> \| <percentage>6+ | - | 设置元素的最大高度。默认无限制。 | +| padding | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的内边距属性。
该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下内边距属性。 | +| padding-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下外边距属性。 | +| margin-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端外边距属性。 | +| border | - | 0 | 使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。 | +| border-style | string | solid | 使用简写属性设置所有边框的样式,可选值为:
- dotted:显示为一系列圆点,圆点半径为border-width的一半。
- dashed:显示为一系列短的方形虚线。
- solid:显示为一条实线。 | +| border-[left\|top\|right\|bottom]-style | string | solid | 分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。 | +| border-[left\|top\|right\|bottom] | - | - | 使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。 | +| border-width | <length> | 0 | 使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度。 | +| border-[left\|top\|right\|bottom]-width | <length> | 0 | 分别设置左、上、右、下四个边框的宽度。 | +| border-color | <color> | black | 使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色。 | +| border-[left\|top\|right\|bottom]-color | <color> | black | 分别设置左、上、右、下四个边框的颜色。 | +| border-radius | <length> | - | border-radius属性设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left\|top\|right\|bottom]-width,border-[left\|top\|right\|bottom]-color ,border-[left\|top\|right\|bottom]-style,如果要设置color、width和style,需要将四个方向一起设置(border-width、border-color、border-style)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 顺序为左下、右下、左上和右上。 | +| border-[top\|bottom]-[left\|right]-radius | <length> | - | 分别设置左上,右上,右下和左下四个角的圆角半径。 | +| background | <linear-gradient> | - | 仅支持设置[渐变样式](../arkui-js/js-components-common-gradient.md),与background-color、background-image不兼容。 | +| background-color | <color> | - | 设置背景颜色。 | +| background-image | string | - | 设置背景图片。与background-color、background不兼容,支持网络图片资源和本地图片资源地址。
示例:
- background-image: url("/common/background.png")
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 不支持svg格式图片。 | +| background-size | - string
- <length> <length>
- <percentage> <percentage> | auto | 设置背景图片的大小。
- string可选值:
  - contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  - cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。
  - auto:保持原图的比例不变。
- length值参数方式:
  设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
- 百分比参数方式:
  以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| background-repeat | string | repeat | 针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。
- repeat:在水平轴和竖直轴上同时重复绘制图片。
- repeat-x:只在水平轴上重复绘制图片。
- repeat-y:只在竖直轴上重复绘制图片。
- no-repeat:不会重复绘制图片。 | +| background-position | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | - 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
  - left:水平方向上最左侧。
  - right:水平方向上最右侧。
  - top:竖直方向上最顶部。
  - bottom:竖直方向上最底部。
  - center:水平方向或竖直方向上中间位置。
- length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
- 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
- 可以混合使用<percentage>和<length>。 | +| box-shadow5+ | string | 0 | 语法:box-shadow: h-shadow v-shadow blur spread color
通过这个样式可以设置当前组件的阴影样式,包括水平位置(必填)、垂直位置(必填)、模糊半径(可选,默认值为0)、阴影延展距离(可选,默认值为0)、阴影颜色(可选,默认值为黑色)。
示例:
- box-shadow :10px 20px 5px 10px \#888888
- box-shadow :100px 100px 30px red
- box-shadow :-100px -100px 0px 40px | +| filter5+ | string | - | 语法:filter: blur(px)
通过这个样式可以设置当前组件布局范围的内容模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- filter: blur(10px) | +| backdrop-filter5+ | string | - | 语法:backdrop-filter: blur(px)
通过这个样式可以设置当前组件布局范围的背景模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- backdrop-filter: blur(10px) | +| window-filter5+ | string | - | 语法:window-filter: blur(percent), style5+
通过这个样式可以设置当前组件布局范围的窗口模糊程度和模糊样式,如果没有设置值,则默认是0%(不模糊),多块模糊区域时不支持设置不同的模糊值和模糊样式。style可选值:small_light(默认值), medium_light, large_light, xlarge_light, small_dark, medium_dark, large_dark, xlarge_dark。
示例:
- window-filter: blur(50%)
- window-filter: blur(10%), large_light | +| opacity | number | 1 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| visibility | string | visible | 是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:
- visible:元素正常显示。
- hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> visibility和display样式都设置时,仅display生效。 | +| flex | number \| string | - | 规定当前组件如何适应父组件中的可用空间。
flex可以指定1个、2个5+或3个5+值。
单值语法:
- 一个无单位数:用来设置组件的flex-grow。
- 一个有效的宽度值5+:用来设置组件的flex-basis。
双值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow。第二个值是以下之一:
- 一个无单位数:用来设置组件的flex-shrink。
- 一个有效的宽度值:用来设置组件的flex-basis。
三值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow;第二个值必须是无单位数,用来设置组件的flex-shrink;第三个值必须是一个有效的宽度值,用来设置组件的flex-basis。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-grow | number | 0 | 设置组件的拉伸样式,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex子元素占用的大小)的分配权重。0为不伸展。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-shrink | number | 1 | 设置组件的收缩样式,元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-basis | <length> | - | 设置组件在主轴方向上的初始大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| align-self6+ | string | - | 设置自身在父元素交叉轴上的对齐方式,该样式会覆盖父元素的align-items样式,仅在父容器为div、list。可选值为:
- stretch 弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start 元素向交叉轴起点对齐。
- flex-end 元素向交叉轴终点对齐。
- center 元素在交叉轴居中。
- baseline 元素在交叉轴基线对齐。 | +| position | string | relative | 设置元素的定位类型,不支持动态变更。
- fixed:相对与整个界面进行定位。
- absolute:相对于父元素进行定位。
- relative:相对于其正常位置进行定位。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> absolute属性仅在父容器为<div>、<stack>时生效。 | +| [left\|top\|right\|bottom] | <length> \| <percentage>6+ | - | left\|top\|right\|bottom需要配合position样式使用,来确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。
- right属性规定元素的右边缘。该属性定义了定位元素右外边距边界与其包含块右边界之间的偏移。
- bottom属性规定元素的底部边缘。该属性定义了一个定位元素的下外边距边界与其包含块下边界之间的偏移。 | +| [start \| end]6+ | <length> \| <percentage> | - | start \| end需要配合position样式使用,来确定元素的偏移位置。
- start属性规定元素的起始边缘。该属性定义了定位元素起始外边距边界与其包含块起始边界之间的偏移。
- end属性规定元素的结尾边缘。该属性定义了一个定位元素的结尾边距边界与其包含块结尾边界之间的偏移。 | +| z-index6+ | number | - | 表示对于同一父节点其子节点的渲染顺序。数值越大,渲染数据越靠后。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> z-index不支持auto,并且opacity等其他样式不会影响z-index的渲染顺序。 | +| image-fill6+ | <color> | - | 为svg图片填充颜色,支持组件范围(与设置图片资源的属性):button(icon属性)、piece(icon属性)、search(icon属性)、input(headericon属性)、textarea(headericon属性)、image(src属性)、toolbar-item(icon属性)。
svg图片文件内的fill属性颜色值在渲染时将被替换为image-fill所配的颜色值,且仅对svg图片内显示声明的fill属性生效。 | +| clip-path6+ | [ <geometry-box> \|\| <basic-shape> ] \| none | - | 设置组件的裁剪区域。区域内的部分显示,区域外的不显示。
<geometry-box>:表示裁剪区域的作用范围,默认为border-box。可选值为:
- margin-box:margin计算入长宽尺寸内。
- border-box:border计算入长宽尺寸内。
- padding-box:padding计算入长宽尺寸内。
- content-box:margin/border/padding不计算入长宽尺寸内。
<basic-shape>:表示裁剪的形状。包含以下类型:
- inset,格式为:inset( <percentage>{1,4} [ round <'border-radius'> ]? )。
- circle,格式为:circle( [ <percentage> ]? [ at <percentage> <percentage> ]? )。
- ellipse,格式为:ellipse( [ <percentage>{2} ]? [ at <percentage> <percentage> ]? )。
- polygon,格式为:polygon( [ <percentage> <percentage> ]\# )
- path,格式为:path( <string> )。 | +| mask-image6+ | - <linear-gradient>
- string | - | 设置渐变色遮罩或本地图片设置。
设置渐变色遮罩,示例:
linear-gradient(to left, black, white)
设置纯色遮罩,示例:
linear-gradient(to right, grey , grey)
设置本地svg图片为遮罩,示例:url(common/mask.svg) | +| mask-size6+ | - string
- <length><length>
- <percentage> <percentage> | auto | 设置遮罩图片显示大小,仅当mask-image为图片资源时有效。
string可选值:
- contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
- cover:把图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
- auto:保持原图的比例不变。
length值参数方式:设置图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
百分比参数方式:以原图宽高的百分比来设置图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| mask-position6+ | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | 设置遮罩图片显示位置,仅当mask-image为图片资源时有效。关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
string可选值:
- left:水平方向上最左侧。
- right:水平方向上最右侧。
- top:竖直方向上最顶部。
- bottom:竖直方向上最底部。
- center:水平方向或竖直方向上中间位置。
length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
可以混合使用<percentage>和<length>。 | +| border-image-source7+ | string | - | 指定元素的边框图片。
示例:
border-image-source: url("/common/images/border.png") | +| border-image-slice7+ | <length> \| <percentage> | 0 | 指定图片的边界内向偏移。
该属性可以有1到4个值:
指定一个值时,该值指定四个边的内偏移。
指定两个值时,第一个值指定上下两边的内偏移,第二个指定左右两边的内偏移。
指定三个值时,第一个指定上边的内偏移,第二个指定左右两边的内偏移,第三个指定下边的内偏移。
指定四个值时分别为上、右、下、左边的内偏移(顺时针顺序)。 | +| border-image-width7+ | <length> \| <percentage> | 0 | 指定图片边界的宽度。
指定一个值时,该值指定四个边的宽度。
指定两个值时,第一个值指定上下两边的宽度 ,第二个指定左右两边的宽度。
指定三个值时,第一个指定上边的宽度 ,第二个指定左右两边的宽度 ,第三个指定下边的宽度。
指定四个值时分别为上、右、下、左边的宽度 (顺时针顺序)。 | +| border-image-outset7+ | <length> \| <percentage> | 0 | 指定边框图像可超出边框的大小。
指定一个值时,边框图像在四个方向超出边框的距离。
指定两个值时,第一个值指定上下两边的边框图像超出边框的距离,第二个指定左右两边的 。
指定三个值时,第一个指定上边的边框图像超出边框的距离 ,第二个指定左右两边的边框图像超出边框的距离 ,第三个指定下边的边框图像超出边框的距离 。
指定四个值时分别为上、右、下、左边的边框图像超出边框的距离 (顺时针顺序)。 | +| border-image-repeat7+ | string | stretch | 定义图片如何填充边框。
stretch: 拉伸图片以填充边框。
repeat:平铺图片以填充边框。
round:平铺图像。当不能整数次平铺时,根据情况放大或缩小图像。
| +| border-image7+ | string | - | 简写属性,可以选择以下两种设置方式:
- 设置图片边框的每个属性。包含图像的边界向内偏移,图像边界的宽度,边框图像可超出边框盒的大小,图片如何填充边框,顺序设置为 border-image-source ,border-image-slice,border-image-width,border-image-outset,border-image-repeat,不设置的值为默认值。
- 渐变色边框
  示例:
  border-image: linear-gradient(red, yellow) 10px | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md index 89b93114ef1b03e466d2b2bb42cbd6f8e90d159a..d11f2880032400ea6ee0152a2902820d519ab181 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md @@ -24,9 +24,9 @@ 除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| type | string | default | 否 | list-item-group类型,同一list支持多种type的list-item-group,相同type的list-item-group需要确保渲染后的视图布局也完全相同,当type固定时,使用show属性代替if属性,确保视图布局不变。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| ---- | ------ | ------- | ---- | ---------------------------------------- | +| type | string | default | 否 | list-item-group类型,同一list支持多种type的list-item-group,相同type的list-item-group需要确保渲染后的视图布局也完全相同,当type固定时,使用show属性代替if属性,确保视图布局不变。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > @@ -37,21 +37,21 @@ 除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -| 名称 | 类型 | 默认值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下
- row:水平方向从左到右 | -| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。
- space-evenly5+:  均匀排列每个元素,每个元素之间的间隔相等。 | +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| --------------- | ------ | ---------- | ---- | ---------------------------------------- | +| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下
- row:水平方向从左到右 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。
- space-evenly5+:  均匀排列每个元素,每个元素之间的间隔相等。 | ## 事件 除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -| 名称 | 参数 | 描述 | -| -------- | -------- | -------- | -| groupclick | { groupid: string } | group点击事件。
groupid:被点击的group的id。 | +| 名称 | 参数 | 描述 | +| ------------- | ---------------------------------- | ---------------------------------------- | +| groupclick | { groupid: string } | group点击事件。
groupid:被点击的group的id。 | | groupcollapse | { groupid: string } | group收拢事件。
groupid:收拢的group的id。
当不输入参数或者groupid为空时收拢所有分组。 | -| groupexpand | { groupid: string } | group展开事件。
groupid:展开的group的id。
当不输入参数或者groupid为空时展开所有分组。 | +| groupexpand | { groupid: string } | group展开事件。
groupid:展开的group的id。
当不输入参数或者groupid为空时展开所有分组。 | ## 方法 diff --git a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md index d653c4fd91115bae20695536326c9e2563aeb7c7..35bf025b6c8e9970c6df66f761f0b412b44df9c9 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md @@ -68,7 +68,7 @@ } ``` - ![zh-cn_image_0000001152773860](figures/zh-cn_image_0000001152773860.png) + ## 方法 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 6089ea601b7359d4da3f4222874d1133616c1f09..c222d894d5c06802e196e1bfe20cd15d9e2b29ed 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -2,7 +2,7 @@ - 组件 - 通用 - - [通用事件](ts-universal-events-index.md) + - 通用事件 - [点击事件](ts-universal-events-click.md) - [触摸事件](ts-universal-events-touch.md) - [挂载卸载事件](ts-universal-events-show-hide.md) @@ -11,7 +11,7 @@ - [焦点事件](ts-universal-focus-event.md) - [鼠标事件](ts-universal-mouse-key.md) - [组件区域变化事件](ts-universal-component-area-change-event.md) - - [通用属性](ts-universal-attributes-index.md) + - 通用属性 - [尺寸设置](ts-universal-attributes-size.md) - [位置设置](ts-universal-attributes-location.md) - [布局约束](ts-universal-attributes-layout-constraints.md) @@ -60,6 +60,7 @@ - [ImageAnimator](ts-basic-components-imageanimator.md) - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) + - [Navigation](ts-basic-components-navigation.md) - [PatternLock](ts-basic-components-patternlock.md) - [PluginComponent](ts-basic-components-plugincomponent.md) - [Progress](ts-basic-components-progress.md) @@ -67,10 +68,13 @@ - [Radio](ts-basic-components-radio.md) - [Rating](ts-basic-components-rating.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) @@ -94,17 +98,13 @@ - [List](ts-container-list.md) - [ListItem](ts-container-listitem.md) - [Navigator](ts-container-navigator.md) - - [Navigation](ts-basic-components-navigation.md) - [Panel](ts-container-panel.md) - [Refresh](ts-container-refresh.md) - [Row](ts-container-row.md) - [RowSplit](ts-container-rowsplit.md) - [Scroll](ts-container-scroll.md) - - [ScrollBar](ts-basic-components-scrollbar.md) - [SideBarContainer](ts-container-sidebarcontainer.md) - [Stack](ts-container-stack.md) - - [Stepper](ts-basic-components-stepper.md) - - [StepperItem](ts-basic-components-stepperitem.md) - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png index c1bfde1c57599f8cc40d0dc50179c71f4dfc2978..2243912034c109d0ffa57837aa28f4fab4ed55d7 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png 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 index 3c6e9c72046d14a46ed93a1075ee580510e64f92..1dc7d8d7beda862221b05a9247723a3f74bf323d 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422898.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422898.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422902.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422902.gif index 93c0edf4c20f9d29725065f5bdf7a5208da2e2fd..7a0a33ad1f90625edd3f24f7c8702ada65d6febd 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422902.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422902.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png index cdb53d971cbadb6479cc755ae0a95cd4c0c3bff1..5b72c400df568916e04f666f40f80d72ca5195f5 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582850.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582850.gif index e7dc2d19afd049c44c75e1288063df96326e524c..dc802e8f3c4d0a865059697e615eac1cd52a337b 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582850.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582850.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193872520.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193872520.png index e764c43599592d821c403aac0d3fa40d9edd22e5..4ff00bf651522edb5aacdada2e984480d435dc14 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193872520.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193872520.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352442.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352442.png index f36078d6d832fa757378b72fa0739f66fe781c64..1b1cedac00a77279faa829636bc85028fb5ec711 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352442.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352442.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205769446.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205769446.png index 8c8194c14b5ca1ea743782db95027035370ead7e..f27c36a73c65f9c87af5cdbc382046cb4b78064b 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205769446.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205769446.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205812616.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205812616.png index 085d31e9bf7c5740ac3c46d04c4098e64eb3a544..9dd3c2c156b40ce5feb16eb8b8d4541361f877d2 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205812616.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205812616.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205972610.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205972610.gif index ecbaeb8cc1a3ec9e1ecfd253b605be50836b1f46..f312df91ae0f7fd8cd8520904a11ddaccd7c58e4 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205972610.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001205972610.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662643.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662643.gif index 8b877c7bedb4021440eeac2b0a9a9c5d28377da3..b0422fb68634122e8ec69e1eb90a7c6bd780b17d 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662643.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662643.gif 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 index 3b2e35a9a29c6f849cd4e766c8fac0016b95365d..747b8f915f2d40803ce6a7937de1add5deb8e640 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662645.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662645.png 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 index 15e3b57fbcadac9e9c6f4c1446bd16c53845f888..605c0a1ddc0e2bace2e4c9a23fc2391af9ebf5bf 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744181.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744181.png 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 index 4f6f99db3df495c744c612e3a2dff20d2a757a43..5c0ada67867ec3765eeb53af5c62369762d0bac4 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864131.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864131.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864139.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864139.gif index 4770183525428b6df03bf1b3eb8cc4160a1568a1..f70d75a50c028de29ab4b60075b7644316927eab 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864139.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864139.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982703.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982703.png index 4e556034506103bd7e7b491d72ef74b9eccde52c..f3ba651bf13f616108247049bbad02662cd7abe0 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982703.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982703.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712415.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712415.png index e764c43599592d821c403aac0d3fa40d9edd22e5..c8740613a2a7585066a447b68c6edae689e9e709 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712415.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712415.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712447.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712447.png index 7dafd299b8e48ead7d6f783e5a370e31257e341c..4869b5a17b785a154f48e18b703e2bc22335af04 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712447.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712447.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250492613.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250492613.gif index 05ad0a8aa0ae63ae9193aa1c9b3f943f060220da..3dfbd730c80b91d5dcb0583fad6af2c6895febfd 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250492613.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250492613.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md index 816d224d7b30b27abcbb8afeb632cd7e912a4ef6..ea467bc9bebefeb6c93353492e8774428e2369a5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md @@ -48,7 +48,7 @@ DatePicker(options?: DatePickerOptions) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | year | number | 选中日期的年。 | - | month | number | 选中日期的月。 | + | month | number | 选中日期的月(0~11),0表示1月,11表示12月。 | | day | number | 选中日期的日。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index da2780cc42bfe57694efc5b9e9679f5fdda58edf..26b9f549bcee8f40b4dd7d04e15f71a486be17a3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -41,8 +41,8 @@ RichText\(content:string\) | \
| 插入一个简单的换行符。 | \

这是一个段落\
这是换行段落\

| | \
| 定义HTML页面中的主题变化(比如话题的转移),并显示为一条水平线。 | \

这个一个段落\

\
\

这是一个段落\

| | \
\
| 常用于组合块级元素,以便通过CSS来对这些元素进行格式化。 | \
\

这是一个在div元素中的标题。\

\
| -| \\ | 定义与文本中其余部分不同的部分,并把这部分文本呈现为斜体文本。 | \

\这是一个斜体\\

| -| \\ | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\为文本加下划线,用户会把它混淆为一个超链接。 | \

这是带有下划线的段落\

| +| \\ | 定义与文本中其余部分不同的部分,并把这部分文本呈现为斜体文本。 | \这是一个斜体\ | +| \\ | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\为文本加下划线,用户会把它混淆为一个超链接。 | \

\这是带有下划线的段落\\

| | \ | 定义HTML文档的样式信息。 | \ | | style | 属性规定元素的行内样式,写在标签内部,在使用的时候需用引号来进行区分,并以; 间隔样式,style='width: 500px;height: 500px;border: 1px soild;margin: 0 auto;'。 | \

这是一个标题\

\

这是一个段落。\

| | \ | 用于定义客户端文本,比如JavaScript。 | \ | 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 71f0dd32abe162f2e8c1524482fa691640e12d22..f860a751b5d7a6c6c0e7bdcb7350b0a6dc590e56 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 @@ -22,40 +22,40 @@ TextArea(value?:{placeholder?: string controller?: TextAreaController}) - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | placeholder | string | 否 | - | 无输入时的提示文本。 | - | controller8+ | [TextAreaController](#textareacontroller8) | 否 | - | 设置TextArea控制器。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ----------------------- | ---------------------------------------- | ---- | ---- | -------------- | + | placeholder | string | 否 | - | 无输入时的提示文本。 | + | controller8+ | [TextAreaController](#textareacontroller8) | 否 | - | 设置TextArea控制器。 | ## 属性 -除支持[通用属性](ts-universal-attributes-index.md)外,还支持以下属性: +除支持通用属性外,还支持以下属性: -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| placeholderColor | Color | - | 设置placeholder文本颜色。 | -| placeholderFont | {
size?: number,
weight?:number \| [FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | 设置placeholder文本样式:
- size: 设置文本尺寸,Length为number类型时,使用fp单位。
- weight: 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。
- family: 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效,例如:'Arial, sans-serif'。
- style: 设置文本的字体样式。 | -| textAlign | TextAlign | Start | 设置文本水平对齐方式。 | -| caretColor | Color | - | 设置输入框光标颜色。 | -| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string)
} | - | 通过正则表达式设置输入过滤器。满足表达式的输入允许显示,不满足的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,不支持过滤8到10位的强密码。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | +| 名称 | 参数类型 | 默认值 | 描述 | +| ------------------------ | ---------------------------------------- | ----- | ---------------------------------------- | +| placeholderColor | Color | - | 设置placeholder文本颜色。 | +| placeholderFont | {
size?: number,
weight?:number \| [FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | 设置placeholder文本样式:
- size: 设置文本尺寸,Length为number类型时,使用fp单位。
- weight: 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。
- family: 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效,例如:'Arial, sans-serif'。
- style: 设置文本的字体样式。 | +| textAlign | TextAlign | Start | 设置文本水平对齐方式。 | +| caretColor | Color | - | 设置输入框光标颜色。 | +| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string)
} | - | 通过正则表达式设置输入过滤器。满足表达式的输入允许显示,不满足的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,不支持过滤8到10位的强密码。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | - TextAlign枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Start | 水平对齐首部。 | - | Center | 水平居中对齐。 | - | End | 水平对齐尾部。 | + | 名称 | 描述 | + | ------ | ------- | + | Start | 水平对齐首部。 | + | Center | 水平居中对齐。 | + | End | 水平对齐尾部。 | ## 事件 -| 名称 | 功能描述 | -| -------- | -------- | -| onChange(callback: (value: string) => void) | 输入发生变化时,触发回调。 | -| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
value:复制的文本内容。 | -| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
value:剪切的文本内容。 | -| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
value:粘贴的文本内容。 | +| 名称 | 功能描述 | +| ---------------------------------------- | ---------------------------------------- | +| onChange(callback: (value: string) => void) | 输入发生变化时,触发回调。 | +| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
value:复制的文本内容。 | +| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
value:剪切的文本内容。 | +| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
value:粘贴的文本内容。 | ## TextAreaController8+ @@ -75,9 +75,9 @@ caretPosition(value: number): void 设置输入光标的位置。 - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | value | number | 是 | - | 从字符串开始到光标所在位置的字符长度。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ----- | ------ | ---- | ---- | ------------------- | + | value | number | 是 | - | 从字符串开始到光标所在位置的字符长度。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index e9398d127b771246c7260f201f2ca38c1ed52552..2a45556e43462bb6fdf754427eb01529fbcbc52f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -22,55 +22,55 @@ TextInput(value?:{placeholder?: string controller?: TextInputController}) - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | placeholder | string | 否 | - | 无输入时的提示文本。 | - | controller8+ | [TextInputController](#textinputcontroller8) | 否 | - | 设置TextInput控制器。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ----------------------- | ---------------------------------------- | ---- | ---- | --------------- | + | placeholder | string | 否 | - | 无输入时的提示文本。 | + | controller8+ | [TextInputController](#textinputcontroller8) | 否 | - | 设置TextInput控制器。 | ## 属性 -除支持[通用属性](ts-universal-attributes-index.md)外,还支持以下属性: +除支持通用属性外,还支持以下属性: -| 名称 | 参数类型 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -| type | InputType | InputType.Normal | 设置输入框类型。 | -| placeholderColor | Color | - | 设置placeholder颜色。 | -| placeholderFont | {
size?: Length,
weight?: number\|[FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | 设置placeholder文本样式:
- size: 设置文本尺寸,Length为number类型时,使用fp单位。
- weight: 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。
- family: 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。
- style: 设置文本的字体样式。 | -| enterKeyType | EnterKeyType | EnterKeyType.Done | 设置输入法回车键类型。 | -| caretColor | Color | - | 设置输入框光标颜色。 | -| maxLength | number | - | 设置文本的最大输入字符数。 | -| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string)
} | - | 正则表达式,满足表达式的输入允许显示,不满足正则表达式的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,8到10位的强密码不支持过滤。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | +| 名称 | 参数类型 | 默认值 | 描述 | +| ------------------------ | ---------------------------------------- | ----------------- | ---------------------------------------- | +| type | InputType | InputType.Normal | 设置输入框类型。 | +| placeholderColor | Color | - | 设置placeholder颜色。 | +| placeholderFont | {
size?: Length,
weight?: number\|[FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | 设置placeholder文本样式:
- size: 设置文本尺寸,Length为number类型时,使用fp单位。
- weight: 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。
- family: 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。
- style: 设置文本的字体样式。 | +| enterKeyType | EnterKeyType | EnterKeyType.Done | 设置输入法回车键类型。 | +| caretColor | Color | - | 设置输入框光标颜色。 | +| maxLength | number | - | 设置文本的最大输入字符数。 | +| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string)
} | - | 正则表达式,满足表达式的输入允许显示,不满足正则表达式的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,8到10位的强密码不支持过滤。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | - EnterKeyType枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | EnterKeyType.Go | 显示Go文本。 | - | EnterKeyType.Search | 显示为搜索样式。 | - | EnterKeyType.Send | 显示为发送样式。 | - | EnterKeyType.Next | 显示为下一个样式。 | - | EnterKeyType.Done | 标准样式。 | + | 名称 | 描述 | + | ------------------- | --------- | + | EnterKeyType.Go | 显示Go文本。 | + | EnterKeyType.Search | 显示为搜索样式。 | + | EnterKeyType.Send | 显示为发送样式。 | + | EnterKeyType.Next | 显示为下一个样式。 | + | EnterKeyType.Done | 标准样式。 | - InputType枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | InputType.Normal | 基本输入模式。 | - | InputType.Password | 密码输入模式。 | - | InputType.Email | e-mail地址输入模式。 | - | InputType.Number | 纯数字输入模式。 | + | 名称 | 描述 | + | ------------------ | ------------- | + | InputType.Normal | 基本输入模式。 | + | InputType.Password | 密码输入模式。 | + | InputType.Email | e-mail地址输入模式。 | + | InputType.Number | 纯数字输入模式。 | ## 事件 -| 名称 | 功能描述 | -| -------- | -------- | -| onChange(value: string) => void | 输入发生变化时,触发回调。 | -| onSubmit(callback: (enterKey: EnterKeyType) => void) | 回车键或者软键盘回车键触发该回调,参数为当前软键盘回车键类型。 | -| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | 输入状态变化时,触发回调。 | -| onEditChange(callback: (isEditing: boolean) => void) 8+| 输入状态变化时,触发回调。 | -| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
value:复制的文本内容。 | -| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
value:剪切的文本内容。 | -| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
value:粘贴的文本内容。 | +| 名称 | 功能描述 | +| ---------------------------------------- | ---------------------------------------- | +| onChange(value: string) => void | 输入发生变化时,触发回调。 | +| onSubmit(callback: (enterKey: EnterKeyType) => void) | 回车键或者软键盘回车键触发该回调,参数为当前软键盘回车键类型。 | +| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | 输入状态变化时,触发回调。 | +| onEditChange(callback: (isEditing: boolean) => void) 8+ | 输入状态变化时,触发回调。 | +| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
value:复制的文本内容。 | +| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
value:剪切的文本内容。 | +| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
value:粘贴的文本内容。 | ### TextInputController8+ @@ -87,9 +87,9 @@ caretPosition(value: number): void 设置光标移动到指定位置。 - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- |-------- |-------- |-------- | - | value | number |是 | - |设置输入光标的位置。
value:从字符串开始到光标所在位置的字符长度。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ----- | ------ | ---- | ---- | ---------------------------------------- | + | value | number | 是 | - | 设置输入光标的位置。
value:从字符串开始到光标所在位置的字符长度。 | ## 示例 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 d424f0c18dfc9d5e1490ab4a17167a82e8a1a535..6bead6a2b88830a32d1d38d0c46b40efecd50f57 100755 --- 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 @@ -18,10 +18,10 @@ 表1 options参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ---------- | ------------------------------- | ---- | ------ | -------------- | - | src | string | 是 | - | 网页资源地址。 | - | controller | [WebController](#WebController) | 否 | - | 控制器。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ---------- | ------------------------------- | ---- | ---- | ------- | + | src | string | 是 | - | 网页资源地址。 | + | controller | [WebController](#webcontroller) | 否 | - | 控制器。 | > ![icon-note.gif](public_sys-resources/icon-note.gif)**说明:** @@ -31,43 +31,43 @@ > - 仅支持本地音视频播放。 ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| ----------------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | -| domStorageAccess | boolean | false | 设置是否开启文档对象模型存储接口(DOM Storage API)权限,默认未开启。 | -| fileAccess | boolean | true | 设置是否开启通过[$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md#资源引用)访问应用中rawfile路径的文件, 默认启用。 | -| imageAccess | boolean | true | 设置是否允许自动加载图片资源,默认允许。 | +| 名称 | 参数类型 | 默认值 | 描述 | +| ----------------- | ---------------------------------------- | -------------- | ---------------------------------------- | +| domStorageAccess | boolean | false | 设置是否开启文档对象模型存储接口(DOM Storage API)权限,默认未开启。 | +| fileAccess | boolean | true | 设置是否开启通过[$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md#资源引用)访问应用中rawfile路径的文件, 默认启用。 | +| imageAccess | boolean | true | 设置是否允许自动加载图片资源,默认允许。 | | javaScriptProxy | {
object: object,
name: string,
methodList: Array\,
controller: WebController
} | - | 注入JavaScript对象到window对象中,并在window对象中调用该对象的方法。所有参数不支持更新。
object: 参与注册的对象。只能声明方法,不能声明属性 。其中方法的参数和返回类型只能为string,number,boolean。
name: 注册对象的名称,与window中调用的对象名一致。注册后window对象可以通过此名字访问应用侧JavaScript对象。
methodList: 参与注册的应用侧JavaScript对象的方法。
controller: 控制器。 | -| javaScriptAccess | boolean | true | 设置是否允许执行JavaScript脚本,默认允许执行。 | -| mixedMode | [MixedMode](#MixedMode) | MixedMode.None | 设置是否允许加载超文本传输协议(HTTP)和超文本传输安全协议(HTTPS)混合内容,默认不允许加载HTTP和HTTPS混合内容。 | -| onlineImageAccess | boolean | true | 设置是否允许从网络加载图片资源(通过HTTP和HTTPS访问的资源),默认允许访问。 | -| zoomAccess | boolean | true | 设置是否支持手势进行缩放,默认允许执行缩放。 | +| javaScriptAccess | boolean | true | 设置是否允许执行JavaScript脚本,默认允许执行。 | +| mixedMode | MixedMode | MixedMode.None | 设置是否允许加载超文本传输协议(HTTP)和超文本传输安全协议(HTTPS)混合内容,默认不允许加载HTTP和HTTPS混合内容。 | +| onlineImageAccess | boolean | true | 设置是否允许从网络加载图片资源(通过HTTP和HTTPS访问的资源),默认允许访问。 | +| zoomAccess | boolean | true | 设置是否支持手势进行缩放,默认允许执行缩放。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > > 通用属性仅支持[width](ts-universal-attributes-size.md#属性)、[height](ts-universal-attributes-size.md#属性)、[padding](ts-universal-attributes-size.md#属性)、[margin](ts-universal-attributes-size.md#属性)、[border](ts-universal-attributes-border.md#属性)。 - MixedMode枚举说明 - | 名称 | 描述 | - | ---------- | ----------------------------------------------------------- | + | 名称 | 描述 | + | ---------- | ---------------------------------- | | All | 允许加载HTTP和HTTPS混合内容。所有不安全的内容都可以被加载。 | - | Compatible | 混合内容兼容性模式,部分不安全的内容可能被加载。 | - | None | 不允许加载HTTP和HTTPS混合内容。 | + | Compatible | 混合内容兼容性模式,部分不安全的内容可能被加载。 | + | None | 不允许加载HTTP和HTTPS混合内容。 | ## 事件 不支持通用事件。 -| 名称 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| onAlert(callback: (event?: { url: string; message: string; result: [JsResult](#JsResult对象说明) }) => boolean) |

网页触发alert()告警弹窗时触发回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(只有确认场景),并且根据用户的确认操作调用JsResult通知web组件。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知web组件用户操作行为。

| -| onBeforeUnload(callback: (event?: { url: string; message: string; result: [JsResult](#JsResult对象说明) }) => boolean) |

刷新或关闭场景下,在即将离开当前页面时触发此回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(包括确认和取消),并且需要根据用户的确认或取消操作调用JsResult通知web组件最终是否离开当前页面。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知web组件用户操作行为。

| -| onConfirm(callback: (event?: { url: string; message: string; result: [JsResult](#JsResult对象说明) }) => boolean) |

网页调用confirm()告警时触发此回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(包括确认和取消),并且需要根据用户的确认或取消操作调用JsResult通知web组件。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知web组件用户操作行为。

| -| onConsole(callback: (event?: { message: [ConsoleMessage](#ConsoleMessage对象说明) }) => boolean) |

通知宿主应用JavaScript console消息。
message:触发的控制台信息。

| +| 名称 | 功能描述 | +| ---------------------------------------- | ---------------------------------------- | +| onAlert(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) |

网页触发alert()告警弹窗时触发回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(只有确认场景),并且根据用户的确认操作调用JsResult通知Web组件。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知Web组件用户操作行为。

| +| onBeforeUnload(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) |

刷新或关闭场景下,在即将离开当前页面时触发此回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(包括确认和取消),并且需要根据用户的确认或取消操作调用JsResult通知Web组件最终是否离开当前页面。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知Web组件用户操作行为。

| +| onConfirm(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) |

网页调用confirm()告警时触发此回调。
当回调返回false时,触发默认弹窗。当回调返回true时,系统应用可以调用系统弹窗能力(包括确认和取消),并且需要根据用户的确认或取消操作调用JsResult通知Web组件。
url:当前显示弹窗所在网页的URL。
message:弹窗中显示的信息。
JsResult:通知Web组件用户操作行为。

| +| onConsole(callback: (event?: { message: [ConsoleMessage](#consolemessage对象说明) }) => boolean) |

通知宿主应用JavaScript console消息。
message:触发的控制台信息。

| | onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) |

网页的下载任务开始时触发该回调。
url:文件下载的URL。
userAgent:下载的用户代理(UA)名称。
contentDisposition:服务器返回的 Content-Disposition响应头,可能为空。
mimetype:服务器返回内容媒体类型(MIME)信息。
contentLength:服务器返回文件的长度。

| -| onErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError对象说明), error: [WebResourceError](#WebResourceError对象说明) }) => void) |

网页加载遇到错误时触发该回调。
出于性能考虑,建议此回调中尽量执行简单逻辑。
request:网页请求的封装信息。
error:网页加载资源错误的封装信息 。

| -| onHttpErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError对象说明), response: [WebResourceResponse](#WebResourceResponse对象说明) }) => void) |

网页加载资源遇到的HTTP错误(响应码>=400)时触发该回调。
request:网页请求的封装信息。
response:网页响应的封装信息

| -| onPageBegin(callback: (event?: { url: string }) => void) |

网页开始加载时触发该回调,且只在主frame触发,iframe或者frameset的内容加载时不会触发此回调。
url:页面的URL地址。

| -| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载完成时触发该回调,且只在主frame触发。
url:页面的URL地址。

| +| onErrorReceive(callback: (event?: { request: [WebResourceRequest](#webresourceerror对象说明), error: [WebResourceError](#webresourceerror对象说明) }) => void) |

网页加载遇到错误时触发该回调。
出于性能考虑,建议此回调中尽量执行简单逻辑。
request:网页请求的封装信息。
error:网页加载资源错误的封装信息 。

| +| onHttpErrorReceive(callback: (event?: { request: [WebResourceRequest](#webresourceerror对象说明), response: [WebResourceResponse](#webresourceresponse对象说明) }) => void) |

网页加载资源遇到的HTTP错误(响应码>=400)时触发该回调。
request:网页请求的封装信息。
response:网页响应的封装信息

| +| onPageBegin(callback: (event?: { url: string }) => void) |

网页开始加载时触发该回调,且只在主frame触发,iframe或者frameset的内容加载时不会触发此回调。
url:页面的URL地址。

| +| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载完成时触发该回调,且只在主frame触发。
url:页面的URL地址。

| | onProgressChange(callback: (event?: { newProgress: number }) => void) |

网页加载进度变化时触发该回调。
newProgress:新的加载进度,取值范围为0到100的整数。

| | onTitleReceive(callback: (event?: { title: string }) => void) |

网页document标题更改时触发该回调。
title:document标题内容。

| @@ -75,12 +75,12 @@ - 接口 - | 接口名称 | 功能描述 | - | ------------------------------- | ------------------------------ | - | getLineNumber(): number | 获取ConsoleMessage的行数。 | + | 接口名称 | 功能描述 | + | ------------------------------- | ---------------------- | + | getLineNumber(): number | 获取ConsoleMessage的行数。 | | getMessage(): string | 获取ConsoleMessage的日志信息。 | | getMessageLevel(): MessageLevel | 获取ConsoleMessage的信息级别。 | - | getSourceId(): string | 获取网页源文件路径和名字。 | + | getSourceId(): string | 获取网页源文件路径和名字。 | - MessageLevel枚举说明 @@ -98,10 +98,10 @@ Web组件返回的弹窗确认或弹窗取消功能对象。 - 接口 - | 接口名称 | 功能描述 | - | --------------------- | ------------------------------------ | - | handleCancel(): void |

通知web组件用户取消弹窗操作。

| - | handleConfirm(): void |

通知web组件用户确认弹窗操作。

| + | 接口名称 | 功能描述 | + | --------------------- | ----------------------- | + | handleCancel(): void |

通知Web组件用户取消弹窗操作。

| + | handleConfirm(): void |

通知Web组件用户确认弹窗操作。

| ### WebResourceError对象说明 @@ -116,13 +116,13 @@ Web组件返回的弹窗确认或弹窗取消功能对象。 - 接口 - | 接口名称 | 功能描述 | - | ------------------------------------------------------ | ---------------------------------------- | - | getRequestHeader(): Array\<[Header](#Header对象说明)\> | 获取资源请求头信息。 | - | getRequestUrl(): string | 获取资源请求的URL信息。 | - | isMainFrame(): boolean | 判断资源请求是否为主frame。 | - | isRedirect(): boolean | 判断资源请求是否被服务端重定向。 | - | isRequestGesture(): boolean | 获取资源请求是否与手势(如点击)相关联。 | + | 接口名称 | 功能描述 | + | ---------------------------------------- | -------------------- | + | getRequestHeader(): Array\<[Header](#header对象说明)\> | 获取资源请求头信息。 | + | getRequestUrl(): string | 获取资源请求的URL信息。 | + | isMainFrame(): boolean | 判断资源请求是否为主frame。 | + | isRedirect(): boolean | 判断资源请求是否被服务端重定向。 | + | isRequestGesture(): boolean | 获取资源请求是否与手势(如点击)相关联。 | ### Header对象说明 @@ -130,28 +130,28 @@ Web组件返回的请求/响应头对象。 - 参数 - | 参数名称 | 参数类型 |参数描述 | - | ----------- | ----------- |---------------------- | - | headerKey | string |请求/响应头的key。 | - | headerValue | string |请求/响应头的value。| + | 参数名称 | 参数类型 | 参数描述 | + | ----------- | ------ | ------------- | + | headerKey | string | 请求/响应头的key。 | + | headerValue | string | 请求/响应头的value。 | ### WebResourceResponse对象说明 - 接口 - | 接口名称 | 功能描述 | - | ------------------------------------ | -------------------------------- | - | getReasonMessage(): string | 获取资源响应的状态码描述。 | - | getResponseCode(): number | 获取资源响应的状态码。 | - | getResponseData(): string | 获取资源响应数据。 | - | getResponseEncoding(): string | 获取资源响应的编码。 | - | getResponseHeader(): Array\<[Header](#Header对象说明)\> | 获取资源响应头。 | - | getResponseMimeType(): string | 获取资源响应的媒体(MIME)类型。 | + | 接口名称 | 功能描述 | + | ---------------------------------------- | ------------------ | + | getReasonMessage(): string | 获取资源响应的状态码描述。 | + | getResponseCode(): number | 获取资源响应的状态码。 | + | getResponseData(): string | 获取资源响应数据。 | + | getResponseEncoding(): string | 获取资源响应的编码。 | + | getResponseHeader(): Array\<[Header](#header对象说明)\> | 获取资源响应头。 | + | getResponseMimeType(): string | 获取资源响应的媒体(MIME)类型。 | ## WebController -通过webController可以控制web组件各种行为,或获取web组件的配置信息。 +通过WebController可以控制Web组件各种行为。一个WebController对象只能控制一个Web组件,且必须在Web组件和WebController绑定后,才能调用WebController上的方法。 ### 创建对象 @@ -185,8 +185,8 @@ accessStep(step: number): boolean - 返回值 - | 参数类型 | 说明 | - | ---- | ------ | + | 参数类型 | 说明 | + | ------- | --------- | | boolean | 页面是否前进或后退 | ### backward @@ -203,9 +203,9 @@ deleteJavaScriptRegister(name: string): void - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ------ | -------- | ---- | ------ | ------------------------------------------------------------ | - | name | string | 是 | - | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ---- | ------ | ---- | ---- | ---------------------------------------- | + | name | string | 是 | - | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | ### forward @@ -221,16 +221,16 @@ getHitTest(): HitTestType - HitTestType枚举说明 - | 名称 | 描述 | - | ------------- | ----------------------------------------- | - | EditText | 可编辑的区域。 | - | Email | 电子邮件地址。 | - | HttpAnchor | 超链接。其src为http。 | + | 名称 | 描述 | + | ------------- | ------------------------ | + | EditText | 可编辑的区域。 | + | Email | 电子邮件地址。 | + | HttpAnchor | 超链接。其src为http。 | | HttpAnchorImg | 带有超链接的图片,其中超链接的src为http。 | - | Img | HTML::img标签。 | - | Map | 地理地址。 | - | Phone | 电话号码。 | - | Unknown | 未知内容。 | + | Img | HTML::img标签。 | + | Map | 地理地址。 | + | PhoneNumber | 电话号码。 | + | Unknown | 未知内容。 | ### loadData @@ -238,19 +238,19 @@ loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: baseUrl为空时,通过”data“协议加载指定的一段字符串。 -当baseUrl为”data“协议时,编码后的data字符串将被web组件作为”data"协议加载。 +当baseUrl为”data“协议时,编码后的data字符串将被Web组件作为”data"协议加载。 -当baseUrl为“http/https"协议时,编码后的data字符串将被web组件以类似loadUrl的方式以非编码字符串处理。 +当baseUrl为“http/https"协议时,编码后的data字符串将被Web组件以类似loadUrl的方式以非编码字符串处理。 - options参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ---------- | -------- | ---- | ------ | ------------------------------------------------------------ | - | data | string | 是 | - | 按照”Base64“或者”URL"编码后的一段字符串。 | - | mimeType | string | 是 | - | 媒体类型(MIME)。 | - | encoding | string | 是 | - | 编码类型,具体为“Base64"或者”URL编码。 | - | baseUrl | string | 否 | - | 指定的一个URL路径(“http”/“https”/"data"协议),并由web组件赋值给window.origin。 | - | historyUrl | string | 否 | - | 历史记录URL。非空时,可被历史记录管理,实现前后后退功能。当baseUrl为空时,此属性无效。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ---------- | ------ | ---- | ---- | ---------------------------------------- | + | data | string | 是 | - | 按照”Base64“或者”URL"编码后的一段字符串。 | + | mimeType | string | 是 | - | 媒体类型(MIME)。 | + | encoding | string | 是 | - | 编码类型,具体为“Base64"或者”URL编码。 | + | baseUrl | string | 否 | - | 指定的一个URL路径(“http”/“https”/"data"协议),并由Web组件赋值给window.origin。 | + | historyUrl | string | 否 | - | 历史记录URL。非空时,可被历史记录管理,实现前后后退功能。当baseUrl为空时,此属性无效。 | ### loadUrl @@ -264,28 +264,28 @@ loadUrl(options:{ url: string, headers?: Array\ }): void - options参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ------- | ------------------------------------- | ---- | ------ | --------------------- | - | url | string | 是 | - | 需要加载的 URL。 | - | headers | Array\<[Header](#Header对象说明)\> | 否 | [] | URL的附加HTTP请求头。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ------- | ------------------------------ | ---- | ---- | -------------- | + | url | string | 是 | - | 需要加载的 URL。 | + | headers | Array\<[Header](#header对象说明)\> | 否 | [] | URL的附加HTTP请求头。 | ### onActive onActive(): void -调用此接口通知web组件进入前台激活状态。 +调用此接口通知Web组件进入前台激活状态。 ### onInactive onInactive(): void -调用此接口通知web组件进入未激活状态。 +调用此接口通知Web组件进入未激活状态。 ### refresh refresh(): void -调用此接口通知web组件刷新网页。 +调用此接口通知Web组件刷新网页。 ### registerJavaScriptProxy @@ -295,11 +295,11 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr - options 参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ---------- | --------------- | ---- | ------ | ------------------------------------------------------------ | - | object | object | 是 | - | 参与注册的应用侧JavaScript对象。只能声明方法,不能声明属性 。其中方法的参数和返回类型只能为string,number,boolean | - | name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。注册后window对象可以通过此名字访问应用侧JavaScript对象。 | - | methodList | Array\ | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ---------- | --------------- | ---- | ---- | ---------------------------------------- | + | object | object | 是 | - | 参与注册的应用侧JavaScript对象。只能声明方法,不能声明属性 。其中方法的参数和返回类型只能为string,number,boolean | + | name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。注册后window对象可以通过此名字访问应用侧JavaScript对象。 | + | methodList | Array\ | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | ### runJavaScript @@ -309,10 +309,10 @@ runJavaScript(options: { script: string, callback?: (result: string) => void }): - options参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | ------------------------ | ---- | ------ | ------------------------------------------------------------ | - | script | string | 是 | - | JavaScript脚本。 | - | callback | (result: string) => void | 否 | - | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | ------------------------ | ---- | ---- | ---------------------------------------- | + | script | string | 是 | - | JavaScript脚本。 | + | callback | (result: string) => void | 否 | - | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | ### stop 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 c787303f5fd9e69d5a033d676ca9bb18ff83d0d3..ea1d29106df1db7eedb5b28b8cec9fd43f5a51d1 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 @@ -18,21 +18,21 @@ Canvas(context: CanvasRenderingContext2D) - 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | ------- | ---------------------------------------------------------- | ---- | ------ | -------------------------------- | - | context | [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) | 是 | - | 见CanvasRenderingContext2D对象。 | + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ------- | ---------------------------------------- | ---- | ---- | ---------------------------- | + | context | [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) | 是 | - | 见CanvasRenderingContext2D对象。 | ## 属性 -支持[通用属性](ts-universal-attributes-index.md)。 +支持通用属性。 ## 事件 -除支持[通用事件](ts-universal-events-index.md)外,还支持如下事件: +除支持通用事件外,还支持如下事件: -| 名称 | 参数 | 描述 | -| ----------------------------- | ---- | ---------------------------------------- | -| onReady(callback: () => void) | 无 | 画布组件的事件回调,可以在此时进行绘制。 | +| 名称 | 参数 | 描述 | +| ----------------------------- | ---- | -------------------- | +| onReady(callback: () => void) | 无 | 画布组件的事件回调,可以在此时进行绘制。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md index 3ce5690369824712c1afecab6115ad301cc521fc..68fa3939ca5c3a0d209c7ecf5c05dfe843af52c7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md @@ -28,15 +28,15 @@ path: string, container: object, render: string, loop: boolean, autoplay: boolea 加载动画,须提前声明Animator('__lottie_ets')对象,并在Canvas完成布局后调用。可配合Canvas组件生命周期接口使用,比如onAppear()与onPageShow()。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | hap包内动画资源文件路径,仅支持json格式。示例:path: "common/lottie/data.json" | - | container | object | 是 | canvas绘图上下文,声明范式需提前声明CanvasRenderingContext2D。 | - | render | string | 是 | 渲染类型,仅支持“canvas”。 | - | loop | boolean \| number | 否 | 动画播放结束后,是否循环播放,默认值true。值类型为number,且大于等于1时为设置的重复播放的次数。 | - | autoplay | boolean | 否 | 是否自动播放动画,默认值true。 | - | name | string | 否 | 开发者自定义的动画名称,后续支持通过该名称引用控制动画,默认为空。 | - | initialSegment | [number, number] | 否 | 指定动画播放的起始帧号,指定动画播放的结束帧号。 | + | 参数 | 类型 | 必填 | 描述 | + | -------------- | --------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | hap包内动画资源文件路径,仅支持json格式。示例:path: "common/lottie/data.json" | + | container | object | 是 | canvas绘图上下文,声明范式需提前声明CanvasRenderingContext2D。 | + | render | string | 是 | 渲染类型,仅支持“canvas”。 | + | loop | boolean \| number | 否 | 动画播放结束后,是否循环播放,默认值true。值类型为number,且大于等于1时为设置的重复播放的次数。 | + | autoplay | boolean | 否 | 是否自动播放动画,默认值true。 | + | name | string | 否 | 开发者自定义的动画名称,后续支持通过该名称引用控制动画,默认为空。 | + | initialSegment | [number, number] | 否 | 指定动画播放的起始帧号,指定动画播放的结束帧号。 | ## lottie.destroy @@ -46,14 +46,14 @@ destroy(name: string): void 销毁动画,页面退出时,必须调用。可配合Canvas组件生命周期接口使用,比如onDisappear()与onPageHide()。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name, 缺省时销毁所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | ---------------------------------------- | + | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name, 缺省时销毁所有动画。 | - 示例 ``` import lottie from 'lottie-web' - + @Entry @Component struct Index { @@ -61,12 +61,12 @@ destroy(name: string): void private animateName: string = "animate" private animatePath: string = "common/lottie/data.json" private animateItem: any = null - + private onPageHide(): void { console.log('onPageHide') lottie.destroy() } - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.controller) @@ -84,7 +84,7 @@ destroy(name: string): void path: this.animatePath, }) }) - + Animator('__lottie_ets') // declare Animator('__lottie_ets') when use lottie Button('load animation') .onClick(() => { @@ -102,7 +102,7 @@ destroy(name: string): void initialSegment: [10, 50], }) }) - + Button('destroy animation') .onClick(() => { lottie.destroy(this.animateName) @@ -125,9 +125,9 @@ play(name: string): void 播放指定动画。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 被指定的动画名, 同loadAnimation接口参数name,缺省时播放所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | ---------------------------------------- | + | name | string | 是 | 被指定的动画名, 同loadAnimation接口参数name,缺省时播放所有动画。 | - 示例 ``` @@ -142,9 +142,9 @@ pause(name: string): void 暂停指定动画,下次调用lottie.play()从当前帧开始。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口入参name,缺省时暂停所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | ---------------------------------------- | + | name | string | 是 | 被指定的动画名,同loadAnimation接口入参name,缺省时暂停所有动画。 | - 示例 ``` @@ -159,9 +159,9 @@ togglePause(name: string): void 暂停或播放指定动画,等效于lottie.play()与lottie.pause()切换调用。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | ---------------------------------------- | + | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | - 示例 ``` @@ -176,9 +176,9 @@ stop(name: string): void 停止指定动画,下次调用lottie.play()从第一帧开始。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | ---------------------------------------- | + | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | - 示例 ``` @@ -193,10 +193,10 @@ setSpeed(speed: number, name: string): void 设置指定动画播放速度。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0/-1.0正常速度播放。 | - | name | string | 是 | 被指定的动画,同loadAnimation接口参数name,缺省时停止所有动画。 | + | 参数 | 类型 | 必填 | 描述 | + | ----- | ------ | ---- | ---------------------------------------- | + | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0/-1.0正常速度播放。 | + | name | string | 是 | 被指定的动画,同loadAnimation接口参数name,缺省时停止所有动画。 | - 示例 ``` @@ -211,10 +211,10 @@ setDirection(direction: AnimationDirection, name: string): void 设置指定动画播放顺序。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1 | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时设置所有动画方向。 | + | 参数 | 类型 | 必填 | 描述 | + | --------- | ------------------ | ---- | ---------------------------------------- | + | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1 | + | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时设置所有动画方向。 | - 示例 ``` @@ -226,28 +226,28 @@ setDirection(direction: AnimationDirection, name: string): void loadAnimation接口的返回对象,具有属性与接口。属性描述如下: -| 参数名称 | 参数类型 | 参数描述 | -| -------- | -------- | -------- | -| name | string | 动画名称。 | -| isLoaded | boolean | 动画是否已加载。 | -| currentFrame | number | 当前播放的帧号, 默认精度为>=0.0的浮点数, 调用setSubframe(false)后精度为去小数点后的正整数。 | -| currentRawFrame | number | 当前播放帧数, 精度为>=0.0的浮点数。 | -| firstFrame | number | 当前播放片段的第一帧帧号。 | -| totalFrames | number | 当前播放片段的总帧数。 | -| frameRate | number | 帧率 (frame/s)。 | -| frameMult | number | 帧率 (frame/ms)。 | -| playSpeed | number | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | -| playDirection | number | 播放方向, 1为正放, -1为倒放。 | -| playCount | number | 动画完成播放的次数。 | -| isPaused | boolean | 当前动画是否已暂停, 值为true动画已暂停。 | -| autoplay | boolean | 加载动画后是否自动播放, 若值为false需要再调用play()接口开始播放。 | -| loop | boolean \| number | 类型为boolean时是否循环播放, 类型为number时播放次数。 | -| renderer | any | 动画渲染对象, 根据渲染类型而定。 | -| animationID | string | 动画ID。 | -| timeCompleted | number | 当前动画片段完成单次播放的帧数, 受AnimationSegment设置影响, 与totalFrames属性值相同。 | -| segmentPos | number | 当前动画片段序号, 值为>=0的正整数。 | -| isSubframeEnabled | boolean | 关联了currentFrame的精度是否为浮点数。 | -| segments | AnimationSegment \| AnimationSegment[] | 当前动画的播放片段。 | +| 参数名称 | 参数类型 | 参数描述 | +| ----------------- | ---------------------------------------- | ---------------------------------------- | +| name | string | 动画名称。 | +| isLoaded | boolean | 动画是否已加载。 | +| currentFrame | number | 当前播放的帧号, 默认精度为>=0.0的浮点数, 调用setSubframe(false)后精度为去小数点后的正整数。 | +| currentRawFrame | number | 当前播放帧数, 精度为>=0.0的浮点数。 | +| firstFrame | number | 当前播放片段的第一帧帧号。 | +| totalFrames | number | 当前播放片段的总帧数。 | +| frameRate | number | 帧率 (frame/s)。 | +| frameMult | number | 帧率 (frame/ms)。 | +| playSpeed | number | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | +| playDirection | number | 播放方向, 1为正放, -1为倒放。 | +| playCount | number | 动画完成播放的次数。 | +| isPaused | boolean | 当前动画是否已暂停, 值为true动画已暂停。 | +| autoplay | boolean | 加载动画后是否自动播放, 若值为false需要再调用play()接口开始播放。 | +| loop | boolean \| number | 类型为boolean时是否循环播放, 类型为number时播放次数。 | +| renderer | any | 动画渲染对象, 根据渲染类型而定。 | +| animationID | string | 动画ID。 | +| timeCompleted | number | 当前动画片段完成单次播放的帧数, 受AnimationSegment设置影响, 与totalFrames属性值相同。 | +| segmentPos | number | 当前动画片段序号, 值为>=0的正整数。 | +| isSubframeEnabled | boolean | 关联了currentFrame的精度是否为浮点数。 | +| segments | AnimationSegment \| AnimationSegment[] | 当前动画的播放片段。 | ## AnimationItem.play @@ -257,9 +257,9 @@ play(name?: string): void 播放动画。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | --------------- | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -274,9 +274,9 @@ destroy(name?: string): void 销毁动画。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | --------------- | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -291,9 +291,9 @@ pause(name?: string): void 暂停动画,下次调用play接口从当前帧开始播放。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | --------------- | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -308,9 +308,9 @@ togglePause(name?: string): void 暂停或播放动画,等效于play接口与pause接口之间轮换调用。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | --------------- | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -325,9 +325,9 @@ stop(name?: string): void 停止动画,下次调用play接口从第一帧开始播放。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------ | ---- | --------------- | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -342,9 +342,9 @@ setSpeed(speed: number): void 设置动画播放速度。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | + | 参数 | 类型 | 必填 | 描述 | + | ----- | ------ | ---- | ---------------------------------------- | + | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | - 示例 ``` @@ -359,9 +359,9 @@ setDirection(direction: AnimationDirection): void 设置动画播放顺序。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1。 | + | 参数 | 类型 | 必填 | 描述 | + | --------- | ------------------ | ---- | ---------------------------------------- | + | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1。 | - 示例 ``` @@ -376,11 +376,11 @@ goToAndStop(value: number, isFrame?: boolean): void 设置动画停止在指定帧或时间进度。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | value | number | 是 | 帧号(值大于等于0)或时间进度(ms)。 | - | isFrame | boolean | 否 | true: 按指定帧控制,false:按指定时间控制,缺省默认false。 | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ------- | ------- | ---- | ---------------------------------------- | + | value | number | 是 | 帧号(值大于等于0)或时间进度(ms)。 | + | isFrame | boolean | 否 | true: 按指定帧控制,false:按指定时间控制,缺省默认false。 | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -398,11 +398,11 @@ goToAndPlay(value: number, isFrame: boolean, name?: string): void 设置动画从指定帧或时间进度开始播放。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | value | number | 是 | 帧号(值大于等于0)或时间进度(ms) | - | isFrame | boolean | 是 | true:按指定帧控制, false:按指定时间控制,缺省默认false。 | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | + | 参数 | 类型 | 必填 | 描述 | + | ------- | ------- | ---- | ---------------------------------------- | + | value | number | 是 | 帧号(值大于等于0)或时间进度(ms) | + | isFrame | boolean | 是 | true:按指定帧控制, false:按指定时间控制,缺省默认false。 | + | name | string | 否 | 被指定的动画名,缺省默认为空。 | - 示例 ``` @@ -420,10 +420,10 @@ playSegments(segments: AnimationSegment | AnimationSegment[], forceFlag: boolean 设置动画仅播放指定片段。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | segments | AnimationSegment = [number, number] \| AnimationSegment[] | 是 | 片段或片段列表;
如果片段列表全部播放完毕后,下轮循环播放仅播放最后一个片段 | - | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | + | 参数 | 类型 | 必填 | 描述 | + | --------- | ---------------------------------------- | ---- | ---------------------------------------- | + | segments | AnimationSegment = [number, number] \| AnimationSegment[] | 是 | 片段或片段列表;
如果片段列表全部播放完毕后,下轮循环播放仅播放最后一个片段 | + | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | - 示例 ``` @@ -441,9 +441,9 @@ resetSegments(forceFlag: boolean): void 重置动画播放片段,播放全帧。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | + | 参数 | 类型 | 必填 | 描述 | + | --------- | ------- | ---- | ------------------------------ | + | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | - 示例 ``` @@ -470,9 +470,9 @@ setSubframe(useSubFrame: boolean): void 设置属性currentFrame的精度显示浮点数。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | useSubFrames | boolean | 是 | currentFrame属性默认显示浮点数,该接口参数将影响currentFrame属性的精度。
true:属性currentFrame显示浮点。
false:属性currentFrame去浮点数显示整数。 | + | 参数 | 类型 | 必填 | 描述 | + | ------------ | ------- | ---- | ---------------------------------------- | + | useSubFrames | boolean | 是 | currentFrame属性默认显示浮点数,该接口参数将影响currentFrame属性的精度。
true:属性currentFrame显示浮点。
false:属性currentFrame去浮点数显示整数。 | - 示例 ``` @@ -487,9 +487,9 @@ getDuration(inFrames?: boolean): void 获取动画单次完整播放的时间(与播放速度无关)或帧数, 与Lottie.loadAnimation接口入参initialSegment有关。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | inFrames | boolean | 否 | true:获取帧数, false:获取时间(单位ms),缺省默认false。 | + | 参数 | 类型 | 必填 | 描述 | + | -------- | ------- | ---- | ---------------------------------------- | + | inFrames | boolean | 否 | true:获取帧数, false:获取时间(单位ms),缺省默认false。 | - 示例 ``` @@ -504,10 +504,10 @@ addEventListener<T = any>(name: AnimationEventName, callback: AnimationEve 添加侦听事件, 事件完成后会触发指定回调函数。返回可删除该侦听事件的函数对象。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | - | callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数 | + | 参数 | 类型 | 必填 | 描述 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | + | callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数 | - 示例 ``` @@ -515,7 +515,7 @@ addEventListener<T = any>(name: AnimationEventName, callback: AnimationEve console.log("grunt loopComplete") } let delFunction = this.animateItem.addEventListener('loopComplete', this.animateName) - + // 删除侦听 delFunction() ``` @@ -528,10 +528,10 @@ removeEventListener<T = any>(name: AnimationEventName, callback?: Animatio 删除侦听事件。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | - | callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数;缺省为空时, 删除此事件的所有回调函数。 | + | 参数 | 类型 | 必填 | 描述 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | + | callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数;缺省为空时, 删除此事件的所有回调函数。 | - 示例 ``` @@ -546,17 +546,17 @@ triggerEvent<T = any>(name: AnimationEventName, args: T): void 直接触发指定事件的所有已设置的回调函数。 - 参数 - | 参数 | 类型 | 必填 | 描述 | - | -------- | -------- | -------- | -------- | - | name | AnimationEventName | 是 | 指定动画事件类型 | - | args | any | 是 | 用户自定义回调参数 | + | 参数 | 类型 | 必填 | 描述 | + | ---- | ------------------ | ---- | --------- | + | name | AnimationEventName | 是 | 指定动画事件类型 | + | args | any | 是 | 用户自定义回调参数 | - 示例 ``` private triggerCallBack: any = function(item) { console.log("trigger loopComplete, name:" + item.name) } - + this.animateItem.addEventListener('loopComplete', this.triggerCallBack) this.animateItem.triggerEvent('loopComplete', this.animateItem) this.animateItem.removeEventListener('loopComplete', this.triggerCallBack) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index 5da7866d6ed1e30ad694df28427ccba86e21daec..10a9a68cda53c73b82ce1dac80ad4044c7acaaf9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -48,7 +48,6 @@ struct DatePickerDialogExample01 { onAccept: (value: DatePickerResult) => { this.selectedDate.setFullYear(value.year, value.month, value.day) console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) - } }, onCancel: () => { console.info("DatePickerDialog:onCancel()") @@ -82,7 +81,6 @@ struct DatePickerDialogExample02 { onAccept: (value: DatePickerResult) => { this.selectedDate.setFullYear(value.year, value.month, value.day) console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) - } }, onCancel: () => { console.info("DatePickerDialog:onCancel()") diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index af0f2a254274647d0eb0d2b3d3e5331ec5c1603d..073e84113a50767dab0a84a294b0ceb45e4faa91 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -40,7 +40,6 @@ struct TimePickerDialogExample01 { TimePickerDialog.show({ useMilitaryTime: this.isUseMilitaryTime, onAccept: (value: TimePickerResult) => { - this.selectedDate.setHours(value.hour, value.minute, value.second) console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) }, onCancel: () => { @@ -69,7 +68,6 @@ struct TimePickerDialogExample02 { TimePickerDialog.show({ useMilitaryTime: this.isUseMilitaryTime, onAccept: (value: TimePickerResult) => { - this.selectedDate.setHours(value.hour, value.minute, value.second) console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) }, onCancel: () => { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-index.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-index.md deleted file mode 100644 index 669c73195512a689a49cd67170984d36483bedd7..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-index.md +++ /dev/null @@ -1,51 +0,0 @@ -# 通用属性 - -- **[尺寸设置](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-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)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-index.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-index.md deleted file mode 100644 index 7e4e932c92f89fb90e62ede96fe9a36cea90f402..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-index.md +++ /dev/null @@ -1,18 +0,0 @@ -# 通用事件 - -- **[点击事件](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)** - diff --git a/zh-cn/application-dev/security/accesstoken-overview.md b/zh-cn/application-dev/security/accesstoken-overview.md index a3f64bb28afda94aa1daf5172b3a1368339c6c67..51230365b662ea9d5f7c5d5cace851b4704a1330 100644 --- a/zh-cn/application-dev/security/accesstoken-overview.md +++ b/zh-cn/application-dev/security/accesstoken-overview.md @@ -76,7 +76,7 @@ ATM(AccessTokenManager)是OpenHarmony上基于AccessToken构建的统一的应 默认情况下,应用的APL等级都为normal等级,如果应用需要将自身的APL等级声明为system_basic及以上的APL等级,需要进行以下步骤: - 申请应用市场审核并通过。 -- 开发应用安装包时,需要修改应用的profile文件,在文件的"apl"字段声明应用的APL等级,并使用profile签名工具生成证书。具体签名流程可以查看页面[配置OpenHarmony应用签名信息](../quick-start/configuring-openharmony-app-signature.md)。 +- 开发应用安装包时,需要修改应用的profile文件,在文件的"apl"字段声明应用的APL等级,并使用profile签名工具生成证书。具体签名流程可以查看页面[配置OpenHarmony应用签名信息](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768)。 ### 权限等级说明 @@ -173,7 +173,7 @@ ACL方式的工作流程可以参考[ACL方式使用说明](#ACL方式使用说 **ACL申请方式须知** * 申请应用市场审核并通过。 -* 开发应用安装包时,需要修改应用的profile文件,在文件的"acl"字段声明目标的访问控制列表,并使用profile签名工具生成证书。具体签名流程可以查看页面[配置OpenHarmony应用签名信息](../quick-start/configuring-openharmony-app-signature.md)。 +* 开发应用安装包时,需要修改应用的profile文件,在文件的"acl"字段声明目标的访问控制列表,并使用profile签名工具生成证书。具体签名流程可以查看页面[配置OpenHarmony应用签名信息](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768)。 ## 权限定义列表 diff --git a/zh-cn/application-dev/security/huks-guidelines.md b/zh-cn/application-dev/security/huks-guidelines.md index f9addff95747fdae1e045da73d739b3696837660..051db91654ca175db4bbb84bed366c838a4cf7b5 100644 --- a/zh-cn/application-dev/security/huks-guidelines.md +++ b/zh-cn/application-dev/security/huks-guidelines.md @@ -9,8 +9,8 @@ | 接口名 | 描述 | | ------------------------------------------------------------ | ---------------- | -| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 生成密钥/密钥对 | -| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | 生成密钥/密钥对 | +| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 生成密钥 | +| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | 生成密钥 | | function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 导出公钥 | | function exportKey(keyAlias: string, options: HuksOptions) : Promise; | 导出公钥 | | function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 查询密钥是否存在 | @@ -26,7 +26,7 @@ import huks from '@ohos.security.huks' ``` -2. 使用generateKey接口生成密钥对。 +2. 使用generateKey接口生成密钥。 keyAlias为生成的密钥别名,options为生成密钥时使用到的参数,需根据具体需要到的算法设定options中的参数。 diff --git a/zh-cn/application-dev/security/userauth-guidelines.md b/zh-cn/application-dev/security/userauth-guidelines.md index 2250ecf1901d683c630388bb267737eea0d56dc5..6d0d5e6e72360338e804feac8744e8f1c16c3f51 100644 --- a/zh-cn/application-dev/security/userauth-guidelines.md +++ b/zh-cn/application-dev/security/userauth-guidelines.md @@ -1,26 +1,26 @@ # 用户认证开发指导 +> **说明:** +> 该开发指导需匹配API Version 8或以上版本的SDK使用。 + ## 场景介绍 当前用户认证支持2D人脸识别、3D人脸识别,可应用于设备解锁、应用登录、支付等身份认证场景。 ## 接口说明 -userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以通过人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md)。 +userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以使用人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md)。 -在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、安全级别和是否本地认证。如果不支持,需要考虑使用其他认证能力。 +在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、认证等级。如果不支持,需要考虑使用其他认证能力。 **表1** 用户认证开放能力列表 | 接口名 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| getAuthenticator(): Authenticator | 获取Authenticator对象,用于执行用户身份认证。6+
获取Authenticator对象,用于检测设备身份认证能力、执行和取消用户身份认证,获取认证过程中的提示信息。7+ | -| checkAvailability(type: AuthType, level: SecureLevel): number | 根据指定的认证类型、安全等级,检测当前设备是否支持相应的认证能力。 | -| execute(type: AuthType, level: SecureLevel, callback: AsyncCallback\): void | 执行用户认证,使用callback方式作为异步方法。 | -| execute(type: AuthType, level: SecureLevel): Promise\ | 执行用户认证,使用Promise方式作为异步方法。 | -| cancel(): void | 取消当前的认证流程。 | -| on(type: "tip", callback: Callback\): void | 订阅指定类型的事件。 | -| off(type: "tip", callback?: Callback\): void | 取消订阅指定类型的事件。 | +| getVersion() : number | 获取认证对象的版本信息。 | +| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | +| auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法。 | +| cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 | ## 开发步骤 @@ -34,68 +34,80 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证 1. 获取Authenticator的单例对象,代码示例如下: ```js - let auth = userIAM_userAuth.getAuthenticator(); + let auth = new userIAM_userAuth.UserAuth(); ``` -2. 检测设备是否具有指定级别的认证能力: +2. (可选)获取认证对象的版本信息,代码示例如下: + + ```js + let auth = new userIAM_userAuth.UserAuth(); + let version = auth.getVersion(); + console.info("auth version = " + version); + ``` - 2D人脸识别支持低于S2级别的认证,3D人脸识别支持低于S3级别的认证。代码示例如下: +3. 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力,代码示例如下: ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - let checkCode = authenticator.checkAvailability("FACE_ONLY", "S2"); - if (checkCode == userIAM_userAuth.CheckAvailabilityResult.SUPPORTED) { + 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); + // 此处添加不支持指定类型认证的逻辑 } ``` -3. (可选)订阅人脸tip信息,代码示例如下: - - ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - let tipCallback = (tip)=>{ - console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" + - tip.tipEvent + ") info(" + tip.tipInfo + ")"); - }; - authenticator.on("tip", tipCallback); - ``` - 4. 执行认证操作,代码示例如下: ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - authenticator.execute("FACE_ONLY", "S2").then((code)=>{ - authenticator.off("tip", tipCallback); - console.info("auth success"); - }).catch((code)=>{ - authenticator.off("tip", tipCallback); - console.error("auth fail, code = " + code); + 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 == '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. (仅执行订阅信息后需要)取消订阅人脸tip信息: +5. 认证过程中取消认证,代码示例如下: ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - let tipCallback = (tip)=>{ - console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode + ") event(" + - tip.tipEvent + ") info(" + tip.tipInfo + ")"); - }; - // 取消订阅指定回调 - authenticator.off("tip", tipCallback); - // 取消订阅所有回调authenticator.off("tip"); - ``` - -6. 认证过程中取消认证,代码示例如下: - - ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - let cancelCode = authenticator.cancel(); - if (cancelCode == userIAM_userAuth.Result.SUCCESS) { + 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"); } - ``` \ No newline at end of file + ``` diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index 591202f71df987981b7f6be39dc04a00510e873d..2666626e9ce1b4dcbd7201faa3814e31925f5e8f 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -24,7 +24,7 @@ - [添加容器](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-event.md) - [页面路由](ui-js-building-ui-routes.md) - 常见组件开发指导 - 容器组件 diff --git a/zh-cn/application-dev/ui/arkui-overview.md b/zh-cn/application-dev/ui/arkui-overview.md index ec0630d641e9a0d17e61b4fa33b63a3fad9f9e49..e80deb47e22b89f623c2d13498222ea3845343fe 100644 --- a/zh-cn/application-dev/ui/arkui-overview.md +++ b/zh-cn/application-dev/ui/arkui-overview.md @@ -2,52 +2,37 @@ ## 框架介绍 -方舟开发框架,是一套UI开发框架,提供开发者进行应用UI开发时所必须的能力。 +方舟开发框架(简称:ArkUI),是一套UI开发框架,提供开发者进行应用UI开发时所必须的能力。 ## 基本概念 -- **组件**:组件是界面搭建与显示的最小单位。开发者通过多种组件的组合,构建出满足自身应用诉求的完整界面。 +- 组件:组件是界面搭建与显示的最小单位。开发者通过多种组件的组合,构建出满足自身应用诉求的完整界面。 -- **页面**:page页面是方舟开发框架最小的调度分割单位。开发者可以将应用设计为多个功能页面,每个页面进行单独的文件管理,并通过路由API实现页面的调度管理,以实现应用内功能的解耦。 +- 页面:page页面是方舟开发框架最小的调度分割单位。开发者可以将应用设计为多个功能页面,每个页面进行单独的文件管理,并通过路由API实现页面的调度管理,以实现应用内功能的解耦。 -## 主要能力 +## 主要特征 -- **多种组件**:方舟开发框架不仅提供了多种基础组件,如文本显示、图片显示、按键交互等,也提供了支持视频播放能力的媒体组件。并且针对不同类型设备进行了组件设计,提供了组件在不同平台上的样式适配能力,此种组件称为“多态组件”。 +- UI组件:方舟开发框架不仅提供了多种基础组件,如文本显示、图片显示、按键交互等,也提供了支持视频播放能力的媒体组件。并且针对不同类型设备进行了组件设计,提供了组件在不同平台上的样式适配能力,此种组件称为“多态组件”。 -- **布局计算**:UI界面设计离不开布局的参与。方舟开发框架提供了多种布局方式,不仅保留了经典的弹性布局能力,也提供了列表、宫格、栅格布局和适应多分辨率场景开发的原子布局能力。 +- 布局:UI界面设计离不开布局的参与。方舟开发框架提供了多种布局方式,不仅保留了经典的弹性布局能力,也提供了列表、宫格、栅格布局和适应多分辨率场景开发的原子布局能力。 -- **动画能力**:方舟开发框架对于UI界面的美化,除了组件内置动画效果外,也提供了属性动画、转场动画和自定义动画能力。 +- 动画:方舟开发框架对于UI界面的美化,除了组件内置动画效果外,也提供了属性动画、转场动画和自定义动画能力。 -- **UI交互**:方舟开发框架提供了多种交互能力,满足应用在不同平台通过不同输入设备均可正常进行UI交互响应,默认适配了触摸手势、遥控器、鼠标等输入操作,同时也提供事件通知能力。 +- 绘制:方舟开发框架提供了多种绘制能力,以满足开发者绘制自定义形状的需求,支持图形绘制、颜色填充、文本绘制、图片绘制等。 -- **绘制**:方舟开发框架提供了多种绘制能力,以满足开发者绘制自定义形状的需求,支持图形绘制、颜色填充、文本绘制、图片绘制等。 +- 交互事件:方舟开发框架提供了多种交互能力,满足应用在不同平台通过不同输入设备均可正常进行UI交互响应,默认适配了触摸手势、遥控器、鼠标等输入操作,同时也提供事件通知能力。 -- **平台API通道**:方舟开发框架提供了API扩展机制,平台能力通过此种机制进行封装,提供风格统一的JS接口。 +- 平台API通道:方舟开发框架提供了API扩展机制,平台能力通过此种机制进行封装,提供风格统一的JS接口。 +- 两种开发范式:方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于JS扩展的类Web开发范式(简称“类Web开发范式”)和基于TS扩展的声明式开发范式(简称“声明式开发范式”)。 -## 选择方案 + | 开发范式名称 | 简介 | 适用场景 | 适用人群 | + | -------- | ---------------------------------------- | ---------------- | ------------------- | + | 类Web开发范式 | 采用经典的HML、CSS、JavaScript三段式开发方式。使用HML标签文件进行布局搭建,使用CSS文件进行样式描述,使用JavaScript文件进行逻辑处理。UI组件与数据之间通过单向数据绑定的方式建立关联,当数据发生变化时,UI界面自动触发更新。此种开发方式,更接近Web前端开发者的使用习惯,快速将已有的Web应用改造成方舟开发框架应用。 | 界面较为简单的中小型应用和卡片 | Web前端开发人员 | + | 声明式开发范式 | 采用TS语言并进行声明式UI语法扩展,从组件、动效和状态管理三个维度提供了UI绘制能力。UI开发更接近自然语义的编程方式,让开发者直观地描述UI界面,不必关心框架如何实现UI绘制和渲染,实现极简高效开发。同时,选用有类型标注的TS语言,引入编译期的类型校验。 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | -方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于JS扩展的类Web开发范式(简称“类Web开发范式”)和基于TS扩展的声明式开发范式(简称“声明式开发范式”)。下面我们对这两种开发范式进行对比与描述。 - - -### 类Web开发范式 - -类Web开发范式,采用经典的HML、CSS、JavaScript三段式开发方式。使用HML标签文件进行布局搭建,使用CSS文件进行样式描述,使用JavaScript文件进行逻辑处理。UI组件与数据之间通过单向数据绑定的方式建立关联,当数据发生变化时,UI界面自动触发更新。此种开发方式,更接近Web前端开发者的使用习惯,快速将已有的Web应用改造成方舟开发框架应用。主要适用于界面较为简单的中小型应用开发。 - - -### 声明式开发范式 - -声明式开发范式,采用TS语言并进行声明式UI语法扩展,从组件、动效和状态管理三个维度提供了UI绘制能力。UI开发更接近自然语义的编程方式,让开发者直观地描述UI界面,不必关心框架如何实现UI绘制和渲染,实现极简高效开发。同时,选用有类型标注的TS语言,引入编译期的类型校验,更适用大型的应用开发。 - - -### 两种开发范式对比 - -| **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** | -| -------- | -------- | -------- | -------- | -------- | -| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 | -| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | ### 框架结构 diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001070558189.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001070558189.png index 3e6c90236fa93360b187945fc9556ae735d4578f..755e48ab0e98bb01ff2541e5cdc74346f7c3ae0b 100755 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001070558189.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001070558189.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001077151676.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001077151676.gif deleted file mode 100644 index 60b842f9bd222e39ca63da1b63f0350ac467d95f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001077151676.gif and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001086587935.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001086587935.gif deleted file mode 100644 index 1ebbb881e306acd9e771a757920f46e7fc61af69..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001086587935.gif and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png index 345a2be66315d210a86c20d30c56b8b5f487c325..3be38a7df454954c455b44bb1fbb6b2158be3785 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png index 89c8accb2a567d32f056cbbb1158c51f3baf013d..57d18b7b7d9333d85824623169fc2f3943568214 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228602.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228602.gif deleted file mode 100644 index fc1eab30eb6a87308eaf399a89f1a755223f3995..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228602.gif and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228638.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228638.gif index b2097084b8dda33575a19b7c97d0555dcd5c04f9..533f2e992735920f588b264d5d7d89a1a7479c8b 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228638.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163228638.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163532072.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163532072.png index 2ca7c5488fb83a122e7f8ea1fba1e2d59324e513..320dba877750c55bcd37ef748930f5c407c5db6e 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163532072.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001163532072.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png index f7b8012da47797dfd3909843cba9af1468fb4e89..e53f6d7e1c8b3060ae000d78555ea0b33ffc97bf 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png index 1b9259dc9c0a7cb3530e3f7d9b0225e5160b92c8..205d18f50424811f04dcecc1b6a95c52530c6527 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168410342.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168410342.png index 3a97ead3b625041b9a3a33c8db8cd7cb79276a2d..5accde8bbb1146e3bade9d6cc4d35127dd58b86f 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168410342.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168410342.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168570318.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168570318.png deleted file mode 100644 index 5e855312aef77f5badc0c0b0b4d5cbeac23b802f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168570318.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png index 411cc11b2ac16047c5e2c8a24b3d572b9e24f768..8c145a2fe59fef14f46b8da08c60b705d6fa366a 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728872.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728872.png index d1dc59cd8ac1b5dc7da2f57d16d9a080bb449114..b6045521e10cf66733222c0b85b1b65dd20cb66f 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728872.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728872.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888224.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888224.png index 4487bdcb98a9b1f912be17041859d7a7a246f183..81f79df7d05de05704fdbe9565d4078e026efd60 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888224.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888224.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png index f33eb296f27701a00461cd9231f7d9af014a3814..e2b4a1b1ce009bec2c798eb1c353ebc7790ac9d9 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png index 15a7e0bdc38655a23f64bfa56c4adad9a6a199a0..adb255e05d2f54161e79e0f0a21ddc6b04552793 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169678922.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169678922.png index fad940f7f4fba442aa1b267c66cdc21c5d3a1d2c..546fb29b1f18573353d11d5515f444bf720fcf52 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169678922.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169678922.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169759552.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169759552.png index 2a2376e7e953d35b7d0fb1f6d53314bc0d7cb6b5..a6d0026ba316551ff0819493b84ae8c9cb063289 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169759552.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169759552.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169918548.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169918548.gif index 220d14e0637e2808211cec10173c6c4a7552b64c..0173419db3fd06cc5d328dd6931a2c76664f4596 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169918548.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001169918548.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170008198.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170008198.gif index d4b3de8f257c571e6fec3ff51795936b2d94d2f0..26152ef9f22387729561bdddb9fa7d50019e08cb 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170008198.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170008198.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170167520.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170167520.gif index d69156cdc0d1f1f33560148c1161618f97acb21d..fb5399a47b281cb586dbc4460fc0db6381d1e4ab 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170167520.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170167520.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170411978.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170411978.gif index 218be7ed11ffd1f1f199c347f0fa90e6f6b64b53..b07f4a9f456b5bccab8fe2a2dc997818efad5ddb 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170411978.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001170411978.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188771430.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188771430.gif index 4a815c6f3db9654b71cc1d11821eab521ca7aeee..4164ebf51f658788a8cd51058db46600b9b9fac0 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188771430.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188771430.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188931396.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188931396.gif index b5e2ed34cf960792ca65ce6d9197ac0fc5d49f8c..7de3e743a4a889057dc7ad5b5ba57101bd8c2485 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188931396.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001188931396.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png deleted file mode 100644 index 00964c1cfa5f006f2e8ac064133e23a2d8fc92aa..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png index 7eb0d2cc3f3dd8e239e9232e655344c864cbf679..f6b70b8f1ef886bf8ed6f26e148bddee0b163fd5 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204538065.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204538065.png index 514bc6e8fcdab7ae01de64d16d92a0541954c458..a84303ae2d68affe3f5702317d9f2bf951c90698 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204538065.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204538065.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204776353.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204776353.png index 883981a250b68a29db2027dee82a9a19c34c8e1a..d0e9cf658b9b396873f24666945bb796384c2041 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204776353.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204776353.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208787005.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208787005.gif deleted file mode 100644 index 80a6d574da0827642f85fd34d1acd11caade21cf..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208787005.gif and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208908643.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208908643.gif index 40f7c00741880a81530581d5488c2ff96e0e7bf2..b3b2de4f42ad63fdde8eccb756bbdb8943d14aed 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208908643.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001208908643.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001209028575.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001209028575.gif index 014958726f3f42a6bd92b341695c8ed03b3fd211..167105139f72d65a10fce1865365d601771ba94e 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001209028575.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001209028575.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001211227617.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001211227617.png index 4d26b5ba589c8b9126c51b54ff4d67476771cdf2..4a2ff6d5872e196a3c1e2e4a21a57a9e838b519f 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001211227617.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001211227617.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213968747.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213968747.png index f125f44d4a956c717f3bf1481f7161cf41e79a39..767315d2f69278028746341e79f88ad179930338 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213968747.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213968747.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214128687.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214128687.png index e42b6a7b9c128f9de2217c988fa34cd385742044..653da4be405165f59cbbe570e9d4d64747fa7495 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214128687.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214128687.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214210217.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214210217.png index 4e6560056b15b9c570758670eb65311168df7e9a..aaa0cbf699a302616ce142f43ea3b96df99d75ac 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214210217.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214210217.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214330169.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214330169.png deleted file mode 100644 index 19ee7009247945887ceb0f8f6f471e45f3116b70..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214330169.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png index 0a44a65c48f7f334e5d77e400495d455dc1283d1..2782851bba344dd8afc82943603e52ab6b452e0a 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214998349.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214998349.png index 9c9be43d1fedfbd8660965190865110f007d8161..fb85274edcd9b0a66eaa9e3da3b77e543c048cc8 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214998349.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214998349.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215079443.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215079443.png index 032c5bae7d3269bd4a3bb813e9d69c9271ac9843..49182b6d8f1c96dcbaac493179fdab3d4b9a7bd4 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215079443.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215079443.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215199399.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215199399.png index 3834601d70a5121e18af408bb6a12bbdbf54a28c..2923d13dcf52b856158b440de03df929abc4955b 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215199399.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215199399.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215318403.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215318403.gif index 5643eb93241bf15f6cb75ffaf463ada35ba13201..8e9c75334361806ac822c8c0f2c377c1679c6ca3 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215318403.gif and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215318403.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217008255.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217008255.gif deleted file mode 100644 index 5e38a4068976c9b5e298ff33ad4cfc711de4b2a6..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217008255.gif and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263259399.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263259399.png index c9e2e084909884daa701f5e967050c849c036e5a..dc4a266c02708116362da21577d5b1e582a011fd 100644 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263259399.png and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263259399.png differ diff --git a/zh-cn/application-dev/ui/js-framework-multiple-languages.md b/zh-cn/application-dev/ui/js-framework-multiple-languages.md index 0ec8fdebbd014e3a78b37fc1148d71d4c0803763..2eab45ca737d35c6a3cea36b9e4a2e936fec487d 100644 --- a/zh-cn/application-dev/ui/js-framework-multiple-languages.md +++ b/zh-cn/application-dev/ui/js-framework-multiple-languages.md @@ -101,7 +101,7 @@ ar-AE.json | 参数 | 类型 | 必填 | 描述 | | ------ | ------------- | ---- | ---------------------------------------- | | path | string | 是 | 资源路径 | - | params | Array\|Object | 否 | 运行时用来替换占位符的实际内容,占位符分为两种:
- 具名占位符,例如{name}。实际内容必须用Object类型指定,例如:$t('strings.object', { name: 'Hello world' })。
- 数字占位符,例如{0}。实际内容必须用Array类型指定,例如:$t('strings.array', ['Hello world'])。 | + | params | Array\|Object | 否 | 运行时用来替换占位符的实际内容,占位符分为两种:
- 具名占位符,例如{name}。实际内容必须用Object类型指定,例如:```$t('strings.object', {name:'Hello world'})```。
- 数字占位符,例如{0}。实际内容必须用Array类型指定,例如:```$t('strings.array', [Hello world']``` | - 简单格式化示例代码 ``` diff --git a/zh-cn/application-dev/ui/js-framework-syntax-hml.md b/zh-cn/application-dev/ui/js-framework-syntax-hml.md index b4fc9e6a3ce4bc85dd6246ad823cf436f7115aa9..2684911c682c245a0c43b739904dd91bf28f1876 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-hml.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-hml.md @@ -39,7 +39,7 @@ export default { > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 针对数组内的数据修改,请使用splice方法生效数据绑定变更。 -> +> > - hml文件中的js表达式不支持ES6语法。 @@ -185,7 +185,7 @@ Touch触摸类事件支持捕获,捕获阶段位于冒泡阶段之前,捕获
``` - + ``` // xxx.js export default { @@ -247,9 +247,9 @@ tid属性主要用来加速for循环的重渲染,旨在列表中的数据有 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 数组中的每个元素必须存在tid指定的数据属性,否则运行时可能会导致异常。 -> +> > - 数组中被tid指定的属性要保证唯一性,如果不是则会造成性能损耗。比如,示例中只有id和name可以作为tid字段,因为它们属于唯一字段。 -> +> > - tid不支持表达式。 @@ -262,8 +262,8 @@ tid属性主要用来加速for循环的重渲染,旨在列表中的数据有
- Hello-TV - Hello-Wearable + Hello-world1 + Hello-world2 Hello-World
``` diff --git a/zh-cn/application-dev/ui/ts-component-based-preview.md b/zh-cn/application-dev/ui/ts-component-based-preview.md index 828093c7822267769a1cf43a054855fe9f71b2d8..73fc57fa9c4d20a3053351cbd48a01ed618fab17 100644 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ b/zh-cn/application-dev/ui/ts-component-based-preview.md @@ -11,7 +11,7 @@ ``` -// Display only Hello Component1 on the PC preview. The content under MyComponent is displayed on the real device. +// Display only Hello Component1 on the preview. The content under MyComponent is displayed on the real device. @Entry @Component struct MyComponent { diff --git a/zh-cn/application-dev/ui/ts-component-based-styles.md b/zh-cn/application-dev/ui/ts-component-based-styles.md index f12baf7957365fb1359099637858e15ab2e41db1..7bf23b92d5ad1c7b4176c1bc4d6206e39c97d310 100644 --- a/zh-cn/application-dev/ui/ts-component-based-styles.md +++ b/zh-cn/application-dev/ui/ts-component-based-styles.md @@ -2,7 +2,7 @@ -@Styles装饰器将新的属性函数添加到基本组件上,如Text、Column、Button等。当前@Styles仅支持[通用属性](../reference/arkui-ts/ts-universal-attributes-index.md)。通过@Styles装饰器可以快速定义并复用组件的自定义样式。 +@Styles装饰器将新的属性函数添加到基本组件上,如Text、Column、Button等。当前@Styles仅支持通用属性。通过@Styles装饰器可以快速定义并复用组件的自定义样式。 @Styles可以定义在组件内或组件外,在组件外定义时需带上function关键字,组件内定义时不需要。 diff --git a/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md b/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md index 4832b4331a9d13aae9b17fc11a2bfd387ed1bd24..e6a2606c9c8d505edddaf331a40d8fe51df37bfe 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md +++ b/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md @@ -79,8 +79,5 @@ ``` -![zh-cn_image_0000001217008255](figures/zh-cn_image_0000001217008255.gif) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > background-position仅支持背景图片的移动,不支持背景颜色(background-color)。 diff --git a/zh-cn/application-dev/ui/ui-js-animate-component.md b/zh-cn/application-dev/ui/ui-js-animate-component.md index 674d3c3b9c5aea8f80b913189dce383836805dbe..91baf79e1993a469e46f03560e64d79e3c14e0ae 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-component.md +++ b/zh-cn/application-dev/ui/ui-js-animate-component.md @@ -104,7 +104,30 @@ export default { this.options = { duration: 4000, }; - this.keyframes = [ { transform: { translate: '-120px -0px', scale: 1, rotate: 0 }, transformOrigin: '100px 100px', offset: 0.0, width: 200, height: 200 }, { transform: { translate: '120px 0px', scale: 1.5, rotate: 90 }, transformOrigin: '100px 100px', offset: 1.0, width: 300, height: 300 } ]; + this.keyframes = [ + { + transform: { + translate: '-120px -0px', + scale: 1, + rotate: 0 + }, + transformOrigin: '100px 100px', + offset: 0.0, + width: 200, + height: 200 + }, + { + transform: { + translate: '120px 0px', + scale: 1.5, + rotate: 90 + }, + transformOrigin: '100px 100px', + offset: 1.0, + width: 300, + height: 300 + } + ]; }, Show() { this.animation = this.$element('content').animate(this.keyframes, this.options); diff --git a/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md b/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md index b4d2bf487d7fd39890b98e6311b2bf9bfbfc58c2..b5b8a275fc48d3b404b54a1acffdb4edd4751bf2 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md +++ b/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md @@ -25,6 +25,8 @@ ``` /* xxx.css */ .container { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; @@ -90,7 +92,7 @@ animator支持事件和接口,可以通过添加frame、cancel、repeat、fini ``` -
+
-
+
this is a dialog
@@ -20,6 +20,8 @@ Dialog组件用于创建自定义弹窗,通常用来展示用户当前需要 ``` /* xxx.css */ .doc-page { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; @@ -83,6 +85,8 @@ export default { ``` /* xxx.css */ .doc-page { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-form.md b/zh-cn/application-dev/ui/ui-js-components-form.md index 6c84b6395881489bb419cd9d057628315f7a5234..43eb0538f1c58edbbbb3c5ab5e1a7acaaff4f69b 100644 --- a/zh-cn/application-dev/ui/ui-js-components-form.md +++ b/zh-cn/application-dev/ui/ui-js-components-form.md @@ -13,7 +13,8 @@ Form是一个表单容器,支持容器内[Input](../reference/arkui-js/js-comp ```
-
+ +
``` @@ -21,6 +22,8 @@ Form是一个表单容器,支持容器内[Input](../reference/arkui-js/js-comp ``` /* xxx.css */ .container { + width:100%; + height:100%; flex-direction: column; justify-content: center; align-items: center; @@ -59,9 +62,8 @@ Form是一个表单容器,支持容器内[Input](../reference/arkui-js/js-comp background-color: #F1F3F5; } .formClass{ - width: 80%; - padding: 10px; - border: 1px solid #c3d3e7; + width: 100%; + height: 20%; } ``` @@ -72,26 +74,46 @@ Form是一个表单容器,支持容器内[Input](../reference/arkui-js/js-comp ## 添加响应事件 为Form组件添加submit和reset事件,来提交表单内容或重置表单选项。 + ``` -
-
-
-
- - - - -
-
- - -
+
+ +
+ + + + +
+
+ + + +
``` +``` +/* index.css */ +.container{ + width: 100%; + height: 100%; + flex-direction: column; + justify-items: center + align-items: center; + background-color: #F1F3F5; +} +.form{ + width: 100%; + height: 30%; + flex-direction: column; + justify-items: center + align-items: center; +} +``` + ``` /* xxx.js */ import prompt from '@system.prompt'; diff --git a/zh-cn/application-dev/ui/ui-js-components-images.md b/zh-cn/application-dev/ui/ui-js-components-images.md index f6833719256cbaab51cf8ae84e9f58e351ca74df..091cf547dea9e8e05696e729d87f5608f6531646 100644 --- a/zh-cn/application-dev/ui/ui-js-components-images.md +++ b/zh-cn/application-dev/ui/ui-js-components-images.md @@ -9,13 +9,15 @@ Image是图片组件,用来渲染展示图片。具体用法请参考[Image AP ```
- +
``` ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -45,15 +47,15 @@ Image是图片组件,用来渲染展示图片。具体用法请参考[Image AP flex-direction: column; align-items: center; justify-content: center; -background-color:#F1F3F5; + background-color:#F1F3F5; } image{ - width: 80%; height: 500px; + width: 80%; + height: 500px; border: 5px solid saddlebrown; border-radius: 20px; object-fit: contain; match-text-direction:true; - } ``` @@ -61,81 +63,6 @@ image{ ![zh-cn_image_0000001163532072](figures/zh-cn_image_0000001163532072.png) -## 显示多张图 - -定义for循环展示多张图片,同时定义option选择图片的展示方式,选择方式请参考object-fit类型说明。 -``` - -
- - - -
- image{{$idx}} - content -
-
-
-
- -
-
-``` - -``` -/* xxx.css */ -.page-container { - flex-direction:column; - background-color:#F1F3F5; -} -.text-container { - width: 300px; - flex-direction: column; - justify-content: center; -} -.item-container { - flex-direction: row; - align-items: center; - justify-content:center; - margin-top:200px; -} -.testimage { - width: 175px; - height: 220px; - border: 5px solid #add8e6; - padding: 5px 5px 5px 5px; - margin: 5px 5px 5px 5px; -} -.testicon { - width: 50px; - height: 50px; - margin-left: 150px; - border-radius: 25px; - background-color: orange; -} -``` - -``` -/* index.js */ -export default { - data: { - url:['common/images/bg-tv.jpg','common/images/img2.jpg'], - list:[0,1], - fit:'cover', - fit_list:['cover','contain','fill','none','scale-down'] - }, - setfit(e) { - this.fit = e.newValue - } -} -``` - - -![zh-cn_image_0000001208787005](figures/zh-cn_image_0000001208787005.gif) - - ## 加载图片 图片成功加载时触发complete事件,返回加载的图源尺寸。加载失败则触发error事件,打印图片加载失败。 @@ -235,7 +162,10 @@ export default { justify-content: space-between; } .testimage { - width: 100%; height: 400px; object-fit: scale-down; border-radius: 20px;} + width: 100%; height: 400px; + object-fit: scale-down; + border-radius: 20px; +} ``` ``` diff --git a/zh-cn/application-dev/ui/ui-js-components-input.md b/zh-cn/application-dev/ui/ui-js-components-input.md index b37afa8a946c8886352ca77754c0ad1acc3f8cd8..d697e7964b575409db4f1509208013248da7ebda 100644 --- a/zh-cn/application-dev/ui/ui-js-components-input.md +++ b/zh-cn/application-dev/ui/ui-js-components-input.md @@ -17,6 +17,8 @@ Input是交互式组件,用于接收用户数据。其类型可设置为日期 ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -54,6 +56,8 @@ Input是交互式组件,用于接收用户数据。其类型可设置为日期 ``` /* xxx.css */ .container { + width: 100%; + height: 100%; align-items: center; flex-direction: column; justify-content: center; @@ -97,9 +101,8 @@ export default { > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 智能穿戴仅支Input类型设置为button、radio、checkbox。 -> -> - 仅当Input类型为checkbox和radio时,当前组件是否选中的属性checked才生效,默认值为false。 +> +> 仅当Input类型为checkbox和radio时,当前组件是否选中的属性checked才生效,默认值为false。 ## 事件绑定 @@ -120,6 +123,7 @@ export default { /* xxx.css */ .content { width: 100%; + height: 100%; flex-direction: column; align-items: center; justify-content: center; @@ -176,6 +180,7 @@ export default { /* xxx.css */ .content { width: 100%; + height: 100%; flex-direction: column; align-items: center; justify-content: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-list.md b/zh-cn/application-dev/ui/ui-js-components-list.md index c0bc55579ab778df91329c6cfcc1ba586aba0f03..849878d6d0a249282c9804ce5fe8e3231fc2840a 100644 --- a/zh-cn/application-dev/ui/ui-js-components-list.md +++ b/zh-cn/application-dev/ui/ui-js-components-list.md @@ -10,7 +10,8 @@ List是用来显示列表的组件,包含一系列相同宽度的列表项, ```
- + + @@ -21,6 +22,8 @@ List是用来显示列表的组件,包含一系列相同宽度的列表项, ``` /* xxx.css */ .container { + width:100%; + height:100%; flex-direction: column; align-items: center; background-color: #F1F3F5; @@ -36,7 +39,7 @@ List是用来显示列表的组件,包含一系列相同宽度的列表项, > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - <list-item-group>是<list>的子组件,实现列表分组功能,不能再嵌套<list>,可以嵌套<list-item>。 -> +> > - <list-item>是<list>的子组件,展示列表的具体项。 @@ -109,7 +112,7 @@ List是用来显示列表的组件,包含一系列相同宽度的列表项, > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - indexer属性生效需要flex-direction属性配合设置为column,且columns属性设置为1。 -> +> > - indexer可以自定义索引表,自定义时"\#"必须要存在。 @@ -191,6 +194,7 @@ export default { ![zh-cn_image_0000001162911958](figures/zh-cn_image_0000001162911958.gif) > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> > - groupcollapse和groupexpand事件仅支持list-item-group组件使用。 @@ -210,7 +214,7 @@ export default {
{{$item.name}} - 18888888888 + 18888888888
@@ -243,7 +247,7 @@ export default { color: #000000; font-size: 39px; } -.phone { +.number { color: black; font-size: 25px; } diff --git a/zh-cn/application-dev/ui/ui-js-components-menu.md b/zh-cn/application-dev/ui/ui-js-components-menu.md index d364094b02bfbcfd9d5db511251e48bc0bf3b86d..0ea286c5d05009fa0c147059a3ae069a8e823d23 100644 --- a/zh-cn/application-dev/ui/ui-js-components-menu.md +++ b/zh-cn/application-dev/ui/ui-js-components-menu.md @@ -25,6 +25,8 @@ ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; @@ -65,6 +67,8 @@ ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; @@ -115,6 +119,8 @@ option{ ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; width: 100%; @@ -254,7 +260,16 @@ export default { {name: "black", checked:false}, ], }, - toggleClick(index){ for(let i=0;i ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 普通选择器设置取值范围时,需要使用数据绑定的方式。 -> -> - 日期选择器的lunarswitch属性只支持手机和平板设备。 +> +> 普通选择器设置取值范围时,需要使用数据绑定的方式。 ## 设置时间展现格式 @@ -86,6 +89,8 @@ Picker的hours属性定义时间的展现格式,可选类型有12小时制和2 ``` /* index.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -102,7 +107,7 @@ Picker的hours属性定义时间的展现格式,可选类型有12小时制和2 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - hours属性为12:按照12小时制显示,用上午和下午进行区分; -> +> > - hours属性为24:按照24小时制显示。 @@ -121,6 +126,8 @@ Picker的hours属性定义时间的展现格式,可选类型有12小时制和2 ``` /* index.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-slider.md b/zh-cn/application-dev/ui/ui-js-components-slider.md index 8c889388e26498991e37f0fd1f0ca5b3ded1f18b..20d4e775e81d5bc5034bb90069729e103e27f927 100644 --- a/zh-cn/application-dev/ui/ui-js-components-slider.md +++ b/zh-cn/application-dev/ui/ui-js-components-slider.md @@ -17,8 +17,6 @@ Slider为滑动条组件,用来快速调节音量、亮度等。具体用法
``` - - ``` /* xxx.css */ .container { @@ -93,10 +91,10 @@ Slider组件通过color、selected-color、block-color样式分别为滑动条 ![zh-cn_image_0000001179438692](figures/zh-cn_image_0000001179438692.gif) > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> mode属性为滑动条样式,仅在手机和平板上生效,可选值为: -> +> mode属性为滑动条样式,可选值为: +> > - outset:滑块在滑杆上; -> +> > - inset:滑块在滑杆内。 @@ -119,6 +117,8 @@ Slider组件通过color、selected-color、block-color样式分别为滑动条 ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-stepper.md b/zh-cn/application-dev/ui/ui-js-components-stepper.md index 22479506c1f62bb740356386eaa4ef374e1ad704..15c8e42a4a754135e2b00941b493561c1add216a 100644 --- a/zh-cn/application-dev/ui/ui-js-components-stepper.md +++ b/zh-cn/application-dev/ui/ui-js-components-stepper.md @@ -14,7 +14,8 @@ ```
- + + Step 1 @@ -27,6 +28,8 @@ ``` /* xxx.css */ .container { + width:100%; + height:100%; flex-direction: column; justify-content: center; align-items: center; @@ -66,6 +69,8 @@ text{ ``` /* index.css */ .container { + width:100%; + height:100%; flex-direction: column; background-color:#F1F3F5; } @@ -102,7 +107,9 @@ text{ ``` /* index.css */ -.container { +.container { + width:100%; + height:100%; flex-direction: column; background-color:#F1F3F5; } @@ -154,6 +161,8 @@ Stepper组件默认填充父容器,通过border和background-color设置边框 ``` /* index.css */ .container { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; @@ -208,6 +217,8 @@ Stepper分别添加finish,change,next,back,skip事件。 ``` /* xxx.css */ .doc-page { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; @@ -325,6 +336,8 @@ export default { ``` /* xxx.css */ .container { + width:100%; + height:100%; flex-direction: column; align-items: center; justify-content: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-swiper.md b/zh-cn/application-dev/ui/ui-js-components-swiper.md index de6c56907cf20ef9484c5101ffff11494f984909..de9f3aa008425bd06e50e3c7865e5a764aabb2f7 100644 --- a/zh-cn/application-dev/ui/ui-js-components-swiper.md +++ b/zh-cn/application-dev/ui/ui-js-components-swiper.md @@ -28,18 +28,24 @@ Swiper为滑动容器,提供切换显示子组件的能力。具体用法请 ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; justify-content: center; width: 100%; } +swiper{ + height: 30%; +} .item{ width: 100%; height: 500px; } text{ width: 100%; + height: 100%; text-align: center; font-size: 50px; color: white; @@ -84,11 +90,15 @@ Swiper组件当不开启循环播放(loop="false")时添加自动播放属 ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; justify-content: center; - width: 100%; +} +swiper{ + height: 30%; } .item{ width: 100%; @@ -96,6 +106,7 @@ Swiper组件当不开启循环播放(loop="false")时添加自动播放属 } text{ width: 100%; + height: 100%; text-align: center; font-size: 50px; color: white; @@ -138,11 +149,12 @@ text{ ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; justify-content: center; - width: 100%; } swiper{ width: 500px; @@ -205,11 +217,15 @@ text{ ``` /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; justify-content: center; - width: 100%; +} +swiper{ + height: 30%; } .item{ width: 100%; @@ -217,6 +233,7 @@ text{ } text{ width: 100%; + height: 100%; text-align: center; font-size: 50px; color: white; 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 4991f8587af2f5e0526245f7dc2b1171f4c50574..aa7e7e71cb4f1e7d7e9a1b850fa5cff7c533bc46 100644 --- a/zh-cn/application-dev/ui/ui-js-components-switch.md +++ b/zh-cn/application-dev/ui/ui-js-components-switch.md @@ -44,6 +44,8 @@ Switch为开关选择器,切换开启或关闭状态。具体用法请参考[S ``` /* xxx.css */ .container { + width: 100%; + height: 100%; display: flex; justify-content: center; align-items: center; @@ -53,7 +55,7 @@ switch{ // 选中时的字体颜色 texton-color: #002aff; // 未选中时的字体颜色 -textoff-color: silver; + textoff-color: silver; text-padding: 20px; font-size: 50px; } @@ -114,6 +116,8 @@ export default { ``` /* xxx.css */ .container { + width: 100%; + height: 100%; background-color: #F1F3F5; flex-direction: column; padding: 50px; diff --git a/zh-cn/application-dev/ui/ui-js-components-text.md b/zh-cn/application-dev/ui/ui-js-components-text.md index 96dfb5a196b80a0cf9f24d836bb71c8668159927..35c7525615dc6619c266dc88eecc99f4c28779be 100644 --- a/zh-cn/application-dev/ui/ui-js-components-text.md +++ b/zh-cn/application-dev/ui/ui-js-components-text.md @@ -10,7 +10,7 @@ Text是文本组件,用于呈现一段文本信息。具体用法请参考[Tex ```
- Hello World + Hello World
``` @@ -33,199 +33,182 @@ Text是文本组件,用于呈现一段文本信息。具体用法请参考[Tex - 添加文本样式 + 设置color、font-size、allow-scale、word-spacing、text-valign属性分别为文本添加颜色、大小、缩放、文本之间的间距和文本在垂直方向的对齐方式。 + + ``` + +
+ + This is a passage + + + This is a passage + +
+ ``` + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: #F1F3F5; + } + ``` + + ![zh-cn_image_0000001220778205](figures/zh-cn_image_0000001220778205.png) - 设置color、font-size、allow-scale、word-spacing、text-valign属性分别为文本添加颜色、大小、缩放、文本之间的间距和文本在垂直方向的对齐方式。 - - - ``` - -
- - This is a passage - - - This is a passage - -
- ``` - - - ``` - /* xxx.css */ - .container { - width: 100%; - height: 100%; - flex-direction: column; - align-items: center; - justify-content: center; - background-color: #F1F3F5; - } - ``` - - - ![zh-cn_image_0000001220778205](figures/zh-cn_image_0000001220778205.png) - 添加划线 + 设置text-decoration和text-decoration-colo属性为文本添加划线和划线颜色,text-decoration枚举值请参考 Text自有样式。 + + ``` + +
+ + This is a passage + + + This is a passage + +
+ ``` + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + } + text{ + font-size: 50px; + } + ``` + + ![zh-cn_image_0000001220856725](figures/zh-cn_image_0000001220856725.png) - 设置text-decoration和text-decoration-colo属性为文本添加划线和划线颜色,text-decoration枚举值请参考Text自有样式。 - - - ``` - -
- - This is a passage - - - This is a passage - -
- ``` - - - ``` - /* xxx.css */ - .container { - width: 100%; - height: 100%; - flex-direction: column; - align-items: center; - justify-content: center; - } - text{ - font-size: 50px; - } - ``` - - - ![zh-cn_image_0000001220856725](figures/zh-cn_image_0000001220856725.png) - 隐藏文本内容 + 当文本内容过多而显示不全时,添加text-overflow属性将隐藏内容以省略号的形式展现。 + + ``` + +
+ + This is a passage + +
+ ``` + + ``` + /* xxx.css */ + .container { + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + background-color: #F1F3F5; + justify-content: center; + } + .text{ + width: 200px; + max-lines: 1; + text-overflow:ellipsis; + } + ``` + + > **说明:** + > - text-overflow样式需要与max-lines样式配套使用,设置了最大行数的情况下生效。 + > - max-lines属性设置文本最多可以展示的行数。 - 当文本内容过多而显示不全时,添加text-overflow属性将隐藏内容以省略号的形式展现。 - - - ``` - -
- - This is a passage - -
- ``` - - - ``` - /* xxx.css */ - .container { - width: 100%; - height: 100%; - flex-direction: column; - align-items: center; - background-color: #F1F3F5; - justify-content: center; - } - .text{ - width: 200px; - max-lines: 1; - text-overflow:ellipsis; - } - ``` - - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > - text-overflow样式需要与max-lines样式配套使用,设置了最大行数的情况下生效。 - > - > - max-lines属性设置文本最多可以展示的行数。 - - - ![zh-cn_image_0000001163656706](figures/zh-cn_image_0000001163656706.png) + ​ ![zh-cn_image_0000001163656706](figures/zh-cn_image_0000001163656706.png) - 设置文本折行 + 设置word-break属性对文本内容做断行处理,word-break枚举值请参考Text自有样式。 - 设置word-break属性对文本内容做断行处理,word-break枚举值请参考Text自有样式。 - - - ``` - -
-
- - Welcome to the world - + ``` + +
+
+ + Welcome to the world + Welcome to the world -
- ``` - - - ``` - /* xxx.css */ - .container { - background-color: #F1F3F5; - flex-direction: column; - align-items: center; - justify-content: center; - } - .content{ - width: 50%; - flex-direction: column; - align-items: center; - justify-content: center; - } - .text1{ - height: 200px; - border:1px solid #1a1919; - margin-bottom: 50px; - text-align: center; - word-break: break-word; - font-size: 40px; - } - .text2{ - height: 200px; - border:1px solid #0931e8; - text-align: center; - word-break: break-all; - font-size: 40px; - } - ``` - - - ![zh-cn_image_0000001209033195](figures/zh-cn_image_0000001209033195.png) +
+ ``` + + ``` + /* xxx.css */ + .container { + background-color: #F1F3F5; + flex-direction: column; + align-items: center; + justify-content: center; + } + .content{ + width: 50%; + flex-direction: column; + align-items: center; + justify-content: center; + } + .text1{ + height: 200px; + border:1px solid #1a1919; + margin-bottom: 50px; + text-align: center; + word-break: break-word; + font-size: 40px; + } + .text2{ + height: 200px; + border:1px solid #0931e8; + text-align: center; + word-break: break-all; + font-size: 40px; + } + ``` + ​ ![zh-cn_image_0000001209033195](figures/zh-cn_image_0000001209033195.png) + - Text组件支持[Span](../reference/arkui-js/js-components-basic-span.md)子组件 - - ``` - -
- - This is a passage - - - This 1 is a 1 passage - -
- ``` - - - ![zh-cn_image_0000001163372568](figures/zh-cn_image_0000001163372568.png) - - + ``` + +
+ + This is a passage + + + This 1 + + is a 1 + passage + +
+ ``` + + ![zh-cn_image_0000001163372568](figures/zh-cn_image_0000001163372568.png) > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 当使用Span子组件组成文本段落时,如果Span属性样式异常(例如:font-weight设置为1000),将导致文本段落显示异常。 - > + > > - 在使用Span子组件时,注意Text组件内不能存在文本内容,如果存在文本内容也只会显示子组件Span里的内容。 - + ## 场景示例 @@ -253,6 +236,8 @@ Text组件通过数据绑定展示文本内容,Span组件通过设置show属 ``` /* xxx.css */ .container { + width: 100%; + height: 100%; align-items: center; flex-direction: column; justify-content: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-toolbar.md b/zh-cn/application-dev/ui/ui-js-components-toolbar.md index cfbe78bf94d912ae2fcac8ad8c3e7bf2cb593cc6..09f8c17ff06b5d686d2367da9eb3014b70bac79f 100644 --- a/zh-cn/application-dev/ui/ui-js-components-toolbar.md +++ b/zh-cn/application-dev/ui/ui-js-components-toolbar.md @@ -23,6 +23,8 @@ Toolbar为页面工具栏组件,用于展示针对当前界面的操作选项 ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -44,7 +46,12 @@ toolbar-item{
- + + + + + +
``` @@ -53,6 +60,8 @@ toolbar-item{ ``` /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -92,6 +101,7 @@ toolbar-item{ background-color: #F1F3F5; flex-direction: column; width: 100%; + height: 100%; justify-content: center; align-items: center; } @@ -131,6 +141,7 @@ toolbar-item{ background-color: #F1F3F5; flex-direction: column; width: 100%; + height: 100%; justify-content: center; align-items: center; } diff --git a/zh-cn/application-dev/ui/ui-js-overview.md b/zh-cn/application-dev/ui/ui-js-overview.md index c955cb6a7a60c37d0fb621f4c0779e67f70bb16f..7bb87d87b265f6c0f4646ad0e63d3651ecb8d1bd 100755 --- a/zh-cn/application-dev/ui/ui-js-overview.md +++ b/zh-cn/application-dev/ui/ui-js-overview.md @@ -12,13 +12,17 @@ ![zh-cn_image_0000001117452952](figures/zh-cn_image_0000001117452952.png) - **Application** + 应用层表示开发者开发的FA应用,这里的FA应用特指JS FA应用。 - **Framework** + 前端框架层主要完成前端页面解析,以及提供MVVM(Model-View-ViewModel)开发模式、页面路由机制和自定义组件等能力。 - **Engine** + 引擎层主要提供动画解析、DOM(Document Object Model)树构建、布局计算、渲染命令构建与绘制、事件管理等能力。 - **Porting Layer** + 适配层主要完成对平台层进行抽象,提供抽象接口,可以对接到系统平台。比如:事件对接、渲染管线对接和系统生命周期对接等。 diff --git a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md index 876ab9c8f4d4915b10e0e8f84f9f0c69c4c05c05..6246ee523ea8676d0bdb500def97cd88c586a2d7 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md +++ b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md @@ -19,7 +19,7 @@ ...... } } - + @Component struct FoodCategory { private foodItems: FoodData[] @@ -27,7 +27,7 @@ ...... } } - + @Entry @Component struct FoodCategoryList { @@ -45,7 +45,7 @@ struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() private showList: boolean = false - + build() { Stack() { if (this.showList) { @@ -65,7 +65,7 @@ struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() private showList: boolean = false - + build() { Stack({ alignContent: Alignment.TopEnd }) { if (this.showList) { @@ -92,7 +92,7 @@ struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() @State private showList: boolean = false - + build() { Stack({ alignContent: Alignment.TopEnd }) { if (this.showList) { @@ -110,7 +110,7 @@ }.height('100%') } } - + ``` 点击切换图标,FoodList组件出现,再次点击,FoodList组件消失。 @@ -143,7 +143,7 @@ private foodItems: FoodData[] build() {} } - + @Component struct FoodCategory { private foodItems: FoodData[] @@ -214,7 +214,7 @@ .width('100%') } } - + @Component struct FoodGrid { private foodItems: FoodData[] @@ -242,43 +242,43 @@ ![zh-cn_image_0000001170167520](figures/zh-cn_image_0000001170167520.gif) 10. 创建展示蔬菜(Category.Vegetable)、水果(Category.Fruit)、坚果(Category.Nut)、海鲜(Category.SeaFood)和甜品(Category.Dessert)分类的页签。 - ``` - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() { - FoodGrid({ foodItems: this.foodItems }) - }.tabBar('All') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) - }.tabBar('Vegetable') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) - }.tabBar('Fruit') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) - }.tabBar('Nut') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) - }.tabBar('Seafood') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) - }.tabBar('Dessert') - } - .barWidth(280) - .barMode(BarMode.Scrollable) - } - } - } - ``` + ``` + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + Stack() { + Tabs() { + TabContent() { + FoodGrid({ foodItems: this.foodItems }) + }.tabBar('All') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) + }.tabBar('Vegetable') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) + }.tabBar('Fruit') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) + }.tabBar('Nut') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) + }.tabBar('Seafood') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) + }.tabBar('Dessert') + } + .barWidth(280) + .barMode(BarMode.Scrollable) + } + } + } + ``` 11. 设置不同食物分类的Grid的行数和高度。因为不同分类的食物数量不同,所以不能用'1fr 1fr 1fr 1fr 1fr 1fr '常量来统一设置成6行。 创建gridRowTemplate和HeightValue成员变量,通过成员变量设置Grid行数和高度。 diff --git a/zh-cn/application-dev/ui/ui-ts-building-data-model.md b/zh-cn/application-dev/ui/ui-ts-building-data-model.md index 401ba84c4072e2ccf8238acb539f9817b30d7adc..4043e160d484f6d3f3586348e7779b4bc6bc87bb 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-data-model.md +++ b/zh-cn/application-dev/ui/ui-ts-building-data-model.md @@ -7,6 +7,7 @@ 1. 新建model文件夹,在model目录下创建FoodData.ets。 + ![zh-cn_image_0000001195119619](figures/zh-cn_image_0000001195119619.png) 2. 定义食物数据的存储模型FoodData和枚举变量Category,FoodData类包含食物id、名称(name)、分类(category)、图片(image)、热量(calories)、蛋白质(protein)、脂肪(fat)、碳水(carbohydrates)和维生素C(vitaminC)属性。 @@ -20,7 +21,7 @@ Seafood, Dessert } - + let NextId = 0; class FoodData { id: string; @@ -32,7 +33,7 @@ fat: number; carbohydrates: number; vitaminC: number; - + constructor(name: string, image: Resource, category: Category, calories: number, protein: number, fat: number, carbohydrates: number, vitaminC: number) { this.id = `${ NextId++ }`; this.name = name; @@ -47,28 +48,10 @@ } ``` -3. 存入食物图片资源。在resources > phone > media目录下存入食物图片资源,图片名称为食物名称。 - ![zh-cn_image_0000001195117633](figures/zh-cn_image_0000001195117633.png) +3. 存入食物图片资源。在resources >base> media目录下存入食物图片资源,图片名称为食物名称。 4. 创建食物资源数据。在model文件夹下创建FoodDataModels.ets,在该页面中声明食物成分数组FoodComposition。 - 以12个食物数据为例,实际开发中,开发者可以自定义更多的数据资源,当食物资源很多时,建议使用数据懒加载LazyForEach。以下营养数据均来自网络。 - - ``` - const FoodComposition: any[] = [ - { 'name': 'Tomato', 'image': $r('app.media.Tomato'), 'category': Category.Vegetable, 'calories': 17, 'protein': 0.9, 'fat': 0.2, 'carbohydrates': 3.9, 'vitaminC': 17.8 }, - { 'name': 'Walnut', 'image': $r('app.media.Walnut'), 'category': Category.Nut, 'calories': 654 , 'protein': 15, 'fat': 65, 'carbohydrates': 14, 'vitaminC': 1.3 }, - { 'name': 'Cucumber', 'image': $r('app.media.Cucumber'), 'category': Category.Vegetable, 'calories': 30, 'protein': 3, 'fat': 0, 'carbohydrates': 1.9, 'vitaminC': 2.1 }, - { 'name': 'Blueberry', 'image': $r('app.media.Blueberry'), 'category': Category.Fruit, 'calories': 57, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 14, 'vitaminC': 9.7 }, - { 'name': 'Crab', 'image': $r('app.media.Crab'), 'category': Category.Seafood, 'calories': 97, 'protein': 19, 'fat': 1.5, 'carbohydrates': 0, 'vitaminC': 7.6 }, - { 'name': 'IceCream', 'image': $r('app.media.IceCream'), 'category': Category.Dessert, 'calories': 207, 'protein': 3.5, 'fat': 11, 'carbohydrates': 24, 'vitaminC': 0.6 }, - { 'name': 'Onion', 'image': $r('app.media.Onion'), 'category': Category.Vegetable, 'calories': 39, 'protein': 1.1, 'fat': 0.1, 'carbohydrates': 9, 'vitaminC': 7.4 }, - { 'name': 'Mushroom', 'image': $r('app.media.Mushroom'), 'category': Category.Vegetable, 'calories': 22, 'protein': 3.1, 'fat': 0.3, 'carbohydrates': 3.3, 'vitaminC': 2.1 }, - { 'name': 'Kiwi', 'image': $r('app.media.Kiwi'), 'category': Category.Fruit, 'calories': 60 , 'protein': 1.1, 'fat': 0.5, 'carbohydrates': 15, 'vitaminC': 20.5 }, - { 'name': 'Pitaya', 'image': $r('app.media.Pitaya'), 'category': Category.Fruit, 'calories': 60, 'protein': 1.2, 'fat': 0, 'carbohydrates': 10, 'vitaminC': 60.9 }, - { 'name': 'Avocado', 'image': $r('app.media.Avocado'), 'category': Category.Fruit, 'calories': 160, 'protein': 2, 'fat': 15, 'carbohydrates': 9, 'vitaminC': 10 }, - { 'name': 'Strawberry', 'image': $r('app.media.Strawberry'), 'category': Category.Fruit, 'calories': 32, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 8, 'vitaminC': 58.8 } - ] - ``` + 实际开发中,开发者可以自定义更多的数据资源,当食物资源很多时,建议使用数据懒加载LazyForEach。 5. 创建initializeOnStartUp方法来初始化FoodData的数组。在FoodDataModels.ets中使用了定义在FoodData.ets的FoodData和Category,所以要将FoodData.ets的FoodData类export,在FoodDataModels.ets内import FoodData和Category。 ``` @@ -81,7 +64,7 @@ } // FoodDataModels.ets import { Category, FoodData } from './FoodData' - + export function initializeOnStartup(): Array { let FoodDataArray: Array = [] FoodComposition.forEach(item => { diff --git a/zh-cn/application-dev/ui/ui-ts-creating-project.md b/zh-cn/application-dev/ui/ui-ts-creating-project.md index a25a1da324b15b3b5ce9cdbca6167da95b968cfd..e35ca9fa9b76d6dd69cbdc26864d649971265693 100644 --- a/zh-cn/application-dev/ui/ui-ts-creating-project.md +++ b/zh-cn/application-dev/ui/ui-ts-creating-project.md @@ -6,25 +6,22 @@ 1. 打开DevEco Studio,点击Create Project。如果已有一个工程,则点击File > New > New project。 + ![zh-cn_image_0000001168956332](figures/zh-cn_image_0000001168956332.png) 2. - 进入选择ability template界面,选择[Standard]Empty Ability。 + 进入选择Ability Template界面,选择Empty Ability。 ![zh-cn_image_0000001168059158](figures/zh-cn_image_0000001168059158.png) -3. - 安装OpenHarmony SDK。 - - ![zh-cn_image_0000001213462329](figures/zh-cn_image_0000001213462329.png) +3. 进入配置工程界面,将工程名字改为HealthyDiet,Project Type选择Application,Compile API选择8,UI Syntax选择eTS。DevEco Studio会默认将工程保存在C盘,如果要更改工程保存位置,点击Save Location的文件夹图标,自行指定工程创建位置。配置完成后点击Finish。 -4. 进入配置工程界面,将工程名字改为HealthyDiet,Project Type选择Application,Device Type选择Phone,Language选择eTS,选择兼容API Version 7。DevEco Studio会默认将工程保存在C盘,如果要更改工程保存位置,点击Save Location的文件夹图标,自行指定工程创建位置。配置完成后点击Finish。 - ![zh-cn_image_0000001167746622](figures/zh-cn_image_0000001167746622.png) -5. 工程创建完成后,打开app.ets。 +4. 工程创建完成后,打开app.ets。 app.ets提供了应用生命周期的接口:onCreate和onDestroy,分别在应用创建之初和应用被销毁时调用。在app.ets里可以声明全局变量,并且声明的数据和方法是整个应用共享的。 + ``` export default { onCreate() { @@ -36,7 +33,7 @@ } ``` -6. 在工程导航栏里,打开index.ets。该页面展示了当前的UI描述,声明式UI框架会自动生成一个组件化的struct,这个struct遵循Builder接口声明,在build方法里面声明当前的布局和组件。 +5. 在工程导航栏里,打开index.ets。该页面展示了当前的UI描述,声明式UI框架会自动生成一个组件化的struct,这个struct遵循Builder接口声明,在build方法里面声明当前的布局和组件。 ``` @Entry @Component @@ -53,14 +50,16 @@ } ``` -7. 点击右侧的Previewer按钮,打开预览窗口。可以看到在手机设备类型的预览窗口中“Hello World”居中加粗显示。 +6. 点击右侧的Previewer按钮,打开预览窗口。可以看到预览窗口中“Hello World”居中加粗显示。 如果没有Previewer按钮,点击settings > SDK Manager > OpenHarmony SDK> Tools 查看是否安装了Previewer。 ![zh-cn_image_0000001214595111](figures/zh-cn_image_0000001214595111.png) -8. 应用安装到手机上运行应用。将手机连接电脑,等IDE识别到物理设备后,点击Run 'entry'按钮。 +7. 应用安装到设备上运行应用。 + + 将设备连接电脑,等IDE识别到物理设备后,点击Run 'entry'按钮。 ![zh-cn_image_0000001148858818](figures/zh-cn_image_0000001148858818.png) - 在安装之前,需要配置应用签名,[配置应用签名教程](../quick-start/configuring-openharmony-app-signature.md)。安装成功后,点击屏幕上的Run图标打开应用,可以看到居中加粗显示的“Hello World”。 + 在安装之前,需要配置应用签名。安装成功后,点击屏幕上的Run图标打开应用,可以看到居中加粗显示的“Hello World”。 ![zh-cn_image_0000001158896538](figures/zh-cn_image_0000001158896538.png) 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 ee4985b077a850d20f5ce1cb2ef441643afb9a94..1b7edd1205710adc65fd787f04aceacdf96ec4ad 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 @@ -24,7 +24,7 @@ ![zh-cn_image_0000001214128687](figures/zh-cn_image_0000001214128687.png) 2. 食物图片展示。 - 创建Image组件,指定Image组件的url,Image组件和Text组件都是必选构造参数组件。为了让Text组件在Image组件上方显示,所以要先声明Image组件。图片资源放在resources下的rawfile文件夹内,引用rawfile下资源时使用“$rawfile('filename')”的形式,filename为rawfile目录下的文件相对路径。当前$rawfile仅支持Image控件引用图片资源。 + 创建Image组件,指定Image组件的url,Image组件和Text组件都是必选构造参数组件。为了让Text组件在Image组件上方显示,所以要先声明Image组件。图片资源放在resources下的rawfile文件夹内,引用rawfile下资源时使用`$rawfile('filename')`的形式,filename为rawfile目录下的文件相对路径。当前`$rawfile`仅支持Image控件引用图片资源。 ``` @Entry @Component @@ -43,15 +43,9 @@ ![zh-cn_image_0000001168410342](figures/zh-cn_image_0000001168410342.png) 3. 通过资源访问图片。 - 除指定图片路径外,也可以使用引用媒体资源符$r引用资源,需要遵循resources文件夹的资源限定词的规则。右键resources文件夹,点击New>Resource Directory,选择Resource Type为Media(图片资源),选择资源限定词为Device-Phone(目前开发设备为手机)。 + 除指定图片路径外,也可以使用引用媒体资源符$r引用资源,需要遵循resources文件夹的资源限定词的规则。右键resources文件夹,点击New>Resource Directory,选择Resource Type为Media(图片资源)。 - ![zh-cn_image_0000001168570318](figures/zh-cn_image_0000001168570318.png) - - 点击OK后,resources文件夹下生成phone.media文件夹。将Tomato.png放入该文件夹内。 - - ![zh-cn_image_0000001214330169](figures/zh-cn_image_0000001214330169.png) - - 就可以通过“$r('app.type.name')”的形式引用应用资源,即$r('app.media.Tomato')。 + 将Tomato.png放入media文件夹内。就可以通过`$r('app.type.name')`的形式引用应用资源,即`$r('app.media.Tomato')`。 ``` @Entry @@ -73,7 +67,7 @@ 4. 设置Image宽高,并且将image的objectFit属性设置为ImageFit.Contain,即保持图片长宽比的情况下,使得图片完整地显示在边界内。 如果Image填满了整个屏幕,原因如下: 1. Image没有设置宽高。 - + 2. Image的objectFit默认属性是ImageFit.Cover,即在保持长宽比的情况下放大或缩小,使其填满整个显示边界。 ``` @@ -183,7 +177,7 @@ .backgroundColor('#FFedf2f5') } } - + @Entry @Component struct FoodDetail { @@ -218,12 +212,12 @@ .backgroundColor('#FFedf2f5') } } - + @Component struct ContentTable { build() {} } - + @Entry @Component struct FoodDetail { @@ -261,7 +255,7 @@ .padding({ top: 30, right: 30, left: 30 }) } } - + @Entry @Component struct FoodDetail { @@ -294,7 +288,7 @@ .backgroundColor('#FFedf2f5') } } - + @Component struct ContentTable { build() { @@ -316,7 +310,7 @@ .padding({ top: 30, right: 30, left: 30 }) } } - + @Entry @Component struct FoodDetail { @@ -415,7 +409,7 @@ .padding({ top: 30, right: 30, left: 30 }) } } - + @Entry @Component struct FoodDetail { @@ -502,7 +496,7 @@ .layoutWeight(2) } } - + build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { this.IngredientItem('Calories', 'Calories', '17kcal') @@ -515,7 +509,7 @@ .padding({ top: 30, right: 30, left: 30 }) } } - + @Entry @Component struct FoodDetail { diff --git a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md index 23a040c5169edcdc73f6837dd9bbd89c39019d12..df9383f16bbd3f62f6de1e8dd6d148ca19d0dedc 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md @@ -108,8 +108,8 @@ GridContainer() { struct GridContainerExample { build() { Column({ space: 5 }) { - GridContainer({ columns: 6, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { - Row() { + GridContainer({ columns: 6 }) { + Flex({justifyContent:FlexAlign.SpaceAround}) { Text('1') .useSizeType({ xs: { span: 2, offset: 0 }, @@ -120,18 +120,18 @@ struct GridContainerExample { .height(100).backgroundColor(0x4682B4).textAlign(TextAlign.Center) Text('2') .useSizeType({ - xs: { span: 2, offset: 2 }, - sm: { span: 2, offset: 2 }, - md: { span: 4, offset: 1 }, - lg: { span: 4, offset: 1 }, + xs: { span: 2, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 4, offset: 0 }, + lg: { span: 4, offset: 0 }, }) .height(100).backgroundColor(0x46F2B4).textAlign(TextAlign.Center) Text('3') .useSizeType({ - xs: { span: 2, offset: 4 }, - sm: { span: 2, offset: 4 }, - md: { span: 1, offset: 5 }, - lg: { span: 1, offset: 5 }, + xs: { span: 2, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 1, offset: 0 }, + lg: { span: 1, offset: 0 }, }) .height(100).backgroundColor(0x46A2B4).textAlign(TextAlign.Center) } diff --git a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md index 0c0bc3943a0c604ddefe14bfa20f772551dcf553..826fdd6f5c0db8f423d9ec0b2f85d6a53ff5c43e 100644 --- a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md +++ b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md @@ -50,7 +50,7 @@ 2. 点击FoodGridItem后跳转到FoodDetail页面。调用页面路由router模块的push接口,将FoodDetail页面推到路由栈中,实现页面跳转。使用router路由API接口,需要先引入router。 ``` import router from '@system.router' - + @Component struct FoodGridItem { private foodItem: FoodData @@ -69,11 +69,11 @@ ![zh-cn_image_0000001169918548](figures/zh-cn_image_0000001169918548.gif) -3. 在FoodDetail页面增加回到食物列表页面的图标。在resources > phone > media文件夹下存入回退图标Back.png。新建自定义组件PageTitle,包含后退的图标和Food Detail的文本,调用路由的router.back()接口,弹出路由栈最上面的页面,即返回上一级页面。 +3. 在FoodDetail页面增加回到食物列表页面的图标。在resources > base > media文件夹下存入回退图标Back.png。新建自定义组件PageTitle,包含后退的图标和Food Detail的文本,调用路由的router.back()接口,弹出路由栈最上面的页面,即返回上一级页面。 ``` // FoodDetail.ets import router from '@system.router' - + @Component struct PageTitle { build() { @@ -148,7 +148,7 @@ ``` // FoodDetail.ets import { FoodData } from '../model/FoodData' - + @Entry @Component struct FoodDetail { @@ -165,7 +165,7 @@ @Component struct FoodDetail { private foodItem: FoodData = router.getParams().foodData - + build() { ...... } @@ -193,7 +193,7 @@ }) } } - + @Component struct FoodImageDisplay { private foodItem: FoodData @@ -210,11 +210,11 @@ .backgroundColor('#FFedf2f5') } } - + @Component struct ContentTable { private foodItem: FoodData - + @Builder IngredientItem(title:string, name: string, value: string) { Flex() { Text(title) @@ -231,7 +231,7 @@ .layoutWeight(2) } } - + build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { this.IngredientItem('Calories', 'Calories', this.foodItem.calories + 'kcal') @@ -244,12 +244,12 @@ .padding({ top: 30, right: 30, left: 30 }) } } - + @Entry @Component struct FoodDetail { private foodItem: FoodData = router.getParams().foodData - + build() { Column() { Stack( { alignContent: Alignment.TopStart }) { diff --git a/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png b/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png index 9d953fc57d179bd67edebd43c2a247585bad7bbe..e79866bfe4f5980fc07efc61e7f2ae6cdcf8e525 100644 Binary files a/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png and b/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png differ diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index d353a4a301a407163944df2cdb22a9d37dbb2eca..b144c5e1f5be369e81d60f76a558ff5c08b2dc11 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -1,38 +1,23 @@ # OpenHarmony应用开发文档 - [应用开发导读](application-dev-guide.md) - 快速开始 - - 应用开发快速入门 - - DevEco Studio(OpenHarmony)使用指南 - - [概述](quick-start/deveco-studio-overview.md) - - [版本变更说明](quick-start/deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - 创建OpenHarmony工程 - - [使用工程向导创建新工程](quick-start/use-wizard-to-create-project.md) - - [通过导入Sample方式创建新工程](quick-start/import-sample-to-create-project.md) - - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) - - 快速入门 - - [前言](quick-start/start-overview.md) - - [使用eTS语言开发](quick-start/start-with-ets.md) - - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) - - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) - - [应用开发包结构说明](quick-start/package-structure.md) - - [资源文件的分类](quick-start/basic-resource-file-categories.md) + + - 快速入门 + - [开发准备](quick-start/start-overview.md) + - [使用eTS语言开发](quick-start/start-with-ets.md) + - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) + - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) + - 开发基础知识 + - [应用开发包结构说明](quick-start/package-structure.md) + - [资源文件的分类](quick-start/basic-resource-file-categories.md) + - [SysCap说明](quick-start/syscap.md) - 开发 - Ability开发 - - [Ability框架概述](ability/ability-brief.md) - - FA模型 - - [FA模型综述](ability/fa-brief.md) - - [PageAbility开发指导](ability/fa-pageability.md) - - [ServiceAbility开发指导](ability/fa-serviceability.md) - - [DataAbility开发指导](ability/fa-dataability.md) - - [FormAbility开发指导](ability/fa-formability.md) - - Stage模型 - - [Stage模型综述](ability/stage-brief.md) - - [Ability开发指导](ability/stage-ability.md) - - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) - - [FormExtensionAbility开发指导](ability/stage-formextension.md) - - [应用迁移开发指导](ability/stage-ability-continuation.md) + - [FA模型综述](ability/fa-brief.md) + - [PageAbility开发指导](ability/fa-pageability.md) + - [ServiceAbility开发指导](ability/fa-serviceability.md) + - [DataAbility开发指导](ability/fa-dataability.md) + - [FormAbility开发指导](ability/fa-formability.md) - 其他 - [WantAgent使用指导](ability/wantagent.md) - [Ability助手使用指导](ability/ability-assistant-guidelines.md) @@ -88,7 +73,7 @@ - [Qrcode开发指导](ui/ui-js-components-qrcode.md) - [Search开发指导](ui/ui-js-components-search.md) - Canvas开发指导 - - [Canvas对象](ui-js-components-canvas.md) + - [Canvas对象](ui/ui-js-components-canvas.md) - [CanvasRenderingContext2D对象](ui/ui-js-components-canvasrenderingcontext2d.md) - [Path2D对象](ui/ui-js-components-path2d.md) - [OffscreenCanvas对象](ui/ui-js-components-offscreencanvas.md) @@ -186,7 +171,7 @@ - 窗口 - [窗口开发概述](windowmanager/window-overview.md) - [窗口开发指导](windowmanager/window-guidelines.md) - - 显示设备 + - 屏幕属性 - [屏幕属性开发概述](windowmanager/display-overview.md) - [屏幕属性开发指导](windowmanager/display-guidelines.md) - 屏幕截图 @@ -204,7 +189,6 @@ - [音频采集开发指导](media/audio-capturer.md) - 视频 - [视频播放开发指导](media/video-playback.md) - - [视频录制开发指导](media/video-recorder.md) - 图片 - [图片开发指导](media/image.md) - 安全 @@ -232,8 +216,8 @@ - [关系型数据库概述](database/database-relational-overview.md) - [关系型数据库开发指导](database/database-relational-guidelines.md) - 轻量级数据存储 - - [轻量级数据存储概述](database/database-preference-overview.md) - - [轻量级数据存储开发指导](database/database-preference-guidelines.md) + - [轻量级数据存储概述](database/database-storage-overview.md) + - [轻量级数据存储开发指导](database/database-storage-guidelines.md) - 分布式数据对象 - [分布式数据对象概述](database/database-distributedobject-overview.md) - [分布式数据对象开发指导](database/database-distributedobject-guidelines.md) @@ -276,13 +260,7 @@ - [Intl开发指导](internationalization/intl-guidelines.md) - [I18n开发指导](internationalization/i18n-guidelines.md) - 工具 - - DevEco Studio(OpenHarmony)使用指南 - - [概述](quick-start/deveco-studio-overview.md) - - [版本变更说明](quick-start/deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [创建OpenHarmony工程](quick-start/create-openharmony-project.md) - - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) + - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) @@ -386,8 +364,7 @@ - [事件参数](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-appendix-types.md) + - [类型说明](reference/arkui-js/js-appendix-types.md) - 组件参考(基于TS扩展的声明式开发范式) - 组件 - 通用 @@ -449,6 +426,7 @@ - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [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) - [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) @@ -456,9 +434,12 @@ - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - [Search](reference/arkui-ts/ts-basic-components-search.md) - [Select](reference/arkui-ts/ts-basic-components-select.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [Span](reference/arkui-ts/ts-basic-components-span.md) - [Text](reference/arkui-ts/ts-basic-components-text.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) @@ -483,17 +464,13 @@ - [List](reference/arkui-ts/ts-container-list.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - [Panel](reference/arkui-ts/ts-container-panel.md) - [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Row](reference/arkui-ts/ts-container-row.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [Stack](reference/arkui-ts/ts-container-stack.md) - - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) - - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) @@ -538,128 +515,207 @@ - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) - 接口参考 - Ability框架 - - [FeatureAbility模块](reference/apis/js-apis-featureAbility.md) - - [ParticleAbility模块](reference/apis/js-apis-particleAbility.md) - - [DataAbilityHelper模块](reference/apis/js-apis-dataAbilityHelper.md) - - [DataUriUtils模块](reference/apis/js-apis-DataUriUtils.md) - - [Bundle模块](reference/apis/js-apis-Bundle.md) - - [Context模块](reference/apis/js-apis-Context.md) - - 事件与通知 - - [CommonEvent模块](reference/apis/js-apis-commonEvent.md) - - [Notification模块](reference/apis/js-apis-notification.md) - - [后台代理提醒](reference/apis/js-apis-reminderAgent.md) - - 资源管理 - - [资源管理](reference/apis/js-apis-resource-manager.md) - - [国际化-Intl](reference/apis/js-apis-intl.md) - - [国际化-I18n](reference/apis/js-apis-i18n.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.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.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.ability.featureAbility (FeatureAbility模块)](reference/apis/js-apis-featureAbility.md) + - [@ohos.application.formBindingData (卡片数据绑定类)](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) + - [@ohos.application.formHost (FormHost)](reference/apis/js-apis-formhost.md) + - [@ohos.application.formInfo (FormInfo)](reference/apis/js-apis-formInfo.md) + - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) + - [@ohos.application.formProvider (FormProvider)](reference/apis/js-apis-formprovider.md) + - [@ohos.ability.particleAbility (particleAbility模块)](reference/apis/js-apis-particleAbility.md) + - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) + - [@ohos.wantAgent (WantAgent模块)](reference/apis/js-apis-wantAgent.md) + - [dataAbilityHelper (DataAbilityHelper模块)](reference/apis/js-apis-dataAbilityHelper.md) + - [context (Context模块)](reference/apis/js-apis-Context.md) + - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) + - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) + - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) + - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) + - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) + - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) + - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) + - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) + - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) + - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) + - 公共事件与通知 + + - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.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) + - 应用程序包管理 + + - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) + - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.zlib (Zip模块)](reference/apis/js-apis-zlib.md) + - UI界面 + + - [@ohos.animator (动画)](reference/apis/js-apis-animator.md) + - [@ohos.mediaquery (媒体查询)](reference/apis/js-apis-mediaquery.md) + - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.router (页面路由)](reference/apis/js-apis-router.md) + - 图形图像 + + - [@ohos.display (屏幕属性)](reference/apis/js-apis-display.md) + - [@ohos.screenshot (屏幕截图)](reference/apis/js-apis-screenshot.md) + - [@ohos.window (窗口)](reference/apis/js-apis-window.md) + - [webgl (WebGL)](reference/apis/js-apis-webgl.md) + - [webgl2 (WebGL2)](reference/apis/js-apis-webgl2.md) - 媒体 - - [音频管理](reference/apis/js-apis-audio.md) - - [媒体服务](reference/apis/js-apis-media.md) - - [图片处理](reference/apis/js-apis-image.md) - - [相机管理](reference/apis/js-apis-camera.md) + + - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.image (图片处理)](reference/apis/js-apis-image.md) + - [@ohos.multimedia.media (媒体服务)](reference/apis/js-apis-media.md) + - [@ohos.multimedia.medialibrary (媒体库管理)](reference/apis/js-apis-medialibrary.md) + - 资源管理 + - [@ohos.i18n (国际化-I18n)](reference/apis/js-apis-i18n.md) + - [@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.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) - 安全 - - [用户认证](reference/apis/js-apis-useriam-userauth.md) - - [访问控制](reference/apis/js-apis-abilityAccessCtrl.md) - - [通用密钥库系统](reference/apis/js-apis-huks.md) + + - [@ohos.abilityAccessCtrl (访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.security.huks (通用密钥库系统)](reference/apis/js-apis-huks.md) + - [@ohos.userIAM.userAuth (用户认证)](reference/apis/js-apis-useriam-userauth.md) + - [@system.cipher (加密算法)](reference/apis/js-apis-system-cipher.md) - 数据管理 - - [轻量级存储](reference/apis/js-apis-data-preferences.md) - - [分布式数据管理](reference/apis/js-apis-distributed-data.md) - - [关系型数据库](reference/apis/js-apis-data-rdb.md) - - [结果集](reference/apis/js-apis-data-resultset.md) - - [DataAbility 谓词](reference/apis/js-apis-data-ability.md) - - [设置数据项名称](reference/apis/js-apis-settings.md) + + - [@ohos.data.dataAbility (DataAbility谓词)](reference/apis/js-apis-data-ability.md) + - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) + - [@ohos.data.distributedDataObject (分布式数据对象)](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.rdb (关系型数据库)](reference/apis/js-apis-data-rdb.md) + - [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md) + - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.md) + - [resultSet (结果集)](reference/apis/js-apis-data-resultset.md) - 文件管理 - - [文件管理](reference/apis/js-apis-fileio.md) - - [Statfs](reference/apis/js-apis-statfs.md) - - [目录环境](reference/apis/js-apis-environment.md) - - [公共文件访问与管理](reference/apis/js-apis-filemanager.md) - - [应用空间统计](reference/apis/js-apis-storage-statistics.md) - - [卷管理](reference/apis/js-apis-volumemanager.md) - - 账号管理 - - [系统帐号管理](reference/apis/js-apis-osAccount.md) - - [分布式帐号管理](reference/apis/js-apis-distributed-account.md) - - [应用帐号管理](reference/apis/js-apis-appAccount.md) + + - [@ohos.environment (目录环境能力)](reference/apis/js-apis-environment.md) + - [@ohos.fileio (文件管理)](reference/apis/js-apis-fileio.md) + - [@ohos.fileManager (公共文件访问与管理)](reference/apis/js-apis-filemanager.md) + - [@ohos.statfs (statfs)](reference/apis/js-apis-statfs.md) + - [@ohos.storageStatistics (应用空间统计)](reference/apis/js-apis-storage-statistics.md) - 电话服务 - - [拨打电话](reference/apis/js-apis-call.md) - - [短信服务](reference/apis/js-apis-sms.md) - - [SIM卡管理](reference/apis/js-apis-sim.md) - - [网络搜索](reference/apis/js-apis-radio.md) - - [observer](reference/apis/js-apis-observer.md) - - [蜂窝数据](reference/apis/js-apis-telephony-data.md) + + - [@ohos.contact (联系人)](reference/apis/js-apis-contact.md) + - [@ohos.telephony.call (拨打电话)](reference/apis/js-apis-call.md) + - [@ohos.telephony.observer (observer)](reference/apis/js-apis-observer.md) + - [@ohos.telephony.radio (网络搜索)](reference/apis/js-apis-radio.md) + - [@ohos.telephony.sim (SIM卡管理)](reference/apis/js-apis-sim.md) + - [@ohos.telephony.sms (短信服务)](reference/apis/js-apis-sms.md) + - [@ohos.telephony.data (蜂窝数据)](reference/apis/js-apis-telephony-data.md) - 网络管理 - - [网络连接管理](reference/apis/js-apis-net-connection.md) - - [Socket连接](reference/apis/js-apis-socket.md) - - [WebSocket连接](reference/apis/js-apis-webSocket.md) - - [数据请求](reference/apis/js-apis-http.md) + - [@ohos.net.connection (网络连接管理)](reference/apis/js-apis-net-connection.md) + - [@ohos.net.http (数据请求)](reference/apis/js-apis-http.md) + - [@ohos.request (上传下载)](reference/apis/js-apis-request.md) + - [@ohos.net.socket (Socket连接)](reference/apis/js-apis-socket.md) + - [@ohos.net.webSocket (WebSocket连接)](reference/apis/js-apis-webSocket.md) - 通信与连接 - - [WLAN](reference/apis/js-apis-wifi.md) - - [Bluetooth](reference/apis/js-apis-bluetooth.md) - - [RPC通信](reference/apis/js-apis-rpc.md) + + - [@ohos.bluetooth (蓝牙)](reference/apis/js-apis-bluetooth.md) + - [@ohos.connectedTag (有源标签)](reference/apis/js-apis-connectedTag.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.accessibility (辅助功能)](reference/apis/js-apis-accessibility.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.hiTraceChain (分布式跟踪)](reference/apis/js-apis-hitracechain.md) + - [@ohos.hiTraceMeter (性能打点)](reference/apis/js-apis-hitracemeter.md) + - [@ohos.inputMethod (输入法框架)](reference/apis/js-apis-inputmethod.md) + - [@ohos.inputMethodEngine (输入法服务)](reference/apis/js-apis-inputmethodengine.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.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) + - [Timer (定时器)](reference/apis/js-apis-timer.md) - 设备管理 - - [传感器](reference/apis/js-apis-sensor.md) - - [振动](reference/apis/js-apis-vibrator.md) - - [屏幕亮度](reference/apis/js-apis-brightness.md) - - [电量信息](reference/apis/js-apis-battery-info.md) - - [系统电源管理](reference/apis/js-apis-power.md) - - [热管理](reference/apis/js-apis-thermal.md) - - [Runninglock锁](reference/apis/js-apis-runninglock.md) - - [设备信息](reference/apis/js-apis-device-info.md) - - [系统属性](reference/apis/js-apis-system-parameter.md) - - [设备管理](reference/apis/js-apis-device-manager.md) - - [窗口](reference/apis/js-apis-window.md) - - [显示设备属性](reference/apis/js-apis-display.md) - - [升级](reference/apis/js-apis-update.md) - - [USB管理](reference/apis/js-apis-usb.md) - - [位置服务](reference/apis/js-apis-geolocation.md) - - [输入设备](js-apis-inputdevice.md) - - [组合按键](js-apis-inputconsumer.md) - - [输入监听](js-apis-inputmonitor.md) - - [事件注入](js-apis-inputeventclient.md) - - 基本功能 - - [应用上下文](reference/apis/js-apis-system-app.md) - - [日志打印](reference/apis/js-apis-logs.md) - - [页面路由](reference/apis/js-apis-router.md) - - [弹窗](reference/apis/js-apis-prompt.md) - - [应用配置](reference/apis/js-apis-system-configuration.md) - - [定时器](reference/apis/js-apis-timer.md) - - [设置系统时间](reference/apis/js-apis-system-time.md) - - [动画](reference/apis/js-apis-animator.md) - - [WebGL](reference/apis/js-apis-webgl.md) - - [WebGL2](reference/apis/js-apis-webgl2.md) - - [屏幕截图](reference/apis/js-apis-screenshot.md) - - [输入法框架](reference/apis/js-apis-inputmethod.md) - - [输入法服务](reference/apis/js-apis-inputmethodengine.md) - - [辅助功能](reference/apis/js-apis-accessibility.md) - - DFX - - [应用打点](reference/apis/js-apis-hiappevent.md) - - [性能打点](reference/apis/js-apis-hitracemeter.md) - - [故障日志获取](reference/apis/js-apis-faultLogger.md) - - [分布式跟踪](reference/apis/js-apis-hitracechain.md) - - [日志打印](reference/apis/js-apis-hilog.md) - - [检测模式](reference/apis/js-apis-hichecker.md) - - [Debug调试](reference/apis/js-apis-hidebug.md) + + - [@ohos.batteryInfo (电量信息)](reference/apis/js-apis-battery-info.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.multimodalInput.inputConsumer (组合按键)](reference/apis/js-apis-inputconsumer.md) + - [@ohos.multimodalInput.inputDevice (输入设备)](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputEventClient (注入按键)](reference/apis/js-apis-inputeventclient.md) + - [@ohos.multimodalInput.inputMonitor (输入监听)](reference/apis/js-apis-inputmonitor.md) + - [@ohos.power (系统电源管理)](reference/apis/js-apis-power.md) + - [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md) + - [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md) + - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.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.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) - 语言基础类库 - - [获取进程相关的信息](reference/apis/js-apis-process.md) - - [URL字符串解析](reference/apis/js-apis-url.md) - - [URI字符串解析](reference/apis/js-apis-uri.md) - - [util工具函数](reference/apis/js-apis-util.md) - - [xml解析与生成](reference/apis/js-apis-xml.md) - - [xml转换JavaScript](reference/apis/js-apis-convertxml.md) - - [启动一个worker](reference/apis/js-apis-worker.md) - - [线性容器ArrayList](reference/apis/js-apis-arraylist.md) - - [线性容器Deque](reference/apis/js-apis-deque.md) - - [线性容器List](reference/apis/js-apis-list.md) - - [线性容器LinkedList](reference/apis/js-apis-linkedlist.md) - - [线性容器Queue](reference/apis/js-apis-queue.md) - - [线性容器Stack](reference/apis/js-apis-stack.md) - - [线性容器Vector](reference/apis/js-apis-vector.md) - - [非线性容器HashSet](reference/apis/js-apis-hashset.md) - - [非线性容器HashMap](reference/apis/js-apis-hashmap.md) - - [非线性容器PlainArray](reference/apis/js-apis-plainarray.md) - - [非线性容器TreeMap](reference/apis/js-apis-treemap.md) - - [非线性容器TreeSet](reference/apis/js-apis-treeset.md) - - [非线性容器LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [非线性容器LightWeightSet](reference/apis/js-apis-lightweightset.md) - - 定制管理 - - [配置策略](reference/apis/js-apis-config-policy.md) - - [企业设备管理](reference/apis/js-apis-enterprise-device-manager.md) \ No newline at end of file + + - [@ohos.convertxml (xml转换JavaScript)](reference/apis/js-apis-convertxml.md) + - [@ohos.process (获取进程相关的信息)](reference/apis/js-apis-process.md) + - [@ohos.uri (URI字符串解析)](reference/apis/js-apis-uri.md) + - [@ohos.url (URL字符串解析)](reference/apis/js-apis-url.md) + - [@ohos.util (util工具函数)](reference/apis/js-apis-util.md) + - [@ohos.util.ArrayList (线性容器ArrayList)](reference/apis/js-apis-arraylist.md) + - [@ohos.util.Deque (线性容器Deque)](reference/apis/js-apis-deque.md) + - [@ohos.util.HashMap (非线性容器HashMap)](reference/apis/js-apis-hashmap.md) + - [@ohos.util.HashSet (非线性容器HashSet)](reference/apis/js-apis-hashset.md) + - [@ohos.util.LightWeightMap (非线性容器LightWeightMap)](reference/apis/js-apis-lightweightmap.md) + - [@ohos.util.LightWeightSet (非线性容器LightWeightSet)](reference/apis/js-apis-lightweightset.md) + - [@ohos.util.LinkedList (线性容器LinkedList)](reference/apis/js-apis-linkedlist.md) + - [@ohos.util.List (线性容器List)](reference/apis/js-apis-list.md) + - [@ohos.util.PlainArray (非线性容器PlainArray)](reference/apis/js-apis-plainarray.md) + - [@ohos.util.Queue (线性容器Queue)](reference/apis/js-apis-queue.md) + - [@ohos.util.Stack (线性容器Stack)](reference/apis/js-apis-stack.md) + - [@ohos.util.TreeMap (非线性容器TreeMap)](reference/apis/js-apis-treemap.md) + - [@ohos.util.TreeSet (非线性容器TreeSet)](reference/apis/js-apis-treeset.md) + - [@ohos.util.Vector (线性容器Vector)](reference/apis/js-apis-vector.md) + - [@ohos.worker (启动一个Worker)](reference/apis/js-apis-worker.md) + - [@ohos.xml (xml解析与生成)](reference/apis/js-apis-xml.md) + - 测试 + - [@ohos.application.testRunner (TestRunner)](reference/apis/js-apis-testRunner.md) + - [@ohos.uitest (UiTest)](reference/apis/js-apis-uitest.md) + - 已停止维护的接口 + + - [@ohos.bytrace (性能打点)](reference/apis/js-apis-bytrace.md) + - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.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) + - [@system.brightness (屏幕亮度)](reference/apis/js-apis-system-brightness.md) + - [@system.configuration (应用配置)](reference/apis/js-apis-system-configuration.md) + - [@system.device (设备信息)](reference/apis/js-apis-system-device.md) + - [@system.fetch (数据请求)](reference/apis/js-apis-system-fetch.md) + - [@system.file (文件存储)](reference/apis/js-apis-system-file.md) + - [@system.geolocation (地理位置)](reference/apis/js-apis-system-location.md) + - [@system.mediaquery (媒体查询)](reference/apis/js-apis-system-mediaquery.md) + - [@system.network (网络状态)](reference/apis/js-apis-system-network.md) + - [@system.notification (通知消息)](reference/apis/js-apis-system-notification.md) + - [@system.package (应用管理)](reference/apis/js-apis-system-package.md) + - [@system.prompt (弹窗)](reference/apis/js-apis-system-prompt.md) + - [@system.request (上传下载)](reference/apis/js-apis-system-request.md) + - [@system.router (页面路由)](reference/apis/js-apis-system-router.md) + - [@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) \ No newline at end of file diff --git a/zh-cn/application-dev/windowmanager/display-guidelines.md b/zh-cn/application-dev/windowmanager/display-guidelines.md index 5133771581ab75d1906bedc5fed4e8cbfba9ef4a..01840842a262aef9b62ebebb216cd6636569768c 100644 --- a/zh-cn/application-dev/windowmanager/display-guidelines.md +++ b/zh-cn/application-dev/windowmanager/display-guidelines.md @@ -8,7 +8,7 @@ 完整版的接口定义请参考API接口说明文件:[屏幕属性](../reference/apis/js-apis-display.md)。 -### 开发步骤 +## 开发步骤 通过`getDefaultDisplay(): Promise`来获取当前默认的`Display`对象,具体代码示例可参考: diff --git a/zh-cn/application-dev/windowmanager/window-guidelines.md b/zh-cn/application-dev/windowmanager/window-guidelines.md index f86b455a118d13d6b6da2c65536e56300ae2fb04..52cce86f0decec5dafe0bb243812da5376baaec0 100644 --- a/zh-cn/application-dev/windowmanager/window-guidelines.md +++ b/zh-cn/application-dev/windowmanager/window-guidelines.md @@ -5,7 +5,7 @@ 通过调用窗口接口可以实现窗口创建与销毁,窗口的位置、大小布局,以及进入沉浸式等。 ## 接口说明 -窗口开放的能力如下:Window类,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-window.md)。 +窗口开放的能力如下:Window类,具体的API详见[接口文档](../reference/apis/js-apis-window.md)。 **表1** 窗口主要接口API diff --git a/zh-cn/contribute/figures/Signed-off-by-example.png b/zh-cn/contribute/figures/Signed-off-by-example.png new file mode 100644 index 0000000000000000000000000000000000000000..c86af5d0e7565bf2ccb578fc258167ce81766269 Binary files /dev/null and b/zh-cn/contribute/figures/Signed-off-by-example.png differ diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" index dec27f13de29311058071d7119c9a6ea38efcfc4..5698d5b40e322ffe1c88fa1f923260924ffd0f32 100755 --- "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" +++ "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" @@ -1,25 +1,26 @@ -# 贡献文档 +# 贡献文档 非常欢迎您贡献文档,我们鼓励开发者以各种方式参与文档反馈和贡献。您可以对现有文档进行评价、简单更改、反馈文档质量问题、贡献您的原创内容。 卓越贡献者将会在开发者社区文档贡献专栏表彰公示。 -- [贡献方式](#section5723203852414) +- [贡献方式](#贡献方式) + - [写作规范](写作规范.md) -## 内容版权 +## 内容版权 用户提交的内容、图片必须是原创内容,不得侵犯他人知识产权。 对应采纳的内容,OpenHarmony有权根据相关规范修改用户提交的内容。 -## License +## License [Creative Commons License version 4.0](https://creativecommons.org/licenses/by/4.0/legalcode) -## 贡献方式 +## 贡献方式 -### 反馈文档问题 +### 反馈文档问题 高质量的问题反馈有助于我们不断完善文档内容和质量,您提供的信息越详尽,对我们问题改进越有帮助。 @@ -35,7 +36,7 @@ >- 搜索现有问题的列表,查看是否已经有相关的或者类似的问题已被记录。 >- 如果新问题与某其他问题或 PR 有关联,可以使用其完整 URL 或带 \# 字符的 PR 编号 来引用它。 -### 简单更改 +### 简单更改 针对现有文档进行快速更改和修复,适合少量内容修改和补充。 @@ -46,7 +47,7 @@ 例如:Signed-off-by: user.name //与DCO签署邮箱保持一致 - ![输入图片说明](https://images.gitee.com/uploads/images/2021/0625/095714_92d8e459_7756659.png "屏幕截图.png") + ​ ![](figures/Signed-off-by-example.png) 文档团队成员将评审并合并您的修改内容,感谢您对OpenHarmony文档的支持和帮助。 @@ -59,7 +60,7 @@ 欢迎开发者参与贡献,详细参考:[为发行版本贡献文档](docs-release-process.md) -### 贡献经验分享内容 +### 贡献经验分享内容 鼓励开发者在学习、开发过程中,总结经验并创建技术内容帮助更多开发者快速上手。推荐输出各类How to教程、常见问题FAQ等。请参考如下写作模板: diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index a88be1fdf243dcf537469ad3dee0cb1b79925449..7b4ed87d4d33897c8d360d44d55a77c459f7d2e2 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -3,7 +3,7 @@ - [设备开发导读](device-dev-guide.md) - 了解OpenHarmony - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - - [术语](glossary/glossary.md) + - [术语](../glossary.md) - [版本说明](../release-notes/Readme.md) - 快速开始 - [轻量和小型系统快速入门](quick-start/quickstart-lite.md) diff --git a/zh-cn/device-dev/device-dev-guide.md b/zh-cn/device-dev/device-dev-guide.md index 7f0119b6f5afc6ebbbc0e9cfef88b07bce2884ac..f48753d2b5791d33926b8d3e5532c9222c8566f4 100644 --- a/zh-cn/device-dev/device-dev-guide.md +++ b/zh-cn/device-dev/device-dev-guide.md @@ -30,146 +30,31 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按 ## 文档导读 -- [轻量和小型系统开发指导](#table3762949121211) -- [标准系统开发指导](#table17667535516) +- 轻量和小型系统开发指导如表1所示。 +- 标准系统开发指导如表2所示。 **表 1** 轻量和小型系统开发指导(参考内存<128MB) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

学习路径

-

开发者业务

-

相关文档

-

了解OpenHarmony

-

整体认知OpenHarmony

-
-

获取开发资源

-

准备开发前相关资源

-
-

快速入门

-

快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行。

-

轻量和小型系统快速入门

-

基础能力使用

-

使用OpenHarmony提供的基础能力

-
-

进阶开发

-

结合系统能力开发智能设备

-
-

移植适配

-
  • 针对特定芯片做移植适配
  • 对三方库进行移植适配
-
-

贡献组件

-

OpenHarmony贡献功能组件

-
-

参考

-

开发参考

-
-
+| 学习路径 | 开发者业务 | 相关文档 | +| -------- | -------- | -------- | +| 了解OpenHarmony | 整体认知OpenHarmony | - [OpenHarmony概述](https://gitee.com/openharmony)
- [术语](../glossary.md) | +| 获取开发资源 | 准备开发前相关资源 | - [获取源码](get-code/sourcecode-acquire.md)
- [获取工具](get-code/gettools-acquire.md) | +| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行。 | [轻量和小型系统快速入门](quick-start/quickstart-lite-overview.md) | +| 基础能力使用 | 使用OpenHarmony提供的基础能力 | - [轻量系统内核开发指南](kernel/kernel-mini-overview.md)
- [小型系统内核开发指南](kernel/kernel-small-overview.md)
- [驱动开发指南](driver/driver-hdf-overview.md)
- [子系统开发指南](subsystems/subsys-build-mini-lite.md)
- [安全指南](security/security-guidelines-overall.md)
- [隐私保护](security/security-privacy-protection.md) | +| 进阶开发 | 结合系统能力开发智能设备 | - [WLAN连接类产品](guide/device-wlan-led-control.md)
- [无屏摄像头类产品](guide/device-iotcamera-control-overview.md)
- [带屏摄像头类产品](guide/device-camera-control-overview.md) | +| 移植适配 | - 针对特定芯片做移植适配
- 对三方库进行移植适配 | - [轻量系统芯片移植指导](porting/oem_transplant_chip_prepare_knows.md)
- [小型系统芯片移植指导](porting/porting-smallchip-prepare-needs.md)
- [轻量和小型系统三方库移植指导](porting/porting-thirdparty-overview.md) | +| 贡献组件 | 为OpenHarmony贡献功能组件 | - [HPM Part 介绍](hpm-part/hpm-part-about.md)
- [HPM Part 开发指导](hpm-part/hpm-part-development.md)
- [HPM Part 参考](hpm-part/hpm-part-reference.md) | +| 参考 | 开发参考 | [常见问题](faqs/faqs-overview.md) | **表 2** 标准系统开发指导(参考内存≥128MB) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

学习路径

-

开发者业务

-

相关文档

-

了解OpenHarmony

-

整体认知OpenHarmony

-
-

获取开发资源

-

准备开发前相关资源

-
-

快速入门

-

快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行。

-

标准系统快速入门

-

基础能力使用

-

使用OpenHarmony提供的基础能力

-
-

进阶开发

-

结合系统能力开发智能设备

-
-

移植适配

-

对三方库进行移植适配

-
-

贡献组件

-

OpenHarmony贡献功能组件

-
-

参考

-

开发参考

-
-
- +| 学习路径 | 开发者业务 | 相关文档 | +| -------- | -------- | -------- | +| 了解OpenHarmony | 整体认知OpenHarmony | - [OpenHarmony概述](https://gitee.com/openharmony)
- [术语](../glossary.md) | +| 获取开发资源 | 准备开发前相关资源 | - [获取源码](get-code/sourcecode-acquire.md)
- [获取工具](get-code/gettools-acquire.md) | +| 快速入门 | 快速熟悉OpenHarmony环境搭建、编译、烧录、调测、运行。 | [标准系统快速入门](quick-start/quickstart-standard-overview.md) | +| 基础能力使用 | 使用OpenHarmony提供的基础能力 | - [内核开发指南](kernel/kernel-standard.md)
- [驱动开发指南](driver/driver-hdf-overview.md)
- [子系统开发指南](subsystems/subsys-build-standard-large.md)
- [安全指南](security/security-guidelines-overall.md)
- [隐私保护](security/security-privacy-protection.md) | +| 进阶开发 | 结合系统能力开发智能设备 | - [时钟应用开发指导](guide/device-clock-guide.md)
- [平台驱动开发示例](guide/device-driver-demo.md)
- [外设驱动开发示例](guide/device-outerdriver-demo.md) | +| 移植适配 | 对三方库进行移植适配 | - [标准系统芯片移植指导](porting/standard-system-porting-guide.md)
- [一种快速移植OpenHarmony Linux内核的方法](porting/porting-linux-kernel.md) | +| 贡献组件 | 为OpenHarmony贡献功能组件 | - [HPM Part 介绍](hpm-part/hpm-part-about.md)
- [HPM Part 开发指导](hpm-part/hpm-part-development.md)
- [HPM Part 参考](hpm-part/hpm-part-reference.md) | +| 参考 | 开发参考 |[常见问题](faqs/faqs-overview.md) | diff --git a/zh-cn/device-dev/driver/Readme-CN.md b/zh-cn/device-dev/driver/Readme-CN.md index 652a8c588ef50fd0c118b2c931661162cd779b6c..9025c280b31c7fe8712c964ed110055cb06cd3af 100755 --- a/zh-cn/device-dev/driver/Readme-CN.md +++ b/zh-cn/device-dev/driver/Readme-CN.md @@ -14,12 +14,12 @@ - [HDMI](driver-platform-hdmi-develop.md) - [I2C](driver-platform-i2c-develop.md) - [I3C](driver-platform-i3c-develop.md) - - [MIPI-CSI](driver-platform-mipicsi-develop.md) - - [MIPI-DSI](driver-platform-mipidsi-develop.md) + - [MIPI CSI](driver-platform-mipicsi-develop.md) + - [MIPI DSI](driver-platform-mipidsi-develop.md) - [MMC](driver-platform-mmc-develop.md) - [PIN](driver-platform-pin-develop.md) - [PWM](driver-platform-pwm-develop.md) - - [REGULATOR](driver-platform-regulator-develop.md) + - [Regulator](driver-platform-regulator-develop.md) - [RTC](driver-platform-rtc-develop.md) - [SDIO](driver-platform-sdio-develop.md) - [SPI](driver-platform-spi-develop.md) @@ -32,24 +32,24 @@ - [HDMI](driver-platform-hdmi-des.md) - [I2C](driver-platform-i2c-des.md) - [I3C](driver-platform-i3c-des.md) - - [MIPI-CSI](driver-platform-mipicsi-des.md) - - [MIPI-DSI](driver-platform-mipidsi-des.md) + - [MIPI CSI](driver-platform-mipicsi-des.md) + - [MIPI DSI](driver-platform-mipidsi-des.md) - [PIN](driver-platform-pin-des.md) - [PWM](driver-platform-pwm-des.md) - - [REGULATOR](driver-platform-regulator-des.md) + - [Regulator](driver-platform-regulator-des.md) - [RTC](driver-platform-rtc-des.md) - [SDIO](driver-platform-sdio-des.md) - [SPI](driver-platform-spi-des.md) - [UART](driver-platform-uart-des.md) - - [WATCHDOG](driver-platform-watchdog-des.md) + - [WatchDog](driver-platform-watchdog-des.md) - [外设驱动使用](driver-peripherals.md) - [LCD](driver-peripherals-lcd-des.md) - - [TOUCHSCREEN](driver-peripherals-touch-des.md) - - [SENSOR](driver-peripherals-sensor-des.md) + - [Touchscreen](driver-peripherals-touch-des.md) + - [Sensor](driver-peripherals-sensor-des.md) - [WLAN](driver-peripherals-external-des.md) - - [AUDIO](driver-peripherals-audio-des.md) + - [Audio](driver-peripherals-audio-des.md) - [USB](driver-peripherals-usb-des.md) - - [CAMERA](driver-peripherals-camera-des.md) - - [VIBRATOR](driver-peripherals-vibrator-des.md) - - [LIGHT](driver-peripherals-light-des.md) + - [Camera](driver-peripherals-camera-des.md) + - [Vibrator](driver-peripherals-vibrator-des.md) + - [Light](driver-peripherals-light-des.md) diff --git a/zh-cn/device-dev/driver/driver-peripherals-audio-des.md b/zh-cn/device-dev/driver/driver-peripherals-audio-des.md index 2058c0d203d204adcd56d2ab7687b0c38d6a0a5a..9a43c856a101dd9d5c8034495900b50490074965 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-audio-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-audio-des.md @@ -1,4 +1,4 @@ -# AUDIO +# Audio ## Audio驱动概述 diff --git a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md index 148726f226c65eaf4a5e3fa7ee09c08ed953c9ff..3eb096c087583406a741b2d0666c293cfc6dd254 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md @@ -1,32 +1,28 @@ -# Camera +# Camera -- [Camera](#camera) - - [概述](#概述) - - [开发指导](#开发指导) - - [HDI接口说明](#hdi接口说明) - - [开发步骤](#开发步骤) - - [开发实例](#开发实例) +## 概述 +### 功能简介 +OpenHarmony相机驱动框架模型对上实现相机HDI(Hardware Device Interface)接口,对下实现相机Pipeline模型,管理相机各个硬件设备。 +该驱动框架模型内部分为三层,依次为HDI实现层、框架层和设备适配层,各层基本概念如下: -## 概述 ++ HDI实现层:实现OHOS(OpenHarmony Operation System)相机标准南向接口。 ++ 框架层:对接HDI实现层的控制、流的转发,实现数据通路的搭建,管理相机各个硬件设备等功能。 ++ 设备适配层:屏蔽底层芯片和OS(Operation System)差异,支持多平台适配。 -OpenHarmony相机驱动框架模型对上实现相机HDI(Hardware Driver Interface)接口,对下实现相机Pipeline模型,管理相机各个硬件设备。 -该驱动框架模型内部分为三层,依次为HDI实现层、框架层和适配层,各层基本概念如下: -+ **HDI实现层**:对上实现OHOS(OpenHarmony Operation System)相机标准南向接口。 - -+ **框架层**:对接HDI实现层的控制、流的转发,实现数据通路的搭建,管理相机各个硬件设备等功能。 +### 运作机制 -+ **适配层**:屏蔽底层芯片和OS(Operation System)差异,支持多平台适配。 +Camera模块主要包含服务、设备的初始化,数据通路的搭建,流的配置、创建、下发、捕获等,具体运作机制参考以下图文解析: -**** -**图 1** 基于HDF驱动框架的Camera驱动模型 -![](figures/logic-view-of-camera-hal-zh.png) +**图 1** 基于HDF驱动框架的Camera驱动模型  -1. 系统启动时创建CameraDeviceHost进程。进程创建后,首先枚举底层设备,创建(也可以通过配置表创建)管理设备树的DeviceManager类及其内部各个底层设备的对象,创建对应的CameraHost类实例并且将其注册到UHDF服务中,方便上层通过UHDF服务获取底层CameraDeviceHost的服务,从而操作底层设备。 +        ![](figures/Camera模块驱动模型.png) -2. Service通过CameraDeviceHost服务获取CameraHost实例,CameraHost可以获取底层的Camera能力,打开手电筒、调用Open接口打开Camera创建连接、创建DeviceManager(负责底层硬件模块上电)、创建CameraDevice(向上提供设备控制接口)。创建CameraDevice时会实例化PipelineCore的各个子模块,其中StreamPiplineCore负责创建Pipeline,MetaQueueManager负责上报meta。 - -3. Service通过底层的CameraDevice配置流、创建Stream类。StreamPipelineStrategy模块通过上层下发的模式和查询配置表创建对应流的Node连接方式,StreamPipelineBuilder模块创建Node实例并且连接返回该Pipline给StreamPipelineDispatcher。StreamPipelineDispatcher提供统一的Pipline调用管理。 +1. 系统启动时创建camera_host进程。进程创建后,首先枚举底层设备,创建(也可以通过配置表创建)管理设备树的DeviceManager类及其内部各个底层设备的对象,创建对应的CameraHost类实例并且将其注册到UHDF服务中,方便相机服务层通过UHDF服务获取底层CameraDeviceHost的服务,从而操作硬件设备。 + +2. Service通过CameraDeviceHost服务获取CameraHost实例,CameraHost可以获取底层的Camera能力,打开手电筒、调用Open接口打开Camera创建连接、创建DeviceManager(负责底层硬件模块上电)、创建CameraDevice(向上提供设备控制接口)。创建CameraDevice时会实例化PipelineCore的各个子模块,其中StreamPipelineCore负责创建Pipeline,MetaQueueManager负责上报metaData。 + +3. Service通过CameraDevice模块配置流、创建Stream类。StreamPipelineStrategy模块通过上层下发的模式和查询配置表创建对应流的Node连接方式,StreamPipelineBuilder模块创建Node实例并且连接返回该Pipeline给StreamPipelineDispatcher。StreamPipelineDispatcher提供统一的Pipeline调用管理。 4. Service通过Stream控制整个流的操作,AttachBufferQueue接口将从显示模块申请的BufferQueue下发到底层,由CameraDeviceDriverModel自行管理buffer,当Capture接口下发命令后,底层开始向上传递buffer。Pipeline的IspNode依次从BufferQueue获取指定数量buffer,然后下发到底层ISP(Image Signal Processor,图像信号处理器)硬件,ISP填充完之后将buffer传递给CameraDeviceDriverModel,CameraDeviceDriverModel通过循环线程将buffer填充到已经创建好的Pipeline中,各个Node处理后通过回调传递给上层,同时buffer返回BufferQueue等待下一次下发。 @@ -34,639 +30,710 @@ OpenHarmony相机驱动框架模型对上实现相机HDI(Hardware Driver Inter 6. Service通过CameraDevice的UpdateSettings接口向下发送CaptureSetting参数,CameraDeviceDriverModel通过StreamPipelineDispatcher模块向各个Node转发,StartStreamingCapture和Capture接口携带的CaptureSetting通过StreamPipelineDispatcher模块向该流所属的Node转发。 -7. Service通过EnableResult和DisableResult接口控制底层meta的上报。如果需要底层meta上报,pipeline会创建CameraDeviceDriverModel内部的一个Bufferqueue用来收集和传递meta,根据StreamPipelineStrategy模块查询配置表并通过StreamPipelineBuilder创建和连接Node,MetaQueueManager下发buffer至底层,底层相关Node填充数据,MetaQueueManager模块再调用上层回调传递给上层。 +7. Service通过EnableResult和DisableResult接口控制底层metaData的上报。如果需要底层metaData上报,pipeline会创建CameraDeviceDriverModel内部的一个Bufferqueue用来收集和传递metaData,根据StreamPipelineStrategy模块查询配置表并通过StreamPipelineBuilder创建和连接Node,MetaQueueManager下发buffer至底层,底层相关Node填充数据,MetaQueueManager模块再调用上层回调传递给上层。 8. Service调用CameraDevice的Close接口,CameraDevice调用对应的DeviceManager模块对各个硬件下电;如果此时在Ipp的SubPipeline中存在OfflineStream,则需要保留OfflineStream,直到执行完毕。 -9. 动态帧率控制。在StreamOperator中起一个CollectBuffer线程,CollectBuffer线程从每一路stream的BufferQueue中获取buffer,如果某一路流的帧率需要控制(为sensor出帧帧率的1/n),可以根据需求控制每一帧的buffer打包,并决定是否collect此路流的buffer(比如sensor出帧帧率为120fps,预览流的帧率为30fps,CollectBuffer线程collect预览流的buffer时,每隔4fps collect一次)。 - -## 开发指导 - -### HDI接口说明 -旨在了解HDI接口的作用及函数参数的传递规则,详情可见[Camera驱动子系统HDI使用说明](https://gitee.com/openharmony/drivers_peripheral/blob/master/camera/README_zh.md)。 - - -### 开发步骤 - -下面分步骤描述了Camera驱动框架的主要接口,包括注册、检测;创建、捕获和销毁流;打开和关闭设备等接口(为了更清晰的展示和描述主要功能的实现部分,该章节删除了部分判错和LOG源码)。 -1. 注册CameraHost - - 定义Camera的HdfDriverEntry结构体,该结构体中定义了CameraHost初始化的方法。 - - ``` - struct HdfDriverEntry g_cameraHostDriverEntry = { - .moduleVersion = 1, - .moduleName = "camera_service", - .Bind = HdfCameraHostDriverBind, - .Init = HdfCameraHostDriverInit, - .Release = HdfCameraHostDriverRelease, - }; - HDF_INIT(g_cameraHostDriverEntry); // 将Camera的HdfDriverEntry结构体注册到HDF上 - ``` - -2. CameraHost初始化 - - 步骤1中提到的HdfCameraHostDriverBind接口提供了CameraServiceDispatch和CameraHostStubInstance的注册。这两个接口一个是远端调用CameraHost的方法,如OpenCamera(),SetFlashlight()等,另外一个是Camera设备的初始化,在开机时被调用。 - - ``` - int HdfCameraHostDriverBind(HdfDeviceObject *deviceObject) - { - HDF_LOGI("HdfCameraHostDriverBind enter!"); - if (deviceObject == nullptr) { - HDF_LOGE("HdfCameraHostDriverBind: HdfDeviceObject is NULL !"); - return HDF_FAILURE; - } - HdfCameraService *hdfCameraService = reinterpret_cast(OsalMemAlloc(sizeof(HdfCameraService))); - if (hdfCameraService == nullptr) { - HDF_LOGE("HdfCameraHostDriverBind OsalMemAlloc HdfCameraService failed!"); - return HDF_FAILURE; - } - hdfCameraService->ioservice.Dispatch = CameraServiceDispatch; // 提供远端CameraHost调用方法 - hdfCameraService->ioservice.Open = nullptr; - hdfCameraService->ioservice.Release = nullptr; - hdfCameraService->instance = CameraHostStubInstance(); // 初始化Camera设备 - deviceObject->service = &hdfCameraService->ioservice; - return HDF_SUCCESS; - } - ``` - - 下面的函数是远端CameraHost调用的方法: - - ``` - int32_t CameraHostStub::CameraHostServiceStubOnRemoteRequest(int cmdId, MessageParcel &data, - MessageParcel &reply, MessageOption &option) - { - switch(cmdId) { - case CMD_CAMERA_HOST_SET_CALLBACK: { - return CameraHostStubSetCallback(data, reply, option); - } - case CMD_CAMERA_HOST_GET_CAMERAID: { - return CameraHostStubGetCameraIds(data, reply, option); - } - case CMD_CAMERA_HOST_GET_CAMERA_ABILITY: { - return CameraHostStubGetCameraAbility(data, reply, option); - } - case CMD_CAMERA_HOST_OPEN_CAMERA: { - return CameraHostStubOpenCamera(data, reply, option); - } - case CMD_CAMERA_HOST_SET_FLASH_LIGHT: { - return CameraHostStubSetFlashlight(data, reply, option); - } - default: { - HDF_LOGE("%s: not support cmd %d", __func__, cmdId); - return HDF_ERR_INVALID_PARAM; - } - } - return HDF_SUCCESS; - } - ``` - - CameraHostStubInstance()接口最终调用CameraHostImpl::Init()方法,该方法会获取物理Camera,并对DeviceManager和PipelineCore进行初始化。 +9. 动态帧率控制。在StreamOperator中起一个CollectBuffer线程,CollectBuffer线程从每一路stream的BufferQueue中获取buffer,如果某一路流的帧率需要控制(为sensor出帧帧率的1/n),可以根据需求控制每一帧的buffer打包,并决定是否collect此路流的buffer(比如sensor出帧帧率为120fps,预览流的帧率为30fps,CollectBuffer线程collect预览流的buffer时,每隔4fps collect一次)。 -3. 获取CamerHost - - 调用Get()接口从远端CameraService中获取CameraHost对象。get()方法如下: - - ``` - sptr ICameraHost::Get(const char *serviceName) - { - do { - using namespace OHOS::HDI::ServiceManager::V1_0; - auto servMgr = IServiceManager::Get(); - if (servMgr == nullptr) { - HDF_LOGE("%s: IServiceManager failed!", __func__); - break; - } - auto remote = servMgr->GetService(serviceName); // 根据serviceName名称获取CameraHost - if (remote != nullptr) { - sptr hostSptr = iface_cast(remote); // 将CameraHostProxy对象返回给调用者,该对象中包含OpenCamera()等方法。 - return hostSptr; - } - HDF_LOGE("%s: GetService failed! serviceName = %s", __func__, serviceName); - } while(false); - HDF_LOGE("%s: get %s failed!", __func__, serviceName); - return nullptr; - } - ``` - -4. OpenCamera()接口 - - CameraHostProxy对象中有五个方法,分别是SetCallback、GetCameraIds、GetCameraAbility、OpenCamera和SetFlashlight。下面着重描述OpenCamera接口。 - CameraHostProxy的OpenCamera()接口通过CMD_CAMERA_HOST_OPEN_CAMERA调用远端CameraHostStubOpenCamera()接口并获取ICameraDevice对象。 - - ``` - CamRetCode CameraHostProxy::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &pDevice) - { - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_OPEN_CAMERA, data, reply, option); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret); - return INVALID_ARGUMENT; - } - CamRetCode retCode = static_cast(reply.ReadInt32()); - bool flag = reply.ReadBool(); - if (flag) { - sptr remoteCameraDevice = reply.ReadRemoteObject(); - if (remoteCameraDevice == nullptr) { - HDF_LOGE("%{public}s: CameraHostProxy remoteCameraDevice is null", __func__); - } - pDevice = OHOS::iface_cast(remoteCameraDevice); - } - return retCode; - } - ``` + - Remote()->SendRequest调用上文提到的CameraHostServiceStubOnRemoteRequest(),根据cmdId进入CameraHostStubOpenCamera()接口,最终调用CameraHostImpl::OpenCamera(),该接口获取了CameraDevice并对硬件进行上电等操作。 +## 开发指导 - ``` - CamRetCode CameraHostImpl::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &device) - { - std::shared_ptr cameraDevice = std::static_pointer_cast(itr->second); - if (cameraDevice == nullptr) { - CAMERA_LOGE("camera device is null."); - return INSUFFICIENT_RESOURCES; - } - CamRetCode ret = cameraDevice->SetCallback(callback); - if (ret != NO_ERROR) { - CAMERA_LOGW("set camera device callback faild."); - return ret; - } - CameraHostConfig *config = CameraHostConfig::GetInstance(); - if (config == nullptr) { - return INVALID_ARGUMENT; - } - std::vector phyCameraIds; - RetCode rc = config->GetPhysicCameraIds(cameraId, phyCameraIds); - if (rc != RC_OK) { - CAMERA_LOGE("get physic cameraId failed."); - return DEVICE_ERROR; - } - if (CameraPowerUp(cameraId, phyCameraIds) != RC_OK) { // 对Camera硬件上电 - CAMERA_LOGE("camera powerup failed."); - CameraPowerDown(phyCameraIds); - return DEVICE_ERROR; - } - - auto sptrDevice = deviceBackup_.find(cameraId); - if (sptrDevice == deviceBackup_.end()) { - deviceBackup_[cameraId] = cameraDevice.get(); - } - device = deviceBackup_[cameraId]; - cameraDevice->SetStatus(true); - return NO_ERROR; - } - ``` -5. GetStreamOperator()接口 +### 场景介绍 - CameraDeviceImpl定义了GetStreamOperator、UpdateSettings、SetResultMode和GetEnabledResult等方法,获取流操作方法如下: +Camera模块主要用以相机预览、拍照、视频流等场景下对相机操作封装,使开发者更易操作相机硬件,提高开发效率。 - ``` - CamRetCode CameraDeviceImpl::GetStreamOperator(const OHOS::sptr &callback, - OHOS::sptr &streamOperator) - { - if (callback == nullptr) { - CAMERA_LOGW("input callback is null."); - return INVALID_ARGUMENT; - } - spCameraDeciceCallback_ = callback; - if (spStreamOperator_ == nullptr) { - // 这里new了一个spStreamOperator对象传递给调用者,以便对stream进行各种操作。 - spStreamOperator_ = new(std::nothrow) StreamOperatorImpl(spCameraDeciceCallback_, shared_from_this()); - if (spStreamOperator_ == nullptr) { - CAMERA_LOGW("create stream operator failed."); - return DEVICE_ERROR; - } - ismOperator_ = spStreamOperator_; - } - streamOperator = ismOperator_; - - spStreamOperator_->SetRequestCallback([this](){ - cameraDeciceCallback_->OnError(REQUEST_TIMEOUT, 0); - }); - } - ``` +### 接口说明 -6. 创建流 +- icamera_device.h - 调用CreateStreams创建流前需要填充StreamInfo结构体,具体内容如下: + | 功能描述 | 接口名称 | + | ---------------------------- | ------------------------------------------------------------ | + | 获取流控制器 | CamRetCode GetStreamOperator(
const OHOS::sptr &callback,
OHOS::sptr &streamOperator) | + | 更新设备控制参数 | CamRetCode UpdateSettings(const std::shared_ptr &settingss) | + | 设置Result回调模式和回调函数 | CamRetCode SetResultMode(const ResultCallbackMode &mode) | + | 获取使能的ResultMeta | CamRetCode GetEnabledResults(std::vector &results) | + | 使能具体的ResultMeta | CamRetCode EnableResult(const std::vector &results) | + | 禁止具体的ResultMeta | CamRetCode DisableResult(const std::vector &results) | + | 关闭Camera设备 | void Close() | - ``` - using StreamInfo = struct _StreamInfo { - int streamId_; - int width_; // 数据流宽 - int height_; // 数据流高 - int format_; // 数据流格式,如PIXEL_FMT_YCRCB_420_SP - int datasapce_; - StreamIntent intent_; // StreamIntent 如PREVIEW - bool tunneledMode_; - OHOS::sptr bufferQueue_; // 数据流bufferQueue可用streamCustomer->CreateProducer()接口创建 - int minFrameDuration_; - EncodeType encodeType_; - }; - ``` +- icamera_device_callback.h - CreateStreams()接口是StreamOperatorImpl类中的方法,该接口的主要作用是创建一个StreamBase对象,通过StreamBase的Init方法初始化CreateBufferPool等操作。 + | 功能描述 | 接口名称 | + | ---------------------------------------------------------- | ------------------------------------------------------------ | + | 设备发生错误时调用,由调用者实现,用于返回错误信息给调用者 | void OnError(ErrorType type, int32_t errorCode) | + | 上报camera设备相关的metadata的回调 | void OnResult(uint64_t timestamp, const std::shared_ptr &result) | - ``` - RetCode StreamOperatorImpl::CreateStream(const std::shared_ptr& streamInfo) - { - static std::map typeMap = { - {PREVIEW, "PREVIEW"}, - {VIDEO, "VIDEO"}, - {STILL_CAPTURE, "STILL_CAPTURE"}, - {POST_VIEW, "POST_VIEW"}, {ANALYZE, "ANALYZE"}, - {CUSTOM, "CUSTOM"} - }; - - auto itr = typeMap.find(streamInfo->intent_); - if (itr == typeMap.end()) { - CAMERA_LOGE("do not support stream type. [type = %{public}d]", streamInfo->intent_); - return RC_ERROR; - } - std::shared_ptr stream = StreamFactory::Instance().CreateShared(itr->second); // 创建StreamBase实例 - RetCode rc = stream->Init(streamInfo); - return RC_OK; - } - ``` -7. 配置流 +- icamera_host.h - CommitStreams()是配置流的接口,必须在创建流之后调用,其主要作用是初始化Pipeline和创建Pipeline。 + | 功能描述 | 接口名称 | + | ------------------------------ | ------------------------------------------------------------ | + | 设置ICameraHost回调接口 | CamRetCode SetCallback(const OHOS::sptr &callback) | + | 获取当前可用的Camera设备ID列表 | CamRetCode GetCameraIds(std::vector &cameraIds) | + | 获取Camera设备能力集合 | CamRetCode GetCameraAbility(const std::string &cameraId,
std::shared_ptr &ability) | + | 打开Camera设备 | CamRetCode OpenCamera(const std::string &cameraId,
const OHOS::sptr &callback,
OHOS::sptr &device) | + | 打开或关闭闪光灯 | CamRetCode SetFlashlight(const std::string &cameraId, bool &isEnable) | - ``` - CamRetCode StreamOperatorImpl::CommitStreams(OperationMode mode, const std::shared_ptr& modeSetting) - { - auto cameraDevice = cameraDevice_.lock(); - if (cameraDevice == nullptr) { - CAMERA_LOGE("camera device closed."); - return CAMERA_CLOSED; - } - std::shared_ptr PipelineCore = - std::static_pointer_cast(cameraDevice)->GetPipelineCore(); - if (PipelineCore == nullptr) { - CAMERA_LOGE("get pipeline core failed."); - return CAMERA_CLOSED; - } - - streamPipeCore_ = PipelineCore->GetStreamPipelineCore(); - if (streamPipeCore_ == nullptr) { - CAMERA_LOGE("get stream pipeline core failed."); - return DEVICE_ERROR; - } - - RetCode rc = streamPipeCore_->Init(); // 对pipelinecore的初始化 - if (rc != RC_OK) { - CAMERA_LOGE("stream pipeline core init failed."); - return DEVICE_ERROR; - } - rc = streamPipeCore_->CreatePipeline(mode); // 创建一个pipeline - if (rc != RC_OK) { - CAMERA_LOGE("create pipeline failed."); - return INVALID_ARGUMENT; - } - return NO_ERROR; - } - ``` +- icamera_host_callback.h -8. 捕获图像 + | 功能描述 | 接口名称 | + | ---------------------- | ------------------------------------------------------------ | + | Camera设备状态变化上报 | void OnCameraStatus(const std::string &cameraId, CameraStatus status) | + | 闪光灯状态变化回调 | void OnFlashlightStatus(const std::string &cameraId, FlashlightStatus status) | - 在调用Capture()接口前需要先填充CaptureInfo结构体,具体内容如下: +- ioffline_stream_operator.h - ``` - using CaptureInfo = struct _CaptureInfo { - std::vector streamIds_; //需要Capture的streamIds - std::shared_ptr captureSetting_; // 这里填充camera ability 可通过CameraHost 的GetCameraAbility()接口获取 - bool enableShutterCallback_; - }; - ``` + | 功能描述 | 接口名称 | + | -------------- | ------------------------------------------------------------ | + | 取消捕获请求 | CamRetCode CancelCapture(int captureId) | + | 释放流 | CamRetCode ReleaseStreams(const std::vector &streamIds) | + | 释放所有离线流 | CamRetCode Release() | - StreamOperatorImpl中的Capture方法主要调用CreateCapture()接口去捕获数据流: +- istream_operator.h - ``` - CamRetCode StreamOperatorImpl::Capture(int captureId, const std::shared_ptr& captureInfo, bool isStreaming) - { - if (!ValidCaptureInfo(captureId, captureInfo)) { - CAMERA_LOGE("capture streamIds is empty. [captureId = %d]", captureId); - return INVALID_ARGUMENT; - } - std::shared_ptr cameraCapture = nullptr; - RetCode rc = CreateCapture(captureId, captureInfo, isStreaming, cameraCapture); - if (rc != RC_OK) { - CAMERA_LOGE("create capture is failed."); - return DEVICE_ERROR; - } - - { - std::unique_lock lock(captureMutex_); - camerCaptureMap_.insert(std::make_pair(captureId, cameraCapture)); - } - - rc = StartThread(); - if (rc != RC_OK) { - CAMERA_LOGE("preview start failed."); - return DEVICE_ERROR; - } - return NO_ERROR; - } - ``` + | 功能描述 | 接口名称 | + | -------------------------------- | ------------------------------------------------------------ | + | 查询是否支持添加参数对应的流 | CamRetCode IsStreamsSupported(
OperationMode mode,
const std::shared_ptr &modeSetting,
const std::vector<std::shared_ptr<StreamInfo>> &info,
StreamSupportType &type) | + | 创建流 | CamRetCode CreateStreams(const std::vector> &streamInfos) | + | 释放流 | CamRetCode ReleaseStreams(const std::vector &streamIds) | + | 配置流 | CamRetCode CommitStreams(OperationMode mode,
const std::shared_ptr &modeSetting) | + | 获取流的属性 | CamRetCode GetStreamAttributes(
std::vector> &attributes) | + | 绑定生产者句柄和指定流 | CamRetCode AttachBufferQueue(int streamId, const OHOS::sptr &producer) | + | 解除生产者句柄和指定流的绑定关系 | CamRetCode DetachBufferQueue(int streamId) | + | 捕获图像 | CamRetCode Capture(int captureId,
const std::shared_ptr &info, bool isStreaming) | + | 取消捕获 | CamRetCode CancelCapture(int captureId) | + | 将指定流转换成离线流 | CamRetCode ChangeToOfflineStream(const std::vector &streamIds,
OHOS::sptr &callback,
OHOS::sptr &offlineOperator) | -9. 取消捕获和释放离线流 +- istream_operator_callback.h - StreamOperatorImpl类中的CancelCapture()接口的主要作用是根据captureId取消数据流的捕获。 + | 功能描述 | 接口名称 | + | ---------------------------------------- | ------------------------------------------------------------ | + | 捕获开始回调,在捕获开始时调用 | void OnCaptureStarted(int32_t captureId, const std::vector &streamIds) | + | 捕获结束回调,在捕获结束时调用 | void OnCaptureEnded(int32_t captureId,
const std::vector> &infos) | + | 捕获错误回调,在捕获过程中发生错误时调用 | void OnCaptureError(int32_t captureId,
const std::vector> &infos) | + | 帧捕获回调 | void OnFrameShutter(int32_t captureId,
const std::vector &streamIds, uint64_t timestamp) | - ``` - CamRetCode StreamOperatorImpl::CancelCapture(int captureId) - { - auto itr = camerCaptureMap_.find(captureId); //根据captureId 在Map中查找对应的CameraCapture对象 - RetCode rc = itr->second->Cancel(); //调用CameraCapture中Cancel方法结束数据捕获 - std::unique_lock lock(captureMutex_); - camerCaptureMap_.erase(itr); //擦除该CameraCapture对象 - return NO_ERROR; - } - ``` +### 开发步骤 +Camera驱动的开发过程主要包含以下步骤: - StreamOperatorImpl类中的ReleaseStreams接口的主要作用是释放之前通过CreateStream()和CommitStreams()接口创建的流,并销毁Pipeline。 +1. **注册CameraHost** + 定义Camera的HdfDriverEntry结构体,该结构体中定义了CameraHost初始化的方法。 ``` - CamRetCode StreamOperatorImpl::ReleaseStreams(const std::vector& streamIds) - { - RetCode rc = DestroyStreamPipeline(streamIds); //销毁该streamIds 的pipeline - rc = DestroyHostStreamMgr(streamIds); - rc = DestroyStreams(streamIds); //销毁该streamIds 的 Stream - return NO_ERROR; - } - ``` - -10. 关闭Camera设备 + struct HdfDriverEntry g_cameraHostDriverEntry = { + .moduleVersion = 1, + .moduleName = "camera_service", + .Bind = HdfCameraHostDriverBind, + .Init = HdfCameraHostDriverInit, + .Release = HdfCameraHostDriverRelease, + }; + HDF_INIT(g_cameraHostDriverEntry); // 将Camera的HdfDriverEntry结构体注册到HDF上 + ``` - 调用CameraDeviceImpl中的Close()来关闭CameraDevice,该接口调用deviceManager中的PowerDown()来给设备下电。 +2. **初始化Host服务** + 步骤1中提到的HdfCameraHostDriverBind接口提供了CameraServiceDispatch和CameraHostStubInstance的注册。这两个接口一个是远端调用CameraHost的方法,如OpenCamera(),SetFlashlight()等,另外一个是Camera设备的初始化,在开机时被调用。 -## 开发实例 - -在/drivers/peripheral/camera/hal/init目录下有一个关于Camera的demo,开机后会在/system/bin下生成可执行文件ohos_camera_demo,该demo可以完成camera的预览,拍照等基础功能。下面我们就以此demo为例讲述怎样用HDI接口去编写预览PreviewOn()和拍照CaptureON()的用例。 - -1. 在main函数中构造一个Hos3516Demo对象,该对象中有对camera初始化、启停流、释放等控制的方法。下面mainDemo->InitSensors()函数为初始化CameraHost,mainDemo->InitCameraDevice()函数为初始化CameraDevice。 - - ``` - int main(int argc, char** argv) - { - RetCode rc = RC_OK; - auto mainDemo = std::make_shared(); - rc = mainDemo->InitSensors(); // 初始化CameraHost - if (rc == RC_ERROR) { - CAMERA_LOGE("main test: mainDemo->InitSensors() error\n"); - return -1; - } - - rc = mainDemo->InitCameraDevice(); // 初始化CameraDevice - if (rc == RC_ERROR) { - CAMERA_LOGE("main test: mainDemo->InitCameraDevice() error\n"); - return -1; - } - - rc = PreviewOn(0, mainDemo); // 配流和启流 - if (rc != RC_OK) { - CAMERA_LOGE("main test: PreviewOn() error demo exit"); - return -1; - } - - ManuList(mainDemo, argc, argv); // 打印菜单到控制台 + ``` + int HdfCameraHostDriverBind(HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfCameraHostDriverBind enter!"); + if (deviceObject == nullptr) { + HDF_LOGE("HdfCameraHostDriverBind: HdfDeviceObject is NULL !"); + return HDF_FAILURE; + } + HdfCameraService *hdfCameraService = reinterpret_cast(OsalMemAlloc(sizeof(HdfCameraService))); + if (hdfCameraService == nullptr) { + HDF_LOGE("HdfCameraHostDriverBind OsalMemAlloc HdfCameraService failed!"); + return HDF_FAILURE; + } + hdfCameraService->ioservice.Dispatch = CameraServiceDispatch; // 提供远端CameraHost调用方法 + hdfCameraService->ioservice.Open = nullptr; + hdfCameraService->ioservice.Release = nullptr; + hdfCameraService->instance = CameraHostStubInstance(); // 初始化Camera设备 + deviceObject->service = &hdfCameraService->ioservice; + return HDF_SUCCESS; + } + ``` + + 下面的函数是远端CameraHost调用的方法: + + ``` + int32_t CameraHostStub::CameraHostServiceStubOnRemoteRequest(int cmdId, MessageParcel &data, + MessageParcel &reply, MessageOption &option) + { + switch(cmdId) { + case CMD_CAMERA_HOST_SET_CALLBACK: { + return CameraHostStubSetCallback(data, reply, option); + } + case CMD_CAMERA_HOST_GET_CAMERAID: { + return CameraHostStubGetCameraIds(data, reply, option); + } + case CMD_CAMERA_HOST_GET_CAMERA_ABILITY: { + return CameraHostStubGetCameraAbility(data, reply, option); + } + case CMD_CAMERA_HOST_OPEN_CAMERA: { + return CameraHostStubOpenCamera(data, reply, option); + } + case CMD_CAMERA_HOST_SET_FLASH_LIGHT: { + return CameraHostStubSetFlashlight(data, reply, option); + } + default: { + HDF_LOGE("%s: not support cmd %d", __func__, cmdId); + return HDF_ERR_INVALID_PARAM; + } + } + return HDF_SUCCESS; + } + ``` + + CameraHostStubInstance()接口最终调用CameraHostImpl::Init()方法,该方法会获取物理Camera,并对DeviceManager和PipelineCore进行初始化。 + +3. **获取Host服务** + + 调用Get()接口从远端CameraService中获取CameraHost对象。get()方法如下: + + ``` + sptr ICameraHost::Get(const char *serviceName) + { + do { + using namespace OHOS::HDI::ServiceManager::V1_0; + auto servMgr = IServiceManager::Get(); + if (servMgr == nullptr) { + HDF_LOGE("%s: IServiceManager failed!", __func__); + break; + } + auto remote = servMgr->GetService(serviceName); // 根据serviceName名称获取CameraHost + if (remote != nullptr) { + sptr hostSptr = iface_cast(remote); // 将CameraHostProxy对象返回给调用者,该对象中包含OpenCamera()等方法。 + return hostSptr; + } + HDF_LOGE("%s: GetService failed! serviceName = %s", __func__, serviceName); + } while(false); + HDF_LOGE("%s: get %s failed!", __func__, serviceName); + return nullptr; + } + ``` + +4. **打开设备** + + CameraHostProxy对象中有五个方法,分别是SetCallback、GetCameraIds、GetCameraAbility、OpenCamera和SetFlashlight。下面着重描述OpenCamera接口。 + CameraHostProxy的OpenCamera()接口通过CMD_CAMERA_HOST_OPEN_CAMERA调用远端CameraHostStubOpenCamera()接口并获取ICameraDevice对象。 + + ``` + CamRetCode CameraHostProxy::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &pDevice) + { + int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_OPEN_CAMERA, data, reply, option); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret); + return INVALID_ARGUMENT; + } + CamRetCode retCode = static_cast(reply.ReadInt32()); + bool flag = reply.ReadBool(); + if (flag) { + sptr remoteCameraDevice = reply.ReadRemoteObject(); + if (remoteCameraDevice == nullptr) { + HDF_LOGE("%{public}s: CameraHostProxy remoteCameraDevice is null", __func__); + } + pDevice = OHOS::iface_cast(remoteCameraDevice); + } + return retCode; + } + ``` + + Remote()->SendRequest调用上文提到的CameraHostServiceStubOnRemoteRequest(),根据cmdId进入CameraHostStubOpenCamera()接口,最终调用CameraHostImpl::OpenCamera(),该接口获取了CameraDevice并对硬件进行上电等操作。 + + ``` + CamRetCode CameraHostImpl::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &device) + { + std::shared_ptr cameraDevice = std::static_pointer_cast(itr->second); + if (cameraDevice == nullptr) { + CAMERA_LOGE("camera device is null."); + return INSUFFICIENT_RESOURCES; + } + CamRetCode ret = cameraDevice->SetCallback(callback); + if (ret != NO_ERROR) { + CAMERA_LOGW("set camera device callback failed."); + return ret; + } + CameraHostConfig *config = CameraHostConfig::GetInstance(); + if (config == nullptr) { + return INVALID_ARGUMENT; + } + std::vector phyCameraIds; + RetCode rc = config->GetPhysicCameraIds(cameraId, phyCameraIds); + if (rc != RC_OK) { + CAMERA_LOGE("get physic cameraId failed."); + return DEVICE_ERROR; + } + if (CameraPowerUp(cameraId, phyCameraIds) != RC_OK) { // 对Camera硬件上电 + CAMERA_LOGE("camera powerup failed."); + CameraPowerDown(phyCameraIds); + return DEVICE_ERROR; + } + + auto sptrDevice = deviceBackup_.find(cameraId); + if (sptrDevice == deviceBackup_.end()) { + deviceBackup_[cameraId] = cameraDevice.get(); + } + device = deviceBackup_[cameraId]; + cameraDevice->SetStatus(true); + return NO_ERROR; + } + ``` + +5. **获取流** + + CameraDeviceImpl定义了GetStreamOperator、UpdateSettings、SetResultMode和GetEnabledResult等方法,获取流操作方法如下: + + ``` + CamRetCode CameraDeviceImpl::GetStreamOperator(const OHOS::sptr &callback, + OHOS::sptr &streamOperator) + { + if (callback == nullptr) { + CAMERA_LOGW("input callback is null."); + return INVALID_ARGUMENT; + } + spCameraDeviceCallback_ = callback; + if (spStreamOperator_ == nullptr) { + // 这里new了一个spStreamOperator对象传递给调用者,以便对stream进行各种操作。 + spStreamOperator_ = new(std::nothrow) StreamOperatorImpl(spCameraDeviceCallback_, shared_from_this()); + if (spStreamOperator_ == nullptr) { + CAMERA_LOGW("create stream operator failed."); + return DEVICE_ERROR; + } + ismOperator_ = spStreamOperator_; + } + streamOperator = ismOperator_; + + spStreamOperator_->SetRequestCallback([this](){ + spCameraDeviceCallback_->OnError(REQUEST_TIMEOUT, 0); + }); + } + ``` + +6. **创建流** + + 调用CreateStreams创建流前需要填充StreamInfo结构体,具体内容如下: + + ``` + using StreamInfo = struct _StreamInfo { + int streamId_; + int width_; // 数据流宽 + int height_; // 数据流高 + int format_; // 数据流格式,如PIXEL_FMT_YCRCB_420_SP + int dataSpace_; + StreamIntent intent_; // StreamIntent 如PREVIEW + bool tunneledMode_; + OHOS::sptr bufferQueue_; // 数据流bufferQueue可用streamCustomer->CreateProducer()接口创建 + int minFrameDuration_; + EncodeType encodeType_; + }; + ``` + + CreateStreams()接口是StreamOperatorImpl类中的方法,该接口的主要作用是创建一个StreamBase对象,通过StreamBase的Init方法初始化CreateBufferPool等操作。 + + ``` + RetCode StreamOperatorImpl::CreateStream(const std::shared_ptr& streamInfo) + { + static std::map typeMap = { + {PREVIEW, "PREVIEW"}, + {VIDEO, "VIDEO"}, + {STILL_CAPTURE, "STILL_CAPTURE"}, + {POST_VIEW, "POST_VIEW"}, {ANALYZE, "ANALYZE"}, + {CUSTOM, "CUSTOM"} + }; + + auto itr = typeMap.find(streamInfo->intent_); + if (itr == typeMap.end()) { + CAMERA_LOGE("do not support stream type. [type = %{public}d]", streamInfo->intent_); + return RC_ERROR; + } + std::shared_ptr stream = StreamFactory::Instance().CreateShared(itr->second); // 创建StreamBase实例 + RetCode rc = stream->Init(streamInfo); + return RC_OK; + } + ``` + +7. **配置流** + + CommitStreams()是配置流的接口,必须在创建流之后调用,其主要作用是初始化Pipeline和创建Pipeline。 + + ``` + CamRetCode StreamOperatorImpl::CommitStreams(OperationMode mode, const std::shared_ptr& modeSetting) + { + auto cameraDevice = cameraDevice_.lock(); + if (cameraDevice == nullptr) { + CAMERA_LOGE("camera device closed."); + return CAMERA_CLOSED; + } + std::shared_ptr PipelineCore = + std::static_pointer_cast(cameraDevice)->GetPipelineCore(); + if (PipelineCore == nullptr) { + CAMERA_LOGE("get pipeline core failed."); + return CAMERA_CLOSED; + } + + streamPipeCore_ = PipelineCore->GetStreamPipelineCore(); + if (streamPipeCore_ == nullptr) { + CAMERA_LOGE("get stream pipeline core failed."); + return DEVICE_ERROR; + } + + RetCode rc = streamPipeCore_->Init(); // 对pipelinecore的初始化 + if (rc != RC_OK) { + CAMERA_LOGE("stream pipeline core init failed."); + return DEVICE_ERROR; + } + rc = streamPipeCore_->CreatePipeline(mode); // 创建一个pipeline + if (rc != RC_OK) { + CAMERA_LOGE("create pipeline failed."); + return INVALID_ARGUMENT; + } + return NO_ERROR; + } + ``` + +8. **捕获图像** + + 在调用Capture()接口前需要先填充CaptureInfo结构体,具体内容如下: + + ``` + using CaptureInfo = struct _CaptureInfo { + std::vector streamIds_; //需要Capture的streamIds + std::shared_ptr captureSetting_; // 这里填充camera ability 可通过CameraHost 的GetCameraAbility()接口获取 + bool enableShutterCallback_; + }; + ``` + + StreamOperatorImpl中的Capture方法主要调用CreateCapture()接口去捕获数据流: + + ``` + CamRetCode StreamOperatorImpl::Capture(int captureId, const std::shared_ptr& captureInfo, bool isStreaming) + { + if (!ValidCaptureInfo(captureId, captureInfo)) { + CAMERA_LOGE("capture streamIds is empty. [captureId = %d]", captureId); + return INVALID_ARGUMENT; + } + std::shared_ptr cameraCapture = nullptr; + RetCode rc = CreateCapture(captureId, captureInfo, isStreaming, cameraCapture); + if (rc != RC_OK) { + CAMERA_LOGE("create capture is failed."); + return DEVICE_ERROR; + } + + { + std::unique_lock lock(captureMutex_); + camerCaptureMap_.insert(std::make_pair(captureId, cameraCapture)); + } + + rc = StartThread(); + if (rc != RC_OK) { + CAMERA_LOGE("preview start failed."); + return DEVICE_ERROR; + } + return NO_ERROR; + } + ``` + +9. **取消捕获和释放离线流** + + StreamOperatorImpl类中的CancelCapture()接口的主要作用是根据captureId取消数据流的捕获。 + + ``` + CamRetCode StreamOperatorImpl::CancelCapture(int captureId) + { + auto itr = camerCaptureMap_.find(captureId); //根据captureId 在Map中查找对应的CameraCapture对象 + RetCode rc = itr->second->Cancel(); //调用CameraCapture中Cancel方法结束数据捕获 + std::unique_lock lock(captureMutex_); + camerCaptureMap_.erase(itr); //擦除该CameraCapture对象 + return NO_ERROR; + } + ``` + + StreamOperatorImpl类中的ReleaseStreams接口的主要作用是释放之前通过CreateStream()和CommitStreams()接口创建的流,并销毁Pipeline。 + + ``` + CamRetCode StreamOperatorImpl::ReleaseStreams(const std::vector& streamIds) + { + RetCode rc = DestroyStreamPipeline(streamIds); //销毁该streamIds 的pipeline + rc = DestroyHostStreamMgr(streamIds); + rc = DestroyStreams(streamIds); //销毁该streamIds 的 Stream + return NO_ERROR; + } + ``` + +10. **关闭Camera设备** - return RC_OK; - } - ``` + 调用CameraDeviceImpl中的Close()来关闭CameraDevice,该接口调用deviceManager中的PowerDown()来给设备下电。 - 初始化CameraHost函数实现如下,这里调用了HDI接口ICameraHost::Get()去获取demoCameraHost,并对其设置回调函数。 +### 开发实例 - ``` - RetCode Hos3516Demo::InitSensors() - { - demoCameraHost_ = ICameraHost::Get(DEMO_SERVICE_NAME); - if (demoCameraHost_ == nullptr) { - CAMERA_LOGE("demo test: ICameraHost::Get error"); - return RC_ERROR; - } - - hostCallback_ = new CameraHostCallback(); - rc = demoCameraHost_->SetCallback(hostCallback_); - return RC_OK; - } - ``` +在/drivers/peripheral/camera/hal/init目录下有一个关于Camera的demo,开机后会在/vendor/bin下生成可执行文件ohos_camera_demo,该demo可以完成Camera的预览,拍照等基础功能。下面我们就以此demo为例讲述怎样用HDI接口去编写预览PreviewOn()和拍照CaptureON()的用例,可参考[ohos_camera_demo](https://gitee.com/openharmony/drivers_peripheral/tree/master/camera/hal/init)。 - 初始化CameraDevice函数实现如下,这里调用了GetCameraIds(cameraIds_),GetCameraAbility(cameraId, ability_),OpenCamera(cameraIds_.front(), callback, demoCameraDevice_)等接口实现了demoCameraHost的获取。 +1. 在main函数中构造一个CameraDemo 对象,该对象中有对Camera初始化、启停流、释放等控制的方法。下面mainDemo->InitSensors()函数为初始化CameraHost,mainDemo->InitCameraDevice()函数为初始化CameraDevice。 - ``` - RetCode Hos3516Demo::InitCameraDevice() - { - (void)demoCameraHost_->GetCameraIds(cameraIds_); - const std::string cameraId = cameraIds_.front(); - demoCameraHost_->GetCameraAbility(cameraId, ability_); - - sptr callback = new CameraDeviceCallback(); - rc = demoCameraHost_->OpenCamera(cameraIds_.front(), callback, demoCameraDevice_); - return RC_OK; - } - ``` + ``` + int main(int argc, char** argv) + { + RetCode rc = RC_OK; + auto mainDemo = std::make_shared(); + rc = mainDemo->InitSensors(); // 初始化CameraHost + if (rc == RC_ERROR) { + CAMERA_LOGE("main test: mainDemo->InitSensors() error\n"); + return -1; + } + + rc = mainDemo->InitCameraDevice(); // 初始化CameraDevice + if (rc == RC_ERROR) { + CAMERA_LOGE("main test: mainDemo->InitCameraDevice() error\n"); + return -1; + } + + rc = PreviewOn(0, mainDemo); // 配流和启流 + if (rc != RC_OK) { + CAMERA_LOGE("main test: PreviewOn() error demo exit"); + return -1; + } + + ManuList(mainDemo, argc, argv); // 打印菜单到控制台 + + return RC_OK; + } + ``` + + 初始化CameraHost函数实现如下,这里调用了HDI接口ICameraHost::Get()去获取demoCameraHost,并对其设置回调函数。 + + ``` + RetCode CameraDemo::InitSensors() + { + demoCameraHost_ = ICameraHost::Get(DEMO_SERVICE_NAME); + if (demoCameraHost_ == nullptr) { + CAMERA_LOGE("demo test: ICameraHost::Get error"); + return RC_ERROR; + } + + hostCallback_ = new CameraHostCallback(); + rc = demoCameraHost_->SetCallback(hostCallback_); + return RC_OK; + } + ``` + + 初始化CameraDevice函数实现如下,这里调用了GetCameraIds(cameraIds_),GetCameraAbility(cameraId, ability_),OpenCamera(cameraIds_.front(), callback, demoCameraDevice_)等接口实现了demoCameraHost的获取。 + + ``` + RetCode CameraDemo::InitCameraDevice() + { + (void)demoCameraHost_->GetCameraIds(cameraIds_); + const std::string cameraId = cameraIds_.front(); + demoCameraHost_->GetCameraAbility(cameraId, ability_); + + sptr callback = new CameraDeviceCallback(); + rc = demoCameraHost_->OpenCamera(cameraIds_.front(), callback, demoCameraDevice_); + return RC_OK; + } + ``` 2. PreviewOn()接口包含配置流、开启预览流和启动Capture动作。该接口执行完成后Camera预览通路已经开始运转并开启了两路流,一路流是preview,另外一路流是capture或者video,两路流中仅对preview流进行capture动作。 - ``` - static RetCode PreviewOn(int mode, const std::shared_ptr& mainDemo) - { - rc = mainDemo->StartPreviewStream(); // 配置preview流 - if (mode == 0) { - rc = mainDemo->StartCaptureStream(); // 配置capture流 - } else { - rc = mainDemo->StartVideoStream(); // 配置video流 - } - - rc = mainDemo->CaptureON(STREAM_ID_PREVIEW, CAPTURE_ID_PREVIEW, CAPTURE_PREVIEW); // 将preview流capture - return RC_OK; - } - ``` - - StartCaptureStream()、StartVideoStream()和StartPreviewStream()接口都会调用CreateStream()接口,只是传入的参数不同。 - - ``` - RetCode Hos3516Demo::StartVideoStream() - { - RetCode rc = RC_OK; - if (isVideoOn_ == 0) { - isVideoOn_ = 1; - rc = CreateStream(STREAM_ID_VIDEO, streamCustomerVideo_, VIDEO); // 如需启preview或者capture流更改该接口参数即可。 - } - return RC_OK; - } - ``` - - CreateStream()方法调用HDI接口去配置和创建流,首先调用HDI接口去获取StreamOperation对象,然后创建一个StreamInfo。调用CreateStreams()和CommitStreams()实际创建流并配置流。 - - ``` - RetCode Hos3516Demo::CreateStreams(const int streamIdSecond, StreamIntent intent) - { - std::vector> streamInfos; - std::vector>().swap(streamInfos); - GetStreamOpt(); // 获取StreamOperator对象 - std::shared_ptr previewStreamInfo = std::make_shared(); - SetStreamInfo(previewStreamInfo, streamCustomerPreview_, STREAM_ID_PREVIEW, PREVIEW); // 填充StreamInfo - if (previewStreamInfo->bufferQueue_ == nullptr) { - CAMERA_LOGE("demo test: CreateStream CreateProducer(); is nullptr\n"); - return RC_ERROR; - } - streamInfos.push_back(previewStreamInfo); - - std::shared_ptr secondStreamInfo = std::make_shared(); - if (streamIdSecond == STREAM_ID_CAPTURE) { - SetStreamInfo(secondStreamInfo, streamCustomerCapture_, STREAM_ID_CAPTURE, intent); - } else { - SetStreamInfo(secondStreamInfo, streamCustomerVideo_, STREAM_ID_VIDEO, intent); - } - - if (secondStreamInfo->bufferQueue_ == nullptr) { - CAMERA_LOGE("demo test: CreateStreams CreateProducer() secondStreamInfo is nullptr\n"); - return RC_ERROR; - } - streamInfos.push_back(secondStreamInfo); - - rc = streamOperator_->CreateStreams(streamInfos); // 创建流 - if (rc != Camera::NO_ERROR) { - CAMERA_LOGE("demo test: CreateStream CreateStreams error\n"); - return RC_ERROR; - } - - rc = streamOperator_->CommitStreams(Camera::NORMAL, ability_); - if (rc != Camera::NO_ERROR) { - CAMERA_LOGE("demo test: CreateStream CommitStreams error\n"); - std::vector streamIds = {STREAM_ID_PREVIEW, streamIdSecond}; - streamOperator_->ReleaseStreams(streamIds); - return RC_ERROR; - } - return RC_OK; - } - ``` - - CaptureON()接口调用streamOperator的Capture()方法获取camera数据并轮转buffer,拉起一个线程接收相应类型的数据。 - - ``` - RetCode Hos3516Demo::CaptureON(const int streamId, const int captureId, CaptureMode mode) - { - std::shared_ptr captureInfo = std::make_shared(); // 创建并填充CaptureInfo - captureInfo->streamIds_ = {streamId}; - captureInfo->captureSetting_ = ability_; - captureInfo->enableShutterCallback_ = false; - - int rc = streamOperator_->Capture(captureId, captureInfo, true); // 实际capture开始,buffer轮转开始 - if (mode == CAPTURE_PREVIEW) { - streamCustomerPreview_->ReceiveFrameOn(nullptr); // 创建预览线程接收递上来的buffer - } else if (mode == CAPTURE_SNAPSHOT) { - streamCustomerCapture_->ReceiveFrameOn([this](void* addr, const uint32_t size) { // 创建capture线程通过StoreImage回调接收递上来的buffer - StoreImage(addr, size); - }); - } else if (mode == CAPTURE_VIDEO) { - OpenVideoFile(); - streamCustomerVideo_->ReceiveFrameOn([this](void* addr, const uint32_t size) {// 创建Video线程通过StoreVideo回调接收递上来的buffer - StoreVideo(addr, size); - }); - } - return RC_OK; - } - ``` + ``` + static RetCode PreviewOn(int mode, const std::shared_ptr& mainDemo) + { + rc = mainDemo->StartPreviewStream(); // 配置preview流 + if (mode == 0) { + rc = mainDemo->StartCaptureStream(); // 配置capture流 + } else { + rc = mainDemo->StartVideoStream(); // 配置video流 + } + + rc = mainDemo->CaptureON(STREAM_ID_PREVIEW, CAPTURE_ID_PREVIEW, CAPTURE_PREVIEW); // 将preview流capture + return RC_OK; + } + ``` + + StartCaptureStream()、StartVideoStream()和StartPreviewStream()接口都会调用CreateStream()接口,只是传入的参数不同。 + + ``` + RetCode CameraDemo::StartVideoStream() + { + RetCode rc = RC_OK; + if (isVideoOn_ == 0) { + isVideoOn_ = 1; + rc = CreateStream(STREAM_ID_VIDEO, streamCustomerVideo_, VIDEO); // 如需启preview或者capture流更改该接口参数即可。 + } + return RC_OK; + } + ``` + + CreateStream()方法调用HDI接口去配置和创建流,首先调用HDI接口去获取StreamOperation对象,然后创建一个StreamInfo。调用CreateStreams()和CommitStreams()实际创建流并配置流。 + + ``` + RetCode CameraDemo::CreateStreams(const int streamIdSecond, StreamIntent intent) + { + std::vector> streamInfos; + std::vector>().swap(streamInfos); + GetStreamOpt(); // 获取StreamOperator对象 + std::shared_ptr previewStreamInfo = std::make_shared(); + SetStreamInfo(previewStreamInfo, streamCustomerPreview_, STREAM_ID_PREVIEW, PREVIEW); // 填充StreamInfo + if (previewStreamInfo->bufferQueue_ == nullptr) { + CAMERA_LOGE("demo test: CreateStream CreateProducer(); is nullptr\n"); + return RC_ERROR; + } + streamInfos.push_back(previewStreamInfo); + + std::shared_ptr secondStreamInfo = std::make_shared(); + if (streamIdSecond == STREAM_ID_CAPTURE) { + SetStreamInfo(secondStreamInfo, streamCustomerCapture_, STREAM_ID_CAPTURE, intent); + } else { + SetStreamInfo(secondStreamInfo, streamCustomerVideo_, STREAM_ID_VIDEO, intent); + } + + if (secondStreamInfo->bufferQueue_ == nullptr) { + CAMERA_LOGE("demo test: CreateStreams CreateProducer() secondStreamInfo is nullptr\n"); + return RC_ERROR; + } + streamInfos.push_back(secondStreamInfo); + + rc = streamOperator_->CreateStreams(streamInfos); // 创建流 + if (rc != Camera::NO_ERROR) { + CAMERA_LOGE("demo test: CreateStream CreateStreams error\n"); + return RC_ERROR; + } + + rc = streamOperator_->CommitStreams(Camera::NORMAL, ability_); + if (rc != Camera::NO_ERROR) { + CAMERA_LOGE("demo test: CreateStream CommitStreams error\n"); + std::vector streamIds = {STREAM_ID_PREVIEW, streamIdSecond}; + streamOperator_->ReleaseStreams(streamIds); + return RC_ERROR; + } + return RC_OK; + } + ``` + + CaptureON()接口调用streamOperator的Capture()方法获取Camera数据并轮转buffer,拉起一个线程接收相应类型的数据。 + + ``` + RetCode CameraDemo::CaptureON(const int streamId, const int captureId, CaptureMode mode) + { + std::shared_ptr captureInfo = std::make_shared(); // 创建并填充CaptureInfo + captureInfo->streamIds_ = {streamId}; + captureInfo->captureSetting_ = ability_; + captureInfo->enableShutterCallback_ = false; + + int rc = streamOperator_->Capture(captureId, captureInfo, true); // 实际capture开始,buffer轮转开始 + if (mode == CAPTURE_PREVIEW) { + streamCustomerPreview_->ReceiveFrameOn(nullptr); // 创建预览线程接收递上来的buffer + } else if (mode == CAPTURE_SNAPSHOT) { + streamCustomerCapture_->ReceiveFrameOn([this](void* addr, const uint32_t size) { // 创建capture线程通过StoreImage回调接收递上来的buffer + StoreImage(addr, size); + }); + } else if (mode == CAPTURE_VIDEO) { + OpenVideoFile(); + streamCustomerVideo_->ReceiveFrameOn([this](void* addr, const uint32_t size) {// 创建Video线程通过StoreVideo回调接收递上来的buffer + StoreVideo(addr, size); + }); + } + return RC_OK; + } + ``` 3. ManuList()函数从控制台通过fgets()接口获取字符,不同字符所对应demo支持的功能不同,并打印出该demo所支持功能的菜单。 - ``` - static void ManuList(const std::shared_ptr& mainDemo, - const int argc, char** argv) - { - int idx, c; - int awb = 1; - constexpr char shortOptions[] = "h:cwvaqof:"; - c = getopt_long(argc, argv, shortOptions, longOptions, &idx); - while(1) { - switch (c) { - case 'h': - c = PutMenuAndGetChr(); // 打印菜单 - break; - - case 'f': - FlashLightTest(mainDemo); // 手电筒功能测试 - c = PutMenuAndGetChr(); - break; - case 'o': - OfflineTest(mainDemo); // Offline功能测试 - c = PutMenuAndGetChr(); - break; - case 'c': - CaptureTest(mainDemo); // Capture功能测试 - c = PutMenuAndGetChr(); - break; - case 'w': // AWB功能测试 - if (awb) { - mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_INCANDESCENT); - } else { - mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_OFF); - } - awb = !awb; - c = PutMenuAndGetChr(); - break; - case 'a': // AE功能测试 - mainDemo->SetAeExpo(); - c = PutMenuAndGetChr(); - break; - case 'v': // Video功能测试 - VideoTest(mainDemo); - c = PutMenuAndGetChr(); - break; - case 'q': // 退出demo - PreviewOff(mainDemo); - mainDemo->QuitDemo(); - exit(EXIT_SUCCESS); - - default: - CAMERA_LOGE("main test: command error please retry input command"); - c = PutMenuAndGetChr(); - break; - } - } - } - ``` - - PutMenuAndGetChr()接口打印了demo程序的菜单,并调用fgets()等待从控制台输入命令,内容如下: - - ``` - static int PutMenuAndGetChr(void) - { - constexpr uint32_t inputCount = 50; - int c = 0; - char strs[inputCount]; - Usage(stdout); - CAMERA_LOGD("pls input command(input -q exit this app)\n"); - fgets(strs, inputCount, stdin); - - for (int i = 0; i < inputCount; i++) { - if (strs[i] != '-') { - c = strs[i]; - break; - } - } - return c; - } - ``` - - 控制台输出菜单详情如下: - - ``` - "Options:\n" - "-h | --help Print this message\n" - "-o | --offline stream offline test\n" - "-c | --capture capture one picture\n" - "-w | --set WB Set white balance Cloudy\n" - "-v | --video capture Viedeo of 10s\n" - "-a | --Set AE Set Auto exposure\n" - "-f | --Set Flashlight Set flashlight ON 5s OFF\n" - "-q | --quit stop preview and quit this app\n"); - ``` - - demo中其他功能会调用不同的HDI接口去实现,与PreviewOn()接口类似,这里不再赘述,具体详情可以参见[ohos_camera_demo](https://gitee.com/openharmony/drivers_peripheral/tree/master/camera/hal/init)。 + ``` + static void ManuList(const std::shared_ptr& mainDemo, + const int argc, char** argv) + { + int idx, c; + int awb = 1; + constexpr char shortOptions[] = "h:cwvaqof:"; + c = getopt_long(argc, argv, shortOptions, longOptions, &idx); + while(1) { + switch (c) { + case 'h': + c = PutMenuAndGetChr(); // 打印菜单 + break; + + case 'f': + FlashLightTest(mainDemo); // 手电筒功能测试 + c = PutMenuAndGetChr(); + break; + case 'o': + OfflineTest(mainDemo); // Offline功能测试 + c = PutMenuAndGetChr(); + break; + case 'c': + CaptureTest(mainDemo); // Capture功能测试 + c = PutMenuAndGetChr(); + break; + case 'w': // AWB功能测试 + if (awb) { + mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_INCANDESCENT); + } else { + mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_OFF); + } + awb = !awb; + c = PutMenuAndGetChr(); + break; + case 'a': // AE功能测试 + mainDemo->SetAeExpo(); + c = PutMenuAndGetChr(); + break; + case 'v': // Video功能测试 + VideoTest(mainDemo); + c = PutMenuAndGetChr(); + break; + case 'q': // 退出demo + PreviewOff(mainDemo); + mainDemo->QuitDemo(); + exit(EXIT_SUCCESS); + + default: + CAMERA_LOGE("main test: command error please retry input command"); + c = PutMenuAndGetChr(); + break; + } + } + } + ``` + + PutMenuAndGetChr()接口打印了demo程序的菜单,并调用fgets()等待从控制台输入命令,内容如下: + + ``` + static int PutMenuAndGetChr(void) + { + constexpr uint32_t inputCount = 50; + int c = 0; + char strs[inputCount]; + Usage(stdout); + CAMERA_LOGD("pls input command(input -q exit this app)\n"); + fgets(strs, inputCount, stdin); + + for (int i = 0; i < inputCount; i++) { + if (strs[i] != '-') { + c = strs[i]; + break; + } + } + return c; + } + ``` + + 控制台输出菜单详情如下: + + ``` + "Options:\n" + "-h | --help Print this message\n" + "-o | --offline stream offline test\n" + "-c | --capture capture one picture\n" + "-w | --set WB Set white balance Cloudy\n" + "-v | --video capture Viedeo of 10s\n" + "-a | --Set AE Set Auto exposure\n" + "-f | --Set Flashlight Set flashlight ON 5s OFF\n" + "-q | --quit stop preview and quit this app\n"); + ``` + diff --git a/zh-cn/device-dev/driver/driver-peripherals-external-des.md b/zh-cn/device-dev/driver/driver-peripherals-external-des.md index 2c2a6fe9d6e99631e69e1935e9f48de9a09b4117..d557d360e51eae7f99db5c7d811fb9959fb66643 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-external-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-external-des.md @@ -1,11 +1,5 @@ # WLAN -- [概述](#section729758162218) - - [WLAN驱动接口架构](#section178022416377) - -- [接口说明](#section7331102018815) -- [开发步骤](#section15957746172412) -- [开发实例](#section1395253612512) ## 概述 @@ -14,9 +8,10 @@ WLAN是基于HDF(Hardware Driver Foundation)驱动框架开发的模块, **图 1** WLAN框架 ![](figures/WLAN框架.png "WLAN框架") -### WLAN驱动接口架构 -WLAN模块有三部分对外开放的API接口,如[下图2](#fig1492411431166)所示: + + +WLAN模块有三部分对外开放的API接口,如[图2](#fig1492411431166)所示: 1. 对HDI层提供的能力接口。 @@ -425,7 +420,7 @@ HDF_INIT(g_hdfHisiChipEntry); #endif #include "wifi_mac80211_ops.h" #include "wal_cfg80211.h" -#include "net_adpater.h" +#include "net_adapter.h" #include "hdf_wlan_utils.h" #define HDF_LOG_TAG Hi3881Driver diff --git a/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md b/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md index 3e6dc90a99165046115f5c66a5f736d2b67dacc8..f3ffb09e6a56840831e9e3371d6c9f501a803e39 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md @@ -1,30 +1,26 @@ # LCD -- [概述](#section141575391542) -- [接口说明](#section53793327396) -- [开发步骤](#section12394223125615) -- [开发实例](#section7441155155813) ## 概述 -LCD(Liquid Crystal Display)液晶显示驱动,对LCD进行上电,并通过接口初始化LCD内部寄存器,使LCD正常工作。Display驱动模型基于HDF( Hardware Driver Foundation)[驱动框架](driver-hdf-overview.md)开发,实现跨OS、跨平台,为LCD硬件提供上下电功能、发送初始化序列功能,使LCD进入正常的工作模式,显示芯片平台侧的图像数据,基于HDF驱动框架的Display驱动模型如[图1](#fig69138814229)。 +LCD(Liquid Crystal Display)液晶显示驱动,对LCD进行上电,并通过接口初始化LCD内部寄存器,使LCD正常工作。Display驱动模型基于HDF(Hardware Driver Foundation)[驱动框架](driver-hdf-overview.md)开发,实现跨OS、跨平台,为LCD硬件提供上下电功能、发送初始化序列功能,使LCD进入正常的工作模式,显示芯片平台侧的图像数据,基于HDF驱动框架的Display驱动模型如[图1](#fig69138814229)。 **图 1** 基于HDF驱动框架的Display驱动模型 ![](figures/基于HDF驱动框架的Display驱动模型.png "基于HDF驱动框架的Display驱动模型") **Display驱动模型介绍** -Display驱动模型主要由平台驱动层、芯片平台适配层、LCD器件驱动层三部分组成。驱动模型基于HDF驱动框架开发,通过Platform层和OSAL层提供的接口,屏蔽内核形态的差异,使得器件驱动可以便利的迁移到不同OS及芯片平台。模型向上对接Display公共hal层,支撑HDI(Hardware Display Interface)接口的实现,通过Display-HDI对图形服务提供各类驱动能力接口。 +Display驱动模型主要由平台驱动层、芯片平台适配层、LCD器件驱动层三部分组成。驱动模型基于HDF驱动框架开发,通过Platform层和OSAL(Operating System Abstraction Layer)层提供的接口,屏蔽内核形态的差异,使得器件驱动可以便利的迁移到不同OS及芯片平台。模型向上对接Display公共HAL层,支撑HDI(Hardware Display Interface)接口的实现,通过Display-HDI对图形服务提供各类驱动能力接口。 -- Display平台驱动层:通过HDF提供的IOService数据通道,与公共Hal层对接,集中接收并处理各类上层调用指令。 -- SOC平台驱动适配层:借助此SOC适配层,实现Display驱动和SOC侧驱动解耦,主要完成芯片平台相关的参数配置,并传递平台驱动层的调用到器件驱动层。 +- Display平台驱动层:通过HDF提供的IOService数据通道,与公共HAL层对接,集中接收并处理各类上层调用指令。 +- SoC平台驱动适配层:借助此SoC适配层,实现Display驱动和SoC侧驱动解耦,主要完成芯片平台相关的参数配置,并传递平台驱动层的调用到器件驱动层。 - LCD器件驱动层:在器件驱动层中,主要实现和器件自身强相关的驱动适配接口,例如发送初始化序列、上下电、背光设置等。 基于Display驱动模型开发LCD驱动,可以借助平台提供的各种能力及接口,较大程度的降低器件驱动的开发周期和难度,提升开发效率。 ## 接口说明 -LCD接口通常可分为MIPI DSI接口、TTL接口和LVDS接口,常用的是MIPI DSI接口和TTL接口,下面对常用的MIPI DSI接口和TTL接口作简要介绍。 +LCD接口通常可分为MIPI DSI(MIPI Display Serial Interface)接口、TTL(Transistor Transistor Logic)接口和LVDS(Low-Voltage Differential Signaling)接口,常用的是MIPI DSI接口和TTL接口,下面对常用的MIPI DSI接口和TTL接口作简要介绍。 - MIPI DSI接口 @@ -38,7 +34,7 @@ LCD接口通常可分为MIPI DSI接口、TTL接口和LVDS接口,常用的是MI **图 3** TTL接口 ![](figures/TTL接口.png "TTL接口") - TTL(Transistor Transistor Logic)即晶体管-晶体管逻辑,TTL电平信号由TTL器件产生,TTL器件是数字集成电路的一大门类,它采用双极型工艺制造,具有高速度、低功耗和品种多等特点。 + TTL即晶体管-晶体管逻辑,TTL电平信号由TTL器件产生,TTL器件是数字集成电路的一大门类,它采用双极型工艺制造,具有高速度、低功耗和品种多等特点。 TTL接口是并行方式传输数据的接口,有数据信号、时钟信号和控制信号(行同步、帧同步、数据有效信号等),在控制信号控制下完成数据传输。通常TTL接口的LCD,内部寄存器读写需要额外的外设接口,比如SPI接口、I2C接口等。 @@ -48,7 +44,7 @@ LCD接口通常可分为MIPI DSI接口、TTL接口和LVDS接口,常用的是MI Display驱动模型基于HDF驱动框架、Platform接口及OSAL接口开发,可以做到不区分OS(LiteOS、Linux)和芯片平台(Hi35xx、Hi38xx、V3S等),为LCD器件提供统一的驱动模型。 1. 添加LCD驱动相关的设备描述配置。 -2. 在SOC平台驱动适配层中适配对应的芯片平台驱动。 +2. 在SoC平台驱动适配层中适配对应的芯片平台驱动。 3. 添加器件驱动,并在驱动入口函数Init中注册Panel驱动数据,驱动数据接口主要包括如下接口: - LCD上下电 @@ -79,7 +75,7 @@ display :: host { serviceName = "hdf_disp"; } } - /* SOC适配层驱动设备描述 */ + /* SoC适配层驱动设备描述 */ device_hi35xx_disp :: device { device0 :: deviceNode { policy = 0; @@ -105,7 +101,7 @@ display :: host { } ``` -SOC适配层驱动,以Hi35xx系列芯片为例,需要在本层驱动中适配MIPI等和芯片平台相关的配置,示例如下: +SoC适配层驱动,以Hi35xx系列芯片为例,需要在本层驱动中适配MIPI等和芯片平台相关的配置,示例如下: ``` static int32_t MipiDsiInit(struct PanelInfo *info) @@ -164,9 +160,9 @@ LCD器件驱动示例如下: #define HORIZONTAL_BACK_PORCH 20 #define HORIZONTAL_FRONT_PORCH 20 #define HORIZONTAL_SYNC_WIDTH 10 -#define VERTIACL_BACK_PORCH 14 -#define VERTIACL_FRONT_PORCH 16 -#define VERTIACL_SYNC_WIDTH 2 +#define VERTICAL_BACK_PORCH 14 +#define VERTICAL_FRONT_PORCH 16 +#define VERTICAL_SYNC_WIDTH 2 #define FRAME_RATE 60 /* Panel Info结构体结构体 */ @@ -305,9 +301,9 @@ static struct PanelInfo g_panelInfo = { .hbp = HORIZONTAL_BACK_PORCH, /* horizontal back porch */ .hfp = HORIZONTAL_FRONT_PORCH, /* horizontal front porch */ .hsw = HORIZONTAL_SYNC_WIDTH, /* horizontal sync width */ - .vbp = VERTIACL_BACK_PORCH, /* vertiacl back porch */ - .vfp = VERTIACL_FRONT_PORCH, /* vertiacl front porch */ - .vsw = VERTIACL_SYNC_WIDTH, /* vertiacl sync width */ + .vbp = VERTICAL_BACK_PORCH, /* vertical back porch */ + .vfp = VERTICAL_FRONT_PORCH, /* vertical front porch */ + .vsw = VERTICAL_SYNC_WIDTH, /* vertical sync width */ .frameRate = FRAME_RATE, /* frame rate */ .intfType = MIPI_DSI, /* panel interface type */ .intfSync = OUTPUT_USER, /* output timming type */ diff --git a/zh-cn/device-dev/driver/driver-peripherals-light-des.md b/zh-cn/device-dev/driver/driver-peripherals-light-des.md index eea5df18f69350273e96ed602b35ce8e764d4d24..b2303a58371da0994d6a60b4874cadde9ba8adef 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-light-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-light-des.md @@ -1,4 +1,4 @@ -# LIGHT +# Light ## 概述 diff --git a/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md b/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md index 49de3c1da24ec4a74d5e39a7ac523fcef0814e92..98c55318a41fbd9e331f31aae2d5532a73dc9e8c 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md @@ -1,4 +1,4 @@ -# SENSOR +# Sensor ## 概述 diff --git a/zh-cn/device-dev/driver/driver-peripherals-touch-des.md b/zh-cn/device-dev/driver/driver-peripherals-touch-des.md index fc3483b3cd316eb8643fd3f48ed617f588b46388..bc837fc1e8478d5d054712ed851124d49cbe6a11 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-touch-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-touch-des.md @@ -1,26 +1,19 @@ -# TOUCHSCREEN +# Touchscreen -- [概述](#section175431838101617) -- [接口说明](#section105459441659) -- [开发步骤](#section65745222184) -- [开发实例](#section263714411191) - - [设备描述配置](#section18249155619195) - - [板级配置及器件私有配置](#section3571192072014) - - [添加器件驱动](#section6356758162015) ## 概述 -- **Touchscreen驱动主要任务** +- Touchscreen驱动主要任务 Touchscreen驱动用于驱动触摸屏使其正常工作,该驱动主要完成如下工作:对触摸屏驱动IC进行上电、配置硬件管脚并初始化其状态、注册中断、配置通信接口(I2C或SPI)、设定Input相关配置、下载及更新固件等操作。 -- **Touchscreen驱动层次说明** +- Touchscreen驱动层次说明 - 本节主要介绍基于Input驱动模型开发touchscreen器件驱动,Input模型整体的框架如[图1](#fig6251184817261)。 + 本节主要介绍基于Input驱动模型开发Touchscreen器件驱动,Input模型整体的框架如[图1](#fig6251184817261)。 - Input驱动模型基于HDF驱动框架、Platform接口、OSAL接口进行开发,向上对接规范化的驱动接口HDI(Hardware Driver Interface)层,通过Input-HDI层对外提供硬件能力,即上层Input service可以通过HDI接口层获取相应的驱动能力,进而操控touchscreen等输入设备。 + Input驱动模型基于HDF驱动框架、Platform接口、OSAL接口进行开发,向上对接规范化的驱动接口HDI(Hardware Driver Interface)层,通过Input-HDI层对外提供硬件能力,即上层Input service可以通过HDI接口层获取相应的驱动能力,进而操控Touchscreen等输入设备。 **图 1** 基于HDF驱动框架的Input驱动模型 @@ -43,7 +36,7 @@ - **基于HDF驱动框架开发器件驱动的优势** - 在HDF(Hardware Driver Foundation)[驱动管理框架](driver-hdf-development.md)的基础上,Input驱动模型调用OSAL接口层和Platfom接口层提供的基础接口进行开发,包括bus通信接口、操作系统原生接口(memory、lock、thread、timer等)。由于OSAL接口和Platform接口屏蔽了芯片平台差异,所以基于Input驱动模型实现的touchscreen驱动可以进行跨平台、跨OS迁移,以便逐步实现驱动的一次开发,多端部署。 + 在HDF(Hardware Driver Foundation)[驱动管理框架](driver-hdf-development.md)的基础上,Input驱动模型调用OSAL接口层和Platform接口层提供的基础接口进行开发,包括bus通信接口、操作系统原生接口(memory、lock、thread、timer等)。由于OSAL接口和Platform接口屏蔽了芯片平台差异,所以基于Input驱动模型实现的Touchscreen驱动可以进行跨平台、跨OS迁移,以便逐步实现驱动的一次开发,多端部署。 ## 接口说明 @@ -63,22 +56,22 @@ Touchscreen器件的硬件接口相对简单,根据PIN脚的属性,可以简 - LDO\_1P8:1.8V数字电路 - LDO\_3P3:3.3V模拟电路 - 通常情况下,touchscreen驱动IC和LCD驱动IC是相互分离的,这种情况下,touchscreen驱动IC一般同时需要1.8V和3.3V两路供电。随着芯片演进,业内已有touchscreen驱动IC和LCD驱动IC集成在一颗IC中的芯片案例,对touchscreen而言,只需要关注1.8V供电即可,其内部需要的3.3V电源,会在驱动IC内部从LCD的VSP电源(典型值5.5V)中分出来。 + 通常情况下,Touchscreen驱动IC和LCD驱动IC是相互分离的,这种情况下,Touchscreen驱动IC一般同时需要1.8V和3.3V两路供电。随着芯片演进,业内已有Touchscreen驱动IC和LCD驱动IC集成在一颗IC中的芯片案例,对Touchscreen而言,只需要关注1.8V供电即可,其内部需要的3.3V电源,会在驱动IC内部从LCD的VSP电源(典型值5.5V)中分出来。 2. **IO控制接口** - Reset:reset管脚,用于在系统休眠、唤醒时,由主机侧对驱动IC进行复位操作。 - INT:中断管脚,需要在驱动初始化时,配置为输入上拉状态。在驱动IC检测到外部触摸信号后,通过操作中断管脚来触发中断,器件驱动则会在中断处理函数中进行报点数据读取等操作。 3. **通信接口** - - I2C:由于touchscreen的报点数据量相对较少,所以一般选用I2C方式传输数据。I2C的具体协议及对应操作接口,可以参考Platform接口层中的[“I2C”使用指南](driver-platform-i2c-des.md#section5361140416)。 + - I2C:由于Touchscreen的报点数据量相对较少,所以一般选用I2C方式传输数据。I2C的具体协议及对应操作接口,可以参考Platform接口层中的[“I2C”使用指南](driver-platform-i2c-des.md#section5361140416)。 - SPI:部分厂商,由于需要传递的数据不止报点坐标,而是需要获取基础容值,数据量较大,所以会选用SPI通信方式。SPI的具体协议及对应操作接口,可以参考Platform接口层中的[“SPI” 使用指南](driver-platform-spi-des.md#section193356154511)。 ## 开发步骤 -Input驱动模型是基于HDF框架、Platform接口和OSAL接口开发,不区分操作系统和芯片平台,为touchscreen等输入器件提供统一的驱动开发架构。 +Input驱动模型是基于HDF框架、Platform接口和OSAL接口开发,不区分操作系统和芯片平台,为Touchscreen等输入器件提供统一的驱动开发架构。 -如下以touchscreen器件驱动为例,说明Input驱动模型的完整加载流程: +如下以Touchscreen器件驱动为例,说明Input驱动模型的完整加载流程: (1)设备描述配置:由开发者参考已有模板进行设备描述配置,包括驱动加载顺序、板级硬件信息、器件私有数据信息等。 @@ -100,7 +93,7 @@ Input驱动模型是基于HDF框架、Platform接口和OSAL接口开发,不区 2. 板级配置及Touchscreen器件私有配置 - 配置对应的IO管脚功能,例如对单板上为touchscreen设计预留的I2C Pin脚,需设置对应的寄存器,使其选择I2C的通信功能。 + 配置对应的IO管脚功能,例如对单板上为Touchscreen设计预留的I2C Pin脚,需设置对应的寄存器,使其选择I2C的通信功能。 3. 实现器件差异化适配接口 @@ -109,7 +102,7 @@ Input驱动模型是基于HDF框架、Platform接口和OSAL接口开发,不区 ## 开发实例 -本实例提供touchscreen驱动开发示例,并简要对具体关键点进行开发说明。 +本实例提供Touchscreen驱动开发示例,并简要对具体关键点进行开发说明。 ### 设备描述配置 diff --git a/zh-cn/device-dev/driver/driver-platform-dac-develop.md b/zh-cn/device-dev/driver/driver-platform-dac-develop.md index 14da38d13c404e0885ddb969e3e565bac5f91b79..70dde5c1b6d98bb7d02ee9978de683302beaa498 100644 --- a/zh-cn/device-dev/driver/driver-platform-dac-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-dac-develop.md @@ -1,14 +1,5 @@ # DAC -- [概述](#1) - - [功能简介](#2) - - [基本概念](#3) - - [运作机制](#4) - - [约束与限制](#5) -- [开发指导](#6) - - [场景介绍](#7) - - [接口说明](#8) - - [开发步骤](#9) ## 概述 @@ -41,7 +32,7 @@ DAC模块支持数模转换的开发。它主要用于: ### 运作机制 -在HDF框架中,同类型设备对象较多时(可能同时存在十几个同类型配置器),若采用独立服务模式则需要配置更多的设备节点,且相关服务会占据更多的内存资源。相反,采用统一服务模式可以使用一个设备服务作为管理器,统一处理所有同类型对象的外部访问(这会在配置文件中有所体现),实现便捷管理和节约资源的目的。DAC模块接口适配模式采用统一服务模式([如图1](#fig14423182615525)所示)。 +在HDF框架中,同类型设备对象较多时(可能同时存在十几个同类型配置器),若采用独立服务模式则需要配置更多的设备节点,且相关服务会占据更多的内存资源。相反,采用统一服务模式可以使用一个设备服务作为管理器,统一处理所有同类型对象的外部访问(这会在配置文件中有所体现),实现便捷管理和节约资源的目的。DAC模块接口适配模式采用统一服务模式(如图1所示)。 DAC模块各分层的作用为:接口层提供打开设备,写入数据,关闭设备接口的能力。核心层主要提供绑定设备、初始化设备以及释放设备的能力。适配层实现其他具体的功能。 @@ -293,7 +284,7 @@ DAC模块适配包含以下四个步骤: ``` ![](../public_sys-resources/icon-note.gif) **说明:** - DacDevice成员DacMethod的定义和成员说明见[接口说明](#section752964871810)。 + DacDevice成员DacMethod的定义和成员说明见[接口说明](#8)。 - Init函数参考 diff --git a/zh-cn/device-dev/driver/driver-platform-hdmi-des.md b/zh-cn/device-dev/driver/driver-platform-hdmi-des.md index 4d4809dd8b78921de7c58887b6a4e97e35f2961a..62258f6ccdfc26a1fbce8e69cf3272626691137d 100755 --- a/zh-cn/device-dev/driver/driver-platform-hdmi-des.md +++ b/zh-cn/device-dev/driver/driver-platform-hdmi-des.md @@ -1,21 +1,11 @@ # HDMI -- [概述](#section1) - - [功能简介](#section2) - - [基本概念](#section3) - - [运作机制](#section4) - - [约束与限制](#section5) -- [使用指导](#section6) - - [场景介绍](#section7) - - [接口说明](#section8) - - [开发步骤](#section9) - - [使用实例](#section10) ## 概述 ### 功能简介 -- HDMI(High-Definition Multiface Interface),即高清多媒体接口,主要用于DVD、机顶盒等音视频Source到TV、显示器等Sink设备的传输。 +- HDMI(High-Definition Multimedia Interface),即高清多媒体接口,主要用于DVD、机顶盒等音视频Source到TV、显示器等Sink设备的传输。 - HDMI以主从方式工作,通常有一个Source端和一个Sink端。 - HDMI接口定义了完成HDMI传输的通用方法集合,包括: @@ -27,7 +17,7 @@ ### 基本概念 -HDMI(High-Definition Multiface Interface)是Hitachi、Panasonic、Philips、SiliconImage、Sony、Thomson、Toshiba共同发布的一款音视频传输协议。传输过程遵循TMDS(Transition Minimized Differential Signaling)协议。 +HDMI(High-Definition Multimedia Interface)是Hitachi、Panasonic、Philips、Silicon Image、Sony、Thomson、Toshiba共同发布的一款音视频传输协议。传输过程遵循TMDS(Transition Minimized Differential Signaling)协议。 - TMDS(Transition Minimized Differential signal):过渡调制差分信号,也被称为最小化传输差分信号,用于发送音频、视频及各种辅助数据。 - DDC(Display Data Channel):显示数据通道,发送端与接收端可利用DDC通道得知彼此的发送与接收能力,但HDMI仅需单向获知接收端(显示器)的能力。 diff --git a/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md b/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md index 9b5e164be92a075f1b500f92e7075deeabcfe1d7..240fc2810e7fcc62f6eac0f0aeab09533f950b34 100755 --- a/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md +++ b/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md @@ -1,20 +1,5 @@ -# MIPI-CSI +# MIPI CSI -- [概述](#section1_MIPI_CSIDes) - - [ComboDevAttr结构体](#section1.1_MIPI_CSIDes) - - [ExtDataType结构体](#section1.2_MIPI_CSIDes) - - [接口说明](#section1.3_MIPI_CSIDes) - -- [使用指导](#section2_MIPI_CSIDes) - - [使用流程](#section2.1_MIPI_CSIDes) - - [获取MIPI-CSI控制器操作句柄](#section2.2_MIPI_CSIDes) - - [MIPI-CSI相应配置](#section2.3_MIPI_CSIDes) - - [复位/撤销复位sensor](#section2.4_MIPI_CSIDes) - - [复位/撤销复位MIPI RX](#section2.5_MIPI_CSIDes) - - [使能/关闭MIPI的时钟](#section2.6_MIPI_CSIDes) - - [使能/关闭MIPI上的sensor时钟](#section2.7_MIPI_CSIDes) - - [释放MIPI-CSI控制器操作句柄](#section2.8_MIPI_CSIDes) -- [使用实例](#section3_MIPI_CSIDes) ## 概述 @@ -57,14 +42,14 @@ ### 接口说明 -**表 3** MIPI-CSI API接口功能介绍 +**表 3** MIPI CSI API接口功能介绍 | 功能分类 | 接口名 | | -------- | -------- | -| 获取/释放MIPI-CSI控制器操作句柄 | MipiCsiOpen:获取MIPI-CSI控制器操作句柄
MipiCsiClose:释放MIPI-CSI控制器操作句柄 | -| MIPI-CSI相应配置 | MipiCsiSetComboDevAttr:设置MIPI,CMOS或者LVDS相机的参数给控制器,参数包括工作模式,图像区域,图像深度,数据速率和物理通道等
MipiCsiSetExtDataType(可选):设置YUV和RAW数据格式和位深
MipiCsiSetHsMode:设置MIPI RX的Lane分布。根据硬件连接的形式选择具体的mode
MipiCsiSetPhyCmvmode:设置共模电压模式 | +| 获取/释放MIPI CSI控制器操作句柄 | MipiCsiOpen:获取MIPI CSI控制器操作句柄
MipiCsiClose:释放MIPI CSI控制器操作句柄 | +| MIPI CSI相应配置 | MipiCsiSetComboDevAttr:设置MIPI,CMOS或者LVDS相机的参数给控制器,参数包括工作模式,图像区域,图像深度,数据速率和物理通道等
MipiCsiSetExtDataType(可选):设置YUV和RAW数据格式和位深
MipiCsiSetHsMode:设置MIPI RX的Lane分布。根据硬件连接的形式选择具体的mode
MipiCsiSetPhyCmvmode:设置共模电压模式 | | 复位/撤销复位Sensor | MipiCsiResetSensor:复位Sensor
MipiCsiUnresetSensor:撤销复位Sensor | | 复位/撤销复位MIPI RX | MipiCsiResetRx:复位MIPI RX。不同的s32WorkingViNum有不同的enSnsType
MipiCsiUnresetRx:撤销复位MIPI RX | | 使能/关闭MIPI的时钟 | MipiCsiEnableClock:使能MIPI的时钟。根据上层函数电泳传递的enSnsType参数决定是用MIPI还是LVDS
MipiCsiDisableClock:关闭MIPI设备的时钟 | @@ -75,16 +60,16 @@ ### 使用流程 -使用MIPI-CSI的一般流程如[图2](#fig2_MIPI_CSIDes)所示。 +使用MIPI CSI的一般流程如[图2](#fig2_MIPI_CSIDes)所示。 -**图 2** MIPI-CSI使用流程图 +**图 2** MIPI CSI使用流程图 ![](figures/MIPI-CSI使用流程图.png) -### 获取MIPI-CSI控制器操作句柄 +### 获取MIPI CSI控制器操作句柄 -在进行MIPI-CSI进行通信前,首先要调用MipiCsiOpen获取控制器操作句柄,该函数会返回指定通道ID的控制器操作句柄。 +在进行MIPI CSI进行通信前,首先要调用MipiCsiOpen获取控制器操作句柄,该函数会返回指定通道ID的控制器操作句柄。 ```c DevHandle MipiCsiOpen(uint8_t id); @@ -101,11 +86,11 @@ DevHandle MipiCsiOpen(uint8_t id); | NULL | 获取失败 | | 设备句柄 | 获取到指令通道的控制器操作句柄,类型为DevHandle | -假设系统中的MIPI-CSI通道为0,获取该通道控制器操作句柄的示例如下: +假设系统中的MIPI CSI通道为0,获取该通道控制器操作句柄的示例如下: ```c DevHandle MipiCsiHandle = NULL; /* 设备句柄 */ -id = 0; /* MiPi-Csi通道ID */ +id = 0; /* MIPI CSI通道ID */ /* 获取控制器操作句柄 */ MipiCsiHandle = MipiCsiOpen(id); @@ -115,9 +100,9 @@ if (MipiCsiHandle == NULL) { } ``` -### MIPI-CSI相应配置 +### MIPI CSI相应配置 -- 写入MIPI-CSI配置 +- 写入MIPI CSI配置 ```c int32_t MipiCsiSetComboDevAttr(DevHandle handle, ComboDevAttr *pAttr); @@ -130,7 +115,7 @@ if (MipiCsiHandle == NULL) { | 参数 | 参数描述 | | ---------- | -------------------------- | | handle | 控制器操作句柄 | - | pAttr | MIPI-CSI相应配置结构体指针 | + | pAttr | MIPI CSI相应配置结构体指针 | | **返回值** | **返回值描述** | | 0 | 设置成功 | | 负数 | 设置失败 | @@ -528,9 +513,9 @@ if (MipiCsiHandle == NULL) { } ``` -### 释放MIPI-CSI控制器操作句柄 +### 释放MIPI CSI控制器操作句柄 -MIPI-CSI使用完成之后,需要释放控制器操作句柄,释放句柄的函数如下所示: +MIPI CSI使用完成之后,需要释放控制器操作句柄,释放句柄的函数如下所示: ```c void MipiCsiClose(DevHandle handle); @@ -544,15 +529,15 @@ void MipiCsiClose(DevHandle handle); | 参数 | 参数描述 | | ------------ | ------------------------------------------------ | - | handle | MIPI-CSI控制器操作句柄 | + | handle | MIPI CSI控制器操作句柄 | ```c -MipiCsiClose(MIPIHandle); /* 释放掉MIPI-CSI控制器操作句柄 */ +MipiCsiClose(MIPIHandle); /* 释放掉MIPI CSI控制器操作句柄 */ ``` ## 使用实例 -MIPI-CSI完整的使用示例如下所示: +MIPI CSI完整的使用示例如下所示: ```c #include "hdf.h" diff --git a/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md b/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md index 28ec36c50a330d89c6c3a923ecd0de58afac8e90..028ed84a555349e7443a409241f1eea6532755a7 100755 --- a/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-mipicsi-develop.md @@ -1,15 +1,12 @@ -# MIPI-CSI +# MIPI CSI -- [概述](#section1_MIPI_CSIDevelop) -- [接口说明](#section2_MIPI_CSIDevelop) -- [开发步骤](#section3_MIPI_CSIDevelop) -- [开发实例](#section4_MIPI_CSIDevelop) ## 概述 -CSI(Camera Serial Interface)是由MIPI(Mobile Industry Processor Interface )联盟下Camera工作组指定的接口标准。在HDF框架中,MIPI-CSI的接口适配模式采用无服务模式,用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,MIPI-CSI的接口关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 +CSI(Camera Serial Interface)是由MIPI(Mobile Industry Processor Interface )联盟下Camera工作组指定的接口标准。在HDF框架中,MIPI CSI的接口适配模式采用无服务模式,用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,MIPI CSI的接口关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 图 1 无服务模式结构图 + ![image1](figures/无服务模式结构图.png) ## 接口说明 @@ -35,7 +32,7 @@ struct MipiCsiCntlrMethod { 表1 MipiCsiCntlrMethod成员的回调函数功能说明 | 成员函数 | 入参 | 出参 | 返回状态 | 功能 | | ------------------ | ------------------------------------------------------------ | ---- | ------------------ | -------------------------- | -| setComboDevAttr | **cntlr**:结构体指针,MipiCsi控制器 ;
**pAttr**:结构体指针,MIPI-CSI相应配置结构体指针 | 无 | HDF_STATUS相关状态 | 写入MIPI-CSI配置 | +| setComboDevAttr | **cntlr**:结构体指针,MipiCsi控制器 ;
**pAttr**:结构体指针,MIPI CSI相应配置结构体指针 | 无 | HDF_STATUS相关状态 | 写入MIPI CSI配置 | | setPhyCmvmode | **cntlr**:结构体指针,MipiCsi控制器 ;
**devno**:uint8_t,设备编号;
**cmvMode**:枚举类型,共模电压模式参数 | 无 | HDF_STATUS相关状态 | 设置共模电压模式 | | setExtDataType | **cntlr**:结构体指针,MipiCsi控制器 ;
**dataType**:结构体指针,定义YUV和原始数据格式以及位深度 | 无 | HDF_STATUS相关状态 | 设置YUV和RAW数据格式和位深 | | setHsMode | **cntlr**:结构体指针,MipiCsi控制器 ;
**laneDivideMode**:枚举类型,lane模式参数 | 无 | HDF_STATUS相关状态 | 设置MIPI RX的Lane分布 | @@ -50,7 +47,7 @@ struct MipiCsiCntlrMethod { ## 开发步骤 -MIPI-CSI模块适配的三个环节是配置属性文件、实例化驱动入、以及实例化核心层接口函数。 +MIPI CSI模块适配的三个环节是配置属性文件、实例化驱动入、以及实例化核心层接口函数。 1. **实例化驱动入口:** - 实例化HdfDriverEntry结构体成员。 @@ -107,7 +104,7 @@ MIPI-CSI模块适配的三个环节是配置属性文件、实例化驱动入、 一般在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。 -- MIPI-CSI驱动入口参考 +- MIPI CSI驱动入口参考 ```c struct HdfDriverEntry g_mipiCsiDriverEntry = { @@ -199,23 +196,24 @@ MIPI-CSI模块适配的三个环节是配置属性文件、实例化驱动入、 - **Init函数参考** - > **入参:** - > HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息 - > - > **返回值:** - > HDF_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf_base.h中HDF_STATUS 定义) - > - > | 状态(值) | 问题描述 | - > | :--------------------- | :----------: | - > | HDF_ERR_INVALID_OBJECT | 无效对象 | - > | HDF_ERR_MALLOC_FAIL | 内存分配失败 | - > | HDF_ERR_INVALID_PARAM | 无效参数 | - > | HDF_ERR_IO | I/O 错误 | - > | HDF_SUCCESS | 执行成功 | - > | HDF_FAILURE | 执行失败 | - > - > **函数说明:** - > MipiCsiCntlrMethod的实例化对象的挂载,调用MipiCsiRegisterCntlr,以及其他厂商自定义初始化操作。 + 入参: + HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息 + + 返回值: + HDF_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf_base.h中HDF_STATUS 定义) + + + | 状态(值) | 问题描述 | + | :--------------------- | :----------: | + | HDF_ERR_INVALID_OBJECT | 无效对象 | + | HDF_ERR_MALLOC_FAIL | 内存分配失败 | + | HDF_ERR_INVALID_PARAM | 无效参数 | + | HDF_ERR_IO | I/O 错误 | + | HDF_SUCCESS | 执行成功 | + | HDF_FAILURE | 执行失败 | + + 函数说明: + MipiCsiCntlrMethod的实例化对象的挂载,调用MipiCsiRegisterCntlr,以及其他厂商自定义初始化操作。 ```c static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device) @@ -282,14 +280,15 @@ MIPI-CSI模块适配的三个环节是配置属性文件、实例化驱动入、 - **Release函数参考** - > **入参:** - > HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 - > - > **返回值:** - > 无 - > - > **函数说明:** - > 该函数需要在驱动入口结构体中赋值给Release接口,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源,该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作**前提**是在Init函数中具备对应赋值的操作。 + 入参: + HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 + + 返回值: + 无 + + 函数说明: + 该函数需要在驱动入口结构体中赋值给Release接口,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源,该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作**前提**是在Init函数中具备对应赋值的操作。 + ```c static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device) diff --git a/zh-cn/device-dev/driver/driver-platform-mipidsi-des.md b/zh-cn/device-dev/driver/driver-platform-mipidsi-des.md index 6be428a3027b44ad6c0a109f18057975a9f0960d..a4e6cc602c99bd09baeee5d85dff19ee9c29c285 100644 --- a/zh-cn/device-dev/driver/driver-platform-mipidsi-des.md +++ b/zh-cn/device-dev/driver/driver-platform-mipidsi-des.md @@ -1,30 +1,21 @@ # MIPI DSI -- [概述](#section16806142183217) -- [接口说明](#section12720125432316) -- [使用指导](#section037231715335) - - [使用流程](#section49299119344) - - [获取MIPI-DSI操作句柄](#section5126155683811) - - [MIPI-DSI相应配置](#section201164274344) - - [发送/回读控制指令](#section199401342173415) - - [释放MIPI-DSI操作句柄](#section161011610357) - -- [使用实例](#section17470126123520) ## 概述 - DSI(Display Serial Interface)是由移动行业处理器接口联盟(Mobile Industry Processor Interface \(MIPI\) Alliance)制定的规范,旨在降低移动设备中显示控制器的成本。它以串行的方式发送像素数据或指令给外设\(通常是LCD或者类似的显示设备\),或从外设中读取状态信息或像素信息;它定义了主机、图像数据源和目标设备之间的串行总线和通信协议。 -- MIPI-DSI具备高速模式和低速模式两种工作模式,全部数据通道都可以用于单向的高速传输,但只有第一个数据通道才可用于低速双向传输,从属端的状态信息、像素等是通过该数据通道返回。时钟通道专用于在高速传输数据的过程中传输同步时钟信号。 +- MIPI DSI具备高速模式和低速模式两种工作模式,全部数据通道都可以用于单向的高速传输,但只有第一个数据通道才可用于低速双向传输,从属端的状态信息、像素等是通过该数据通道返回。时钟通道专用于在高速传输数据的过程中传输同步时钟信号。 - 图1显示了简化的DSI接口。从概念上看,符合DSI的接口与基于DBI-2和DPI-2标准的接口具有相同的功能。它向外围设备传输像素或命令数据,并且可以从外围设备读取状态或像素信息。主要区别在于,DSI对所有像素数据、命令和事件进行序列化,而在传统接口中,这些像素数据、命令和事件通常需要附加控制信号才能在并行数据总线上传输。 **图 1** DSI发送、接收接口 + ![](figures/DSI发送-接收接口.png "DSI发送-接收接口") ## 接口说明 -**表 1** MIPI-DSI API接口功能介绍 +**表 1** MIPI DSI API接口功能介绍 - - - - - - - - - - - - @@ -93,14 +84,15 @@ ### 使用流程 -使用MIPI-DSI的一般流程如[图2](#fig129103491241)所示。 +使用MIPI DSI的一般流程如[图2](#fig129103491241)所示。 + +**图 2** MIPI DSI使用流程图 -**图 2** MIPI-DSI使用流程图 ![](figures/MIPI-DSI使用流程图.png) -### 获取MIPI-DSI操作句柄 +### 获取MIPI DSI操作句柄 -在进行MIPI-DSI进行通信前,首先要调用MipiDsiOpen获取操作句柄,该函数会返回指定通道ID的操作句柄。 +在进行MIPI DSI进行通信前,首先要调用MipiDsiOpen获取操作句柄,该函数会返回指定通道ID的操作句柄。 DevHandle MipiDsiOpen\(uint8\_t id\); @@ -136,11 +128,11 @@ DevHandle MipiDsiOpen\(uint8\_t id\);

功能分类

@@ -35,52 +26,52 @@

设置/获取当前MIPI-DSI相关配置

+

设置/获取当前MIPI DSI相关配置

MipiDsiSetCfg

设置MIPI-DSI相关配置

+

设置MIPI DSI相关配置

MipiDsiGetCfg

获取当前MIPI-DSI相关配置

+

获取当前MIPI DSI相关配置

获取/释放MIPI-DSI操作句柄

+

获取/释放MIPI DSI操作句柄

MipiDsiOpen

获取MIPI-DSI操作句柄

+

获取MIPI DSI操作句柄

MipiDsiClose

释放MIPI-DSI操作句柄

+

释放MIPI DSI操作句柄

设置MIPI-DSI进入Low power模式/High speed模式

+

设置MIPI DSI进入Low power模式/High speed模式

MipiDsiSetLpMode

设置MIPI-DSI进入Low power模式

+

设置MIPI DSI进入Low power模式

MipiDsiSetHsMode

设置MIPI-DSI进入High speed模式

+

设置MIPI DSI进入High speed模式

MIPI-DSI发送/回读指令

+

MIPI DSI发送/回读指令

MipiDsiTx

MIPI-DSI发送相应指令的接口

+

MIPI DSI发送相应指令的接口

MipiDsiRx

MIPI-DSI按期望长度回读的接口

+

MIPI DSI按期望长度回读的接口

-假设系统中的MIPI-DSI通道为0,获取该通道操作句柄的示例如下: +假设系统中的MIPI DSI通道为0,获取该通道操作句柄的示例如下: ``` DevHandle mipiDsiHandle = NULL; /* 设备句柄 */ -chnId = 0; /* MIPI-DSI通道ID */ +chnId = 0; /* MIPI DSI通道ID */ /* 获取操作句柄 */ mipiDsiHandle = MipiDsiOpen(chnId); @@ -150,9 +142,9 @@ if (mipiDsiHandle == NULL) { } ``` -### MIPI-DSI相应配置 +### MIPI DSI相应配置 -- 写入MIPI-DSI配置 +- 写入MIPI DSI配置 int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\); @@ -172,7 +164,7 @@ int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\);

cfg

-

MIPI-DSI相应配置buf 指针

+

MIPI DSI相应配置buf 指针

返回值

@@ -220,7 +212,7 @@ if (ret != 0) { } ``` -- 获取当前MIPI-DSI的配置 +- 获取当前MIPI DSI的配置 int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\); @@ -240,7 +232,7 @@ int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\);

cfg

-

MIPI-DSI相应配置buf 指针

+

MIPI DSI相应配置buf 指针

返回值

@@ -422,9 +414,9 @@ HdfFree(cmdRead->payload); HdfFree(cmdRead); ``` -### 释放MIPI-DSI操作句柄 +### 释放MIPI DSI操作句柄 -MIPI-DSI使用完成之后,需要释放操作句柄,释放句柄的函数如下所示: +MIPI DSI使用完成之后,需要释放操作句柄,释放句柄的函数如下所示: void MipiDsiClose\(DevHandle handle\); @@ -441,19 +433,19 @@ void MipiDsiClose\(DevHandle handle\);

handle

-

MIPI-DSI操作句柄

+

MIPI DSI操作句柄

``` -MipiDsiClose(mipiHandle); /* 释放掉MIPI-DSI操作句柄 */ +MipiDsiClose(mipiHandle); /* 释放掉MIPI DSI操作句柄 */ ``` ## 使用实例 -MIPI-DSI完整的使用示例如下所示: +MIPI DSI完整的使用示例如下所示: ``` #include "hdf.h" diff --git a/zh-cn/device-dev/driver/driver-platform-mipidsi-develop.md b/zh-cn/device-dev/driver/driver-platform-mipidsi-develop.md index 49d492ba8b5ff283573d7446abe0eaaea88e9f20..4998851b8ed39de5f550e40b8613b5ba21475b30 100755 --- a/zh-cn/device-dev/driver/driver-platform-mipidsi-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-mipidsi-develop.md @@ -69,9 +69,9 @@ struct MipiDsiCntlrMethod { // 核心层结构体的成员函数

getCmd

-

cntlr: 结构体指针,MipiDsi控制器 ;

+

cntlr:结构体指针,MipiDsi控制器;
cmd:传入的命令描述结构体指针;
readLen:读取的数据大小;

-

cmd: 结构体指针,用于传出指令值;

+

out:结构体指针,用于存储读取的数据。

HDF_STATUS相关状态

diff --git a/zh-cn/device-dev/driver/driver-platform-pin-develop.md b/zh-cn/device-dev/driver/driver-platform-pin-develop.md index 890e385759a8fc987a2ec306b07f8375ecf373c5..63c6c3ca978b57b1669186413fd73dadb533051c 100755 --- a/zh-cn/device-dev/driver/driver-platform-pin-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-pin-develop.md @@ -20,7 +20,7 @@ PIN是一个软件层面的概念,目的是为了统一各SoC厂商PIN管脚 ### 运作机制 -在HDF框架中,PIN模块暂不支持用户态,所以不需要发布服务,接口适配模式采用无服务模式(如[图1](#无服务模式结构图)所示),用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,其关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 +在HDF框架中,PIN模块暂不支持用户态,所以不需要发布服务,接口适配模式采用无服务模式(如图1所示),用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,其关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 PIN模块各分层作用:接口层提供获取PIN管脚、设置PIN管脚推拉方式、获取PIN管脚推拉方式、设置PIN管脚推拉强度、获取PIN管脚推拉强度、设置PIN管脚功能、获取PIN管脚功能、释放PIN管脚的接口。核心层主要提供PIN管脚资源匹配,PIN管脚控制器的添加、移除以及管理的能力,通过钩子函数与适配层交互。适配层主要是将钩子函数的功能实例化,实现具体的功能。 diff --git a/zh-cn/device-dev/driver/driver-platform-pwm-develop.md b/zh-cn/device-dev/driver/driver-platform-pwm-develop.md index 9d927033fa4f97c645c552bd7306a7542a0571f0..0c1f22f0d56d60a95419556574daf98c4b7a9ef0 100755 --- a/zh-cn/device-dev/driver/driver-platform-pwm-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-pwm-develop.md @@ -1,15 +1,12 @@ # PWM -- [概述](#section1591602238164144) -- [接口说明](#section752964871810) -- [开发步骤](#section967396342164144) -- [开发实例](#section1883877829164144) ## 概述 PWM(Pulse Width Modulator)即脉冲宽度调节器,在HDF框架中,PWM的接口适配模式采用独立服务模式,在这种模式下,每一个设备对象会独立发布一个设备服务来处理外部访问,设备管理器收到API的访问请求之后,通过提取该请求的参数,达到调用实际设备对象的相应内部方法的目的。独立服务模式可以直接借助HDFDeviceManager的服务管理能力,但需要为每个设备单独配置设备节点,增加内存占用。 **图 1** PWM独立服务模式结构图 + ![](figures/独立服务模式结构图.png "PWM独立服务模式结构图") ## 接口说明 @@ -115,8 +112,8 @@ PWM模块适配HDF框架的三个环节是配置属性文件,实例化驱动 HDF_INIT(g_hdfPwm); ``` -2. 完成驱动入口注册之后,下一步请在device\_info.hcs文件中添加deviceNode信息,并在 pwm\_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层PwmDev成员的默认值或限制范围有密切关系。 如有更多个器件信息,则需要在device\_info文件增加deviceNode信息,以及在pwm\_config文件中增加对应的器件属性**。** - - device\_info.hcs 配置参考。 +2. 完成驱动入口注册之后,下一步请在device\_info.hcs文件中添加deviceNode信息,并在 pwm\_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层PwmDev成员的默认值或限制范围有密切关系。 如有更多个器件信息,则需要在device\_info文件增加deviceNode信息,以及在pwm\_config文件中增加对应的器件属性。 + - device\_info.hcs 配置参考 ``` root { diff --git a/zh-cn/device-dev/driver/driver-platform-rtc-develop.md b/zh-cn/device-dev/driver/driver-platform-rtc-develop.md index 8b5023bf9f92bcf28d5ae4ae84d7d6bad572c2b9..3a2c2b4d7c59e3623b4b8a8daa3965bcc827f64e 100755 --- a/zh-cn/device-dev/driver/driver-platform-rtc-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-rtc-develop.md @@ -386,11 +386,11 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动 - Init函数参考 - 入参**:** + 入参: HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 - 返回值**:** + 返回值: HDF\_STATUS相关状态。 @@ -428,11 +428,11 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动 - Release 函数参考 - 入参**:** + 入参: HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 - 返回值**:** + 返回值: 无。 diff --git a/zh-cn/device-dev/driver/driver-platform-uart-develop.md b/zh-cn/device-dev/driver/driver-platform-uart-develop.md index b0c410be520e08c8f7551afbb25d54de9c1b229a..3027609990281feddef5c46800c681e644b5e003 100755 --- a/zh-cn/device-dev/driver/driver-platform-uart-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-uart-develop.md @@ -1,9 +1,5 @@ # UART -- [概述](#section1761881586154520) -- [接口说明](#section752964871810) -- [开发步骤](#section944397404154520) -- [开发实例](#section774610224154520) ## 概述 @@ -349,7 +345,7 @@ UART模块适配HDF框架的三个环节是配置属性文件,实例化驱动 HdfDeviceObject 这个是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 - **返回值:** + 返回值: HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 @@ -425,7 +421,7 @@ UART模块适配HDF框架的三个环节是配置属性文件,实例化驱动 - Init函数参考 - 入参**:** + 入参: HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 @@ -507,7 +503,7 @@ UART模块适配HDF框架的三个环节是配置属性文件,实例化驱动 函数说明: - 该函数需要在驱动入口结构体中赋值给 Release 接口, 当HDF框架调用Init函数初始化驱动失败时,可以调用 Release 释放驱动资源, 该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作**前提**是在Init函数中具备对应赋值的操作。 + 该函数需要在驱动入口结构体中赋值给 Release 接口, 当HDF框架调用Init函数初始化驱动失败时,可以调用 Release 释放驱动资源, 该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。 ``` void HdfUartDeviceRelease(struct HdfDeviceObject *device) @@ -535,10 +531,10 @@ UART模块适配HDF框架的三个环节是配置属性文件,实例化驱动 if (port->physBase != 0) { OsalIoUnmap((void *)port->physBase);//地址反映射 } - (void)OsalMemFree(port); + OsalMemFree(port); udd->private = NULL; } - (void)OsalMemFree(udd);//释放UartDriverData + OsalMemFree(udd);//释放UartDriverData host->priv = NULL; } ``` diff --git a/zh-cn/device-dev/driver/driver-platform-watchdog-des.md b/zh-cn/device-dev/driver/driver-platform-watchdog-des.md index fcc46c34fcc16906c9f15e55016aea94513f3f58..d23190f4463a1c4e63e68fd070f8795996ac14b0 100644 --- a/zh-cn/device-dev/driver/driver-platform-watchdog-des.md +++ b/zh-cn/device-dev/driver/driver-platform-watchdog-des.md @@ -1,23 +1,10 @@ -# WATCHDOG - -- [概述](#section14918241977) -- [接口说明](#section1180575010271) -- [使用指导](#section10103184312813) - - [使用流程](#section10181195910815) - - [打开看门狗设备](#section66089201107) - - [获取看门狗状态](#section786624341011) - - [设置超时时间](#section182386137111) - - [获取超时时间](#section1883310371114) - - [启动看门狗](#section82501405123) - - [喂狗](#section3547530101211) - - [停止看门狗](#section944595841217) - - [关闭看门狗设备](#section96561824121311) - -- [使用实例](#section1724514523135) +# Watchdog + + ## 概述 -看门狗(watchdog),又叫看门狗计时器(watchdog timer),是一种硬件的计时设备,当系统的主程序发生某些错误时,导致未及时清除看门狗计时器的计时值,这时看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。 +看门狗(Watchdog),又叫看门狗计时器(Watchdog Timer),是一种硬件的计时设备,当系统的主程序发生某些错误时,导致未及时清除看门狗计时器的计时值,这时看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。 ## 接口说明 @@ -541,12 +528,12 @@ static int32_t TestCaseWatchdog(void) /* 接下来持续不喂狗,使得看门狗计时器超时 */ for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) { - HDF_LOGE("%s: watiting dog buck %d times... \n", __func__, i); + HDF_LOGE("%s: watiting dog back %d times... \n", __func__, i); OsalSleep(1); } /* 当不喂狗时间到达之前设定的超时时间的时候,系统会发生复位,理论上观察不到此日志的打印 */ - HDF_LOGE("%s: dog has't buck!!! \n", __func__, i); + HDF_LOGE("%s: dog hasn't back!!! \n", __func__, i); WatchdogClose(handle); return -1; } diff --git a/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md b/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md index eda28043c4ffac4aedf14ba132895ca9bee13b90..986db11f17ffdf04bc7b9bfaf6404f9b19482529 100755 --- a/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md @@ -1,9 +1,5 @@ # WatchDog -- [概述](#section1315827527160117) -- [接口说明](#section752964871810) -- [开发步骤](#section477974542160117) -- [开发实例](#section1832270347160117) ## 概述 @@ -245,11 +241,11 @@ Watchdog模块适配HDF框架的三个环节是配置属性文件,实例化驱 - Init函数和Bind函数参考 - 入参**:** + 入参: HdfDeviceObject :HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。 - 返回值**:** + 返回值: HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 @@ -290,7 +286,7 @@ Watchdog模块适配HDF框架的三个环节是配置属性文件,实例化驱 - 函数说明**:** + 函数说明: 初始化自定义结构体对象,初始化WatchdogCntlr成员,调用核心层WatchdogCntlrAdd函数。 @@ -332,13 +328,13 @@ Watchdog模块适配HDF框架的三个环节是配置属性文件,实例化驱 HdfDeviceObject :HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。 - 返回值**:** + 返回值: 无。 - 函数说明**:** + 函数说明: - 该函数需要在驱动入口结构体中赋值给Release,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作**前提**是在Init函数中具备对应赋值的操作。 + 该函数需要在驱动入口结构体中赋值给Release,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。 ``` static void Hi35xxWatchdogRelease(struct HdfDeviceObject *device) diff --git "a/zh-cn/device-dev/driver/figures/Camera\346\250\241\345\235\227\351\251\261\345\212\250\346\250\241\345\236\213.png" "b/zh-cn/device-dev/driver/figures/Camera\346\250\241\345\235\227\351\251\261\345\212\250\346\250\241\345\236\213.png" new file mode 100644 index 0000000000000000000000000000000000000000..1a4fa27e98e5bb4568be1399b57da3b987ee4fbf Binary files /dev/null and "b/zh-cn/device-dev/driver/figures/Camera\346\250\241\345\235\227\351\251\261\345\212\250\346\250\241\345\236\213.png" differ diff --git a/zh-cn/device-dev/faqs/faqs-burning.md b/zh-cn/device-dev/faqs/faqs-burning.md index 8e1424d971579d0caac271ecda23281d04c4aa18..75a3001178f55436df63f40ffe6643c1a7b59e09 100644 --- a/zh-cn/device-dev/faqs/faqs-burning.md +++ b/zh-cn/device-dev/faqs/faqs-burning.md @@ -84,7 +84,7 @@ 2. 根据USB烧写步骤烧写U-boot文件。 - 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3518_upload-0000001057313128)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 + 按照[Hi3516系列USB烧写步骤](../quick-start/quickstart-lite-steps-hi3516-burn.md)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 3. 烧写完成后,登录串口如下图所示。 diff --git a/zh-cn/device-dev/get-code/Readme-CN.md b/zh-cn/device-dev/get-code/Readme-CN.md index 82da2d561e3ade5ee95dbe4c1411c4114ad6ad2b..2e2aa40f2e1e91131a00b6b98bacd70cb1b57977 100755 --- a/zh-cn/device-dev/get-code/Readme-CN.md +++ b/zh-cn/device-dev/get-code/Readme-CN.md @@ -1,9 +1,8 @@ # 获取源码 -- [获取源码](sourcecode.md) - - [源码获取](sourcecode-acquire.md) - -- [获取工具](gettools.md) - - [Docker编译环境](gettools-acquire.md) - - [IDE](gettools-ide.md) +- [源码获取](sourcecode-acquire.md) +- 工具 + - [工具概述](gettools-overview.md) + - [Docker编译环境](gettools-acquire.md) + - [IDE](gettools-ide.md) diff --git a/zh-cn/device-dev/get-code/gettools-acquire.md b/zh-cn/device-dev/get-code/gettools-acquire.md index ded916b192889b065e7b4d4c0870408a06a76c3c..b6f42a39d4e912cbb2af5754f845b0f15ef1bce0 100644 --- a/zh-cn/device-dev/get-code/gettools-acquire.md +++ b/zh-cn/device-dev/get-code/gettools-acquire.md @@ -78,7 +78,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完 OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud.com/swr/?region=cn-south-1#/app/warehouse/warehouseMangeDetail/goldensir/openharmony-docker/openharmony-docker?type=ownImage)上。开发者可以通过该镜像在很大程度上简化编译前的环境配置。下文将介绍具体使用步骤。 -### 搭建Docker环境-轻量系统类设备(参考内存≥128KB)和小型系统类设备(参考内存≥1MB) +### 搭建Docker环境(轻量系统和小型系统) 1. 获取Docker镜像。 @@ -101,7 +101,7 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud ``` -### 编译源码-轻量系统类设备(参考内存≥128KB)和小型系统类设备(参考内存≥1MB) +### 编译源码-轻量系统类设备(轻量系统和小型系统) 通过如下编译脚本启动轻量系统类设备(参考内存≥128KB)和小型系统类设备(参考内存≥1MB)的编译。下文以Hi3516平台为例说明具体编译步骤。 @@ -132,7 +132,7 @@ hb set 编译结果文件生成在out/hispark\_taurus/ipcamera\_hispark\_taurus目录下。 -### 搭建Docker环境-标准系统类设备(参考内存≥128MB) +### 搭建Docker环境(标准系统) 1. 获取Docker镜像。 @@ -147,7 +147,7 @@ hb set ``` -### 编译源码-标准系统类设备(参考内存≥128MB) +### 编译源码(标准系统) 通过如下编译脚本启动标准系统类设备(参考内存≥128MB)的编译。 @@ -236,5 +236,4 @@ docker\_dist是一个[HPM](https://hpm.harmonyos.com/)系统中的模板组件 # windows下的编译,需要配置gitbash hpm config set shellPath "gitbash路径" hpm run distWithDocker solution={product} - ``` - + ``` \ No newline at end of file diff --git a/zh-cn/device-dev/get-code/gettools-ide.md b/zh-cn/device-dev/get-code/gettools-ide.md index b12dbbf1deeb74896a04c9a61d3f9f4aa8830708..042268f26cd4c238c58e8d607fb924ad4bd34f40 100644 --- a/zh-cn/device-dev/get-code/gettools-ide.md +++ b/zh-cn/device-dev/get-code/gettools-ide.md @@ -5,13 +5,10 @@ ## 获取设备开发工具(HUAWEI DevEco Device Tool) -HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持代码编辑、编译、烧录、调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上。具体可参见[获取工具](https://device.harmonyos.com/cn/ide)和[工具使用指南](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905)**。** +HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持代码编辑、编译、烧录、调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上。具体可参见[获取工具](https://device.harmonyos.com/cn/ide)和[工具使用指南](https://device.harmonyos.com/cn/docs/ide/user-guides/service_introduction-0000001050166905)。 -Huawei DevEco Device Tool支持 OpenHarmony设备开发的演进路标如下: - -![](figure/evolution-roadmap.png) ## 获取应用开发工具(HUAWEI DevEco Studio) -HUAWEI DevEco Studio(以下简称DevEco Studio)是面向华为终端全场景多设备的一站式集成开发环境(IDE),为开发者提供工程模板创建、开发、编译、调试、发布等E2E的OpenHarmony应用开发服务。通过使用DevEco Studio,开发者可以更高效的开发具备OpenHarmony分布式能力的应用,进而提升创新效率。具体可参见[获取工具](https://developer.harmonyos.com/cn/develop/deveco-studio)和[工具使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/tools_overview-0000001053582387)。 +HUAWEI DevEco Studio(以下简称DevEco Studio)是面向华为终端全场景多设备的一站式集成开发环境(IDE),为开发者提供工程模板创建、开发、编译、调试、发布等E2E的OpenHarmony应用开发服务。通过使用DevEco Studio,开发者可以更高效的开发具备OpenHarmony分布式能力的应用,进而提升创新效率。具体可参见[获取工具](https://developer.harmonyos.com/cn/develop/deveco-studio)和[工具使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)。 diff --git a/zh-cn/device-dev/get-code/gettools-overview.md b/zh-cn/device-dev/get-code/gettools-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..7678c05a9c76761f27c02bca830bb387ad84e78a --- /dev/null +++ b/zh-cn/device-dev/get-code/gettools-overview.md @@ -0,0 +1,10 @@ +# 工具概述 + +为了方便开发者进行设备开发,OpenHarmony提供了HUAWEI DevEco Device Tool(以下简称DevEco Device Tool)一站式集成开发环境,同时借助了应用容器引擎Docker简化编译环境搭建。 + +**表1** 工具简介 + +| 工具 | 简介 | 相关资源 | +| ---- | ------ | ------ | +| DevEco Device Tool | DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一站式集成开发环境,支持OpenHarmony的组件按需定制,支持代码编辑、编译、烧录和调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上。 | [DevEco Device Tool使用指南](https://device.harmonyos.com/cn/docs/documentation/guide/service_introduction-0000001050166905) | +| Docker | 在编译环节,开发者需要先安装对应OpenHarmony系统类型的编译工具链。OpenHarmony系统为开发者提供的Docker环境已经将对应的编译工具链进行了封装,开发者可省略对应工具的安装,直接使用Docker环境进行编译。 | [Docker编译环境](gettools-acquire.md) | diff --git a/zh-cn/device-dev/get-code/sourcecode-acquire.md b/zh-cn/device-dev/get-code/sourcecode-acquire.md index 5448d127f5f6d40bca369c7eddc09770a33e77b6..80c7ef6ccd3ccd06fefedc02e912d944659564eb 100644 --- a/zh-cn/device-dev/get-code/sourcecode-acquire.md +++ b/zh-cn/device-dev/get-code/sourcecode-acquire.md @@ -32,7 +32,7 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 ### 前提条件 -1. 注册码云gitee账号。 +1. 注册码云gitee帐号。 2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 3. 安装[git客户端](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 @@ -45,7 +45,7 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 4. 安装码云repo工具,可以执行如下命令。 ``` - curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 chmod a+x /usr/local/bin/repo pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests ``` @@ -53,7 +53,6 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 ### 操作步骤 -**获取轻量/小型/标准系统源码** >![](../public_sys-resources/icon-note.gif) **说明:** >Master主干为开发分支,开发者可通过Master主干获取最新特性。发布版本代码相对比较稳定,开发者可基于发布版本代码进行商用功能开发。 @@ -157,7 +156,7 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 为了获得更好的下载性能,您可以选择从以下站点的镜像库获取源码或者对应的解决方案。 -本部分只提供OpenHarmony Master最新版本和LTS最新版本的获取源码方式, 其他版本获取源码方式以及具体版本信息请参考[Release-Notes](../../release-notes/Readme.md)。 +本部分只提供OpenHarmony LTS最新版本和最新发布版本的源码获取方式, 其他版本获取源码方式以及具体版本信息请参考[Release-Notes](../../release-notes/Readme.md)。 **表 1** 获取源码路径 @@ -235,7 +234,7 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发

-

-

Master版本源码

+

最新发布版本源码

版本信息

@@ -244,65 +243,65 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发

SHA256校验码

-

全量代码Beta版本(标准、轻量和小型系统)

+

全量代码Release版本(标准、轻量和小型系统)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

Hi3516标准系统解决方案(二进制)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

RK3568标准系统解决方案(二进制)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

Hi3861解决方案(二进制)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

Hi3516解决方案-LiteOS(二进制)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

Hi3516解决方案-Linux(二进制)

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

SHA256校验码

+

SHA256校验码

RELEASE-NOTES

-

3.1 Beta

+

3.1 Release

-

站点

+

站点

-

@@ -328,7 +327,11 @@ OpenHarmony当前为开发者提供了以下4种获取源码的方式,开发 -## 获取方式4:从github镜像仓库获取\(每天UTC时间23点同步\) +## 获取方式4:从github镜像仓库获取 + +>![](../public_sys-resources/icon-note.gif) **说明:** +>镜像仓库每日23:00(UTC +8:00)同步。 + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[GitHub帮助中心](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account))。 diff --git a/zh-cn/device-dev/glossary/Readme-CN.md b/zh-cn/device-dev/glossary/Readme-CN.md deleted file mode 100755 index e69d48c93789ee931046637f2f6262f867c7a4ef..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/glossary/Readme-CN.md +++ /dev/null @@ -1,4 +0,0 @@ -# 术语 - -- [术语](glossary.md) - diff --git a/zh-cn/device-dev/glossary/glossary.md b/zh-cn/device-dev/glossary/glossary.md deleted file mode 100644 index 7d73579241e5befbae77bbba662eb15df86a04ab..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/glossary/glossary.md +++ /dev/null @@ -1,99 +0,0 @@ -# 术语 - -- [A](#section1679023922312) -- [B](#section62182102017) -- [D](#section1670294920236) -- [F](#section5406185415236) -- [H](#section891816813243) -- [I](#section10124052142516) -- [P](#section779354121411) -- [S](#section25661636182615) - -## A - -- **Ability** - - 应用的重要组成部分,是应用所具备能力的抽象。Ability分为两种类型,Feature Ability和Particle Ability。 - - -- **AbilitySlice** - - 切片,是单个可视化界面及其交互逻辑的总和,是Feature Ability的组成单元。一个Feature Ability可以包含一组业务关系密切的可视化界面,每一个可视化界面对应一个AbilitySlice。 - -- **AMS** - - Ability Manager Service,Ability管理服务。 - - -## B - -- **BMS** - - Bundle Manager Service,包管理服务。 - - -## D - -- **DevEco Studio for Embedded** - - 嵌入式设备开发IDE。 - -- **DMS** - - Distributed Management Service,分布式管理服务。 - - -## F - -- **FA** - - Feature Ability,代表有界面的Ability,用于与用户进行交互。 - - -## H - -- **HAP** - - OpenHarmony Ability Package,一个HAP文件包含应用的所有内容,由代码、资源、三方库及应用配置文件组成,其文件后缀名为.hap。 - -- **HCS** - - HDF Configuration Source是HDF驱动框架的配置描述语言,是为了实现配置代码与驱动代码解耦,以及便于配置的管理而设计的一种Key-Value为主体的文本格式。 - - -- **HC-GEN** - - HDF Configuration Generator是HCS配置转换工具,可以将HDF配置文件转换为软件可读取的文件格式。 - - -- **HDF** - - Hardware Driver Foundation,硬件驱动框架,用于提供统一外设访问能力和驱动开发、管理框架。 - - -## I - -- **IDN** - - Intelligent Distributed Networking,是OpenHarmony特有的分布式组网能力单元。开发者可以通过IDN获取分布式网络内的设备列表和设备状态信息,以及注册分布式网络内设备的在网状态变化信息。 - - -## P - -- **PA** - - Particle Ability,代表无界面的Ability,主要为Feature Ability提供支持,例如作为后台服务提供计算能力,或作为数据仓库提供数据访问能力。 - - -## S - -- **Super virtual device,超级虚拟终端** - - 亦称超级终端,通过分布式技术将多个终端的能力进行整合,存放在一个虚拟的硬件资源池里,根据业务需要统一管理和调度终端能力,来对外提供服务。 - -- **System Type,系统类型** - - Mini System,轻量系统:面向MCU类处理器,例如ARM Cortex-M、RISC-V 32位的设备,资源极其有限,参考内存≥128KiB,提供丰富的近距连接能力以及丰富的外设总线访问能力。典型产品有智能家居领域的联接类模组、传感器设备等。 - - Small System,小型系统:面向应用处理器,例如Arm Cortex-A的设备,参考内存≥1MiB,提供更高的安全能力,提供标准的图形框架,提供视频编解码的多媒体能力。典型产品有智能家居领域的IPCamera、电子猫眼、路由器以及智慧出行域的行车记录仪等。 - - Standard System,标准系统:面向应用处理器,例如Arm Cortex-A的设备,参考内存≥128MiB,提供增强的交互能力,提供3D GPU以及硬件合成能力,提供更多控件以及动效更丰富的图形能力,提供完整的应用框架。典型产品有高端的冰箱显示屏等。 - - diff --git a/zh-cn/device-dev/guide/device-clock-guide.md b/zh-cn/device-dev/guide/device-clock-guide.md index d42e3f024bf38c9acd8fb6788152ecc410d8cf67..e391435a81f6cd7cf190585e714688b2d5ebb9c7 100644 --- a/zh-cn/device-dev/guide/device-clock-guide.md +++ b/zh-cn/device-dev/guide/device-clock-guide.md @@ -255,7 +255,7 @@ ## 签名打包 -代码编写完成后,在真机设备上运行应用,需要先对应用进行签名,然后再进行打包,具体操作请参考[签名打包指导](../../application-dev/quick-start/configuring-openharmony-app-signature.md)。 +代码编写完成后,在真机设备上运行应用,需要先对应用进行签名,然后再进行打包,具体操作请参考[签名打包指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768)。 ## 真机运行 diff --git a/zh-cn/device-dev/hpm-part/hpm-part-reference.md b/zh-cn/device-dev/hpm-part/hpm-part-reference.md index 68ba5bae2ca3bdb83015e71261e729b80767523c..430503f30c21ceae523136efb5d8c62d15a7efe1 100644 --- a/zh-cn/device-dev/hpm-part/hpm-part-reference.md +++ b/zh-cn/device-dev/hpm-part/hpm-part-reference.md @@ -157,22 +157,22 @@ Part的全生命周期管理,可以通过hpm命令工具进行操作,hpm的 | -------- | -------- | -------- | | 版本查询 | hpm -V或hpm --version | 查看hpm-cli版本号。 | | 帮助查询 | hpm -h或hpm --version | 查看命令列表及帮助。 | -| hpm -h | 查看命令帮助。 | +|| hpm -h | 查看命令帮助。 | | 创建 | hpm init bundle | 创建Part工程。 | -| hpm init -t template | 根据模板创建脚手架工程。 | +|| hpm init -t template | 根据模板创建脚手架工程。 | | 安装 | hpm install或hpm i | 安装bundle.json中依赖的Part。 | -| hpm install bundle\@version | 安装指定Part版本。 | +|| hpm install bundle\@version | 安装指定Part版本。 | | 卸载 | hpm uninstall bundle | 删除depedencies依赖的Part。 | -| hpm remove或hpm rm bundlename | 删除depedencies依赖的Part。 | +|| hpm remove或hpm rm bundlename | 删除depedencies依赖的Part。 | | 查看 | hpm list或者hpm ls | 显示当前HPM Part的依赖树。 | -| hpm dependencies | 生成当前HPM Part依赖关系数据(在hpm ui也集成了该命令的调用,可以图形化的展示) | +|| hpm dependencies | 生成当前HPM Part依赖关系数据(在hpm ui也集成了该命令的调用,可以图形化的展示) | | 搜索 | hpm search name | 搜索Bundle,--json,可以以json格式输出 -type 可以设置搜索Bundle的类型,包括part、distribution、code-segment三种。 | | 设置hpm配置项 | hpm config set key value | 设置配置值,如服务器地址,网络代理。 | -| hpm config delete key | 删除配置。 | +|| hpm config delete key | 删除配置。 | | 更新 | hpm update | 更新当前Part依赖的Part的版本。 | -| hpm check-update | 检查依赖的Part版本是否有更新。 | +|| hpm check-update | 检查依赖的Part版本是否有更新。 | | 编译 | hpm build | 编译HPM Part。 | -| hpm dist | 针对发行版(distribution),发行版编译构建(依赖bundle.json的scripts中的dist脚本)。 | +|| hpm dist | 针对发行版(distribution),发行版编译构建(依赖bundle.json的scripts中的dist脚本)。 | | 打包 | hpm pack | 本地Part打包依赖。 | | 烧录 | hpm run flash | 烧录固件(依赖bundle.json的scripts中的flash脚本)。 | | 发布 | hpm publish | 发布Part,发布的Part在仓库中必须唯一,且版本唯一(需要账号登录)。 | diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 460efc5e8e693dffd23f0dd8aca05eb4c165b4b6..4c4d3321fe06193d07094d9698de34c5251abe61 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -34,8 +34,7 @@ - [LMS调测](kernel-mini-memory-lms.md) - 附录 - [内核编码规范](kernel-mini-appx-code.md) - - 基本数据结构 - - [双向链表](kernel-mini-appx-data-list.md) + - [双向链表](kernel-mini-appx-data-list.md) - 标准库支持 - [CMSIS支持](kernel-mini-appx-lib-cmsis.md) - [POSIX支持](kernel-mini-appx-lib-posix.md) @@ -179,8 +178,7 @@ - [开发板Patch使用指导](kernel-standard-patch.md) - [Linux内核编译与构建指导](kernel-standard-build.md) - [内核增强特性](kernel-standard-enhanced-features.md) - - [内存管理](kernel-standard-mm.md) - - [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md) + - [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md) - [任务调度](kernel-standard-sched.md) - [关联线程组调度](kernel-standard-sched-rtg.md) - [CPU轻量级隔离](kernel-standard-sched-cpuisolation.md) diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-event.md b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-event.md index 0cf23cf3299a0f2c791e49978dbe85bc6ae76a41..c74bda8669b02d01b16b8b0c5e40b032d0c8e1f4 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-event.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-event.md @@ -61,6 +61,7 @@ typedef struct tagEvent { **事件销毁**:销毁指定的事件控制块。 **图1** 轻量系统事件运作原理图 + ![zh-cn_image_0000001200771972](figures/zh-cn_image_0000001200771972.png) diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-mutex.md b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-mutex.md index 2ade826ed4bd7d3cac587ed7382dca1b3c2cff41..b0b3672de9bf13f28ccd2e9448d58818d3be93db 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-mutex.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-mutex.md @@ -25,6 +25,7 @@ 用互斥锁处理非共享资源的同步访问时,如果有任务访问该资源,则互斥锁为加锁状态。此时其他任务如果想访问这个公共资源则会被阻塞,直到互斥锁被持有该锁的任务释放后,其他任务才能重新访问该公共资源,此时互斥锁再次上锁,如此确保同一时刻只有一个任务正在访问这个公共资源,保证了公共资源操作的完整性。 **图1** 轻量系统互斥锁运作示意图 + ![zh-cn_image_0000001245411845](figures/zh-cn_image_0000001245411845.png) diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md index a0c26722dc5d3b20d66207016a9ffb75070f563b..25a9bdf2a39a1a891d5077d6c7fbef9a3fd45fdb 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md @@ -82,6 +82,7 @@ typedef struct - 删除队列时,根据队列ID找到对应队列,把队列状态置为未使用,把队列控制块置为初始状态,并释放队列所占内存。 **图1** 队列读写数据操作示意图 + ![zh-cn_image_0000001200452026](figures/zh-cn_image_0000001200452026.png) 上图对读写队列做了示意,图中只画了尾节点写入方式,没有画头节点写入,但是两者是类似的。 diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-sem.md b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-sem.md index 0e56c02c75e1608bc42d7880b1e8ffef05331256..b1c3df8154ae243ceb67fa6d3fe42dd64fc0bc4b 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-sem.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-sem.md @@ -61,6 +61,7 @@ typedef struct { 信号量允许多个任务在同一时刻访问共享资源,但会限制同一时刻访问此资源的最大任务数目。当访问资源的任务数达到该资源允许的最大数量时,会阻塞其他试图获取该资源的任务,直到有任务释放该信号量。 **图1** 轻量系统信号量运作示意图 + ![zh-cn_image_0000001245051881](figures/zh-cn_image_0000001245051881.png) diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md b/zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md index 4b50b4216bcfd0791bc7158abb8718df30f0be1f..bdc14c81c379baea8a14f2f9be9a39e9ecf803e9 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md @@ -15,6 +15,7 @@ OpenHarmony LiteOS-M动态内存在TLSF算法的基础上,对区间的划分进行了优化,获得更优的性能,降低了碎片率。动态内存核心算法框图如下: **图1** 轻量系统动态内存核心算法 + ![zh-cn_image_0000001199352445](figures/zh-cn_image_0000001199352445.png) $$根据空闲内存块的大小,使用多个空闲链表来管理。根据内存空闲块大小分为两个部分:[4, 127]和[2^{7}$, 2^{31}$],如上图size class所示: @@ -28,6 +29,7 @@ $$根据空闲内存块的大小,使用多个空闲链表来管理。根据内 内存管理结构如下图所示: **图2** 轻量系统动态内存管理结构图 + ![zh-cn_image_0000001153313284](figures/zh-cn_image_0000001153313284.png) - 内存池池头部分 @@ -39,6 +41,7 @@ $$根据空闲内存块的大小,使用多个空闲链表来管理。根据内 一些芯片片内RAM大小无法满足要求,需要使用片外物理内存进行扩充。对于这样的多段非连续性内存, LiteOS-M内核支持把多个非连续性内存逻辑上合一,用户不感知底层的多段非连续性内存区域。 LiteOS-M内核内存模块把不连续的内存区域作为空闲内存结点插入到空闲内存节点链表,把不同内存区域间的不连续部分标记为虚拟的已使用内存节点,从逻辑上把多个非连续性内存区域实现为一个统一的内存池。下面通过示意图说明下多段非连续性内存的运行机制: **图3** 非连续性内存合一示意图 + ![zh-cn_image_0000001198253551](figures/zh-cn_image_0000001198253551.png) 结合上述示意图,非连续性内存合并为一个统一的内存池的步骤如下: diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-memory-static.md b/zh-cn/device-dev/kernel/kernel-mini-basic-memory-static.md index b4007c0e108eaff2ef24fafb7bdcc229be5cee00..ee8c5cfcd56d7c5bceea8373dba6c600b8cea590 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-memory-static.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-memory-static.md @@ -15,6 +15,7 @@ 静态内存池由一个控制块LOS_MEMBOX_INFO和若干相同大小的内存块LOS_MEMBOX_NODE构成。控制块位于内存池头部,用于内存块管理,包含内存块大小uwBlkSize,内存块数量uwBlkNum,已分配使用的内存块数量uwBlkCnt和空闲内存块链表stFreeList。内存块的申请和释放以块大小为粒度,每个内存块包含指向下一个内存块的指针pstNext。 **图1** 静态内存示意图 + ![zh-cn_image_0000001199352039](figures/zh-cn_image_0000001199352039.png) diff --git a/zh-cn/device-dev/kernel/kernel-mini-extend-dynamic-loading.md b/zh-cn/device-dev/kernel/kernel-mini-extend-dynamic-loading.md index fd952435e7384edb43ce410368a2cbdffebdf177..6d1468a89862758eadc50ea7efe6101961b4ca6a 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-extend-dynamic-loading.md +++ b/zh-cn/device-dev/kernel/kernel-mini-extend-dynamic-loading.md @@ -14,6 +14,7 @@ 在硬件资源有限的小设备中,需要通过算法的动态部署能力来解决无法同时部署多种算法的问题。以开发者易用为主要考虑因素,同时考虑到多平台的通用性,LiteOS-M选择业界标准的ELF加载方案,方便拓展算法生态。LiteOS-M提供类似于dlopen、dlsym等接口,APP通过动态加载模块提供的接口可以加载、卸载相应算法库。如图1所示,APP需要通过三方算法库所需接口获取对应信息输出,三方算法库又依赖内核提供的基本接口,如malloc等。APP加载所需接口,并对相关的未定义符号完成重定位后,APP即可调用该接口完成功能调用。目前动态加载组件只支持arm架构。此外,待加载的共享库需要验签或者限制来源,确保系统的安全性。 **图1** LiteOS-M内核动态加载架构图 + ![zh-cn_image_0000001200292052](figures/zh-cn_image_0000001200292052.png) @@ -38,6 +39,7 @@ const SymInfo sym_##func __attribute__((section(".sym."#func))) = { \ ``` **图2** 导出的符号表信息 + ![zh-cn_image_0000001245171875](figures/zh-cn_image_0000001245171875.png) @@ -67,6 +69,7 @@ Program Headers: ``` **图3** ELF文件的加载过程 + ![zh-cn_image_0000001245251887](figures/zh-cn_image_0000001245251887.png) @@ -75,6 +78,7 @@ Program Headers: 如图4所示,通过ELF文件的.dynamic段获取重定位表,遍历表中每一个需要重定位的条目,再根据需要重定位的符号名在共享库和内核提供的导出符号表中查找相应符号并更新相应的重定位信息。 **图4** ELF文件的链接过程 + ![zh-cn_image_0000001200612006](figures/zh-cn_image_0000001200612006.png) diff --git a/zh-cn/device-dev/kernel/kernel-mini-overview.md b/zh-cn/device-dev/kernel/kernel-mini-overview.md index 1a7369be0157374070625b7298c70e614c5cedf3..acb6d758c187ee0f4de207ba922af252fcda898b 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-overview.md +++ b/zh-cn/device-dev/kernel/kernel-mini-overview.md @@ -11,6 +11,7 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系 OpenHarmony LiteOS-M内核架构包含硬件相关层以及硬件无关层,如下图所示,其中硬件相关层按不同编译工具链、芯片架构分类,提供统一的HAL(Hardware Abstraction Layer)接口,提升了硬件易适配性,满足AIoT类型丰富的硬件和编译工具链的拓展;其他模块属于硬件无关层,其中基础内核模块提供基础能力,扩展模块提供网络、文件系统等组件能力,还提供错误处理、调测等能力,KAL(Kernel Abstraction Layer)模块提供统一的标准接口。 **图1** 内核架构图 + ![zh-cn_image_0000001199351155](figures/zh-cn_image_0000001199351155.png) @@ -34,4 +35,5 @@ LiteOS-M已经支持ARM Cortex-M3、ARM Cortex-M4、ARM Cortex-M7、ARM Cortex-M 在开发板配置文件target_config.h配置系统时钟、每秒Tick数,可以对任务、内存、IPC、异常处理模块进行裁剪配置。系统启动时,根据配置进行指定模块的初始化。内核启动流程包含外设初始化、系统时钟配置、内核初始化、操作系统启动等,详见内核启动流程。 **图2** 内核启动流程 + ![zh-cn_image_0000001160338832](figures/zh-cn_image_0000001160338832.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-interrupt.md b/zh-cn/device-dev/kernel/kernel-small-basic-interrupt.md index f301f86be53fb5872f11721c84e0896666d26454..b02fbca5f53e91e52c9d4458a89b538c6e76859c 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-interrupt.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-interrupt.md @@ -24,6 +24,7 @@ 以ARMv7-a架构为例,中断和异常处理的入口为中断向量表,中断向量表包含各个中断和异常处理的入口函数。 **图1** 中断向量表 + ![zh-cn_image_0000001199713709](figures/zh-cn_image_0000001199713709.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-memory-heap.md b/zh-cn/device-dev/kernel/kernel-small-basic-memory-heap.md index b48497b6fe520d6016ef3cd1bf33ec82f39e39f1..03865134dc388cfba4644d6a3b10110f3d3bfdca 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-memory-heap.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-memory-heap.md @@ -19,6 +19,7 @@ 堆内存管理,即在内存资源充足的情况下,根据用户需求,从系统配置的一块比较大的连续内存(内存池,也是堆内存)中分配任意大小的内存块。当用户不需要该内存块时,又可以释放回系统供下一次使用。与静态内存相比,动态内存管理的优点是按需分配,缺点是内存池中容易出现碎片。OpenHarmony LiteOS-A堆内存在TLSF算法的基础上,对区间的划分进行了优化,获得更优的性能,降低了碎片率。动态内存核心算法框图如下: **图1** 小型系统动态内存核心算法 + ![zh-cn_image_0000001146437734](figures/zh-cn_image_0000001146437734.png) $$根据空闲内存块的大小,使用多个空闲链表来管理。根据内存空闲块大小分为两个部分:[4, 127]和[2^{7}$, 2^{31}$],如上图size class所示: @@ -32,6 +33,7 @@ $$根据空闲内存块的大小,使用多个空闲链表来管理。根据内 内存管理结构如图2所示: **图2** 小型系统动态内存管理结构图 + ![zh-cn_image_0000001180855455](figures/zh-cn_image_0000001180855455.png) - 内存池池头部分 diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-memory-physical.md b/zh-cn/device-dev/kernel/kernel-small-basic-memory-physical.md index cdcb103fe76dfdf3a0f20817d5863f9024f5bc7c..d58e00336b4699661f91c574f5545daee58bd2a0 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-memory-physical.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-memory-physical.md @@ -18,6 +18,7 @@ 如下图所示,LiteOS-A内核的物理内存使用分布视图,主要由内核镜像、内核堆及物理页组成。内核堆部分见堆内存管理一节。 **图1** 物理内存使用分布图 + ![zh-cn_image_0000001179140185](figures/zh-cn_image_0000001179140185.png) 伙伴算法把所有空闲页帧分成9个内存块组,每组中内存块包含2的幂次方个页帧,例如:第0组的内存块包含2的0次方个页帧,即1个页帧;第8组的内存块包含2的8次方个页帧,即256个页帧。相同大小的内存块挂在同一个链表上进行管理。 @@ -26,12 +27,14 @@ 系统申请12KiB内存,即3个页帧时,9个内存块组中索引为3的链表挂着一块大小为8个页帧的内存块满足要求,分配出12KiB内存后还剩余20KiB内存,即5个页帧,将5个页帧分成2的幂次方之和,即4跟1,尝试查找伙伴进行合并。4个页帧的内存块没有伙伴则直接插到索引为2的链表上,继续查找1个页帧的内存块是否有伙伴,索引为0的链表上此时有1个,如果两个内存块地址连续则进行合并,并将内存块挂到索引为1的链表上,否则不做处理。 **图2** 内存申请示意图 + ![zh-cn_image_0000001189778871](figures/zh-cn_image_0000001189778871.png) - 释放内存 系统释放12KiB内存,即3个页帧,将3个页帧分成2的幂次方之和,即2跟1,尝试查找伙伴进行合并,索引为1的链表上有1个内存块,若地址连续则合并,并将合并后的内存块挂到索引为2的链表上,索引为0的链表上此时也有1个,如果地址连续则进行合并,并将合并后的内存块挂到索引为1的链表上,此时继续判断是否有伙伴,重复上述操作。 **图3** 内存释放示意图 + ![zh-cn_image_0000001143739220](figures/zh-cn_image_0000001143739220.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-memory-virtual.md b/zh-cn/device-dev/kernel/kernel-small-basic-memory-virtual.md index 51d6be2faf4739b132c878a90f9d737aed72923b..341d52d3e3b04afe05eb4d4ac8c39fffd3be9c41 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-memory-virtual.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-memory-virtual.md @@ -39,6 +39,7 @@ - CPU访问的虚拟地址所在的页,如V2,没有与具体的物理页做映射,系统会触发缺页异常,系统申请一个物理页,并把相应的信息拷贝到物理页中,并且把物理页的起始地址更新到页表条目中。此时CPU重新执行访问虚拟内存的指令便能够访问到具体的代码或数据。 **图1** 内存映射示意图 + ![zh-cn_image_0000001179142959](figures/zh-cn_image_0000001179142959.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-process-process.md b/zh-cn/device-dev/kernel/kernel-small-basic-process-process.md index 42ce52464fc75475b6265a306696d7e4b1a424d6..b7279869d597ec5e6c9196b54ad59ac0a900531e 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-process-process.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-process-process.md @@ -35,6 +35,7 @@ - 僵尸(Zombies):进程运行结束,等待父进程回收其控制块资源。 **图1** 进程状态迁移示意图 + ![zh-cn_image_0000001219007317](figures/zh-cn_image_0000001219007317.png) **进程状态迁移说明:** @@ -73,6 +74,7 @@ OpenHarmony 提供的进程模块主要用于实现用户态进程的隔离, 进程只是资源管理单元,实际运行是由进程内的各个线程完成的,不同进程内的线程相互切换时会进行进程空间的切换。 **图2** 进程管理示意图 + ![zh-cn_image_0000001199736949](figures/zh-cn_image_0000001199736949.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-process-scheduler.md b/zh-cn/device-dev/kernel/kernel-small-basic-process-scheduler.md index 880cc6a7527a12f24c4ad910d0409e90fdd703f7..13e34604281730a69cd574e59091c84472d91ea2 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-process-scheduler.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-process-scheduler.md @@ -22,11 +22,13 @@ OpenHarmony 调度的最小单元为线程。 OpenHarmony 采用进程优先级队列+线程优先级队列的方式,进程优先级范围为0-31,共有32个进程优先级桶队列,每个桶队列对应一个线程优先级桶队列;线程优先级范围也为0-31,一个线程优先级桶队列也有32个优先级队列。 **图1** 调度优先级桶队列示意图 + ![zh-cn_image_0000001199705711](figures/zh-cn_image_0000001199705711.png) OpenHarmony 在系统启动内核初始化之后开始调度,运行过程中创建的进程或线程会被加入到调度队列,系统根据进程和线程的优先级及线程的时间片消耗情况选择最优的线程进行调度运行,线程一旦调度到就会从调度队列上删除,线程在运行过程中发生阻塞,会被加入到对应的阻塞队列中并触发一次调度,调度其它线程运行。如果调度队列上没有可以调度的线程,则系统就会选择KIdle进程的线程进行调度运行。 **图2** 调度流程示意图 + ![zh-cn_image_0000001199706239](figures/zh-cn_image_0000001199706239.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-process-thread.md b/zh-cn/device-dev/kernel/kernel-small-basic-process-thread.md index 1041d75552b1f5981f8d2331880b29d1cb17cd7e..b7fc2e1c7c642a1f599e31934c1ec56f2ee52f00 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-process-thread.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-process-thread.md @@ -34,6 +34,7 @@ OpenHarmony 内核的任务一共有32个优先级(0-31),最高优先级为0 - 退出(Exit):任务运行结束,等待父任务回收其控制块资源。 **图1** 任务状态迁移示意图 + ![zh-cn_image_0000001173399977](figures/zh-cn_image_0000001173399977.png) **任务状态迁移说明:** diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-event.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-event.md index ee8d3eec26df29b7815c2aa3ea43a88af7928f0f..16fb303396261a81fd8e8f0432e8735d131447f5 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-event.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-event.md @@ -74,6 +74,7 @@ typedef struct tagEvent { **事件销毁**:销毁指定的事件控制块。 **图1** 小型系统事件运作原理图 + ![zh-cn_image_0000001180952545](figures/zh-cn_image_0000001180952545.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-mutex.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-mutex.md index 7733c14375fa9d75b03bf6ad9147b0ebb4b1b794..5e19269ba323b5897230dca86ebe8ea764bf51f4 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-mutex.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-mutex.md @@ -41,6 +41,7 @@ 用互斥锁处理非共享资源的同步访问时,如果有任务访问该资源,则互斥锁为加锁状态。此时其他任务如果想访问这个公共资源则会被阻塞,直到互斥锁被持有该锁的任务释放后,其他任务才能重新访问该公共资源,此时互斥锁再次上锁,如此确保同一时刻只有一个任务正在访问这个公共资源,保证了公共资源操作的完整性。 **图1** 小型系统互斥锁运作示意图 + ![zh-cn_image_0000001177654887](figures/zh-cn_image_0000001177654887.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-queue.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-queue.md index bb7baf57ea7a5f580689dd86f80223b06eb4c62c..01b0c66ba94c35b9d5d72f1623636c98f00531d5 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-queue.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-queue.md @@ -1,245 +1,246 @@ -# 消息队列 - -- [基本概念](#基本概念) -- [运行机制](#运行机制) - - [队列控制块](#队列控制块) - - [队列运作原理](#队列运作原理) -- [开发指导](#开发指导) - - [接口说明](#接口说明) - - [开发流程](#开发流程) -- [编程实例](#编程实例) - - [实例描述](#实例描述) - - [编程示例](#编程示例) - - [结果验证](#结果验证) - -## 基本概念 - -队列又称消息队列,是一种常用于任务间通信的数据结构。队列接收来自任务或中断的不固定长度消息,并根据不同的接口确定传递的消息是否存放在队列空间中。 - -任务能够从队列里面读取消息,当队列中的消息为空时,挂起读取任务;当队列中有新消息时,挂起的读取任务被唤醒并处理新消息。任务也能够往队列里写入消息,当队列已经写满消息时,挂起写入任务;当队列中有空闲消息节点时,挂起的写入任务被唤醒并写入消息。 - -可以通过调整读队列和写队列的超时时间来调整读写接口的阻塞模式,如果将读队列和写队列的超时时间设置为0,就不会挂起任务,接口会直接返回,这就是非阻塞模式。反之,如果将都队列和写队列的超时时间设置为大于0的时间,就会以阻塞模式运行。 - -消息队列提供了异步处理机制,允许将一个消息放入队列,但不立即处理。同时队列还有缓冲消息的作用,可以使用队列实现任务异步通信,队列具有如下特性: - -- 消息以先进先出的方式排队,支持异步读写。 - -- 读队列和写队列都支持超时机制。 - -- 每读取一条消息,就会将该消息节点设置为空闲。 - -- 发送消息类型由通信双方约定,可以允许不同长度(不超过队列的消息节点大小)的消息。 - -- 一个任务能够从任意一个消息队列接收和发送消息。 - -- 多个任务能够从同一个消息队列接收和发送消息。 - -- 创建队列时所需的队列空间,接口内系统自行动态申请内存。 - - -## 运行机制 - - -### 队列控制块 - -``` -/** - * 队列控制块数据结构 - */ -typedef struct { - UINT8 *queueHandle; /**< Pointer to a queue handle */ - UINT16 queueState; /**< Queue state */ - UINT16 queueLen; /**< Queue length */ - UINT16 queueSize; /**< Node size */ - UINT32 queueID; /**< queueID */ - UINT16 queueHead; /**< Node head */ - UINT16 queueTail; /**< Node tail */ - UINT16 readWriteableCnt[OS_QUEUE_N_RW]; /**< Count of readable or writable resources, 0:readable, 1:writable */ - LOS_DL_LIST readWriteList[OS_QUEUE_N_RW]; /**< the linked list to be read or written, 0:readlist, 1:writelist */ - LOS_DL_LIST memList; /**< Pointer to the memory linked list */ -} LosQueueCB; -``` - -每个队列控制块中都含有队列状态,表示该队列的使用情况: - -- OS_QUEUE_UNUSED:队列未被使用。 - -- OS_QUEUE_INUSED:队列被使用中。 - - -### 队列运作原理 - -- 创建队列时,创建队列成功会返回队列ID。 - -- 在队列控制块中维护着一个消息头节点位置Head和一个消息尾节点位置Tail,用于表示当前队列中消息的存储情况。Head表示队列中被占用的消息节点的起始位置。Tail表示被占用的消息节点的结束位置,也是空闲消息节点的起始位置。队列刚创建时,Head和Tail均指向队列起始位置。 - -- 写队列时,根据readWriteableCnt[1]判断队列是否可以写入,不能对已满(readWriteableCnt[1]为0)队列进行写操作。写队列支持两种写入方式:向队列尾节点写入,也可以向队列头节点写入。尾节点写入时,根据Tail找到起始空闲消息节点作为数据写入对象,如果Tail已经指向队列尾部则采用回卷方式。头节点写入时,将Head的前一个节点作为数据写入对象,如果Head指向队列起始位置则采用回卷方式。 - -- 读队列时,根据readWriteableCnt[0]判断队列是否有消息需要读取,对全部空闲(readWriteableCnt[0]为0)队列进行读操作会引起任务挂起。如果队列可以读取消息,则根据Head找到最先写入队列的消息节点进行读取。如果Head已经指向队列尾部则采用回卷方式。 - -- 删除队列时,根据队列ID找到对应队列,把队列状态置为未使用,把队列控制块置为初始状态,并释放队列所占内存。 - -**图1** 队列读写数据操作示意图 -![zh-cn_image_0000001132875772](figures/zh-cn_image_0000001132875772.png) - -上图对读写队列做了示意,图中只画了尾节点写入方式,没有画头节点写入,但是两者是类似的。 - - -## 开发指导 - - -### 接口说明 - -| 功能分类 | 接口**名称** | 描述 | -| -------- | -------- | -------- | -| 创建/删除消息队列 | LOS_QueueCreate | 创建一个消息队列,由系统动态申请队列空间 | -| | LOS_QueueDelete |根据队列ID删除一个指定队列| -| 读/写队列(不带拷贝) | LOS_QueueRead | 读取指定队列头节点中的数据(队列节点中的数据实际上是一个地址) | -| | LOS_QueueWrite |向指定队列尾节点中写入入参bufferAddr的值(即buffer的地址)| -| | LOS_QueueWriteHead |向指定队列头节点中写入入参bufferAddr的值(即buffer的地址)| -| 读/写队列(带拷贝) | LOS_QueueReadCopy | 读取指定队列头节点中的数据 | -| | LOS_QueueWriteCopy |向指定队列尾节点中写入入参bufferAddr中保存的数据| -| | LOS_QueueWriteHeadCopy |向指定队列头节点中写入入参bufferAddr中保存的数据| -| 获取队列信息 | LOS_QueueInfoGet | 获取指定队列的信息,包括队列ID、队列长度、消息节点大小、头节点、尾节点、可读节点数量、可写节点数量、等待读操作的任务、等待写操作的任务 | - - -### 开发流程 - -1. 用LOS_QueueCreate创建队列。创建成功后,可以得到队列ID。 - -2. 通过LOS_QueueWrite或者LOS_QueueWriteCopy写队列。 - -3. 通过LOS_QueueRead或者LOS_QueueReadCopy读队列。 - -4. 通过LOS_QueueInfoGet获取队列信息。 - -5. 通过LOS_QueueDelete删除队列。 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 系统支持的最大队列数是指:整个系统的队列资源总个数,而非用户能使用的个数。例如:系统软件定时器多占用一个队列资源,那么用户能使用的队列资源就会减少一个。 -> -> - 创建队列时传入的队列名和flags暂时未使用,作为以后的预留参数。 -> -> - 队列接口函数中的入参timeOut是相对时间。 -> -> - LOS_QueueReadCopy和LOS_QueueWriteCopy及LOS_QueueWriteHeadCopy是一组接口,LOS_QueueRead和LOS_QueueWrite及LOS_QueueWriteHead是一组接口,每组接口需要配套使用。 -> -> - 鉴于LOS_QueueWrite和LOS_QueueWriteHead和LOS_QueueRead这组接口实际操作的是数据地址,用户必须保证调用LOS_QueueRead获取到的指针所指向的内存区域在读队列期间没有被异常修改或释放,否则可能导致不可预知的后果。 +# 消息队列 + +- [基本概念](#基本概念) +- [运行机制](#运行机制) + - [队列控制块](#队列控制块) + - [队列运作原理](#队列运作原理) +- [开发指导](#开发指导) + - [接口说明](#接口说明) + - [开发流程](#开发流程) +- [编程实例](#编程实例) + - [实例描述](#实例描述) + - [编程示例](#编程示例) + - [结果验证](#结果验证) + +## 基本概念 + +队列又称消息队列,是一种常用于任务间通信的数据结构。队列接收来自任务或中断的不固定长度消息,并根据不同的接口确定传递的消息是否存放在队列空间中。 + +任务能够从队列里面读取消息,当队列中的消息为空时,挂起读取任务;当队列中有新消息时,挂起的读取任务被唤醒并处理新消息。任务也能够往队列里写入消息,当队列已经写满消息时,挂起写入任务;当队列中有空闲消息节点时,挂起的写入任务被唤醒并写入消息。 + +可以通过调整读队列和写队列的超时时间来调整读写接口的阻塞模式,如果将读队列和写队列的超时时间设置为0,就不会挂起任务,接口会直接返回,这就是非阻塞模式。反之,如果将都队列和写队列的超时时间设置为大于0的时间,就会以阻塞模式运行。 + +消息队列提供了异步处理机制,允许将一个消息放入队列,但不立即处理。同时队列还有缓冲消息的作用,可以使用队列实现任务异步通信,队列具有如下特性: + +- 消息以先进先出的方式排队,支持异步读写。 + +- 读队列和写队列都支持超时机制。 + +- 每读取一条消息,就会将该消息节点设置为空闲。 + +- 发送消息类型由通信双方约定,可以允许不同长度(不超过队列的消息节点大小)的消息。 + +- 一个任务能够从任意一个消息队列接收和发送消息。 + +- 多个任务能够从同一个消息队列接收和发送消息。 + +- 创建队列时所需的队列空间,接口内系统自行动态申请内存。 + + +## 运行机制 + + +### 队列控制块 + +``` +/** + * 队列控制块数据结构 + */ +typedef struct { + UINT8 *queueHandle; /**< Pointer to a queue handle */ + UINT16 queueState; /**< Queue state */ + UINT16 queueLen; /**< Queue length */ + UINT16 queueSize; /**< Node size */ + UINT32 queueID; /**< queueID */ + UINT16 queueHead; /**< Node head */ + UINT16 queueTail; /**< Node tail */ + UINT16 readWriteableCnt[OS_QUEUE_N_RW]; /**< Count of readable or writable resources, 0:readable, 1:writable */ + LOS_DL_LIST readWriteList[OS_QUEUE_N_RW]; /**< the linked list to be read or written, 0:readlist, 1:writelist */ + LOS_DL_LIST memList; /**< Pointer to the memory linked list */ +} LosQueueCB; +``` + +每个队列控制块中都含有队列状态,表示该队列的使用情况: + +- OS_QUEUE_UNUSED:队列未被使用。 + +- OS_QUEUE_INUSED:队列被使用中。 + + +### 队列运作原理 + +- 创建队列时,创建队列成功会返回队列ID。 + +- 在队列控制块中维护着一个消息头节点位置Head和一个消息尾节点位置Tail,用于表示当前队列中消息的存储情况。Head表示队列中被占用的消息节点的起始位置。Tail表示被占用的消息节点的结束位置,也是空闲消息节点的起始位置。队列刚创建时,Head和Tail均指向队列起始位置。 + +- 写队列时,根据readWriteableCnt[1]判断队列是否可以写入,不能对已满(readWriteableCnt[1]为0)队列进行写操作。写队列支持两种写入方式:向队列尾节点写入,也可以向队列头节点写入。尾节点写入时,根据Tail找到起始空闲消息节点作为数据写入对象,如果Tail已经指向队列尾部则采用回卷方式。头节点写入时,将Head的前一个节点作为数据写入对象,如果Head指向队列起始位置则采用回卷方式。 + +- 读队列时,根据readWriteableCnt[0]判断队列是否有消息需要读取,对全部空闲(readWriteableCnt[0]为0)队列进行读操作会引起任务挂起。如果队列可以读取消息,则根据Head找到最先写入队列的消息节点进行读取。如果Head已经指向队列尾部则采用回卷方式。 + +- 删除队列时,根据队列ID找到对应队列,把队列状态置为未使用,把队列控制块置为初始状态,并释放队列所占内存。 + +**图1** 队列读写数据操作示意图 + +![zh-cn_image_0000001132875772](figures/zh-cn_image_0000001132875772.png) + +上图对读写队列做了示意,图中只画了尾节点写入方式,没有画头节点写入,但是两者是类似的。 + + +## 开发指导 + + +### 接口说明 + +| 功能分类 | 接口**名称** | 描述 | +| -------- | -------- | -------- | +| 创建/删除消息队列 | LOS_QueueCreate | 创建一个消息队列,由系统动态申请队列空间 | +| | LOS_QueueDelete |根据队列ID删除一个指定队列| +| 读/写队列(不带拷贝) | LOS_QueueRead | 读取指定队列头节点中的数据(队列节点中的数据实际上是一个地址) | +| | LOS_QueueWrite |向指定队列尾节点中写入入参bufferAddr的值(即buffer的地址)| +| | LOS_QueueWriteHead |向指定队列头节点中写入入参bufferAddr的值(即buffer的地址)| +| 读/写队列(带拷贝) | LOS_QueueReadCopy | 读取指定队列头节点中的数据 | +| | LOS_QueueWriteCopy |向指定队列尾节点中写入入参bufferAddr中保存的数据| +| | LOS_QueueWriteHeadCopy |向指定队列头节点中写入入参bufferAddr中保存的数据| +| 获取队列信息 | LOS_QueueInfoGet | 获取指定队列的信息,包括队列ID、队列长度、消息节点大小、头节点、尾节点、可读节点数量、可写节点数量、等待读操作的任务、等待写操作的任务 | + + +### 开发流程 + +1. 用LOS_QueueCreate创建队列。创建成功后,可以得到队列ID。 + +2. 通过LOS_QueueWrite或者LOS_QueueWriteCopy写队列。 + +3. 通过LOS_QueueRead或者LOS_QueueReadCopy读队列。 + +4. 通过LOS_QueueInfoGet获取队列信息。 + +5. 通过LOS_QueueDelete删除队列。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 系统支持的最大队列数是指:整个系统的队列资源总个数,而非用户能使用的个数。例如:系统软件定时器多占用一个队列资源,那么用户能使用的队列资源就会减少一个。 +> +> - 创建队列时传入的队列名和flags暂时未使用,作为以后的预留参数。 +> +> - 队列接口函数中的入参timeOut是相对时间。 +> +> - LOS_QueueReadCopy和LOS_QueueWriteCopy及LOS_QueueWriteHeadCopy是一组接口,LOS_QueueRead和LOS_QueueWrite及LOS_QueueWriteHead是一组接口,每组接口需要配套使用。 +> +> - 鉴于LOS_QueueWrite和LOS_QueueWriteHead和LOS_QueueRead这组接口实际操作的是数据地址,用户必须保证调用LOS_QueueRead获取到的指针所指向的内存区域在读队列期间没有被异常修改或释放,否则可能导致不可预知的后果。 > > - LOS_QueueRead和LOS_QueueReadCopy接口的读取长度如果小于消息实际长度,消息将被截断。 -> -> - 鉴于LOS_QueueWrite和LOS_QueueWriteHead和LOS_QueueRead这组接口实际操作的是数据地址,也就意味着实际写和读的消息长度仅仅是一个指针数据,因此用户使用这组接口之前,需确保创建队列时的消息节点大小,为一个指针的长度,避免不必要的浪费和读取失败。 - - -## 编程实例 - - -### 实例描述 - -创建一个队列,两个任务。任务1调用写队列接口发送消息,任务2通过读队列接口接收消息。 - -1. 通过LOS_TaskCreate创建任务1和任务2。 - -2. 通过LOS_QueueCreate创建一个消息队列。 - -3. 在任务1 SendEntry中发送消息。 - -4. 在任务2 RecvEntry中接收消息。 - -5. 通过LOS_QueueDelete删除队列。 - - -### 编程示例 - -示例代码如下: - -``` -#include "los_task.h" -#include "los_queue.h" -static UINT32 g_queue; -#define BUFFER_LEN 50 - -VOID SendEntry(VOID) -{ - UINT32 ret = 0; - CHAR abuf[] = "test message"; - UINT32 len = sizeof(abuf); - - ret = LOS_QueueWriteCopy(g_queue, abuf, len, 0); - if(ret != LOS_OK) { - printf("send message failure, error: %x\n", ret); - } -} - -VOID RecvEntry(VOID) -{ - UINT32 ret = 0; - CHAR readBuf[BUFFER_LEN] = {0}; - UINT32 readLen = BUFFER_LEN; - - //休眠1s - usleep(1000000); - ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0); - if(ret != LOS_OK) { - printf("recv message failure, error: %x\n", ret); - } - - printf("recv message: %s\n", readBuf); - - ret = LOS_QueueDelete(g_queue); - if(ret != LOS_OK) { - printf("delete the queue failure, error: %x\n", ret); - } - - printf("delete the queue success!\n"); -} - -UINT32 ExampleQueue(VOID) -{ - printf("start queue example\n"); - UINT32 ret = 0; - UINT32 task1, task2; - TSK_INIT_PARAM_S initParam = {0}; - - initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)SendEntry; - initParam.usTaskPrio = 9; - initParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; - initParam.pcName = "SendQueue"; - - LOS_TaskLock(); - ret = LOS_TaskCreate(&task1, &initParam); - if(ret != LOS_OK) { - printf("create task1 failed, error: %x\n", ret); - return ret; - } - - initParam.pcName = "RecvQueue"; - initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry; - ret = LOS_TaskCreate(&task2, &initParam); - if(ret != LOS_OK) { - printf("create task2 failed, error: %x\n", ret); - return ret; - } - - ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50); - if(ret != LOS_OK) { - printf("create queue failure, error: %x\n", ret); - } - - printf("create the queue success!\n"); - LOS_TaskUnlock(); - return ret; -} -``` - - -### 结果验证 - -编译运行得到的结果为: - -``` -start test example -create the queue success! -recv message: test message -delete the queue success! -``` +> +> - 鉴于LOS_QueueWrite和LOS_QueueWriteHead和LOS_QueueRead这组接口实际操作的是数据地址,也就意味着实际写和读的消息长度仅仅是一个指针数据,因此用户使用这组接口之前,需确保创建队列时的消息节点大小,为一个指针的长度,避免不必要的浪费和读取失败。 + + +## 编程实例 + + +### 实例描述 + +创建一个队列,两个任务。任务1调用写队列接口发送消息,任务2通过读队列接口接收消息。 + +1. 通过LOS_TaskCreate创建任务1和任务2。 + +2. 通过LOS_QueueCreate创建一个消息队列。 + +3. 在任务1 SendEntry中发送消息。 + +4. 在任务2 RecvEntry中接收消息。 + +5. 通过LOS_QueueDelete删除队列。 + + +### 编程示例 + +示例代码如下: + +``` +#include "los_task.h" +#include "los_queue.h" +static UINT32 g_queue; +#define BUFFER_LEN 50 + +VOID SendEntry(VOID) +{ + UINT32 ret = 0; + CHAR abuf[] = "test message"; + UINT32 len = sizeof(abuf); + + ret = LOS_QueueWriteCopy(g_queue, abuf, len, 0); + if(ret != LOS_OK) { + printf("send message failure, error: %x\n", ret); + } +} + +VOID RecvEntry(VOID) +{ + UINT32 ret = 0; + CHAR readBuf[BUFFER_LEN] = {0}; + UINT32 readLen = BUFFER_LEN; + + //休眠1s + usleep(1000000); + ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0); + if(ret != LOS_OK) { + printf("recv message failure, error: %x\n", ret); + } + + printf("recv message: %s\n", readBuf); + + ret = LOS_QueueDelete(g_queue); + if(ret != LOS_OK) { + printf("delete the queue failure, error: %x\n", ret); + } + + printf("delete the queue success!\n"); +} + +UINT32 ExampleQueue(VOID) +{ + printf("start queue example\n"); + UINT32 ret = 0; + UINT32 task1, task2; + TSK_INIT_PARAM_S initParam = {0}; + + initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)SendEntry; + initParam.usTaskPrio = 9; + initParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + initParam.pcName = "SendQueue"; + + LOS_TaskLock(); + ret = LOS_TaskCreate(&task1, &initParam); + if(ret != LOS_OK) { + printf("create task1 failed, error: %x\n", ret); + return ret; + } + + initParam.pcName = "RecvQueue"; + initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry; + ret = LOS_TaskCreate(&task2, &initParam); + if(ret != LOS_OK) { + printf("create task2 failed, error: %x\n", ret); + return ret; + } + + ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50); + if(ret != LOS_OK) { + printf("create queue failure, error: %x\n", ret); + } + + printf("create the queue success!\n"); + LOS_TaskUnlock(); + return ret; +} +``` + + +### 结果验证 + +编译运行得到的结果为: + +``` +start test example +create the queue success! +recv message: test message +delete the queue success! +``` diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-semaphore.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-semaphore.md index fb78120cfaa905d8824d928870e91dfe5f6bb112..29792644b50f139f558653e559567f0416d4134a 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-semaphore.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-semaphore.md @@ -57,6 +57,7 @@ 运行示意图如下图所示: **图1** 小型系统信号量运作示意图 + ![zh-cn_image_0000001132774752](figures/zh-cn_image_0000001132774752.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-mutex.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-mutex.md index 73d28d8a975a1c8260c92d6ad024a918f3f83cb4..aeb787007463f44223b53aec735206490f1ef6da 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-mutex.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-mutex.md @@ -19,6 +19,7 @@ Futex(Fast userspace mutex,用户态快速互斥锁)是内核提供的一种 当前哈希桶共有80个,0~63号桶用于存放私有锁(以虚拟地址进行哈希),64~79号桶用于存放共享锁(以物理地址进行哈希),私有/共享属性通过用户态锁的初始化以及Futex系统调用入参确定。 **图1** Futex设计图 + ![zh-cn_image_0000001127535690](figures/zh-cn_image_0000001127535690.jpg) 如图1,每个futex哈希桶中存放被futex_list串联起来的哈希值相同的futex node,每个futex node对应一个被挂起的task,node中key值唯一标识一把用户态锁,具有相同key值的node被queue_list串联起来表示被同一把锁阻塞的task队列。 diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-linking.md b/zh-cn/device-dev/kernel/kernel-small-bundles-linking.md index d0d9e4768af3505aa71d1b3b028cf6e9b56eca2c..d5f8e4ed93c4ff087091bdab580b5ed34ea5f718 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-linking.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-linking.md @@ -22,6 +22,7 @@ OpenHarmony系统的动态加载与链接机制主要是由内核加载器以及 ## 运行机制 **图1** 动态加载流程 + ![zh-cn_image_0000001133104502](figures/zh-cn_image_0000001133104502.png) 1. 内核将应用程序ELF文件的PT_LOAD段信息映射至进程空间。对于ET_EXEC类型的文件,根据PT_LOAD段中p_vaddr进行固定地址映射;对于ET_DYN类型(位置无关的可执行程序,通过编译选项“-fPIE”得到)的文件,内核通过mmap接口选择base基址进行映射(load_addr = base + p_vaddr)。 @@ -31,6 +32,7 @@ OpenHarmony系统的动态加载与链接机制主要是由内核加载器以及 3. 动态链接器自举并查找应用程序依赖的所有共享库并对导入符号进行重定位,最后跳转至应用程序的e_entry(或base + e_entry),开始运行应用程序。 **图2** 程序执行流程 + ![zh-cn_image_0000001133264664](figures/zh-cn_image_0000001133264664.png) 1. 加载器与链接器调用mmap映射PT_LOAD段; diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-share.md b/zh-cn/device-dev/kernel/kernel-small-bundles-share.md index 326d2761fa6f26dfa737ab5d2f01f6f37f4abe52..53b043f66e8c775904b1a6820e64cbcadb36ac86 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-share.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-share.md @@ -21,6 +21,7 @@ VDSO总体可分为数据页与代码页两部分: - 代码页提供屏蔽系统调用的主要逻辑; **图1** VDSO系统设计 + ![zh-cn_image_0000001173586763](figures/zh-cn_image_0000001173586763.jpg) 如图1所示,当前VDSO机制有以下几个主要步骤: diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-system.md b/zh-cn/device-dev/kernel/kernel-small-bundles-system.md index da585ebaa0698f0e241206588ed6f5c74fd2636a..69ec5a0e9d6186c3f4a2364c49fd6497a9fbe39d 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-system.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-system.md @@ -14,7 +14,9 @@ OpenHarmony LiteOS-A实现了用户态与内核态的区分隔离,用户态程 ## 运行机制 如图1所示,用户程序通过调用System API(系统API,通常是系统提供的POSIX接口)进行内核资源访问与交互请求,POSIX接口内部会触发SVC/SWI异常,完成系统从用户态到内核态的切换,然后对接到内核的Syscall Handler(系统调用统一处理接口)进行参数解析,最终分发至具体的内核处理函数。 + **图1** 系统调用示意图 + ![zh-cn_image_0000001132856572](figures/zh-cn_image_0000001132856572.png) Syscall Handler的具体实现在kernel/liteos_a/syscall/los_syscall.c中OsArmA32SyscallHandle函数,在进入系统软中断异常时会调用此函数,并且按照kernel/liteos_a/syscall/syscall_lookup.h中的清单进行系统调用的入参解析,执行各系统调用最终对应的内核处理函数。 diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-user-function.md b/zh-cn/device-dev/kernel/kernel-small-debug-user-function.md index 3955e8ae2208343a320340a12a035ee2f680e554..5c52ef6395fbd1764d4b42b0356125c7dbbc7600 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-user-function.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-user-function.md @@ -13,11 +13,13 @@ 释放内存时:根据需要释放的内存地址匹配内存节点控制块并将该控制块删除。 **图1** 堆内存节点信息链表 + ![zh-cn_image_0000001165890158](figures/zh-cn_image_0000001165890158.png) 申请内存时,返回地址会被保存到LR寄存器中。进程运行过程中,系统会在内存节点控制块中添加疑似泄漏点对应的lr等信息。如下图所示: **图2** 堆内存节点信息 + ![zh-cn_image_0000001165890518](figures/zh-cn_image_0000001165890518.png) 其中,TID表示线程ID;PID表示进程ID;ptr表示申请的内存地址;size表示申请的内存大小;lr[n]表示函数调用栈地址,变量n可以根据具体场景的需要进行配置。 @@ -27,6 +29,7 @@ 用户通过串口或文件等方式,将各个进程内存调测信息导出,利用addr2line工具将导出的信息转换成导致内存泄漏的代码行,便可以解决内存泄露问题。 **图3** 泄漏点代码行定位流程 + ![zh-cn_image_0000001165730464](figures/zh-cn_image_0000001165730464.png) @@ -41,15 +44,18 @@ 用户程序申请堆内存时,在堆内存节点处添加校验值等信息,如果校验值异常,则很有可能是前一块堆内存使用越界导致的(目前无法识别校验值被野指针破坏的场景)。在内存申请、释放时校验内存节点校验值的正确性,若内存节点被破坏,校验失败时则输出tid、pid及当前被踩节点前一块堆内存申请时保存的调用栈信息,通过addr2line工具可获得具体的代码行信息,辅助用户解决问题。 **图4** node节点头信息添加校验值 + ![zh-cn_image_0000001211449151](figures/zh-cn_image_0000001211449151.png) free堆内存时,不会立即把该内存块释放掉,而是在内存中写入魔术数字0xFE,并放到free队列中(保证在一定时间内不会再被malloc函数分配),当有野指针或use-after-free的情况对该内存进行读取的操作时,能够发现数据异常,但是对于写操作则无法判断出来。 **图5** free流程图 + ![zh-cn_image_0000001165890904](figures/zh-cn_image_0000001165890904.png) - 使用malloc申请内存(大于0x1c000bytes时通过mmap申请) 当malloc通过mmap申请大块内存时,在返回给用户使用的内存区间头和尾分别多申请一个页,一个页PAGE_SIZE当前为0x1000,这两个页分别通过mprotect接口设置权限为PROT_NONE(无可读可写权限),可以有效防止内存越界读写问题:越界读写数据时由于无读写权限而导致用户程序异常,根据异常调用栈信息可找到相应的代码逻辑。 **图6** malloc通过mmap机制申请内存的内存布局 + ![zh-cn_image_0000001211130993](figures/zh-cn_image_0000001211130993.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-user-guide-use-api.md b/zh-cn/device-dev/kernel/kernel-small-debug-user-guide-use-api.md index 850590180cb2811f0d88183498550efa5770c9ad..d09659aa3f9e116f2514ee56b09d0b9f39f2e56e 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-user-guide-use-api.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-user-guide-use-api.md @@ -41,7 +41,7 @@ int main() ## 编译 ``` -$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home//harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) +$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home//directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) ``` @@ -54,7 +54,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp > > - -target arm-liteos用于指定编译器相关库文件路径。 > -> - --sysroot=/home/<user-name>/harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot用于指定编译器库文件搜索根目录,假设OpenHarmony工程代码存放路径为/home/<user-name>/harmony。其中out/hispark_taurus/ipcamera_hispark_taurus路径为在编译时,hb set命令指定的具体产品,本示例选择的是ipcamera_hispark_taurus产品。 +> - --sysroot=/home/<user-name>/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot用于指定编译器库文件搜索根目录,假设OpenHarmony工程代码存放路径为/home/<user-name>/directory。其中out/hispark_taurus/ipcamera_hispark_taurus路径为在编译时,hb set命令指定的具体产品,本示例选择的是ipcamera_hispark_taurus产品。 > > - $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)用于指定相应的unwind库的路径。 diff --git a/zh-cn/device-dev/kernel/kernel-small-overview.md b/zh-cn/device-dev/kernel/kernel-small-overview.md index 9071dd20c8357d694da0f9a68662d9f44390d963..ea55e488e6dccddebfff2def5a3850532633aa14 100644 --- a/zh-cn/device-dev/kernel/kernel-small-overview.md +++ b/zh-cn/device-dev/kernel/kernel-small-overview.md @@ -30,6 +30,7 @@ OpenHarmony 轻量级内核是基于IoT领域轻量级物联网操作系统Huawe 轻量级内核主要由基础内核、扩展组件、HDF框架、POSIX接口组成。轻量级内核的文件系统、网络协议等扩展功能(没有像微内核那样运行在用户态)运行在内核地址空间,主要考虑组件之间直接函数调用比进程间通信或远程过程调用要快得多。 **图1** OpenHarmony LiteOS-A内核架构图 + ![zh-cn_image_0000001160018656](figures/zh-cn_image_0000001160018656.png) - 基础内核主要包括内核的基础机制,如调度、内存管理、中断异常等 diff --git a/zh-cn/device-dev/kernel/kernel-small-start-kernel.md b/zh-cn/device-dev/kernel/kernel-small-start-kernel.md index e8c305fcc3fe764a16b6e812c7c199037c28b376..b447eb81c69428f4b4e3795f71ab75dd47b03db7 100644 --- a/zh-cn/device-dev/kernel/kernel-small-start-kernel.md +++ b/zh-cn/device-dev/kernel/kernel-small-start-kernel.md @@ -10,6 +10,7 @@ **图1** 内核启动流程图 + ![zh-cn_image_0000001153832492](figures/zh-cn_image_0000001153832492.png) diff --git a/zh-cn/device-dev/kernel/kernel-small-start-user.md b/zh-cn/device-dev/kernel/kernel-small-start-user.md index 589d0266666f4f97df1f93c30459c649e982b708..e1d376bef41516854bc233a01758e3138fb9f042 100644 --- a/zh-cn/device-dev/kernel/kernel-small-start-user.md +++ b/zh-cn/device-dev/kernel/kernel-small-start-user.md @@ -10,6 +10,7 @@ 根进程是系统第一个用户态进程,进程ID为1,它是所有用户态进程的祖先。 **图1** 进程树示意图 + ![zh-cn_image_0000001178108019](figures/zh-cn_image_0000001178108019.png) @@ -47,19 +48,6 @@ LITE_USER_SEC_ENTRY VOID OsUserInit(VOID *args) ## 用户态程序运行 用户态程序常见编译方式有如下两种: -1. [利用框架编译用户态进程](../quick-start/quickstart-standard-running-rk3568-create.md)。 - -2. 手动编译 - 实例: - ``` - clang --target=arm-liteos --sysroot=prebuilts/lite/sysroot -o helloworld helloworld.c - ``` - - **clang**:参考[LLVM安装指导](../quick-start/quickstart-lite-package-environment.md#安装llvm-仅openharmony_v1-x分支-标签需要-)安装LLVM编译器。 - - **--target**:--target=arm-liteos,指定编译平台为arm-liteos。 - - **--sysroot**:--sysroot=${YOUR_ROOT_PATH}/prebuilts/lite/sysroot,指定头文件以及依赖标准库搜索路径为prebuilts下的指定路径。 用户态程序启动有如下常见方式: diff --git a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md index 795d9534a38a108150185689518a2263db889e1f..c804aa0e3964cf198664eaa59f9c484e94bd78d4 100644 --- a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md +++ b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md @@ -1413,7 +1413,7 @@ APP_FEATURE_INIT(AppEntry); }, ``` -## 兼容性认证 +## 兼容性测评 ### 产品兼容性规范 @@ -1456,7 +1456,7 @@ APP_FEATURE_INIT(AppEntry); ### 报告提交 -将上图`XTS`用例的情况保存为测试报告,上传到`OpenHarmony`兼容性测试网站进行认证,作为`sig`仓库转正到`master`仓库的必要条件。详细步骤如下: +将上图`XTS`用例的情况保存为测试报告,上传到`OpenHarmony`兼容性测试网站进行测评,作为`sig`仓库转正到`master`仓库的必要条件。详细步骤如下: 步骤1:将`XTS`测试报告压缩成`zip`文件。 diff --git a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md index 15adc37f7525d8167aa00896d658a9427dca0dcd..a46c494c890d4701030e79e85ed526b44ff2d40b 100644 --- a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md +++ b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md @@ -6,7 +6,7 @@ ## 编译环境搭建 -首先请搭建OpenHarmony基础环境,步骤请参考轻量和小型系统入门[linux环境搭建](../quick-start/quickstart-lite-package-environment.md)。用户态和LiteOS-A的内核态编译均使用llvm编译器编译,安装方法在搭建基础环境中已提供。若选择移植linux内核,请执行如下命令安装gcc-arm-linux-gnueabi交叉编译工具链,用于编译linux内核态镜像: +首先请搭建OpenHarmony基础环境,步骤请参考轻量和小型系统入门[linux环境搭建](../quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md)。用户态和LiteOS-A的内核态编译均使用llvm编译器编译,安装方法在搭建基础环境中已提供。若选择移植linux内核,请执行如下命令安装gcc-arm-linux-gnueabi交叉编译工具链,用于编译linux内核态镜像: ``` sudo apt-get install gcc-arm-linux-gnueabi diff --git a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md index 6800ba882e2a34476c4aeafa6e4f107af8cb0a9b..aa82bc3e8ecd190233c23021ec6a121987b8c19d 100644 --- a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md +++ b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md @@ -227,7 +227,7 @@ CMake方式可通过指定工具链进行交叉编译,修改并编译该库, 1. 搭建OpenHarmony环境 - 以hi3518ev300为例,编译出OpenHarmony镜像,烧写到开发板,参考[开发Hi3518第一个示例程序](../quick-start/quickstart-lite-steps-hi3518-running.md)。 + 以hi3516ev300为例,编译出OpenHarmony镜像,烧写到开发板,参考[开发Hi3516第一个示例程序](../quick-start/quickstart-ide-lite-steps-hi3516-running.md)。 进入系统如下所示: diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index 2e6f75717127b19bd89a7154c6759460739bee5c..623dbf6c1335167f117d457d2dedf2bbbdaeb728 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -1,64 +1,45 @@ # 快速入门 - -- [轻量和小型系统入门](quickstart-lite.md) - - [轻量与小型系统入门概述](quickstart-lite-overview.md) - - [搭建轻量与小型系统环境](quickstart-lite-env-setup.md) - - [搭建系统环境概述](quickstart-lite-env-setup-overview.md) - - [开发环境准备](quickstart-lite-env-prepare.md) - - [获取源码](quickstart-lite-sourcecode-acquire.md) - - [使用安装包方式搭建编译环境](quickstart-lite-package-environment.md) - - [使用Docker方式搭建编译环境](quickstart-lite-docker-environment.md) - - [常见问题](quickstart-lite-env-setup-faqs.md) - - - [运行“Hello World”](quickstart-lite-steps.md) - - [Hi3861开发板](quickstart-lite-steps-hi3861.md) - - [安装开发板环境](quickstart-lite-steps-hi3861-setting.md) - - [新建应用程序](quickstart-lite-steps-hi3861-application-framework.md) - - [编译](quickstart-lite-steps-hi3861-building.md) - - [烧录](quickstart-lite-steps-hi3861-burn.md) - - [调试验证](quickstart-lite-steps-hi3861-debug.md) - - [运行](quickstart-lite-steps-hi3861-running.md) - - [常见问题](quickstart-lite-steps-hi3861-faqs.md) - - - [Hi3516开发板](quickstart-lite-steps-hi3516.md) - - [安装开发板环境](quickstart-lite-steps-hi3516-setting.md) - - [新建应用程序](quickstart-lite-steps-hi3516-application-framework.md) - - [编译](quickstart-lite-steps-hi3516-building.md) - - [烧录](quickstart-lite-steps-hi3516-burn.md) - - [运行](quickstart-lite-steps-hi3516-running.md) - - [常见问题](quickstart-lite-steps-hi3516-faqs.md) - - - [Hi3518开发板](quickstart-lite-steps-hi3518.md) - - [安装开发板环境](quickstart-lite-steps-hi3518-setting.md) - - [新建应用程序](quickstart-lite-steps-hi3518-application-framework.md) - - [编译](quickstart-lite-steps-hi3518-building.md) - - [烧录](quickstart-lite-steps-hi3518-burn.md) - - [运行](quickstart-lite-steps-hi3518-running.md) - - [常见问题](quickstart-lite-steps-hi3518-faqs.md) - - - [附录](quickstart-lite-introduction.md) - - [Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md) - - [Hi3518开发板介绍](quickstart-lite-introduction-hi3518.md) - -- [标准系统入门](quickstart-standard.md) - - [标准系统入门简介](quickstart-standard-overview.md) - - [标准系统开发环境准备(仅Hi3516需要)](quickstart-standard-env-setup.md) - - [获取源码](quickstart-standard-sourcecode-acquire.md) - - [运行“Hello World”](quickstart-standard-running.md) - - [Hi3516开发板](quickstart-standard-running-hi3516.md) - - [创建应用程序](quickstart-standard-running-hi3516-create.md) - - [编译](quickstart-standard-running-hi3516-build.md) - - [烧录](quickstart-standard-running-hi3516-burn.md) - - [运行](quickstart-standard-running-hi3516-run.md) - - - [RK3568开发板](quickstart-standard-running-rk3568.md) - - [创建应用程序](quickstart-standard-running-rk3568-create.md) - - [编译](quickstart-standard-running-rk3568-build.md) - - [烧录](quickstart-standard-running-rk3568-burn.md) - - [运行](quickstart-standard-running-rk3568-run.md) - - - [常见问题](quickstart-standard-faqs.md) - - [附录](quickstart-standard-appendix.md) - - [Hi3516开发板介绍](quickstart-standard-appendix-hi3516.md) - - [RK3568开发板介绍](quickstart-standard-appendix-rk3568.md) \ No newline at end of file +- 轻量和小型系统快速入门 + - [轻量与小型系统入门概述](quickstart-ide-lite-overview.md) + - 准备轻量与小型系统环境 + - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-lite-env-setup-win-ubuntu.md) + - [获取源码](quickstart-ide-lite-sourcecode-acquire.md) + - [创建源码工程](quickstart-ide-lite-create-project.md) + - 运行“Hello World” + - Hi3861开发板 + - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3861-application-framework.md) + - [编译](quickstart-ide-lite-steps-hi3861-building.md) + - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) + - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) + - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) + - [运行](quickstart-ide-lite-steps-hi3816-running.md) + - Hi3516开发板 + - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-application-framework.md) + - [编译](quickstart-ide-lite-steps-hi3516-building.md) + - [烧录](quickstart-ide-lite-steps-hi3516-burn.md) + - [运行](quickstart-ide-lite-steps-hi3516-running.md) + - 附录 + - 开发板介绍 + - [Hi3861开发板介绍](quickstart-ide-lite-introduction-hi3861.md) + - [Hi3516开发板介绍](quickstart-ide-lite-introduction-hi3516.md) +- 标准系统快速入门 + - [标准系统入门概述](quickstart-ide-standard-overview.md) + - 准备标准系统环境 + - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-standard-env-setup-win-ubuntu.md) + - [获取源码](quickstart-ide-standard-sourcecode-acquire.md) + - [创建源码工程](quickstart-ide-standard-create-project.md) + - 运行“Hello World” + - Hi3516开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-hi3516-create.md) + - [编译](quickstart-ide-standard-running-hi3516-build.md) + - [烧录](quickstart-ide-standard-running-hi3516-burning.md) + - [运行](quickstart-ide-standard-running-hi3516-running.md) + - RK3568开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) + - [编译](quickstart-ide-standard-running-rk3568-build.md) + - [烧录](quickstart-ide-standard-running-rk3568-burning.md) + - [运行](quickstart-ide-standard-running-rk3568-running.md) + - 附录 + - 开发板介绍 + - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) + - [RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md) diff --git a/zh-cn/device-dev/quick-start/figures/1-11.png b/zh-cn/device-dev/quick-start/figures/1-11.png deleted file mode 100644 index 8ed1535a6bc23dc5bd02fbd5a3f1392f46ad8d83..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/1-11.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/1.png b/zh-cn/device-dev/quick-start/figures/1.png deleted file mode 100644 index 791dfeae272070b7e285ea3070ebd3b1e9100eb5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/1.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/10.png b/zh-cn/device-dev/quick-start/figures/10.png deleted file mode 100644 index 3b7f6f4766c54f6ca1e0057fc8f869785cc63e56..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/10.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/2021-01-27_170334-10.png b/zh-cn/device-dev/quick-start/figures/2021-01-27_170334-10.png deleted file mode 100644 index 5b573a4ddfe89fe25cb1b567736823244fdb9e97..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/2021-01-27_170334-10.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/2021-01-27_170334.png b/zh-cn/device-dev/quick-start/figures/2021-01-27_170334.png deleted file mode 100644 index 5b573a4ddfe89fe25cb1b567736823244fdb9e97..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/2021-01-27_170334.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/3-0.png b/zh-cn/device-dev/quick-start/figures/3-0.png deleted file mode 100644 index f354b2d27ce06bd5af6a8702c0894bf5c50a97bb..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/3-0.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/3.png b/zh-cn/device-dev/quick-start/figures/3.png deleted file mode 100644 index 91f3fa22153f501e308fab46f92f2e95995f1917..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/3.png and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/3516\346\255\243\351\235\242.png" "b/zh-cn/device-dev/quick-start/figures/3516\346\255\243\351\235\242.png" deleted file mode 100644 index 6975fb5fef92e35dec2de84b7e7035a39794bdf4..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/3516\346\255\243\351\235\242.png" and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/4.png b/zh-cn/device-dev/quick-start/figures/4.png deleted file mode 100644 index 3f5fa2829949e59d498da9dd5ff1f48fa0647cf1..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/4.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/5.png b/zh-cn/device-dev/quick-start/figures/5.png deleted file mode 100644 index f3a76a6922315fe595ae4214331ce322766b3b48..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/5.png and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3516\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" "b/zh-cn/device-dev/quick-start/figures/Hi3516\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" deleted file mode 100644 index 6975fb5fef92e35dec2de84b7e7035a39794bdf4..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/Hi3516\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3518EV300\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" "b/zh-cn/device-dev/quick-start/figures/Hi3518EV300\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" deleted file mode 100755 index 93cadcb6edf9d8b4d701faf7e070f74cc09ef553..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/Hi3518EV300\345\215\225\346\235\277\346\255\243\351\235\242\345\244\226\350\247\202\345\233\276.png" and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3518\346\255\243\350\203\214\351\235\242.png" "b/zh-cn/device-dev/quick-start/figures/Hi3518\346\255\243\350\203\214\351\235\242.png" deleted file mode 100644 index 3e0ff2fdbfbaca179f1320b5d53ebf755d1c84a3..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/Hi3518\346\255\243\350\203\214\351\235\242.png" and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3518\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" "b/zh-cn/device-dev/quick-start/figures/Hi3518\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" deleted file mode 100644 index ffdeca24f4b017d7a35fc96999d04faaa09972e5..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/Hi3518\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/RK3568\345\274\200\345\217\221\346\235\277\346\255\243\351\235\242.png" "b/zh-cn/device-dev/quick-start/figures/RK3568\345\274\200\345\217\221\346\235\277\346\255\243\351\235\242.png" deleted file mode 100644 index fbd3cb48f2cb35c02595be0293733644e16020bd..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/RK3568\345\274\200\345\217\221\346\235\277\346\255\243\351\235\242.png" and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/Snap22.png b/zh-cn/device-dev/quick-start/figures/Snap22.png deleted file mode 100644 index d94579cb7ff78a40cef6cf5d1945e742a9551e8b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/Snap22.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/Snap23.png b/zh-cn/device-dev/quick-start/figures/Snap23.png deleted file mode 100644 index 92e51762a2dcd636135f6e7856073a5b8aecd1d6..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/Snap23.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/Snap24.png b/zh-cn/device-dev/quick-start/figures/Snap24.png deleted file mode 100644 index d4996e347660921fc3f723e5b48942f1fd6636f5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/Snap24.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/button.png b/zh-cn/device-dev/quick-start/figures/button.png deleted file mode 100755 index 686385e096a24ec1906169d2b11f75030c386b9f..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/button.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/deveco-device-tool-install-sucessful.png b/zh-cn/device-dev/quick-start/figures/deveco-device-tool-install-sucessful.png deleted file mode 100644 index 0a54838f89062fd67328ef76e4a1cf770c6aee13..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/deveco-device-tool-install-sucessful.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3516-burning-succeeded-net.png b/zh-cn/device-dev/quick-start/figures/hi3516-burning-succeeded-net.png deleted file mode 100644 index 67d8044b72056d4ed6230ccc4ad99d5e954596b6..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3516-burning-succeeded-net.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3516-import-projects.png b/zh-cn/device-dev/quick-start/figures/hi3516-import-projects.png deleted file mode 100644 index 6c575b3495a0503e463a71f2b50766bc2f3e1b94..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3516-import-projects.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3516-restart-the-development-board.png b/zh-cn/device-dev/quick-start/figures/hi3516-restart-the-development-board.png deleted file mode 100644 index 281958fe76a787acc5d0b98f5ea248fa5abf2405..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3516-restart-the-development-board.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3516-upload-start-burning.png b/zh-cn/device-dev/quick-start/figures/hi3516-upload-start-burning.png deleted file mode 100644 index fb2db198cc61ed10136f0e3382deed352300a62b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3516-upload-start-burning.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3518-bootloader.png b/zh-cn/device-dev/quick-start/figures/hi3518-bootloader.png deleted file mode 100644 index 2d67376af75fa7693ed16299de75255c08178c14..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3518-bootloader.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3518-import-projects.png b/zh-cn/device-dev/quick-start/figures/hi3518-import-projects.png deleted file mode 100644 index d54cd737e32311492dc2058251e7cb8acf905fb5..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3518-import-projects.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3518-monitor.png b/zh-cn/device-dev/quick-start/figures/hi3518-monitor.png deleted file mode 100644 index d287df0c64ca5e2ffc27aa1acd820cdf0e6b40c6..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3518-monitor.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3518-reset-success.png b/zh-cn/device-dev/quick-start/figures/hi3518-reset-success.png deleted file mode 100644 index 8e3d4e7d2a36e2b880f592ec88b01b6c4bef07cc..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3518-reset-success.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3861-burning-succeeded.png b/zh-cn/device-dev/quick-start/figures/hi3861-burning-succeeded.png deleted file mode 100755 index 3628f3f4778012a577d4ee28c703669eb5533594..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3861-burning-succeeded.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3861-import-projects.png b/zh-cn/device-dev/quick-start/figures/hi3861-import-projects.png deleted file mode 100644 index 6eaa9eb2450ef15e7124df610712fc797c548351..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3861-import-projects.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3861-record-the-serial-port-number.png b/zh-cn/device-dev/quick-start/figures/hi3861-record-the-serial-port-number.png deleted file mode 100755 index 43496f076a463ec6fbf320b358a32505284ff40f..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3861-record-the-serial-port-number.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hi3861-upload.png b/zh-cn/device-dev/quick-start/figures/hi3861-upload.png deleted file mode 100644 index 8dde7632636856203030c2abf0867f03abaafcba..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hi3861-upload.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/hisilicon-arm-linux.png b/zh-cn/device-dev/quick-start/figures/hisilicon-arm-linux.png deleted file mode 100644 index 114a8e1c31ab1a58ece6b0d1e00d673256b42b2b..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/hisilicon-arm-linux.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/import-project.png b/zh-cn/device-dev/quick-start/figures/import-project.png deleted file mode 100644 index 5ba534eaf39165891a31c7837ae7ff4126f6414c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/import-project.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/ip-address-information.png b/zh-cn/device-dev/quick-start/figures/ip-address-information.png deleted file mode 100644 index 72dd05e3ae1eb91156df98cb1915b6264b3bbe5a..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/ip-address-information.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/press-any-key-to-enter-the-system.gif b/zh-cn/device-dev/quick-start/figures/press-any-key-to-enter-the-system.gif deleted file mode 100644 index 5e0e2bec9e8ce82561047fe7d5f000e0d2c4f962..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/press-any-key-to-enter-the-system.gif and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/record-the-serial-port-number.png b/zh-cn/device-dev/quick-start/figures/record-the-serial-port-number.png deleted file mode 100644 index 09f33e3992c0c1d78713eea949e4b9a19f5802ec..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/record-the-serial-port-number.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/rk3568-helloworld.png b/zh-cn/device-dev/quick-start/figures/rk3568-helloworld.png deleted file mode 100644 index da22f3989b1daa362c7471789cdaa94ffb862f75..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/rk3568-helloworld.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001073838982.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001073838982.png deleted file mode 100644 index 0bbff7eb0b5ab322e8995acf2b86d93038c8530c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001073838982.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001074287476.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001074287476.png deleted file mode 100644 index 29a273e5115ffd7a0724cde58215ffb79827576c..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001074287476.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001075566984.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001075566984.png deleted file mode 100644 index dee491aaa290b425a4a6cd9e4aee61b3b05cc3dc..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001075566984.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001113969536.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001113969536.png deleted file mode 100644 index baac7b26450b8bc195a0db0bb3bb41119c0d9828..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001113969536.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001117329380.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001117329380.png deleted file mode 100644 index 7bd316dfd5a64c873682bf865a79ec1f2354cc40..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001117329380.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/import-project-confirm.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001135394334.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/import-project-confirm.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001135394334.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001163045527.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001163045527.png deleted file mode 100644 index d8ac531b8265f265e2bd25518b212143fc61e4cf..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001163045527.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/monitor.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001164506870.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/monitor.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001164506870.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171426014.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171426014.png new file mode 100644 index 0000000000000000000000000000000000000000..0a03074ea251b2e2b94ae8370a7d7fb01757f21d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171426014.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455564.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455564.png deleted file mode 100644 index c846be0d2767953df4a3ac78408963f252af040d..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455564.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171774086.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171774086.png deleted file mode 100644 index 1b002b247b704150040e90ecb149d782ba8db3a8..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171774086.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177301516.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177301516.png deleted file mode 100644 index 4cc2bbf53d65b0c66f07b330aa8881c5194328bd..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177301516.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177474882.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177474882.png deleted file mode 100644 index 68b1730cb6d1b91b6e364c7301d6dcc4c9976ec7..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177474882.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177478136.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177478136.png deleted file mode 100644 index fcaf25e47e2e47ecad8aebe463aeccdf1d8bf85e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177478136.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177480146.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177480146.png deleted file mode 100644 index 99ed8317b5cee8e5e9d460ff31d5c8a1a2fe343e..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177480146.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193533352.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193533352.png deleted file mode 100644 index da22f3989b1daa362c7471789cdaa94ffb862f75..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193533352.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png new file mode 100644 index 0000000000000000000000000000000000000000..378084aa4b6a467f549a6c97bde39c7720d6b427 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193920448.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png new file mode 100644 index 0000000000000000000000000000000000000000..216476f79ed241c3b77d7d2d688cb6fcdc1d8423 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001193983334.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194078294.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194078294.png deleted file mode 100644 index 35a95f501f5e3c5c8ebf187e7f29e6af0a4566b0..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194078294.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194080414.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194080414.png new file mode 100644 index 0000000000000000000000000000000000000000..014bd33ebc03f13666ece9abfd3636658cead3fc Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194080414.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194504874.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194504874.png new file mode 100644 index 0000000000000000000000000000000000000000..fdd12932d3777bd30a208e539a78ede6384cce19 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194504874.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634 - \345\211\257\346\234\254.png" "b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634 - \345\211\257\346\234\254.png" deleted file mode 100644 index 9f418473587db76e56981c0f384bf4b8634e3911..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634 - \345\211\257\346\234\254.png" and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634.png deleted file mode 100644 index 9f418473587db76e56981c0f384bf4b8634e3911..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194668634.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194821710.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194821710.png new file mode 100644 index 0000000000000000000000000000000000000000..17d64a31a527a2b7453cc8490655609bd338ad7c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194821710.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194984912.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194984912.png new file mode 100644 index 0000000000000000000000000000000000000000..3c8dca4d0e669c502404754a2685b5877513dda0 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001194984912.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001174595590.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198466090.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001174595590.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198466090.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177608370.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566364.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177608370.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198566364.png diff --git a/zh-cn/device-dev/quick-start/figures/hi3518-reboot-success.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198626874.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/hi3518-reboot-success.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198626874.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239348791.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198722374.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239348791.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198722374.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222994321.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198889702.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222994321.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198889702.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222999125.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198943768.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222999125.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001198943768.png diff --git a/zh-cn/device-dev/quick-start/figures/bootloader.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001209906547.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/bootloader.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001209906547.png diff --git a/zh-cn/device-dev/quick-start/figures/reset_success.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001210385161.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/reset_success.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001210385161.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215720398.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215720398.png new file mode 100644 index 0000000000000000000000000000000000000000..7d3cfad060738e0802619fc90017db774b6c0949 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215720398.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215737140.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215737140.png new file mode 100644 index 0000000000000000000000000000000000000000..393d6f7fbedfc3ad5556fd1ab23f5ee093a4d90f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215737140.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215743910.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215743910.png new file mode 100644 index 0000000000000000000000000000000000000000..2abb1d54a0ca92661418c44ea7b8338ede0c56ed Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215743910.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215878922.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215878922.png new file mode 100644 index 0000000000000000000000000000000000000000..8fa9d13fe838efe888dee5e645fdb9cbd67d84df Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215878922.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215879750.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215879750.png new file mode 100644 index 0000000000000000000000000000000000000000..9d2abb322f686beae3152cb08cf6ddf44da85052 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215879750.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215897530.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215897530.png new file mode 100644 index 0000000000000000000000000000000000000000..72dd27e9a926f6148201ce09cf66fdf52a8f58e0 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001215897530.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216274840.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216274840.png new file mode 100644 index 0000000000000000000000000000000000000000..c1816c41bceaeeca5385b6353ef94576db30d84a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216274840.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216440138.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216440138.png new file mode 100644 index 0000000000000000000000000000000000000000..119b63f736e3146a4c29ef39b6ba3f9ee590e578 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216440138.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216516128.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216516128.png new file mode 100644 index 0000000000000000000000000000000000000000..c1816c41bceaeeca5385b6353ef94576db30d84a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216516128.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216535397.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216535397.png deleted file mode 100644 index ad4fd618860ca9f79e9bdc39436c3b2f9cdb72de..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216535397.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693913.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693913.png deleted file mode 100644 index 1b002b247b704150040e90ecb149d782ba8db3a8..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693913.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693915.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693915.png deleted file mode 100644 index 9284df45bb1415d84f0325df85b4eb5c223281e8..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216693915.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216761476.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216761476.png new file mode 100644 index 0000000000000000000000000000000000000000..5d40e2fd4d1c8e51acfa232dff98bc0c7643f79f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216761476.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001217013865.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001217013865.png deleted file mode 100644 index b6bc36af5339ea5a4f67640e69836965b3776e17..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001217013865.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png new file mode 100644 index 0000000000000000000000000000000000000000..c3013a3f9bd3951e53e1f0848c12700024c5f5e8 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001220852754.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png new file mode 100644 index 0000000000000000000000000000000000000000..8d6c2de3aeeda000f6b0258f53de71e147ce5b27 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221012766.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221025048.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221025048.png new file mode 100644 index 0000000000000000000000000000000000000000..f17d2dd5dbc86b98a659218ed4a5e3a69409ae54 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221025048.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221036768.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221036768.png new file mode 100644 index 0000000000000000000000000000000000000000..369ec62f556fad6d1eee65d79c68cd1904dd9f43 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221036768.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221172710.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221172710.png new file mode 100644 index 0000000000000000000000000000000000000000..29b22463c375704734e6925861551aa27ec7b295 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221172710.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221344980.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221344980.png new file mode 100644 index 0000000000000000000000000000000000000000..7bf0acc41746926462ab3c352f143f90f2e65358 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221344980.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221356692.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221356692.png new file mode 100644 index 0000000000000000000000000000000000000000..8f5ee977c68bce18bed83887191ddf870df7d8e9 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001221356692.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222361042.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222361042.png new file mode 100644 index 0000000000000000000000000000000000000000..b9214e26adb933752fad2b983effb4cc655d2b84 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222361042.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222781271.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222781271.png deleted file mode 100644 index 8d396bf2fc7b36362a95c6719d202b2f057e4a46..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222781271.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222969587.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222969587.png deleted file mode 100644 index 1ba77b7feaca23043e71171824cdead7c4f8f108..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222969587.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222981447.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222981447.png deleted file mode 100644 index 6c862cc279d2936ddec4ecda0a23e1d55a63cbee..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222981447.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222997983.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222997983.png deleted file mode 100644 index f0d98bd6deb22fc7814a42630b8565d9b5979659..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222997983.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223000051.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223000051.png deleted file mode 100644 index 6117c80b45f64348ad307e64723495cdc8c45cb1..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223000051.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223185957.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223185957.png deleted file mode 100644 index 764643ce134811551984284ed5ec6b60943f8ea4..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223185957.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223190441.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223190441.png new file mode 100644 index 0000000000000000000000000000000000000000..63d053122f3c7beaa990f63431ccb16692562535 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001223190441.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001224173270.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001224173270.png new file mode 100644 index 0000000000000000000000000000000000000000..32669a1101e812fe29604d57a086ebc137dddf21 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001224173270.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001225760456.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001225760456.png new file mode 100644 index 0000000000000000000000000000000000000000..9e249959cad7e68b535f8732b44e20db9f6db2fc Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001225760456.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226034634.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226034634.png new file mode 100644 index 0000000000000000000000000000000000000000..ae7a0816ce444713af16d9d7b89a06b9689410ce Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226034634.png differ diff --git a/zh-cn/device-dev/quick-start/figures/start-the-system.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602238.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/start-the-system.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602238.png diff --git a/zh-cn/device-dev/quick-start/figures/rk3568-run-configuration.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602250.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/rk3568-run-configuration.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602250.png diff --git "a/zh-cn/device-dev/quick-start/figures/RK3568\345\274\200\345\217\221\346\235\277\350\203\214\351\235\242.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602394.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/RK3568\345\274\200\345\217\221\346\235\277\350\203\214\351\235\242.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602394.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602398.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602398.png new file mode 100644 index 0000000000000000000000000000000000000000..f1aa2e319290cf3700a49391c3f078092a80821e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602398.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\347\263\273\347\273\237\345\220\257\345\212\250\346\225\210\346\236\234\345\233\276.jpg" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602406.jpg similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\347\263\273\347\273\237\345\220\257\345\212\250\346\225\210\346\236\234\345\233\276.jpg" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602406.jpg diff --git a/zh-cn/device-dev/quick-start/figures/11.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602414.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/11.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226602414.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001185334336.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634668.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001185334336.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634668.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png new file mode 100644 index 0000000000000000000000000000000000000000..5e307225f0246c7d1afe8b949a8135b5a0e94a51 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634676.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3861\345\274\200\345\217\221\346\235\277\345\244\226\350\247\202\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634692.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/Hi3861\345\274\200\345\217\221\346\235\277\345\244\226\350\247\202\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634692.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png new file mode 100644 index 0000000000000000000000000000000000000000..8c6ec0adb87f693519f0e3b00b3aa7053f3e23ae Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634700.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3861\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634716.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/Hi3861\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634716.png diff --git "a/zh-cn/device-dev/quick-start/figures/\346\211\223\345\274\200\344\270\262\345\217\243\345\244\261\350\264\245\345\233\276-1.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634728.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\211\223\345\274\200\344\270\262\345\217\243\345\244\261\350\264\245\345\233\276-1.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634728.png diff --git "a/zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\351\230\262\347\201\253\345\242\231\350\256\276\347\275\256\345\233\276-6.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634732.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\351\230\262\347\201\253\345\242\231\350\256\276\347\275\256\345\233\276-6.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226634732.png diff --git a/zh-cn/device-dev/quick-start/figures/Save-the-parameter-settings.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762210.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/Save-the-parameter-settings.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762210.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg new file mode 100644 index 0000000000000000000000000000000000000000..31c5a26705cd1da6cf9cb6f3bb356994e4ecc22e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762222.jpg differ diff --git a/zh-cn/device-dev/quick-start/figures/open-the-serial-port-tool.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762374.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/open-the-serial-port-tool.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762374.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png new file mode 100644 index 0000000000000000000000000000000000000000..5006140f00ec1195d04297cdeb26ad935fb9f0e5 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226762378.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226764302.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226764302.png new file mode 100644 index 0000000000000000000000000000000000000000..2867669fa29196d144506268bd3480863933afd5 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226764302.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png new file mode 100644 index 0000000000000000000000000000000000000000..e674bafb0adaa4c0ff8efaf297ee52bab3165212 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794644.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794660.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794660.png new file mode 100644 index 0000000000000000000000000000000000000000..4829c4ecd911b02b1066790a85360aabb5492ec3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794660.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455566.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794688.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455566.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794688.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171615542.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794696.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171615542.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794696.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png new file mode 100644 index 0000000000000000000000000000000000000000..9d3bdbfe1eac9dc532496a7785e8caf99c41780b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226794704.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png new file mode 100644 index 0000000000000000000000000000000000000000..f1aa2e319290cf3700a49391c3f078092a80821e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922154.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922302.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922302.png new file mode 100644 index 0000000000000000000000000000000000000000..7e136511b44f7b758ed4830ab20e58905a7cf241 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922302.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\344\270\215\351\200\232-\345\215\225\346\235\277\346\227\240\346\263\225\350\216\267\345\217\226\346\226\207\344\273\266\345\233\276-5.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922306.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\344\270\215\351\200\232-\345\215\225\346\235\277\346\227\240\346\263\225\350\216\267\345\217\226\346\226\207\344\273\266\345\233\276-5.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922306.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png new file mode 100644 index 0000000000000000000000000000000000000000..504da23ba456a9c377525e22c4630361286b5dd7 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922310.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922318.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922318.png new file mode 100644 index 0000000000000000000000000000000000000000..e53a724993830b5d0e6e1e9871d99dfc99c55f11 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922318.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171615534.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922322.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171615534.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226922322.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png new file mode 100644 index 0000000000000000000000000000000000000000..4829c4ecd911b02b1066790a85360aabb5492ec3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954632.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276\346\230\257\345\220\246\345\255\230\345\234\250\345\215\240\347\224\250\344\270\262\345\217\243\347\232\204\347\273\210\347\253\257-2.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954644.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276\346\230\257\345\220\246\345\255\230\345\234\250\345\215\240\347\224\250\344\270\262\345\217\243\347\232\204\347\273\210\347\253\257-2.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954644.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954648.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954648.png new file mode 100644 index 0000000000000000000000000000000000000000..ebf4f8eba03720edddfb9ef8eb38bd5f71126f2a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001226954648.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png new file mode 100644 index 0000000000000000000000000000000000000000..6d350e5d4db03fecc5c1b8055b01cdf73667ed36 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082162.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png new file mode 100644 index 0000000000000000000000000000000000000000..e53a724993830b5d0e6e1e9871d99dfc99c55f11 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082182.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png new file mode 100644 index 0000000000000000000000000000000000000000..a56a33574b9766509dc8add6ba3a1ecc578fe92c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082314.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\351\230\262\347\201\253\345\242\231\350\256\276\347\275\256\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082322.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\351\230\262\347\201\253\345\242\231\350\256\276\347\275\256\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082322.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png new file mode 100644 index 0000000000000000000000000000000000000000..527fe8b9836daf35c8300e0e84bdb2ca390f85a5 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227082334.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png new file mode 100644 index 0000000000000000000000000000000000000000..67e50038e79cf0f7c2a6bd79b48c63b7557179a4 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114584.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png new file mode 100644 index 0000000000000000000000000000000000000000..ebf4f8eba03720edddfb9ef8eb38bd5f71126f2a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114612.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png new file mode 100644 index 0000000000000000000000000000000000000000..a56a33574b9766509dc8add6ba3a1ecc578fe92c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114628.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171934032.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114636.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171934032.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114636.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png new file mode 100644 index 0000000000000000000000000000000000000000..ff9105c313d5755f140920bbfc2399e3ccb5e2f5 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114640.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png new file mode 100644 index 0000000000000000000000000000000000000000..8c6ec0adb87f693519f0e3b00b3aa7053f3e23ae Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227114644.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227277128.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227277128.png new file mode 100644 index 0000000000000000000000000000000000000000..fd2a5588e6576449bcb9ec1f92a12649dcd6c5d0 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227277128.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227549226.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227549226.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227549226.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711014.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711014.png new file mode 100644 index 0000000000000000000000000000000000000000..7cc145edaa4ec883d4090febcf38fec14b35b46f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711014.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711882.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711882.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227711882.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227712350.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227712350.png new file mode 100644 index 0000000000000000000000000000000000000000..0e1bebbb79fd4281b41173171d4a96fb0e84c166 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227712350.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227757036.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227757036.png new file mode 100644 index 0000000000000000000000000000000000000000..c354bdb69c0293fd19cb71905f828fca1fe7d09c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001227757036.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png new file mode 100644 index 0000000000000000000000000000000000000000..e9127be45474fa5d254a8444bc96d34ec8798108 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001237801283.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238760373.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238760373.png new file mode 100644 index 0000000000000000000000000000000000000000..97111fcc9b48ba155466930d3dc00a6f45c13b8b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238760373.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238880335.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238880335.png new file mode 100644 index 0000000000000000000000000000000000000000..63a15bf3fbf9cd40422878607655443f6addc335 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238880335.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239080359.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239080359.png new file mode 100644 index 0000000000000000000000000000000000000000..3160087388750499cbfcb6d12979fd9d7a33e410 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239080359.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239221905.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239221905.png new file mode 100644 index 0000000000000000000000000000000000000000..04a5b8220042d6025e1866c51796f75dd9cb55f1 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239221905.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239226427.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239226427.png deleted file mode 100644 index c1682cf47759f73fb37d266140789c0d75d9d8d2..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239226427.png and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png new file mode 100644 index 0000000000000000000000000000000000000000..b9b0c15345138b5d784e027330b650e16b97ee4e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239275843.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239634067.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239634067.png new file mode 100644 index 0000000000000000000000000000000000000000..e6bc8d9c83c45f71ad7ea181903503a9c8d4eb3b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239634067.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239650137.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239650137.png new file mode 100644 index 0000000000000000000000000000000000000000..204894213329c4de1edf74d869c1bfd8e8e78d04 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239650137.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239661509.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239661509.png new file mode 100644 index 0000000000000000000000000000000000000000..c3f10040538814eccbecf2ef37d472d59743e08f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001239661509.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222794413.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243290907.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001222794413.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243290907.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238878219.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243641075.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001238878219.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243641075.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177798424.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243704061.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001177798424.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001243704061.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260519729.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260519729.png new file mode 100644 index 0000000000000000000000000000000000000000..b34a869072221246762fe4bf430b74a2e601792e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260519729.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260919759.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260919759.png new file mode 100644 index 0000000000000000000000000000000000000000..4faf554e6df1789b66a1fdc1017423497dbf5362 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001260919759.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261315939.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261315939.png new file mode 100644 index 0000000000000000000000000000000000000000..1c6100e34e0d37e937742da452fe9ff6fbf9dab2 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261315939.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png new file mode 100644 index 0000000000000000000000000000000000000000..349188d5e1a6e11772c88615dc00deffc8dd39b7 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261395999.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261515989.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261515989.png new file mode 100644 index 0000000000000000000000000000000000000000..aa41b99e1141cb361782dce26180fc118fd86442 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001261515989.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265492885.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265492885.png new file mode 100644 index 0000000000000000000000000000000000000000..7cc6ca102383151b5b67447332e73fc16c5ef85e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265492885.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265505181.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265505181.png new file mode 100644 index 0000000000000000000000000000000000000000..eff6401bb39152c2d02b7f17e557b1cd5dbb0e87 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265505181.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png new file mode 100644 index 0000000000000000000000000000000000000000..93be7d7b91882bc5d372fe465a0d3a8b2972371f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png new file mode 100644 index 0000000000000000000000000000000000000000..4c1ce174731a8e20b62d119cbe1728e9a8394176 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265652869.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265665157.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265665157.png new file mode 100644 index 0000000000000000000000000000000000000000..0a574b8ee51edd1f4049e5ca6821a9347a45c2de Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265665157.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265676877.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265676877.png new file mode 100644 index 0000000000000000000000000000000000000000..a87d8c651147e1b7cb1f3d60513a6b3139540399 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265676877.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png new file mode 100644 index 0000000000000000000000000000000000000000..659d732a4d044cfa4dacb84c5ec96bfc6b29707e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265772913.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265785209.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265785209.png new file mode 100644 index 0000000000000000000000000000000000000000..0e5a65d7765d8bc936ca9a2d7db12f3adeffd831 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265785209.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265945173.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265945173.png new file mode 100644 index 0000000000000000000000000000000000000000..f2447dd8f49268594e781e1c68751b209e01894c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265945173.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265956897.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265956897.png new file mode 100644 index 0000000000000000000000000000000000000000..671c269d4f497fe7bda04bb2e21d3ede4f474399 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265956897.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001267231481.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001267231481.png new file mode 100644 index 0000000000000000000000000000000000000000..f931e2cfba06791a3891248c5d8e6a9f0e86bf0e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001267231481.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268653461.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268653461.png new file mode 100644 index 0000000000000000000000000000000000000000..90cf63342d2ebaf5ae348117f19f713247a5b554 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001268653461.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270076961.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270076961.png new file mode 100644 index 0000000000000000000000000000000000000000..97d98319b294e132d43cd4f75a2cc8031995b99f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270076961.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270356233.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270356233.png new file mode 100644 index 0000000000000000000000000000000000000000..d45442dd53b2c38c44b91dede158abec7e1bf231 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001270356233.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202289.gif b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202289.gif new file mode 100644 index 0000000000000000000000000000000000000000..52b3511bd7ec50a86e9b348aecfb1704dae36188 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202289.gif differ diff --git "a/zh-cn/device-dev/quick-start/figures/\351\230\262\347\201\253\345\242\231\345\222\214\347\275\221\347\273\234\344\277\235\346\212\244\347\225\214\351\235\242\345\233\276-7.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202457.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\351\230\262\347\201\253\345\242\231\345\222\214\347\275\221\347\273\234\344\277\235\346\212\244\347\225\214\351\235\242\345\233\276-7.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202457.png diff --git "a/zh-cn/device-dev/quick-start/figures/\346\211\223\345\274\200\344\270\262\345\217\243\345\244\261\350\264\245\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202461.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\211\223\345\274\200\344\270\262\345\217\243\345\244\261\350\264\245\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202461.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png new file mode 100644 index 0000000000000000000000000000000000000000..f1aa2e319290cf3700a49391c3f078092a80821e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202465.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\345\205\263\351\227\255\344\270\262\345\217\243\347\273\210\347\253\257-3.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202469.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\345\205\263\351\227\255\344\270\262\345\217\243\347\273\210\347\253\257-3.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202469.png diff --git "a/zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276\346\230\257\345\220\246\345\255\230\345\234\250\345\215\240\347\224\250\344\270\262\345\217\243\347\232\204\347\273\210\347\253\257.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202473.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276\346\230\257\345\220\246\345\255\230\345\234\250\345\215\240\347\224\250\344\270\262\345\217\243\347\232\204\347\273\210\347\253\257.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271202473.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png new file mode 100644 index 0000000000000000000000000000000000000000..bc935a8970e39629d2c93f6b92f96c5fa7d1a49b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234705.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png new file mode 100644 index 0000000000000000000000000000000000000000..e53a724993830b5d0e6e1e9871d99dfc99c55f11 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234717.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png new file mode 100644 index 0000000000000000000000000000000000000000..7de3c25e7ef2abc8d85d8bc945249f571f6bf0c3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234729.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/SCons\345\256\211\350\243\205\346\210\220\345\212\237\347\225\214\351\235\242-\347\211\210\346\234\254\350\246\201\346\261\2023-0-4\344\273\245\344\270\212.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234749.png old mode 100755 new mode 100644 similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/SCons\345\256\211\350\243\205\346\210\220\345\212\237\347\225\214\351\235\242-\347\211\210\346\234\254\350\246\201\346\261\2023-0-4\344\273\245\344\270\212.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234749.png diff --git "a/zh-cn/device-dev/quick-start/figures/U-boot\347\203\247\345\206\231\345\256\214\346\210\220\344\270\262\345\217\243\346\230\276\347\244\272\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234753.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/U-boot\347\203\247\345\206\231\345\256\214\346\210\220\344\270\262\345\217\243\346\230\276\347\244\272\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234753.png diff --git "a/zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\344\270\215\351\200\232-\345\215\225\346\235\277\346\227\240\346\263\225\350\216\267\345\217\226\346\226\207\344\273\266\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234757.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\347\275\221\347\273\234\344\270\215\351\200\232-\345\215\225\346\235\277\346\227\240\346\263\225\350\216\267\345\217\226\346\226\207\344\273\266\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234757.png diff --git "a/zh-cn/device-dev/quick-start/figures/\345\205\263\351\227\255\344\270\262\345\217\243\347\273\210\347\253\257.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234761.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\345\205\263\351\227\255\344\270\262\345\217\243\347\273\210\347\253\257.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234761.png diff --git "a/zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276Visual-Studio-Code\345\272\224\347\224\250\345\233\276-8.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234765.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276Visual-Studio-Code\345\272\224\347\224\250\345\233\276-8.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234765.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234769.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234769.png new file mode 100644 index 0000000000000000000000000000000000000000..02f74a108d5223682d57dc2e18aaefc3d31e6518 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234769.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png new file mode 100644 index 0000000000000000000000000000000000000000..e53a724993830b5d0e6e1e9871d99dfc99c55f11 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271234773.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237241.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237241.png new file mode 100644 index 0000000000000000000000000000000000000000..caa9309b7f069597073ffa593a7fbc6820b4b2e9 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271237241.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png new file mode 100644 index 0000000000000000000000000000000000000000..f1aa2e319290cf3700a49391c3f078092a80821e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322277.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png new file mode 100644 index 0000000000000000000000000000000000000000..8baa9c7c75625c18979d30ab52b2a0f64e0e8349 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322293.png differ diff --git a/zh-cn/device-dev/quick-start/figures/setenv-bootargs.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322437.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/setenv-bootargs.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271322437.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354693.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354693.png new file mode 100644 index 0000000000000000000000000000000000000000..02f74a108d5223682d57dc2e18aaefc3d31e6518 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354693.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png new file mode 100644 index 0000000000000000000000000000000000000000..a8037d1ebc95a3c9383d87678981b3ae5ccc8144 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354733.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171774098.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354745.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171774098.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354745.png diff --git "a/zh-cn/device-dev/quick-start/figures/\351\230\262\347\201\253\345\242\231\345\222\214\347\275\221\347\273\234\344\277\235\346\212\244\347\225\214\351\235\242\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354749.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\351\230\262\347\201\253\345\242\231\345\222\214\347\275\221\347\273\234\344\277\235\346\212\244\347\225\214\351\235\242\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271354749.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png new file mode 100644 index 0000000000000000000000000000000000000000..c728580c57510fa2fe67a7e337492adae328d7ea Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442261.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif new file mode 100644 index 0000000000000000000000000000000000000000..52b3511bd7ec50a86e9b348aecfb1704dae36188 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442265.gif differ diff --git "a/zh-cn/device-dev/quick-start/figures/\345\205\201\350\256\270Visual-Studio-Code\345\272\224\347\224\250\350\256\277\351\227\256\347\275\221\347\273\234-9.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442273.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\345\205\201\350\256\270Visual-Studio-Code\345\272\224\347\224\250\350\256\277\351\227\256\347\275\221\347\273\234-9.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271442273.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png new file mode 100644 index 0000000000000000000000000000000000000000..53cbcb8b0d0c30cb289b746d20b6c73927019d1a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271448821.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png new file mode 100644 index 0000000000000000000000000000000000000000..5086d2b4518cfea4040f3cc243abb2e6087af350 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474569.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001217013871.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474573.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001217013871.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474573.png diff --git "a/zh-cn/device-dev/quick-start/figures/\345\205\201\350\256\270Visual-Studio-Code\345\272\224\347\224\250\350\256\277\351\227\256\347\275\221\347\273\234.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474585.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\345\205\201\350\256\270Visual-Studio-Code\345\272\224\347\224\250\350\256\277\351\227\256\347\275\221\347\273\234.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271474585.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271477045.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271532317.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271532317.png new file mode 100644 index 0000000000000000000000000000000000000000..ad87d810ad5c3ea136c05c8cb36096c3250ca91c Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271532317.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png new file mode 100644 index 0000000000000000000000000000000000000000..5e307225f0246c7d1afe8b949a8135b5a0e94a51 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562257.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png new file mode 100644 index 0000000000000000000000000000000000000000..802cce4e760102043f177cb2fa71e8bd16539ba1 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562269.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562277.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562277.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562277.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562433.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562433.png new file mode 100644 index 0000000000000000000000000000000000000000..e828c808f0fae09773a8408647a9e5386e4d6c21 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562433.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png new file mode 100644 index 0000000000000000000000000000000000000000..47231369bbeb827e70a8720b7a3d03ac58fad0c3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562437.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276Visual-Studio-Code\345\272\224\347\224\250\345\233\276.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562445.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/\346\237\245\346\211\276Visual-Studio-Code\345\272\224\347\224\250\345\233\276.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562445.png diff --git a/zh-cn/device-dev/quick-start/figures/changjian1-4.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562449.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/changjian1-4.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562449.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216535401.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562453.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001216535401.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271562453.png diff --git a/zh-cn/device-dev/quick-start/figures/reboot_success.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594709.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/reboot_success.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594709.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png new file mode 100644 index 0000000000000000000000000000000000000000..9d3bdbfe1eac9dc532496a7785e8caf99c41780b Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594733.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/Hi3516\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594749.png similarity index 100% rename from "zh-cn/device-dev/quick-start/figures/Hi3516\347\274\226\350\257\221\350\256\276\347\275\256\345\233\276\344\276\213-Docker\346\226\271\345\274\217.png" rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594749.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455574.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594753.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001171455574.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594753.png diff --git a/zh-cn/device-dev/quick-start/figures/changjian1.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594765.png similarity index 100% rename from zh-cn/device-dev/quick-start/figures/changjian1.png rename to zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271594765.png diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271791385.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271791385.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271791385.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271912277.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271912277.png new file mode 100644 index 0000000000000000000000000000000000000000..53cbcb8b0d0c30cb289b746d20b6c73927019d1a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001271912277.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272032361.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272032361.png new file mode 100644 index 0000000000000000000000000000000000000000..c55a6ddd1aa319adfa05987ff3f5c79231e7208d Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272032361.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272109325.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272109325.png new file mode 100644 index 0000000000000000000000000000000000000000..caa9309b7f069597073ffa593a7fbc6820b4b2e9 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001272109325.png differ diff --git "a/zh-cn/device-dev/quick-start/figures/\346\240\207\345\207\206\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" "b/zh-cn/device-dev/quick-start/figures/\346\240\207\345\207\206\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" deleted file mode 100644 index cb0aff9ea08110a305f663126f5e26f150f89344..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/\346\240\207\345\207\206\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" and /dev/null differ diff --git "a/zh-cn/device-dev/quick-start/figures/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" "b/zh-cn/device-dev/quick-start/figures/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" deleted file mode 100644 index c453bf36bea44aad382c65cd18ea0d8abbead981..0000000000000000000000000000000000000000 Binary files "a/zh-cn/device-dev/quick-start/figures/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\277\253\351\200\237\345\205\245\351\227\250\346\265\201\347\250\213.png" and /dev/null differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-caution.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-caution.gif differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-danger.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-danger.gif differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-note.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-note.gif differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-notice.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-notice.gif differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-tip.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-tip.gif differ diff --git a/zh-cn/device-dev/quick-start/public_sys-resources/icon-warning.gif b/zh-cn/device-dev/quick-start/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/quick-start/public_sys-resources/icon-warning.gif differ diff --git a/zh-cn/device-dev/quick-start/quickstart-docker-lite.md b/zh-cn/device-dev/quick-start/quickstart-docker-lite.md new file mode 100644 index 0000000000000000000000000000000000000000..aafc6e81655de9c5e21aebfd2d9a73aa6b788f25 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-docker-lite.md @@ -0,0 +1,13 @@ +# 轻量和小型系统快速入门(安装包方式) + + + +- **[轻量与小型系统入门概述](quickstart-lite-overview.md)** + +- **[搭建轻量与小型系统环境](quickstart-lite-env-setup.md)** + +- **[运行“Hello World”](quickstart-lite-steps.md)** + +- **[常见问题](quickstart-lite-env-setup-faqs.md)** + +- **[附录](quickstart-lite-appendix.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md new file mode 100644 index 0000000000000000000000000000000000000000..058be22d4b7ea1bba2a7b1b0334fd7075c522977 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md @@ -0,0 +1,5 @@ +# 附录 + + + +- **[开发板介绍](quickstart-ide-lite-board-introduction.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-board-introduction.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-board-introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..42af216304448d111ca6513bcd57f5c8df5e41f3 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-board-introduction.md @@ -0,0 +1,7 @@ +# 开发板介绍 + + + +- **[Hi3861开发板介绍](quickstart-ide-lite-introduction-hi3861.md)** + +- **[Hi3516开发板介绍](quickstart-ide-lite-introduction-hi3516.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md new file mode 100644 index 0000000000000000000000000000000000000000..2b1f2a549d7c82bd5517f482e3b6aa35b0444098 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-create-project.md @@ -0,0 +1,35 @@ +# 创建源码工程 + + +在完成[搭建Windows+Ubuntu混合开发环境](../quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md)和[获取源码](../quick-start/quickstart-ide-lite-sourcecode-acquire.md)后,您需要在Windows环境中按照如下步骤创建源码工程。 + + +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 + + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) + +2. 选择要导入的源码目录,点击**Import**打开。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 + + ![zh-cn_image_0000001271477045](figures/zh-cn_image_0000001271477045.png) + +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) + +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 + + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) + +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。下图以导入wifiiot_hispark_pegasus为例进行说明。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - Hi3861开发板Product选择“wifiiot_hispark_pegasus”。 + > + > - Hi3516DV300开发板Product选择“ipcamera_hispark_taurus”。 + + ![zh-cn_image_0000001271237241](figures/zh-cn_image_0000001271237241.png) + +6. 点击**Open**打开工程或源码。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md new file mode 100644 index 0000000000000000000000000000000000000000..a33608c7a17421b99bfb8ddca7b3eb5acdae9645 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md @@ -0,0 +1,204 @@ +# 搭建Windows+Ubuntu混合开发环境 + + +通常在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,需要使用Ubuntu的编译环境对源码进行编译。 + + +在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 + + +## 系统要求 + +- Windows系统要求:Windows10 64位系统。 + +- Ubuntu系统要求:Ubuntu20.04及以上版本,内存推荐16 GB及以上。 + +- Windows系统和Ubuntu系统的用户名不能包含中文字符。 + +- Windows和Ubuntu系统上安装的DevEco Device Tool为3.0 Release版本。 + + +## 搭建Ubuntu环境 + +在Windows+Ubuntu混合开发环境场景中,在Ubuntu系统上可以不用安装Visual Studio Code,这种情况下,Ubuntu环境中就没有DevEco Device Tool的可视化操作界面。如果需要使用到Ubuntu下的DevEco Device Tool可视化操作界面,环境搭建请参考[搭建Ubuntu开发环境](https://device.harmonyos.com/cn/docs/documentation/guide/ide-install-ubuntu-0000001072959308)。 + +1. 将Ubuntu Shell环境修改为bash。 + + 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 + + ``` + ls -l /bin/sh + ``` + + ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) + + 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 + + ``` + sudo dpkg-reconfigure dash + ``` + + ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) + +2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Linux版本。 + +3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 + + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.400.zip为软件包名称,请根据实际进行修改。 + + ``` + unzip devicetool-linux-tool-3.0.0.400.zip + ``` + + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + ``` + chmod u+x devicetool-linux-tool-3.0.0.400.sh + ``` + +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 安装过程中,会自动检查Python是否安装,且要求Python为3.8~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 + + + ``` + sudo ./devicetool-linux-tool-3.0.0.400.sh + ``` + + 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 + + ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) + + +## 搭建Windows开发环境 + +通过Windows系统远程访问Ubuntu环境,需要先在Windows系统中安装DevEco Device Tool,以便使用Windows平台的DevEco Device Tool可视化界面进行相关操作。 + +1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Windows版。 + +2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 + +3. 设置DevEco Device Tool的安装路径,建议安装到非系统盘符,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 + > + > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) + + ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) + +4. 根据安装向导提示,勾选要自动安装的软件。 + 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 + + ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) + + 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 + + ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) + +5. 在以下界面点击**Next**,进行软件下载和安装。 + + ![zh-cn_image_0000001239634067](figures/zh-cn_image_0000001239634067.png) + +6. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 + + ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) + +7. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 + + ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) + + +## 配置Windows远程访问Ubuntu环境 + + +### 安装SSH服务并获取远程访问的IP地址 + +1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 + + + ``` + sudo apt-get install openssh-server + ``` + +2. 执行如下命令,启动SSH服务。 + + ``` + sudo systemctl start ssh + ``` + +3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 + + ``` + ifconfig + ``` + + ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) + + +### 安装Remote SSH + +1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 + + ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) + +2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 + + ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) + + +### 远程连接Ubuntu环境 + +1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXOPLORER页面点击+按钮。 + + ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) + +2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 + + ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) + +3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 + + ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) + +4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 + + ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) + +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 + + ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) + + 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 + + +### 注册访问Ubuntu环境的公钥 + +在完成以上操作后,您就可以通过Windows远程连接Ubuntu环境进行开发了,但在使用过程中,需要您频繁的输入远程连接密码来进行连接。为解决该问题,您可以使用SSH公钥来进行设置。 + +1. 打开Git bash命令行窗口,执行如下命令,生成SSH公钥,请注意,在执行命令过程中,请根据界面提示进行操作。username和ip请填写连接Ubuntu系统时需要的参数。 + + ``` + ssh-keygen -t rsa + ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip + ``` + + ![zh-cn_image_0000001271532317](figures/zh-cn_image_0000001271532317.png) + +2. 在Visual Studio Code中,点击远程连接的设置按钮,并选择打开config文件。 + + ![zh-cn_image_0000001226034634](figures/zh-cn_image_0000001226034634.png) + +3. 在config配置文件中添加SSK Key文件信息,如下图所示,然后保存即可。 + + ![zh-cn_image_0000001270356233](figures/zh-cn_image_0000001270356233.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup.md new file mode 100644 index 0000000000000000000000000000000000000000..01bb396569ec280242d7d1283c63d65046683c04 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-env-setup.md @@ -0,0 +1,7 @@ +# 准备轻量与小型系统环境 + + + +- **[搭建Windows+Ubuntu混合开发环境](quickstart-ide-lite-env-setup-win-ubuntu.md)** + +- **[获取源码](quickstart-ide-lite-sourcecode-acquire.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..c0e420294b3a6e05dfd96f96d9d48d32ab58fbf9 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3516.md @@ -0,0 +1,20 @@ +# Hi3516开发板介绍 + + +## 简介 + +Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器,同时集成高性能NNIE引擎,使得Hi3516DV300在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 + + **图1** Hi3516单板正面外观图 + +![zh-cn_image_0000001271234717](figures/zh-cn_image_0000001271234717.png) + + +## 开发板规格 + + **表1** Hi3516开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md new file mode 100644 index 0000000000000000000000000000000000000000..7a5a9076e74010492c44c838fad539ec3bcf124e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-introduction-hi3861.md @@ -0,0 +1,68 @@ +# Hi3861开发板介绍 + + +## 简介 + +Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持OpenHarmony,并配套提供开放、易用的开发和调试运行环境。 + + **图1** Hi3861开发板外观图 + + ![zh-cn_image_0000001226634692](figures/zh-cn_image_0000001226634692.png) + +另外,Hi3861开发板还可以通过与Hi3861底板连接,扩充自身的外设能力,底板如下图所示。 + + **图2** Hi3861底板外观图 + +![zh-cn_image_0000001226794660](figures/zh-cn_image_0000001226794660.png) + +- RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 + +- Hi3861 WLAN基带支持正交频分复用(OFDM)技术,并向下兼容直接序列扩频(DSSS)和补码键控(CCK)技术,支持IEEE 802.11 b/g/n协议的各种数据速率。 + +- Hi3861芯片集成高性能32bit微处理器、硬件安全引擎以及丰富的外设接口,外设接口包括SPI(Synchronous Peripheral Interface)、UART(Universal Asynchronous Receiver & Transmitter)、I2C(The Inter Integrated Circuit)、PWM(Pulse Width Modulation)、GPIO(General Purpose Input/Output)和多路ADC(Analog to Digital Converter),同时支持高速SDIO2.0(Secure Digital Input/Output)接口,最高时钟可达50MHz;芯片内置SRAM(Static Random Access Memory)和Flash,可独立运行,并支持在Flash上运行程序。 + +- Hi3861芯片适用于智能家电等物联网智能终端领域。 + + **图3** Hi3861功能框图 + + ![zh-cn_image_0000001271234729](figures/zh-cn_image_0000001271234729.png) + + +## 资源和约束 + +Hi3861开发板资源十分有限,整板共2MB FLASH,352KB RAM。在编写业务代码时,需注意资源使用效率。 + + +## 开发板规格 + + **表1** Hi3861开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| 通用规格 | - 1×1 2.4GHz频段(ch1~ch14)
- PHY支持IEEE 802.11b/g/n
- MAC支持IEEE802.11 d/e/h/i/k/v/w
- 内置PA和LNA,集成TX/RX Switch、Balun等
- 支持STA和AP形态,作为AP时最大支持6 个STA接入
- 支持WFA WPA/WPA2 personal、WPS2.0
- 支持与BT/BLE芯片共存的2/3/4 线PTA方案
- 电源电压输入范围:2.3V~3.6V
- IO电源电压支持1.8V和3.3V
- 支持RF自校准方案
- 低功耗:
  - Ultra Deep Sleep模式:5μA \@3.3V
  - DTIM1:1.5mA \@3.3V
  - DTIM3:0.8mA \@3.3V | +| PHY特性 | - 支持IEEE802.11b/g/n单天线所有的数据速率
- 支持最大速率:72.2Mbps\@HT20 MCS7
- 支持标准20MHz带宽和5M/10M窄带宽
- 支持STBC
- 支持Short-GI | +| MAC特性 | - 支持A-MPDU,A-MSDU
- 支持Blk-ACK
- 支持QoS,满足不同业务服务质量需求 | +| CPU子系统 | - 高性能 32bit微处理器,最大工作频率160MHz
- 内嵌SRAM 352KB、ROM 288KB
- 内嵌 2MB Flash | +| 外围接口 | - 1个SDIO接口、2个SPI接口、2个I2C接口、3个UART接口、15个GPIO接口、7路ADC输入、6路PWM、1个I2S接口(注:上述接口通过复用实现)
- 外部主晶体频率40M或24M | +| 其他信息 | - 封装:QFN-32,5mm×5mm
- 工作温度:-40℃ ~ +85℃ | + + +## OpenHarmony关键特性 + +OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 + + **表2** OpenHarmony关键组件列表 + +| 组件名 | 能力介绍 | +| -------- | -------- | +| WLAN服务 | 提供WLAN服务能力。包括:station和hotspot模式的连接、断开、状态查询等。 | +| 模组外设控制 | 提供操作外设的能力。包括:I2C、I2S、ADC、UART、SPI、SDIO、GPIO、PWM、FLASH等。 | +| 分布式软总线 | 在OpenHarmony分布式网络中,提供设备被发现、数据传输的能力。 | +| 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 | +| 基础加解密 | 提供密钥管理、加解密等能力。 | +| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 | +| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。 | +| 系统属性 | 提供获取与设置系统属性的能力。 | +| 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 | +| DFX | 提供DFX能力。包括:流水日志、时间打点等。 | +| XTS | 提供OpenHarmony生态认证测试套件的集合能力。 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..3f1b6b56cb815e006e5f4ce5ccf7b9f3a108ebc4 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-overview.md @@ -0,0 +1,40 @@ +# 轻量与小型系统入门概述 + + +## 简介 + +OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存≥128KiB)。通过本文,开发者可以快速熟悉OpenHarmony轻量和小型系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 + +考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: + +- IDE方式:完全采用IDE(Deveco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 + +- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 + OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 + +本文采用Deveco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-package-directory.md)。 + + +## 开发环境 + +开发者通常习惯采用Windows+Ubuntu环境进行OpenHarmony开发: + +- Windows:用于源码开发、烧录等。 + +- Ubuntu:用于源码编译。 + +本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 + + +## 开发板 + +本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-board-introduction.md),开发者可根据需要自行购买开发板。 + + +## 开发流程 + +轻量和小型系统快速入门流程如下图所示。 + + **图1** 轻量和小型系统快速入门开发流程 + + ![zh-cn_image_0000001226634676](figures/zh-cn_image_0000001226634676.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md new file mode 100644 index 0000000000000000000000000000000000000000..36370ae29e5d5e88b038213fe24746c4d9a9d858 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-sourcecode-acquire.md @@ -0,0 +1,79 @@ +# 获取源码 + + +在Ubuntu环境下通过以下步骤拉取OpenHarmony源码。 + + +## 准备工作 + +1. 注册码云gitee帐号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装git客户端和git-lfs。 + + 更新软件源: + + ``` + sudo apt-get update + ``` + + 通过以下命令安装: + + ``` + sudo apt-get install git git-lfs + ``` + +4. 配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +5. 执行如下命令安装码云repo工具。 + + ``` + curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +## 获取源码 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 + +- **OpenHarmony主干代码获取** + + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + + 方式二:通过repo + https下载。 + + + ``` + repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- **OpenHarmony发布分支代码获取** + + OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 + + +## 执行prebuilts + + 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 + +``` +bash build/prebuilts_download.sh +``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..928049b41efe3db8ca86b6b36dd276421ec285d6 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md @@ -0,0 +1,139 @@ +# 编写“Hello World”程序 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下: + + + +``` +applications/sample/hello +│── BUILD.gn +└── src + └── helloworld.c +``` + + +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 新建目录及源码。 + + 新建**applications/sample/hello/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + + int main(int argc, char **argv) + { + printf("\n\n"); + printf("\n\t\tHello OHOS!\n"); + printf("\n\n\n"); + + return 0; + } + ``` + +2. 新建编译组织文件。 + + 新建**applications/sample/hello/BUILD.gn**文件,内容如下所示: + + + ``` + import("//build/lite/config/component/lite_component.gni") + lite_component("hello-OHOS") { + features = [ ":helloworld" ] + } + executable("helloworld") { + output_name = "helloworld" + sources = [ "src/helloworld.c" ] + } + ``` + +3. 添加新组件。 + + 修改文件**build/lite/components/applications.json**,添加组件hello_world_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "components": [ + { + "component": "camera_sample_communication", + "description": "Communication related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/communication" + ], + "targets": [ + "//applications/sample/camera/communication:sample" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##start## + { + "component": "hello_world_app", + "description": "hello world samples.", + "optional": "true", + "dirs": [ + "applications/sample/hello" + ], + "targets": [ + "//applications/sample/hello:hello-OHOS" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##end## + { + "component": "camera_sample_app", + "description": "Camera related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/launcher", + "applications/sample/camera/cameraApp", + "applications/sample/camera/setting", + "applications/sample/camera/gallery", + "applications/sample/camera/media" + ], + ``` + +4. 修改单板配置文件。 + + 修改文件**vendor/hisilicon/hispark_taurus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "subsystem": "applications", + "components": [ + { "component": "camera_sample_app", "features":[] }, + { "component": "camera_sample_ai", "features":[] }, + ##start## + { "component": "hello_world_app", "features":[] }, + ##end## + { "component": "camera_screensaver_app", "features":[] } + ] + }, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md new file mode 100644 index 0000000000000000000000000000000000000000..994c0243842d03f4b4b5d4ee86d0b199981d4709 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-building.md @@ -0,0 +1,31 @@ +# 编译 + + +1. 在Projects中,点击**Settings**按钮,进入Hi3516DV300配置界面。 + + ![zh-cn_image_0000001265492885](figures/zh-cn_image_0000001265492885.png) + +2. 在toolchain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**SetUp**按钮,自动安装所需工具链。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001265652869](figures/zh-cn_image_0000001265652869.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001220852754](figures/zh-cn_image_0000001220852754.png) + +3. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug“类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 + + ![zh-cn_image_0000001221172710](figures/zh-cn_image_0000001221172710.png) + +4. 在“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 + + ![zh-cn_image_0000001265772913](figures/zh-cn_image_0000001265772913.png) + +5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001221012766](figures/zh-cn_image_0000001221012766.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3516DV300开发板烧录](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..135e480680fe44c4fdc01508b0d6ceb377d5f155 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-burn.md @@ -0,0 +1,71 @@ +# 烧录 + + +Hi3516DV300支持USB烧录、网口烧录和串口烧录三种方式,本文采用USB方式进行烧录。相关操作在Windows环境下进行 。 + + +1. 请连接好电脑和待烧录开发板,需要同时连接串口和USB口,具体可参考[Hi3516DV300开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)。 + +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 + + ![zh-cn_image_0000001216516128](figures/zh-cn_image_0000001216516128.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) + +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 + - upload_port:选择已查询到的串口号。 + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 + + ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) + +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 + + 1. 在“hi3516dv300_fastboot”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zh-cn_image_0000001198889702](figures/zh-cn_image_0000001198889702.png) + + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![zh-cn_image_0000001243290907](figures/zh-cn_image_0000001243290907.png) + + 3. 按照相同的方法修改kernel、rootfs和userfs的烧录文件信息。 + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击hi3516dv300下的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您是第一次在工作台烧录Hi3516DV300/Hi3518EV300开发板,可能烧录失败,提示“not find the Devices”,然后根据[Hi3516DV300/Hi3518EV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)进行处理后再重新烧录。 + + ![zh-cn_image_0000001267231481](figures/zh-cn_image_0000001267231481.png) + +9. 在终端窗口显示如下提示信息时,按住复位键,插拔USB线,最后松开复位键启动烧录。 + + ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) + + 启动烧录后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) + +10. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md new file mode 100644 index 0000000000000000000000000000000000000000..a4815fbabddc6eef7b9a967c9fcaed272532402a --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-running.md @@ -0,0 +1,51 @@ +# 运行 + + +## 启动系统 + +在完成Hi3516DV300的烧录后,还需要设置BootLoader引导程序,才能运行OpenHarmony系统。 + +1. 在Hi3516DV300任务中,点击Configure bootloader(Boot OS)进行配置即可。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > DevEco Device Tool针对Hi3516DV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 + + ![zh-cn_image_0000001226794644](figures/zh-cn_image_0000001226794644.png) + +2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 + + ![zh-cn_image_0000001227114584](figures/zh-cn_image_0000001227114584.png) + +3. 在任务栏点击**Monitor**按钮,启动串口工具。 + + ![zh-cn_image_0000001271234705](figures/zh-cn_image_0000001271234705.png) + +4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 + + ![zh-cn_image_0000001271594709](figures/zh-cn_image_0000001271594709.png) + + +## 运行“Hello World” + +系统启动成功后,通过以下步骤运行“Hello World”。 + +1. 在启动界面进入bin目录。 + + ``` + cd bin + ``` + +2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 + + ``` + ./helloworld + ``` + + 界面打印“Hello World!”,程序运行成功。 + + ![zh-cn_image_0000001271354693](figures/zh-cn_image_0000001271354693.png) + + +## 下一步学习 + +恭喜您,已完成Hi3516的快速上手!建议您下一步进入[带屏摄像头类产品开发](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-camera.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..e7f1497495db288027bde1bc7bbb79f80b48bdaf --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3516.md @@ -0,0 +1,11 @@ +# Hi3516开发板 + + + +- **[编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-application-framework.md)** + +- **[编译](quickstart-ide-lite-steps-hi3516-building.md)** + +- **[烧录](quickstart-ide-lite-steps-hi3516-burn.md)** + +- **[运行](quickstart-ide-lite-steps-hi3516-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md new file mode 100644 index 0000000000000000000000000000000000000000..4d87208d9e71ecedc29d01ef693feacbbf2cb760 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md @@ -0,0 +1,19 @@ +# 运行 + + +## 运行结果 + +示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: + + +``` +ready to OS start +FileSystem mount ok. +wifi init success! +[DEMO] Hello world. +``` + + +## 下一步学习 + +恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入[WLAN产品开发](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-wlan.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-application-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..f9adf40d8b20a2fd6ff4610a3b1416805bf7e581 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-application-framework.md @@ -0,0 +1,141 @@ +# 编写“Hello World”程序 + + +下方将通过修改源码的方式展示如何编写简单程序,输出“Hello world”。请在下载的源码目录中进行下述操作。 + + +1. 确定目录结构。 + + 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 + + 例如:在app下新增业务my_first_app,其中hello_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: + + + ``` + . + └── applications + └── sample + └── wifi-iot + └── app + └── my_first_app + │── hello_world.c + └── BUILD.gn + ``` + +2. 编写业务代码。 + + 新建./applications/sample/wifi-iot/app/my_first_app下的hello_world.c文件,在hello_world.c中新建业务入口函数HelloWorld,并实现业务逻辑。并在代码最下方,使用OpenHarmony启动恢复模块接口SYS_RUN()启动业务。(SYS_RUN定义在ohos_init.h文件中) + + ``` + #include + #include "ohos_init.h" + #include "ohos_types.h" + + void HelloWorld(void) + { + printf("[DEMO] Hello world.\n"); + } + SYS_RUN(HelloWorld); + ``` + +3. 编写用于将业务构建成静态库的BUILD.gn文件。 + + 新建./applications/sample/wifi-iot/app/my_first_app下的BUILD.gn文件,并完成如下配置。 + + 如步骤1所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。 + + + ``` + static_library("myapp") { + sources = [ + "hello_world.c" + ] + include_dirs = [ + "//utils/native/lite/include" + ] + } + ``` + + - static_library中指定业务模块的编译结果,为静态库文件libmyapp.a,开发者根据实际情况完成填写。 + - sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//"则表示绝对路径(此处为代码根路径),若不包含"//"则表示相对路径。 + - include_dirs中指定source所需要依赖的.h文件路径。 + +4. 添加新组件。 + + 修改文件**build/lite/components/applications.json**,添加组件hello_world_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "components": [ + { + "component": "camera_sample_communication", + "description": "Communication related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/communication" + ], + "targets": [ + "//applications/sample/camera/communication:sample" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##start## + { + "component": "hello_world_app", + "description": "hello world samples.", + "optional": "true", + "dirs": [ + "applications/sample/wifi-iot/app/my_first_app" + ], + "targets": [ + "//applications/sample/wifi-iot/app/my_first_app:myapp" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_m" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##end## + { + "component": "camera_sample_app", + "description": "Camera related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/launcher", + "applications/sample/camera/cameraApp", + "applications/sample/camera/setting", + "applications/sample/camera/gallery", + "applications/sample/camera/media" + ], + ``` + +5. 修改单板配置文件。 + + 修改文件**vendor/hisilicon/hispark_pegasus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "subsystem": "applications", + "components": [ + ##start## + { "component": "hello_world_app", "features":[] }, + ##end## + { "component": "wifi_iot_sample_app", "features":[] } + ] + }, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md new file mode 100644 index 0000000000000000000000000000000000000000..8516383794e4e9330024143a89b3cecc2839df4b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-building.md @@ -0,0 +1,31 @@ +# 编译 + + +1. 在Projects中,点击**Settings**按钮,进入Hi3861配置界面。 + + ![zh-cn_image_0000001265785209](figures/zh-cn_image_0000001265785209.png) + +2. 在toolchain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**SetUp**按钮,自动安装所需工具链。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001221025048](figures/zh-cn_image_0000001221025048.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001221344980](figures/zh-cn_image_0000001221344980.png) + +3. 在“hi3861”配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 + + ![zh-cn_image_0000001265945173](figures/zh-cn_image_0000001265945173.png) + +4. 在DevEco Device Tool界面的“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 + + ![zh-cn_image_0000001265505181](figures/zh-cn_image_0000001265505181.png) + +5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001265665157](figures/zh-cn_image_0000001265665157.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3861V100开发板烧录](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3861-upload-0000001051668683)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md new file mode 100644 index 0000000000000000000000000000000000000000..2c1ffd875a1b4f40a58967c323dc62b27ffa3037 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-burn.md @@ -0,0 +1,55 @@ +# 烧录 + + +Hi3861V100开发板支持串口烧录方式,在Windows下通过以下步骤进行烧录: + + +1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md)。 + +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 + + ![zh-cn_image_0000001216274840](figures/zh-cn_image_0000001216274840.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3861V100开发板串口驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/hi3861-drivers-0000001058153433)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001198943768](figures/zh-cn_image_0000001198943768.png) + +5. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 + + - upload_port:选择已查询的串口号。 + - upload_protocol:选择烧录协议,选择“hiburn-serial”。 + - upload_partitions:选择待烧录的文件,默认选择hi3861_app。 + + ![zh-cn_image_0000001243704061](figures/zh-cn_image_0000001243704061.png) + +6. 检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。 + 在“hi3861_app”页签,在New Option选项中选择partition_bin(烧录文件路径),然后设置待烧录文件的地址。 + + ![zh-cn_image_0000001260919759](figures/zh-cn_image_0000001260919759.png) + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 + + ![zh-cn_image_0000001216440138](figures/zh-cn_image_0000001216440138.png) + +9. 启动烧录后,显示如下提示信息时,请按开发板上的RST按钮重启开发板。 + + ![zh-cn_image_0000001198466090](figures/zh-cn_image_0000001198466090.png) + +10. 重新上电后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001216761476](figures/zh-cn_image_0000001216761476.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md new file mode 100644 index 0000000000000000000000000000000000000000..9968bd4f98d11b134b3edc3fd81ed0359bcfd2f3 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-debug.md @@ -0,0 +1,65 @@ +# 调试验证 + + +完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 + + +1. 通过printf打印日志 + +2. 通过asm文件定位panic问题 + + +由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 + + +## printf打印 + +代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: + + +``` +void HelloWorld(void) +{ + printf("[DEMO] Hello world.\n"); +} +``` + + +## 根据asm文件进行问题定位 + + 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 + +``` +=======KERNEL PANIC======= +**Call Stack* +Call Stack 0 -- 4860d8 addr:f784c +Call Stack 1 -- 47b2b2 addr:f788c +Call Stack 2 -- 3e562c addr:f789c +Call Stack 3 -- 4101de addr:f78ac +Call Stack 4 -- 3e5f32 addr:f78cc +Call Stack 5 -- 3f78c0 addr:f78ec +Call Stack 6 -- 3f5e24 addr:f78fc +Call Stack end*** +``` + +为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 + +1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) + +2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 + + ``` + Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB + Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data + Call Stack 2 -- 3e562c addr:f789c + Call Stack 3 -- 4101de addr:f78ac + Call Stack 4 -- 3e5f32 addr:f78cc + Call Stack 5 -- 3f78c0 addr:f78ec + Call Stack 6 -- 3f5e24 addr:f78fc + ``` + +3. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 + + ![zh-cn_image_0000001226634668](figures/zh-cn_image_0000001226634668.png) + +4. 完成代码排查及修改。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md new file mode 100644 index 0000000000000000000000000000000000000000..24949702fdf8e661836459439037f2ee07520829 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md @@ -0,0 +1,39 @@ +# 联网 + + +完成版本编译及烧录后,下面开始介绍如何在串口终端上执行AT命令,使Hi3861 WLAN模组联网。 + + +1. 保持Windows工作台和Hi3861 WLAN模组的连接状态,在DevEco工具最下方,点击“DevEco:Serial Monitor”按钮。 + + **图1** 打开DevEco串口终端示意图 + + ![zh-cn_image_0000001226634700](figures/zh-cn_image_0000001226634700.png) + +2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 + + **图2** Hi3861 WLAN模组复位成功示意图 + + ![zh-cn_image_0000001271594733](figures/zh-cn_image_0000001271594733.png) + +3. 在DevEco的串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 + + ``` + AT+STARTSTA # 启动STA模式 + AT+SCAN # 扫描周边AP + AT+SCANRESULT # 显示扫描结果 + AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 + AT+STASTAT # 查看连接结果 + AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 + ``` + +4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 + + ``` + AT+IFCFG # 查看模组接口IP + AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 + ``` + + **图3** Hi3861 WLAN模组联网成功示意图 + + ![zh-cn_image_0000001227114612](figures/zh-cn_image_0000001227114612.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md new file mode 100644 index 0000000000000000000000000000000000000000..4bbfca7971cb04475f28dd8c90b20343e195495a --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861.md @@ -0,0 +1,15 @@ +# Hi3861开发板 + + + +- **[编写“Hello World”程序](quickstart-ide-lite-steps-hi3861-application-framework.md)** + +- **[编译](quickstart-ide-lite-steps-hi3861-building.md)** + +- **[烧录](quickstart-ide-lite-steps-hi3861-burn.md)** + +- **[联网](quickstart-ide-lite-steps-hi3861-netconfig.md)** + +- **[调试验证](quickstart-ide-lite-steps-hi3861-debug.md)** + +- **[运行](quickstart-ide-lite-steps-hi3816-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps.md new file mode 100644 index 0000000000000000000000000000000000000000..afae2813c9df669d91d5b8dcfa468f4225f78e6e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps.md @@ -0,0 +1,7 @@ +# 运行“Hello World” + + + +- **[Hi3861开发板](quickstart-ide-lite-steps-hi3861.md)** + +- **[Hi3516开发板](quickstart-ide-lite-steps-hi3516.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite.md new file mode 100644 index 0000000000000000000000000000000000000000..bc21ff3cad893009bc0b3dd2b8345a2efcf3c917 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-lite.md @@ -0,0 +1,13 @@ +# 轻量和小型系统快速入门-IDE + + + +- **[轻量与小型系统入门概述](quickstart-ide-lite-overview.md)** + +- **[准备轻量与小型系统环境](quickstart-ide-lite-env-setup.md)** + +- **[创建源码工程](quickstart-ide-lite-create-project.md)** + +- **[运行“Hello World”](quickstart-ide-lite-steps.md)** + +- **[附录](quickstart-ide-lite-appendix.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-appendix.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-appendix.md new file mode 100644 index 0000000000000000000000000000000000000000..56f67faa0344da0f160035b3c285ebc3b1a88941 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-appendix.md @@ -0,0 +1,5 @@ +# 附录 + + + +- **[开发板介绍](quickstart-ide-standard-board-introduction.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..fe7e28246dea89f0f07384d7ce5d1401a1229972 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3516.md @@ -0,0 +1,20 @@ +# Hi3516开发板介绍 + + +## 开发板简介 + +Hi3516DV300是新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器、高性能NNIE引擎,在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 + + **图1** Hi3516单板正面外观图 + + ![zh-cn_image_0000001227082182](figures/zh-cn_image_0000001227082182.png) + + +## 开发板规格 + + **表1** Hi3516开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md new file mode 100644 index 0000000000000000000000000000000000000000..2ba3a5247ee3715543dbe5c307c17f4b2c49b545 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-rk3568.md @@ -0,0 +1,41 @@ +# RK3568开发板介绍 + + +## 开发板简介 + +RK3568开发板基于Rockchip RK3568芯片,集成双核心架构GPU以及高效能NPU;搭载四核64位Cortex-A55处理器,采用22nm先进工艺,主频高达2.0GHz;支持蓝牙、Wi-Fi、音频、视频和摄像头等功能,拥有丰富的扩展接口,支持多种视频输入输出接口;配置双千兆自适应RJ45以太网口,可满足NVR、工业网关等多网口产品需求。 + + **图1** RK3568开发板正面 + + ![zh-cn_image_0000001271442129](figures/zh-cn_image_0000001271442261.png) + + **图2** RK3568开发板背面 + + ![zh-cn_image_0000001271322293](figures/zh-cn_image_0000001271322293.png) + + +## 开发板规格 + + **表1** RK3568开发板规格说明 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| 显示接口 | - 1×HDMI2.0(Type-A)接口,支持4K/60fps输出
- 2×MIPI接口,支1920\*1080\@60fps输出
- 1×eDP接口,支持2K\@60fps输出 | +| 音频接口 | - 1×8ch I2S/TDM/PDM
- 1×HDMI音频输出
- 1×喇叭输出
- 1×耳机输出
- 1×麦克风,板载音频输入 | +| 以太网 | 2×GMAC(10/100/1000M) | +| 无线网络 | SDIO接口,支持WIFI6 5G/2.5G,BT4.2 | +| 摄像头接口 | MIPI-CSI2,1x4-lane/2x2-lane\@2.5Gbps/lane | +| USB | - 2×USB2.0 Host,Type-A
- 1×USB3.0 Host,Type-A
- 1×USB3.0 OTG | +| PCIe | 1×2Lanes PCIe3.0 Connector (RC Mode) | +| SATA | 1×SATA3.0 Connector | +| SDMMC | 1×Micro SD Card3.0 | +| 按键 | - 1×Vol+/Recovery
- 1×Reset
- 1×Power
- 1×Vol-
- 1×Mute | +| 调试 | 1×调试串口 | +| RTC | 1×RTC | +| IR | 1×IR | +| 三色灯 | 3×LED | +| G-sensor | 1×G-sensor | +| FAN | 1×Fan | +| 扩展接口 | 20Pin扩展接口包括:
- 2×ADC接口
- 2×I2C接口
- 7×GPIO口(或者3×gpio + 4×uart信号)
- 3×VCC电源(12V、3.3V、5V) | +| 底板尺寸 | 180mm×130mm | +| PCB规格 | 4 层板 | diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..ed8ec794b4c41d062627bf8da28791ab49535f4d --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction.md @@ -0,0 +1,7 @@ +# 开发板介绍 + + + +- **[Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md)** + +- **[RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md new file mode 100644 index 0000000000000000000000000000000000000000..2a5a0cd98d7d3891275b543fa610684dd5968a01 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-create-project.md @@ -0,0 +1,35 @@ +# 创建源码工程 + + +在完成[搭建Windows+Ubuntu混合开发环境](../quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md)和[获取源码](../quick-start/quickstart-ide-standard-sourcecode-acquire.md)后,您需要在Windows环境中按照如下步骤创建源码工程。 + + +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 + + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) + +2. 选择要导入的源码目录,点击**Import**打开。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 + + ![zh-cn_image_0000001271562277](figures/zh-cn_image_0000001271562277.png) + +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) + +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 + + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) + +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。下图以导入Hi3516DV300为例进行展示 。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - Hi3516DV300开发板Product选择“Hi3516DV300”。 + > + > - RK3568开发板Product选择“rk3568”。 + + ![zh-cn_image_0000001271448821](figures/zh-cn_image_0000001271448821.png) + +6. 点击**Open**打开工程或源码。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md new file mode 100644 index 0000000000000000000000000000000000000000..2fa94a00e076e924fc6d3da37cb1d52dec6b64d6 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md @@ -0,0 +1,205 @@ +# 搭建Windows+Ubuntu混合开发环境 + + +通常在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,需要使用Ubuntu的编译环境对源码进行编译。 + + +在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 + + +## 系统要求 + +- Windows系统要求:Windows10 64位系统。 + +- Ubuntu系统要求:Ubuntu20.04及以上版本,内存推荐16 GB及以上。 + +- Windows系统和Ubuntu系统的用户名不能包含中文字符。 + +- Windows和Ubuntu系统上安装的DevEco Device Tool为3.0 Release版本。 + + +## 搭建Ubuntu环境 + +在Windows+Ubuntu混合开发环境场景中,在Ubuntu系统上可以不用安装Visual Studio Code,这种情况下,Ubuntu环境中就没有DevEco Device Tool的可视化操作界面。如果需要使用到Ubuntu下的DevEco Device Tool可视化操作界面,环境搭建请参考[搭建Ubuntu开发环境](https://device.harmonyos.com/cn/docs/documentation/guide/ide-install-ubuntu-0000001072959308)。 + +1. 将Ubuntu Shell环境修改为bash。 + + 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 + + ``` + ls -l /bin/sh + ``` + + ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) + + 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 + + ``` + sudo dpkg-reconfigure dash + ``` + + ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) + +2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Linux版本。 + +3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 + + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.400.zip为软件包名称,请根据实际进行修改。 + + ``` + unzip devicetool-linux-tool-3.0.0.400.zip + ``` + + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + ``` + chmod u+x devicetool-linux-tool-3.0.0.400.sh + ``` + +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 安装过程中,会自动检查Python是否安装,且要求Python为3.8~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 + + + ``` + sudo ./devicetool-linux-tool-3.0.0.400.sh + ``` + + 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 + + ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) + + +## 搭建Windows开发环境 + +通过Windows系统远程访问Ubuntu环境,需要先在Windows系统中安装DevEco Device Tool,以便使用Windows平台的DevEco Device Tool可视化界面进行相关操作。 + +1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Windows版。 + +2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 + +3. 设置DevEco Device Tool的安装路径,建议安装到非系统盘符,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 + > + > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) + + ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) + +4. 根据安装向导提示,勾选要自动安装的软件。 + + 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 + + ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) + + 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 + + ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) + +5. 在以下界面点击**Next**,进行软件下载和安装。 + + ![zh-cn_image_0000001239634067](figures/zh-cn_image_0000001239634067.png) + +6. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 + + ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) + +7. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 + + ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) + + +## 配置Windows远程访问Ubuntu环境 + + +### 安装SSH服务并获取远程访问的IP地址 + +1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 + + + ``` + sudo apt-get install openssh-server + ``` + +2. 执行如下命令,启动SSH服务。 + + ``` + sudo systemctl start ssh + ``` + +3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 + + ``` + ifconfig + ``` + + ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) + + +### 安装Remote SSH + +1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 + + ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) + +2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 + + ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) + + +### 远程连接Ubuntu环境 + +1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXOPLORER页面点击+按钮。 + + ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) + +2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 + + ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) + +3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 + + ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) + +4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 + + ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) + +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 + + ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) + + 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 + + +### 注册访问Ubuntu环境的公钥 + +在完成以上操作后,您就可以通过Windows远程连接Ubuntu环境进行开发了,但在使用过程中,需要您频繁的输入远程连接密码来进行连接。为解决该问题,您可以使用SSH公钥来进行设置。 + +1. 打开Git bash命令行窗口,执行如下命令,生成SSH公钥,请注意,在执行命令过程中,请根据界面提示进行操作。username和ip请填写连接Ubuntu系统时需要的参数。 + + ``` + ssh-keygen -t rsa + ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip + ``` + + ![zh-cn_image_0000001271532317](figures/zh-cn_image_0000001271532317.png) + +2. 在Visual Studio Code中,点击远程连接的设置按钮,并选择打开config文件。 + + ![zh-cn_image_0000001226034634](figures/zh-cn_image_0000001226034634.png) + +3. 在config配置文件中添加SSK Key文件信息,如下图所示,然后保存即可。 + + ![zh-cn_image_0000001270356233](figures/zh-cn_image_0000001270356233.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup.md new file mode 100644 index 0000000000000000000000000000000000000000..b84e4b918f08cb55be2499a7430758b77ba06185 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-env-setup.md @@ -0,0 +1,7 @@ +# 准备标准系统环境 + + + +- **[搭建Windows+Ubuntu混合开发环境](quickstart-ide-standard-env-setup-win-ubuntu.md)** + +- **[获取源码](quickstart-ide-standard-sourcecode-acquire.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..a63a062889da8bdf6e09308e52abb0a511060977 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md @@ -0,0 +1,40 @@ +# 标准系统入门概述 + + +## 简介 + +OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 + +考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: + +- IDE方式:完全采用IDE(Deveco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 + +- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 + OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 + +本文采用Deveco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[标准系统快速入门(安装包方式)](../quick-start/quickstart-standard-package-directory.md)。 + + +## 开发环境 + +开发者通常习惯采用Windows+Ubuntu环境进行OpenHarmony开发: + +- Windows:用于源码开发、烧录等。 + +- Ubuntu:用于源码编译。 + +本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 + + +## 开发板 + +本文选取了两款典型开发板:Hi3516DV300、RK3568,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction.md),开发者可根据需要自行购买开发板。 + + +## 开发流程 + +标准系统快速入门流程如下图所示: + + **图1** 标准系统快速入门开发流程 + + ![zh-cn_image_0000001271562257](figures/zh-cn_image_0000001271562257.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md new file mode 100644 index 0000000000000000000000000000000000000000..f47fdb8a0b73ea59345d386fcd5df0d83fe7476e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-build.md @@ -0,0 +1,31 @@ +# 编译 + + +1. 在Projects中,点击**Settings**按钮,进入Hi3516DV300配置界面。 + + ![zh-cn_image_0000001265492885](figures/zh-cn_image_0000001265492885.png) + +2. 在toolchain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**SetUp**按钮,自动安装所需工具链。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001227277128](figures/zh-cn_image_0000001227277128.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001227757036](figures/zh-cn_image_0000001227757036.png) + +3. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug“类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 + + ![zh-cn_image_0000001221172710](figures/zh-cn_image_0000001221172710.png) + +4. 在“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 + + ![zh-cn_image_0000001265772913](figures/zh-cn_image_0000001265772913.png) + +5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001221012766](figures/zh-cn_image_0000001221012766.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3516DV300开发板烧录](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..91eb2201ae897796459d41e0c73829a0fd854a6e --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-burning.md @@ -0,0 +1,70 @@ +# 烧录 + + +在Windows下采用USB烧录方式进行Hi3516DV300的烧录。 + + +1. 请连接好电脑和待烧录开发板,需要同时连接串口和USB口,具体可参考[Hi3516DV300开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)。 + +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 + + ![zh-cn_image_0000001216516128](figures/zh-cn_image_0000001216516128.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) + +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 + - upload_port:选择已查询到的串口号。 + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 + + ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) + +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 + + 1. 在“hi3516dv300_fastboot”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zh-cn_image_0000001198889702](figures/zh-cn_image_0000001198889702.png) + + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![zh-cn_image_0000001243290907](figures/zh-cn_image_0000001243290907.png) + + 3. 按照相同的方法修改kernel、rootfs和userfs的烧录文件信息。 + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击hi3516dv300下的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您是第一次在工作台烧录Hi3516DV300/Hi3518EV300开发板,可能烧录失败,提示“not find the Devices”,然后根据[Hi3516DV300/Hi3518EV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)进行处理后再重新烧录。 + + ![zh-cn_image_0000001267231481](figures/zh-cn_image_0000001267231481.png) + +9. 在终端窗口显示如下提示信息时,按住复位键,插拔USB线,最后松开复位键启动烧录。 + + ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) + + 启动烧录后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) + +10. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md new file mode 100644 index 0000000000000000000000000000000000000000..ef28bc5a77938c136d91e24cc47c24aa6e889d15 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md @@ -0,0 +1,163 @@ +# 编写“Hello World”程序 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下。 + + +``` +applications/sample/hello +│── BUILD.gn +│── include +│ └── helloworld.h +│── src +│ └── helloworld.c +├── bundle.json +build +└── subsystem_config.json +productdefine/common +└── products + └── Hi3516DV300.json +``` + + +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + + +1. 创建目录,编写业务代码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + + void HelloPrint(); + + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + + 在productdefine\common\products\Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 + + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md new file mode 100644 index 0000000000000000000000000000000000000000..862d9d8eeb6b3e574264a79e8aff4e8cb0a66556 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516-running.md @@ -0,0 +1,57 @@ +# 运行 + + +## 启动系统 + +烧录完成后通过以下步骤启动系统: + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 + +1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 + + ![zh-cn_image_0000001227082162](figures/zh-cn_image_0000001227082162.png) + +2. 重启开发板,在倒计时结束前,按任意键进入系统。 + + ![zh-cn_image_0000001271202289](figures/zh-cn_image_0000001271202289.gif) + +3. 通过以下两条命令设置启动参数。 + + ``` + setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; + ``` + + + ``` + setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' + ``` + + ![zh-cn_image_0000001271562269](figures/zh-cn_image_0000001271562269.png) + +4. 保存参数设置。 + + ``` + save + ``` + + ![zh-cn_image_0000001226762210](figures/zh-cn_image_0000001226762210.png) + +5. 重启开发板,完成系统启动。 + + ``` + reset + ``` + + ![zh-cn_image_0000001226602238](figures/zh-cn_image_0000001226602238.png) + + +## 运行“Hello World” + +设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + +![zh-cn_image_0000001271322277](figures/zh-cn_image_0000001271322277.png) + +## 下一步 + +恭喜!您已经完成了OpenHarmony标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..7c1174828b36de829b266183e646c2771902b12b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3516.md @@ -0,0 +1,11 @@ +# Hi3516开发板 + + + +- **[编写“Hello World”程序](quickstart-ide-standard-running-hi3516-create.md)** + +- **[编译](quickstart-ide-standard-running-hi3516-build.md)** + +- **[烧录](quickstart-ide-standard-running-hi3516-burning.md)** + +- **[运行](quickstart-ide-standard-running-hi3516-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md new file mode 100644 index 0000000000000000000000000000000000000000..36b6db97896abe50590de548cdd1672f2168b312 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-build.md @@ -0,0 +1,31 @@ +# 编译 + + +1. 在Projects中,点击**Settings**按钮,进入HH-SCDY200配置界面。 + + ![zh-cn_image_0000001221036768](figures/zh-cn_image_0000001221036768.png) + +2. 在toolchain页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**SetUp**按钮,自动安装所需工具链。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + + ![zh-cn_image_0000001221356692](figures/zh-cn_image_0000001221356692.png) + + 工具链自动安装完成后如下图所示。 + + ![zh-cn_image_0000001265676877](figures/zh-cn_image_0000001265676877.png) + +3. 在“hh_scdy200”配置页签中,设置源码的编译类型**build_type**,默认为"debug类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 + + ![zh-cn_image_0000001265956897](figures/zh-cn_image_0000001265956897.png) + +4. 在DevEco Device Tool界面的“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 + + ![zh-cn_image_0000001265516901](figures/zh-cn_image_0000001265516901.png) + +5. 等待编译完成,在**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zh-cn_image_0000001222361042](figures/zh-cn_image_0000001222361042.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[RK3568开发板烧录](https://device.harmonyos.com/cn/docs/documentation/guide/ide-rk3568-upload-0000001239220669)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..b69bca22fd0732fddf3f5e197a07173fef8e3782 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md @@ -0,0 +1,55 @@ +# 烧录 + + +1. [下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe,双击DriverInstall.exe打开安装程序,点击“驱动安装”按钮,按提示安装USB驱动。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果已经安装旧版本的烧写工具,请先点击"驱动卸载"按钮卸载驱动,然后再点击"驱动安装"按钮安装驱动。 + +2. 请连接好电脑和待烧录开发板,连接USB接口。 + +3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +4. 打开DevEco Device Tool,在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001239661509](figures/zh-cn_image_0000001239661509.png) + +5. 在“hh_scdy200”页签,设置烧录选项,包括upload_partitions和upload_protocol。 + + - upload_partitions:选择待烧录的文件。 + - upload_protocol:选择烧录协议,固定选择“upgrade”。 + + ![zh-cn_image_0000001194504874](figures/zh-cn_image_0000001194504874.png) + +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:loader、parameter、uboot、boot_linux、system、vendor和userdata。 + + 1. 在“hh_scdy200_loader”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zh-cn_image_0000001224173270](figures/zh-cn_image_0000001224173270.png) + + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![zh-cn_image_0000001268653461](figures/zh-cn_image_0000001268653461.png) + + 3. 按照相同的方法修改parameter、uboot、boot_linux、system、vendor和userdata的烧录文件信息。 + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击工程的Open按钮,打开工程文件,点击![zh-cn_image_0000001239221905](figures/zh-cn_image_0000001239221905.png)图标,打开DevEco Device Tool界面,在“PROJECT TASKS”中,点击hh_scdy200下的**Upload**按钮,启动烧录。 + + ![zh-cn_image_0000001194821710](figures/zh-cn_image_0000001194821710.png) + +9. 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001194984912](figures/zh-cn_image_0000001194984912.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md new file mode 100644 index 0000000000000000000000000000000000000000..a75e9ec604f558d1ef513193b37d35f6556f54b7 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md @@ -0,0 +1,161 @@ +# 编写“Hello World”程序 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下。 + + +``` +applications/sample/hello +│── BUILD.gn +│── include +│ └── helloworld.h +│── src +│ └── helloworld.c +├── bundle.json +build +└── subsystem_config.json +productdefine/common +└── products + └── rk3568.json +``` + + +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 创建目录,编写业务代码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + + void HelloPrint(); + + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + + 在productdefine\common\products\rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md new file mode 100644 index 0000000000000000000000000000000000000000..f051a86097b10b995fc10652057bf58342d6c14d --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-running.md @@ -0,0 +1,21 @@ +# 运行 + + +## 启动系统 + +镜像烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 + + **图1** 系统启动效果图 + + ![zh-cn_image_0000001226762222](figures/zh-cn_image_0000001226762222.jpg) + + +## 运行“Hello World” + +1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 + + ![zh-cn_image_0000001226602250](figures/zh-cn_image_0000001226602250.png) + +2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + + ![zh-cn_image_0000001226922154](figures/zh-cn_image_0000001226922154.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568.md new file mode 100644 index 0000000000000000000000000000000000000000..9378ffbe110060f9709adb306fe4f5a6703e9be3 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568.md @@ -0,0 +1,11 @@ +# RK3568开发板 + + + +- **[编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md)** + +- **[编译](quickstart-ide-standard-running-rk3568-build.md)** + +- **[烧录](quickstart-ide-standard-running-rk3568-burning.md)** + +- **[运行](quickstart-ide-standard-running-rk3568-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running.md new file mode 100644 index 0000000000000000000000000000000000000000..794f1ba83e738adbc8fd98402a911f3ce280c6e0 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running.md @@ -0,0 +1,7 @@ +# 运行“Hello World” + + + +- **[Hi3516开发板](quickstart-ide-standard-running-hi3516.md)** + +- **[RK3568开发板](quickstart-ide-standard-running-rk3568.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md new file mode 100644 index 0000000000000000000000000000000000000000..9a3e40f9c5c6cea3434f71b66ca569f1151fff08 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-sourcecode-acquire.md @@ -0,0 +1,79 @@ +# 获取源码 + + +在Ubuntu环境下通过以下步骤拉取OpenHarmony源码。 + + +## 前提条件 + +1. 注册码云gitee帐号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装git客户端和git-lfs。 + + 更新软件源: + + ``` + sudo apt-get update + ``` + + 通过以下命令安装: + + ``` + sudo apt-get install git git-lfs + ``` + +4. 配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +5. 安装码云repo工具,可以执行如下命令。 + + ``` + curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +## 获取源码 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 + +- **OpenHarmony主干代码获取** + + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + + 方式二:通过repo + https下载。 + + + ``` + repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- **OpenHarmony发布分支代码获取** + + OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 + + +## 执行prebuilts + + 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 + +``` +bash build/prebuilts_download.sh +``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-appendix.md b/zh-cn/device-dev/quick-start/quickstart-lite-appendix.md new file mode 100644 index 0000000000000000000000000000000000000000..6aa44d7ffef8a24ecdf64aedd7a984034c615f3c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-appendix.md @@ -0,0 +1,7 @@ +# 附录 + + + +- **[开发板介绍](quickstart-lite-board-introduction.md)** + +- **[参考信息](quickstart-lite-reference.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-board-introduction.md b/zh-cn/device-dev/quick-start/quickstart-lite-board-introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..2d333b5bce032b3ae4215452e1fe2712528e5a23 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-board-introduction.md @@ -0,0 +1,7 @@ +# 开发板介绍 + + + +- **[Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md)** + +- **[Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md deleted file mode 100644 index 0618477f49c778435cc98ff6624cb93700ab74ae..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md +++ /dev/null @@ -1,34 +0,0 @@ -# 使用Docker方式搭建编译环境 - -- [安装Docker](#section7337134183512) -- [获取Docker环境](#section15666113905015) - -使用安装包方式搭建Ubuntu编译环境步骤如下: - -1. 安装Docker -2. 获取Docker环境: - -想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建使用指南](../subsystems/subsys-build-mini-lite.md)。 - -## 安装Docker - -- 请参考[官方指导](https://docs.docker.com/engine/install/)。 - -## 获取Docker环境 - ->![](../public_sys-resources/icon-note.gif) **说明:** ->不同的源码版本要匹配使用对应版本的Docker环境,本文以Master主干代码为例进行说明。 - -OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud.com/swr/?region=cn-south-1#/app/warehouse/warehouseMangeDetail/goldensir/openharmony-docker/openharmony-docker?type=ownImage)上。开发者可以通过该镜像在很大程度上简化编译前的环境配置。下文将介绍具体使用步骤。 - -1. 获取Docker镜像。 - - ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - -2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 - - ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-prepare.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-prepare.md deleted file mode 100644 index e211b8ba3126aa456ab25efd42272f9d5019250d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-prepare.md +++ /dev/null @@ -1,73 +0,0 @@ -# 开发环境准备 - -- [系统要求](#zh-cn_topic_0000001072959308_section1865184385215) -- [安装DevEco Device Tool](#zh-cn_topic_0000001072959308_section86587531620) - -DevEco Device Tool Ubuntu版本支持OpenHarmony源码开发、编译、烧录的一站式开发环境,因此,本章节为您介绍在Ubuntu环境下,如何搭建一套完整的可视化开发环境。 - -## 系统要求 - -- Ubuntu18及以上版本,内存推荐16 GB及以上。 -- 系统的用户名不能含有中文字符。 -- 只能使用普通用户角色搭建开发环境。 - -## 安装DevEco Device Tool - -DevEco Device Tool基于Visual Studio Code进行扩展,在Visual Studio Code上以插件方式运行,Visual Studio Code版本为1.60及以上。同时,DevEco Device Tool还依赖Python工具,并要求Python为3.8\~3.9版本。 - -在安装过程中,DevEco Device Tool会自动检查Visual Studio Code和Python,如果检测到Visual Studio Code、Python未安装或版本不符合要求,安装程序会自动安装Visual Studio Code和Python。 - -1. 将Ubuntu Shell环境修改为bash。 - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 - - ``` - ls -l /bin/sh - ``` - - ![](figures/zh-cn_image_0000001194078294.png) - - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![](figures/zh-cn_image_0000001238878219.png) - -2. 下载[DevEco Device Tool 3.0 Beta2](https://device.harmonyos.com/cn/ide#download_beta)Linux版本,下载时,请先使用华为开发者帐号进行登录后下载。如未注册华为开发者账号,请先[注册](https://developer.huawei.com/consumer/cn/doc/start/registration-and-verification-0000001053628148)。 -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.200.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.300.zip - ``` - - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.300.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >安装过程中,会自动检查Visual Studio Code和Python是否安装,且版本符合要求,其中Visual Studio Code为1.60及以上版本,Python为3.8\~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.300.sh -- --install-plugins - ``` - - 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![](figures/zh-cn_image_0000001239348791.png) - -5. 安装完成后,在Ubuntu左下角的![](figures/zh-cn_image_0000001075566984.png)中,启动Visual Studio Code。 -6. 启动Visual Studio Code,DevEco Device Tool运行依赖C/C++、CodeLLDB插件,请点击Visual Studio Code左侧的![](figures/button.png)按钮,分别搜索和安装C/C++、CodeLLDB插件。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果在插件市场安装C/C++和CodeLLDB插件不成功,可手动下载插件后进行安装,具体请参考:[离线安装C/C++和CodeLLDB插件](https://device.harmonyos.com/cn/docs/documentation/guide/offline_plugin_install-0000001074376846)。 - - ![](figures/deveco-device-tool-install-sucessful.png) - -7. 重启Visual Studio Code,点击![](figures/zh-cn_image_0000001239226427.png)进入DevEco Device Tool工具界面。至此,DevEco Device Tool Ubuntu开发环境安装完成。![](figures/zh-cn_image_0000001194668634.png) - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-faqs.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-faqs.md index b7b3133f5378aa7f4cb4e054da1af675b559fa01..c52bbbfbad5bcaff99dc4cd822afb645aa0b630f 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-faqs.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-faqs.md @@ -1,112 +1,9 @@ -# 常见问题 +# 常见问题 -- [hb 安装过程中出现乱码、段错误](#section411894616119) -- [hb 安装过程中提示"cannot import 'sysconfig' from 'distutils'"](#section629417571626) -- [hb 安装过程中提示"module 'platform' has no attribute 'linux\_distribution'"](#section10871523332) -- [hb 安装过程中提示"Could not find a version that satisfies the requirement ohos-build"](#section47351657163213) -- [Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt\_pkg”](#section159891252236) -## hb 安装过程中出现乱码、段错误 -- **现象描述** - - 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 - - -- **可能原因** - - pip版本过低。 - -- **解决办法** - - 执行如下命令升级pip。 - - ``` - python3 -m pip install -U pip - ``` - - -## hb 安装过程中提示"cannot import 'sysconfig' from 'distutils'" - -- **现象描述** - - 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" - - -- **可能原因** - - 缺少distutils模块。 - -- **解决办法** - - 执行如下命令安装。 - - ``` - sudo apt-get install python3.8-distutils - ``` - - -## hb 安装过程中提示"module 'platform' has no attribute 'linux\_distribution'" - -- **现象描述** - - 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux\_distribution'" - - -- **可能原因** - - python3 pip安装兼容性问题。 - -- **解决办法** - - 执行如下命令重新安装pip。 - - ``` - sudo apt remove python3-pip - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - -## hb 安装过程中提示"Could not find a version that satisfies the requirement ohos-build" - -- **现象描述** - - 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" - - -- **可能原因** - - 可能是网络环境较差导致的安装失败。 - -- **解决办法** - 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 - 2. 若网络正常,请尝试指定临时pypi源的方式安装: - - ``` - python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build - ``` - - - -## Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt\_pkg” - -- **现象描述** - - Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt\_pkg" - - -- **可能原因** - - python3 apt安装兼容性问题。 - -- **解决办法** - - 执行如下命令重新安装python3-apt。 - - ``` - sudo apt-get remove python3-apt - sudo apt-get install python3-apt - ``` +- **[hb安装异常](quickstart-lite-faq-hb.md)** +- **[编译异常](quickstart-lite-faq-compose.md)** +- **[烧录异常](quickstart-lite-faq-burning.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-overview.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-overview.md deleted file mode 100644 index 6d4f19d180be977622c1c7e497d9dd869b2d0bd5..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-overview.md +++ /dev/null @@ -1,6 +0,0 @@ -# 搭建系统环境概述 - -OpenHarmony可以使用DevEco Device Tool进行开发、编译、烧录、调测等。 - -当前DevEco Device Tool发布了Windows和Ubuntu两个版本,本文以Ubuntu版本进行相应开发介绍。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md index e0ec56568ea23d405647084fb006cc00327e3bb8..6ef934965ed16d267e3031c1262bf74aa65ac9a8 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @@ -1,15 +1,419 @@ -# 搭建轻量与小型系统环境 +# 搭建轻量与小型系统环境 -- **[搭建系统环境概述](quickstart-lite-env-setup-overview.md)** -- **[开发环境准备](quickstart-lite-env-prepare.md)** +## 系统要求 -- **[获取源码](quickstart-lite-sourcecode-acquire.md)** +- Windows系统要求:Windows10 64位系统。 -- **[使用安装包方式搭建编译环境](quickstart-lite-package-environment.md)** +- Ubuntu系统要求:Ubuntu18.04及以上版本,内存推荐16 GB及以上。 -- **[使用Docker方式搭建编译环境](quickstart-lite-docker-environment.md)** +- Windows系统和Ubuntu系统的用户名不能包含中文字符。 -- **[常见问题](quickstart-lite-env-setup-faqs.md)** +- Windows和Ubuntu上安装的DevEco Device Tool为3.0 Release版本。 +## 安装必要的库和工具 + +编译OpenHarmony需要一些库和工具,可以通过以下步骤进行安装。 + +相应操作在Ubuntu环境中进行。 + +1. 使用如下apt-get命令安装后续操作所需的库和工具: + + ``` + sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: + > + > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 + > + > - Java要求java8及以上版本,此处以java8为例。 + +2. 将python 3.8设置为默认python版本。 + 查看python 3.8的位置: + + + ``` + which python3.8 + ``` + + 将python和python3切换为python3.8: + + ``` + sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 + sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 + ``` + + +## 安装DevEco Device Tool + +通过Windows系统远程访问Ubuntu环境进行烧录等操作,需要先在Windows和Ubuntu下分别安装DevEco Device Tool。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> DevEco Device Tool是OpenHarmony的一站式开发工具,支持源码开发、编译、烧录,调测等,本文主要用其远端连接Ubuntu环境进行烧录和运行。 + + +### 安装Window版本DevEco Device Tool + +1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Windows版。 + +2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 + +3. 设置DevEco Device Tool的安装路径,建议安装到非系统盘符,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 + > + > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) + + ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) + +4. 根据安装向导提示,勾选要自动安装的软件。 + + 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 + + ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) + + 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 + + ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) + +5. 在以下界面点击**Next**,进行软件下载和安装。 + + ![zh-cn_image_0000001239634067](figures/zh-cn_image_0000001239634067.png) + +6. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 + + ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) + +7. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 + + ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) + + +### 安装Ubuntu版本DevEco Device Tool + +1. 将Ubuntu Shell环境修改为bash。 + + 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 + + ``` + ls -l /bin/sh + ``` + + ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) + + 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 + + ``` + sudo dpkg-reconfigure dash + ``` + + ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) + +2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Linux版本。 + +3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 + + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.400.zip为软件包名称,请根据实际进行修改。 + + ``` + unzip devicetool-linux-tool-3.0.0.400.zip + ``` + + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + ``` + chmod u+x devicetool-linux-tool-3.0.0.400.sh + ``` + +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 安装过程中,会自动检查Python是否安装,且要求Python为3.8~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 + + + ``` + sudo ./devicetool-linux-tool-3.0.0.400.sh + ``` + + 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 + + ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) + + +## 配置Windows远程访问Ubuntu环境 + + +### 安装SSH服务并获取远程访问的IP地址 + +1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 + + + ``` + sudo apt-get install openssh-server + ``` + +2. 执行如下命令,启动SSH服务。 + + ``` + sudo systemctl start ssh + ``` + +3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 + + ``` + ifconfig + ``` + + ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) + + +### 安装Remote SSH + +1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 + + ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) + +2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 + + ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) + + +### 远程连接Ubuntu环境 + +1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXOPLORER页面点击+按钮。 + + ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) + +2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 + + ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) + +3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 + + ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) + +4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 + + ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) + +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 + + ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) + + 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 + + +### 注册访问Ubuntu环境的公钥 + +在完成以上操作后,您就可以通过Windows远程连接Ubuntu环境进行开发了,但在使用过程中,需要您频繁的输入远程连接密码来进行连接。为解决该问题,您可以使用SSH公钥来进行设置。 + +1. 打开Git bash命令行窗口,执行如下命令,生成SSH公钥,请注意,在执行命令过程中,请根据界面提示进行操作。username和ip请填写连接Ubuntu系统时需要的参数。 + + ``` + ssh-keygen -t rsa + ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip + ``` + + ![zh-cn_image_0000001271532317](figures/zh-cn_image_0000001271532317.png) + +2. 在Visual Studio Code中,点击远程连接的设置按钮,并选择打开config文件。 + + ![zh-cn_image_0000001226034634](figures/zh-cn_image_0000001226034634.png) + +3. 在config配置文件中添加SSK Key文件信息,如下图所示,然后保存即可。 + + ![zh-cn_image_0000001270356233](figures/zh-cn_image_0000001270356233.png) + + +## 获取源码 + +在Ubuntu环境下通过以下步骤拉取OpenHarmony源码。 + + +### 准备工作 + +1. 注册码云gitee帐号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装git客户端和git-lfs。(上述工具已在安装必要的库和工具小节安装。如已安装,请忽略) + + 更新软件源: + + ``` + sudo apt-get update + ``` + + 通过以下命令安装: + + ``` + sudo apt-get install git git-lfs + ``` + +4. 配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +5. 执行如下命令安装码云repo工具。 + + ``` + curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### 获取源码 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 + +- **OpenHarmony主干代码获取** + + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + + 方式二:通过repo + https下载。 + + + ``` + repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- **OpenHarmony发布分支代码获取** + + OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 + + +### 执行prebuilts + + 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 + +``` +bash build/prebuilts_download.sh +``` + + +## 安装编译工具 + +想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-build.md)。 + +相关操作在Ubuntu环境下进行。 + + +### 安装hb + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 如需安装代理,请参考[配置代理](../quick-start/quickstart-lite-reference.md#配置代理)。 + +1. 运行如下命令安装hb并更新至最新版本 + + ``` + pip3 install --user build/lite + ``` + +2. 设置环境变量 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/.local/bin:$PATH + ``` + + 执行如下命令更新环境变量。 + + ``` + source ~/.bashrc + ``` + +3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: + + ``` + usage: hb + + OHOS build system + + positional arguments: + {build,set,env,clean} + build Build source code + set OHOS build settings + env Show OHOS build env + clean Clean output + + optional arguments: + -h, --help show this help message and exit + ``` + +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> - 可采用以下命令卸载hb: +> +> ``` +> pip3 uninstall ohos-build +> ``` +> +> - 若安装hb的过程中遇到问题,请参见下文[常见问题](../quick-start/quickstart-lite-faq-hb.md)进行解决。 + + +### 安装LLVM(仅OpenHarmony_v1.x分支/标签需要) + +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> 如果下载的源码为OpenHarmony_v1.x分支/标签,请按下面的步骤安装9.0.0版本的llvm。 +> +> 如果下载的源码为Master及非OpenHarmony_v1.x分支/标签,可直接跳过本小节,hb会自动下载最新的llvm。 + +1. 打开Linux编译服务器终端。 + +2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar)。 + +3. 解压LLVM安装包至~/llvm路径下。 + + ``` + tar -zxvf llvm.tar -C ~/ + ``` + +4. 设置环境变量。 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + + ``` + export PATH=~/llvm/bin:$PATH + ``` + +5. 生效环境变量。 + + ``` + source ~/.bashrc + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md b/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..43c9baef63931bec9d01c3440515a371858843bf --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-faq-burning.md @@ -0,0 +1,142 @@ +# 烧录异常 + + +## 烧写选择串口后提示“Error: Opening COMxx: Access denied” + +- **现象描述** + + 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 + + **图1** 打开串口失败图 + + ![zh-cn_image_0000001226634728](figures/zh-cn_image_0000001226634728.png) + +- **可能原因** + + 串口已经被占用。 + +- **解决办法** + +1. 按图依次选择下拉框,查找带有serial-xx的终端。 + + **图2** 查找是否存在占用串口的终端 + + ![zh-cn_image_0000001226954644](figures/zh-cn_image_0000001226954644.png) + +2. 点击标号中的垃圾桶图标,关闭串口。 + + **图3** 关闭串口终端 + + ![zh-cn_image_0000001271234761](figures/zh-cn_image_0000001271234761.png) + +3. 重新点击烧写,选择串口并开始烧写程序。 + + **图4** 重新启动烧写任务 + + ![zh-cn_image_0000001271594765](figures/zh-cn_image_0000001271594765.png) + + +## Windows电脑与单板网络连接失败 + +- **现象描述** + + 点击烧写并选择串口后,无法获取文件。 + + **图5** 网络不通,单板无法获取文件图 + + ![zh-cn_image_0000001271234757](figures/zh-cn_image_0000001271234757.png) + +- **可能原因** + + 单板网络与Windows电脑不联通。 + + Windows电脑防火墙未允许Visual Studio Code联网。 + +- **解决方法** + +1. 检查网线是否连接。 + +2. 点击Windows防火墙。 + + **图6** 网络防火墙设置图 + + ![zh-cn_image_0000001226634732](figures/zh-cn_image_0000001226634732.png) + +3. 点击“允许应用通过防火墙”。 + + **图7** 防火墙和网络保护界面图 + + ![zh-cn_image_0000001271354749](figures/zh-cn_image_0000001271354749.png) + +4. 查找Visual Studio Code应用。 + + **图8** 查找Visual Studio Code应用图 + + ![zh-cn_image_0000001271234765](figures/zh-cn_image_0000001271234765.png) + +5. 勾选Visual Studio Code的专用和公用网络的访问权限。 + + **图9** 允许Visual Studio Code应用访问网络 + + ![zh-cn_image_0000001271474585](figures/zh-cn_image_0000001271474585.png) + + +## 烧写失败 + +- **现象描述** + + 点击烧写并选择串口后,出现无法烧写的情况。 + +- **可能原因** + + 安装IDE插件DevEco后未重启。 + +- **解决方法** + + 重启IDE。 + + +## (Hi3516)串口无回显 + +- **现象描述** + + 串口显示已连接,重启单板后,回车无任何回显。 + +- **可能原因1** + + 串口连接错误。 + +- **解决办法** + + 修改串口号。 + + 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按“烧写选择串口后提示“Error: Opening COMxx: Access denied””修改串口号。 + +- **可能原因2** + + 单板U-boot被损坏。 + +- **解决办法** + + 烧写U-boot。 + + 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 + +1. 获取引导文件U-boot。 + + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 单板的U-boot文件请在开源包中获取: + > + > Hi3516DV300:device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin + > + > Hi3518EV300:device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin + +2. 根据USB烧写步骤烧写U-boot文件。 + + 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3518-upload-0000001057313128#section93591711580)中描述的烧写方法,选择对应单板的U-boot文件进行烧写。 + +3. 烧写完成后,登录串口如下图所示。 + + **图10** U-boot烧写完成串口显示图 + + ![zh-cn_image_0000001271234753](figures/zh-cn_image_0000001271234753.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md b/zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md new file mode 100644 index 0000000000000000000000000000000000000000..af9022ffa62633c6987cb7ca0fb7f170486b3619 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-faq-compose.md @@ -0,0 +1,292 @@ +# 编译异常 + + +## Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg” + +- **现象描述** + + Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg" + +- **可能原因** + + python3 apt安装兼容性问题。 + +- **解决办法** + + 执行如下命令重新安装python3-apt。 + + + ``` + sudo apt-get remove python3-apt + sudo apt-get install python3-apt + ``` + + +## 编译构建过程中,提示找不到“python” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + -bash: /usr/bin/python: No such file or directory + ``` + +- **可能原因**1 + + 没有装python。 + +- **解决办法** + + 请使用如下命令安装Python,下方以Python3.8为例。 + + + ``` + sudo apt-get install python3.8 + ``` + +- **可能原因2** + + usr/bin目录下没有python软链接 + + ![zh-cn_image_0000001271354745](figures/zh-cn_image_0000001271354745.png) + +- **解决办法** + + 请运行以下命令添加软链接: + + + ``` + # cd /usr/bin/ + # which python3 + # ln -s /usr/local/bin/python3 python + # python --version + ``` + + 例: + + ![zh-cn_image_0000001227114636](figures/zh-cn_image_0000001227114636.png) + + +## 编译构建过程中,提示找不到“python3” + +- **现象描述** + + ![zh-cn_image_0000001227114640](figures/zh-cn_image_0000001227114640.png) + +- **可能原因** + + 没有装python3。 + +- **解决办法** + + 请使用如下命令安装Python3。 + + + ``` + sudo apt-get install python3.8 + ``` + + +## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details + ``` + +- **可能原因** + + 环境中未安装“gcc”。 + +- **解决办法** + + 1. 通过命令“apt-get install gcc”在线安装。 + 2. 完成后,重新安装python3。 + + +## 安装python3过程中,提示“-bash: make: command not found” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + -bash: make: command not found + ``` + +- **可能原因** + + 环境中未安装“make”。 + +- **解决办法** + + 1. 通过命令“apt-get install make”在线安装。 + 2. 完成后,重新安装python3。 + + +## 安装python3过程中,提示“No module named '_ctypes'” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + ModuleNotFoundError:No module named ‘_ctypes’ + ``` + +- **可能原因** + + 环境中未安装“libffi”和“libffi-devel”。 + +- **解决办法** + + 1. 通过命令“apt-get install libffi\* -y”,在线安装。 + 2. 完成后,重新安装python3。 + + +## 编译构建过程中,提示“No module named 'Crypto'” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + ModuleNotFoundError: No module named 'Crypto' + ``` + +- **可能原因** + + 环境中未安装“Crypto”。 + +- **解决办法** + + 方法1:通过命令“pip3 install Crypto”,在线安装。 + + 方法2:离线安装。 + + 通过网页[https://pypi.org/project/pycrypto/#files](https://pypi.org/project/pycrypto/#files),下载源码。 + + ![zh-cn_image_0000001226794696](figures/zh-cn_image_0000001226794696.png) + + 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 + + 完成上述安装后,重新构建。 + + +## (Hi3861)编译构建过程中,提示“No module named 'ecdsa'” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + ModuleNotFoundError:No module named 'ecdsa' + ``` + +- **可能原因** + + 环境中未安装“ecdsa”。 + +- **解决办法** + + 方法1:通过命令“pip3 install ecdsa”,在线安装。 + + 方法2:离线安装 + + 通过网页[https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files),下载安装包。 + + ![zh-cn_image_0000001271594753](figures/zh-cn_image_0000001271594753.png) + + 将安装包放置Linux服务器中,并安装“pip3 install ecdsa-0.15-py2.py3-none-any.whl”。 + + 完成上述安装后,重新构建。 + + +## (Hi3861)编译构建过程中,提示“Could not find a version that satisfies the requirement six>=1.9.0” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + Could not find a version that satisfies the requirement six>=1.9.0 + ``` + +- **可能原因** + + 环境中未安装合适的“six”。 + +- **解决办法** + + 方法1:通过命令“pip3 install six”,在线安装。 + + 方法2:离线安装。 + + 通过网页[https://pypi.org/project/six/#files](https://pypi.org/project/six/#files),下载安装包。 + + ![zh-cn_image_0000001271474573](figures/zh-cn_image_0000001271474573.png) + + 将源码放置在Linux服务器中,并安装“pip3 install six-1.14.0-py2.py3-none-any.whl”。 + + 完成上述安装后,重新构建。 + + +## (Hi3861)编译构建过程中,提示找不到“-lgcc” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + riscv32-unknown-elf-ld: cannot find -lgcc + ``` + +- **可能原因** + + 交叉编译器gcc_riscv32的PATH添加错误,如下,在"bin"后多添加了一个“/”,应该删除。 + + + ``` + ~/gcc_riscv32/bin/:/data/toolchain/ + ``` + +- **解决办法** + + 重新修改gcc_riscv32的PATH,将多余的“/”删除。 + + + ``` + ~/gcc_riscv32/bin:/data/toolchain/ + ``` + + +## (Hi3861)安装kconfiglib时,遇到lsb_release错误 + +- **现象描述** + + 安装kconfiglib过程中遇到如下错误打印: + + + ``` + subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. + ``` + +- **可能原因** + + lsb_release模块基于的python版本与现有python版本不一致。 + +- **解决办法** + + 执行"find / -name lsb_release",找到lsb_release位置并删除,如:"sudo rm -rf /usr/bin/lsb_release"。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md b/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md new file mode 100644 index 0000000000000000000000000000000000000000..9accfa1781e1ae816c3d304f005e942809ffcf2c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-faq-hb.md @@ -0,0 +1,71 @@ +# hb安装异常 + + +## hb安装过程中出现乱码、段错误 + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 + +- **可能原因** + pip版本过低。 + +- **解决办法** + 执行如下命令升级pip。 + + + ``` + python3 -m pip install -U pip + ``` + + +## hb安装过程中提示"cannot import 'sysconfig' from 'distutils'" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" + +- **可能原因** + 缺少distutils模块。 + +- **解决办法** + 执行如下命令安装。 + + + ``` + sudo apt-get install python3.8-distutils + ``` + + +## hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux_distribution'" + +- **可能原因** + python3 pip安装兼容性问题。 + +- **解决办法** + 执行如下命令重新安装pip。 + + + ``` + sudo apt remove python3-pip + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +## hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" + +- **可能原因** + 可能是网络环境较差导致的安装失败。 + +- **解决办法** + 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 + 2. 若网络正常,请尝试指定临时pypi源的方式安装: + + ``` + python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md b/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md new file mode 100644 index 0000000000000000000000000000000000000000..f4e4860f8d984874154142c13d6a4416857ba928 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-ide-directory.md @@ -0,0 +1,25 @@ +## 轻量和小型系统快速入门(IDE方式) +- [轻量与小型系统入门概述](quickstart-ide-lite-overview.md) + - 准备轻量与小型系统环境 + - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-lite-env-setup-win-ubuntu.md) + - [获取源码](quickstart-ide-lite-sourcecode-acquire.md) + - [创建源码工程](quickstart-ide-lite-create-project.md) + - 运行“Hello World” + - Hi3861开发板 + - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3861-application-framework.md) + - [编译](quickstart-ide-lite-steps-hi3861-building.md) + - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) + - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) + - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) + - [运行](quickstart-ide-lite-steps-hi3816-running.md) + - Hi3516开发板 + - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-application-framework.md) + - [编译](quickstart-ide-lite-steps-hi3516-building.md) + - [烧录](quickstart-ide-lite-steps-hi3516-burn.md) + - [运行](quickstart-ide-lite-steps-hi3516-running.md) + - 附录 + - 开发板介绍 + - [Hi3861开发板介绍](quickstart-ide-lite-introduction-hi3861.md) + - [Hi3516开发板介绍](quickstart-ide-lite-introduction-hi3516.md) + + - [轻量和小型系统快速入门(安装包方式)](quickstart-lite-package-directory.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md index 4627956c67b342391c73c14edb9fd226d4e2bcfe..2424e5b823237f233eadac771ddfdde72ff8005e 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md @@ -1,42 +1,20 @@ -# Hi3516开发板介绍 +# Hi3516开发板介绍 -- [简介](#section26131214194212) -- [开发板规格](#section15192203316533) -## 简介 +## 简介 -Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP\(Image Signal Processor\)、H.265视频压缩编码器,同时集成高性能NNIE引擎,使得Hi3516DV300在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 +Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器,同时集成高性能NNIE引擎,使得Hi3516DV300在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 -**图 1** Hi3516单板正面外观图 + **图1** Hi3516单板正面外观图 + +![zh-cn_image_0000001271234773](figures/zh-cn_image_0000001271234773.png) -![](figures/3516正面.png) +## 开发板规格 -## 开发板规格 - -**表 1** Hi3516开发板规格清单 - - - - - - - - - - - - - -

规格类型

-

规格清单

-

处理器及内部存储

-
  • Hi3516DV300芯片
  • DDR3 1GB
  • eMMC4.5,8GB容量
-

外部器件

-
  • 以太网口
  • 音频视频
    • 1路语音输入
    • 1路单声道(AC_L)输出,接3W功放(LM4871)
    • MicroHDMI(1路HDMI 1.4)
    -
  • 摄像头
    • 传感器IMX335
    • 镜头M12,焦距4mm,光圈1.8
    -
  • 显示屏
    • LCD连接器(2.35寸)
    • LCD连接器(5.5寸)
    -
  • 外部器件及接口
    • SD卡接口
    • JTAG/I2S 接口
    • ADC接口
    • 舵机接口
    • Grove连接器
    • USB2.0(Type C)
    • 功能按键3个,2个用户自定义按键,1个升级按键
    • LED指示灯,绿灯,红灯
    -
-
+ **表1** Hi3516开发板规格清单 +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3518.md b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3518.md deleted file mode 100644 index ff1f64345ed002848fd3ad2061c01c4125e6e884..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3518.md +++ /dev/null @@ -1,57 +0,0 @@ -# Hi3518开发板介绍 - -- [简介](#section14815247616) -- [开发板规格](#section765112478446) - -## 简介 - -Hi3518EV300作为新一代智慧视觉处理SOC,集成新一代ISP\(Image Signal Processor\)以及H.265视频压缩编码器,同时采用先进低功耗工艺和低功耗架构设计,使其在低码率、高画质、低功耗等方面引领行业水平。 - -**图 1** Hi3518EV300单板正面外观图 -![](figures/Hi3518EV300单板正面外观图.png "Hi3518EV300单板正面外观图") - -**图 2** Hi3518EV300单板背面外观图 - - -![](figures/Hi3518正背面.png) - -## 开发板规格 - -**表 1** Hi3518开发板规格清单 - - - - - - - - - - - - - - - - - - - - - - -

规格类型

-

规格清单

-

处理器内核

-
  • 海思3518EV300
-

成像器件

-
  • 1/2.9 F23
-

外部接口

-
  • 外置麦克风MIC
  • 外置8Ω/1.5W扬声器
-

外部存储器接口

-
  • TF卡

    最大支持128GB(通用FAT32格式)

    -
-

WLAN协议

-
  • 支持 802.11 b/g/n
-
- diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md index c25192dba43b4a238db330dadb2b7b4d3affe26e..a4f7e77326e963518d4027fe8da52f3e89809b6d 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md @@ -1,155 +1,68 @@ -# Hi3861开发板介绍 +# Hi3861开发板介绍 -- [简介](#section19352114194115) -- [资源和约束](#section82610215014) -- [开发板规格](#section169054431017) -- [OpenHarmony关键特性](#section1317173016507) -## 简介 +## 简介 Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持OpenHarmony,并配套提供开放、易用的开发和调试运行环境。 -**图 1** Hi3861开发板外观图 -![](figures/Hi3861开发板外观图.png "Hi3861开发板外观图") + **图1** Hi3861开发板外观图 + + ![zh-cn_image_0000001271474569](figures/zh-cn_image_0000001271474569.png) 另外,Hi3861开发板还可以通过与Hi3861底板连接,扩充自身的外设能力,底板如下图所示。 -**图 2** Hi3861底板外观图 + **图2** Hi3861底板外观图 + +![zh-cn_image_0000001226954632](figures/zh-cn_image_0000001226954632.png) +- RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 -![](figures/zh-cn_image_0000001171455564.png) +- Hi3861 WLAN基带支持正交频分复用(OFDM)技术,并向下兼容直接序列扩频(DSSS)和补码键控(CCK)技术,支持IEEE 802.11 b/g/n协议的各种数据速率。 -- RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 -- Hi3861 WLAN基带支持正交频分复用(OFDM)技术,并向下兼容直接序列扩频(DSSS)和补码键控(CCK)技术,支持IEEE 802.11 b/g/n协议的各种数据速率。 -- Hi3861芯片集成高性能32bit微处理器、硬件安全引擎以及丰富的外设接口,外设接口包括SPI(Synchronous Peripheral Interface)、UART(Universal Asynchronous Receiver & Transmitter)、I2C(The Inter Integrated Circuit)、PWM(Pulse Width Modulation)、GPIO(General Purpose Input/Output)和多路ADC(Analog to Digital Converter),同时支持高速SDIO2.0(Secure Digital Input/Output)接口,最高时钟可达50MHz;芯片内置SRAM(Static Random Access Memory)和Flash,可独立运行,并支持在Flash上运行程序。 -- Hi3861芯片适用于智能家电等物联网智能终端领域。 +- Hi3861芯片集成高性能32bit微处理器、硬件安全引擎以及丰富的外设接口,外设接口包括SPI(Synchronous Peripheral Interface)、UART(Universal Asynchronous Receiver & Transmitter)、I2C(The Inter Integrated Circuit)、PWM(Pulse Width Modulation)、GPIO(General Purpose Input/Output)和多路ADC(Analog to Digital Converter),同时支持高速SDIO2.0(Secure Digital Input/Output)接口,最高时钟可达50MHz;芯片内置SRAM(Static Random Access Memory)和Flash,可独立运行,并支持在Flash上运行程序。 - **图 3** Hi3861功能框图 - +- Hi3861芯片适用于智能家电等物联网智能终端领域。 - ![](figures/zh-cn_image_0000001171455566.png) + **图3** Hi3861功能框图 + + ![zh-cn_image_0000001226794688](figures/zh-cn_image_0000001226794688.png) -## 资源和约束 +## 资源和约束 Hi3861开发板资源十分有限,整板共2MB FLASH,352KB RAM。在编写业务代码时,需注意资源使用效率。 -## 开发板规格 - -**表 1** Hi3861开发板规格清单 - - - - - - - - - - - - - - - - - - - - - - - - - -

规格类型

-

规格清单

-

通用规格

-
  • 1×1 2.4GHz频段(ch1~ch14)
  • PHY支持IEEE 802.11b/g/n
  • MAC支持IEEE802.11 d/e/h/i/k/v/w
-
  • 内置PA和LNA,集成TX/RX Switch、Balun等
  • 支持STA和AP形态,作为AP时最大支持6 个STA接入
  • 支持WFA WPA/WPA2 personal、WPS2.0
  • 支持与BT/BLE芯片共存的2/3/4 线PTA方案
  • 电源电压输入范围:2.3V~3.6V
-
  • IO电源电压支持1.8V和3.3V
-
  • 支持RF自校准方案
  • 低功耗:
    • Ultra Deep Sleep模式:5μA@3.3V
    • DTIM1:1.5mA@3.3V
    • DTIM3:0.8mA@3.3V
    -
-

PHY特性

-
  • 支持IEEE802.11b/g/n单天线所有的数据速率
  • 支持最大速率:72.2Mbps@HT20 MCS7
  • 支持标准20MHz带宽和5M/10M窄带宽
  • 支持STBC
  • 支持Short-GI
-

MAC特性

-
  • 支持A-MPDU,A-MSDU
  • 支持Blk-ACK
  • 支持QoS,满足不同业务服务质量需求
-

CPU子系统

-
  • 高性能 32bit微处理器,最大工作频率160MHz
  • 内嵌SRAM 352KB、ROM 288KB
  • 内嵌 2MB Flash
-

外围接口

-
  • 1个SDIO接口、2个SPI接口、2个I2C接口、3个UART接口、15个GPIO接口、7路ADC输入、6路PWM、1个I2S接口(注:上述接口通过复用实现)
  • 外部主晶体频率40M或24M
-

其他信息

-
  • 封装:QFN-32,5mm×5mm
  • 工作温度:-40℃ ~ +85℃
-
- -## OpenHarmony关键特性 -OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 +## 开发板规格 + + **表1** Hi3861开发板规格清单 -**表 2** OpenHarmony关键组件列表 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

组件名

-

能力介绍

-

WLAN服务

-

提供WLAN服务能力。包括:station和hotspot模式的连接、断开、状态查询等。

-

模组外设控制

-

提供操作外设的能力。包括:I2C、I2S、ADC、UART、SPI、SDIO、GPIO、PWM、FLASH等。

-

分布式软总线

-

OpenHarmony分布式网络中,提供设备被发现、数据传输的能力。

-

设备安全绑定

-

提供在设备互联场景中,数据在设备之间的安全流转的能力。

-

基础加解密

-

提供密钥管理、加解密等能力。

-

系统服务管理

-

系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。

-

启动引导

-

提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。

-

系统属性

-

提供获取与设置系统属性的能力。

-

基础库

-

提供公共基础库能力。包括:文件操作、KV存储管理等。

-

DFX

-

提供DFX能力。包括:流水日志、时间打点等。

-

XTS

-

提供OpenHarmony生态认证测试套件的集合能力。

-
+| 规格类型 | 规格清单 | +| -------- | -------- | +| 通用规格 | - 1×1 2.4GHz频段(ch1~ch14)
- PHY支持IEEE 802.11b/g/n
- MAC支持IEEE802.11 d/e/h/i/k/v/w
- 内置PA和LNA,集成TX/RX Switch、Balun等
- 支持STA和AP形态,作为AP时最大支持6 个STA接入
- 支持WFA WPA/WPA2 personal、WPS2.0
- 支持与BT/BLE芯片共存的2/3/4 线PTA方案
- 电源电压输入范围:2.3V~3.6V
- IO电源电压支持1.8V和3.3V
- 支持RF自校准方案
- 低功耗:
  - Ultra Deep Sleep模式:5μA \@3.3V
  - DTIM1:1.5mA \@3.3V
  - DTIM3:0.8mA \@3.3V | +| PHY特性 | - 支持IEEE802.11b/g/n单天线所有的数据速率
- 支持最大速率:72.2Mbps\@HT20 MCS7
- 支持标准20MHz带宽和5M/10M窄带宽
- 支持STBC
- 支持Short-GI | +| MAC特性 | - 支持A-MPDU,A-MSDU
- 支持Blk-ACK
- 支持QoS,满足不同业务服务质量需求 | +| CPU子系统 | - 高性能 32bit微处理器,最大工作频率160MHz
- 内嵌SRAM 352KB、ROM 288KB
- 内嵌 2MB Flash | +| 外围接口 | - 1个SDIO接口、2个SPI接口、2个I2C接口、3个UART接口、15个GPIO接口、7路ADC输入、6路PWM、1个I2S接口(注:上述接口通过复用实现)
- 外部主晶体频率40M或24M | +| 其他信息 | - 封装:QFN-32,5mm×5mm
- 工作温度:-40℃ ~ +85℃ | + + +## OpenHarmony关键特性 + +OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件如下表所示。 + **表2** OpenHarmony关键组件列表 + +| 组件名 | 能力介绍 | +| -------- | -------- | +| WLAN服务 | 提供WLAN服务能力。包括:station和hotspot模式的连接、断开、状态查询等。 | +| 模组外设控制 | 提供操作外设的能力。包括:I2C、I2S、ADC、UART、SPI、SDIO、GPIO、PWM、FLASH等。 | +| 分布式软总线 | 在OpenHarmony分布式网络中,提供设备被发现、数据传输的能力。 | +| 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 | +| 基础加解密 | 提供密钥管理、加解密等能力。 | +| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 | +| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。 | +| 系统属性 | 提供获取与设置系统属性的能力。 | +| 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 | +| DFX | 提供DFX能力。包括:流水日志、时间打点等。 | +| XTS | 提供OpenHarmony生态认证测试套件的集合能力。 | diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-introduction.md b/zh-cn/device-dev/quick-start/quickstart-lite-introduction.md deleted file mode 100644 index 95c5c0fc921ec6ff41696685ae06ff340a5d7568..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-introduction.md +++ /dev/null @@ -1,9 +0,0 @@ -# 附录 - -- **[Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md)** - -- **[Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md)** - -- **[Hi3518开发板介绍](quickstart-lite-introduction-hi3518.md)** - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md b/zh-cn/device-dev/quick-start/quickstart-lite-overview.md index 1feb98128e79e121fe6403300d74196875695ff2..291ad0accad339b86416c7656c503b7021110e6a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-overview.md @@ -1,23 +1,43 @@ -# 轻量与小型系统入门概述 +# 轻量与小型系统入门概述 -OpenHarmony轻量和小型系统适用于内存较小的IOT设备。通过本文,开发者可以快速熟悉OpenHarmony轻量和小型系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 -轻量和小型系统的开发有以下两种方法: +## 简介 -- 用Windows环境进行开发和烧录,使用Linux环境进行编译。 -- 统一使用Linux环境进行开发、编译和烧录。 -因目前Windows系统不支持编译,暂时无法全部使用Windows环境进行开发,开发者可根据使用习惯选择合适的开发方法。 +OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存≥128KiB)。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 -本文将介绍第二种方法,下方所有操作均在Linux环境下进行。 -本文选取了三款典型开发板:Hi3861 WLAN模组、Hi3516DV300、Hi3518EV300,并基于上述三款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](quickstart-lite-introduction-hi3861.md#section19352114194115),开发者可根据需要自行购买的开发板。 +考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: -轻量和小型系统快速入门流程如下图所示,其中搭建编译环境环节可根据实际情况选择Docker方式或安装包方式其中一种即可。 ->![](../public_sys-resources/icon-note.gif) **说明:** ->Docker环境已经封装了相关编译工具,开发者在使用该Docker环境时可以省去Ubuntu编译环境及开发板环境的的搭建操作。 +- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 -**图 1** 轻量和小型系统快速入门流程 -![](figures/轻量和小型系统快速入门流程.png "轻量和小型系统快速入门流程") +- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 + +本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[轻量与小型系统快速入门(IDE方式)](../quick-start/quickstart-ide-lite.md)。 + + +## 开发环境 + +开发者通常习惯采用Windows+Ubuntu环境进行OpenHarmony开发: + +- Windows:用于源码开发、烧录等。 + +- Ubuntu:用于源码编译。 + +本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 + + +## 开发板 + +本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-lite-board-introduction.md),开发者可根据需要自行购买开发板。 + + +## 开发流程 + +轻量和小型系统快速入门流程如下图所示。 + + **图1** 轻量和小型系统快速入门开发流程 + + ![zh-cn_image_0000001227114628](figures/zh-cn_image_0000001227114628.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md new file mode 100644 index 0000000000000000000000000000000000000000..981ec0208e7896beec0e7f4ad8d4b556a506b02f --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-package-directory.md @@ -0,0 +1,28 @@ +## 轻量和小型系统快速入门(安装包方式) +- [轻量与小型系统入门概述](quickstart-lite-overview.md) +- [搭建轻量与小型系统环境](quickstart-lite-env-setup.md) +- 运行“Hello World” + - Hi3861开发板 + - [安装Hi3861开发板环境](quickstart-lite-steps-hi3861-setting.md) + - [编写“Hello World”程序](quickstart-lite-steps-hi3861-application-framework.md) + - [编译](quickstart-lite-steps-hi3861-building.md) + - [烧录](quickstart-lite-steps-hi3861-burn.md) + - [联网](quickstart-lite-steps-hi3861-netconfig.md) + - [调试验证](quickstart-lite-steps-hi3861-debug.md) + - [运行](quickstart-lite-steps-hi3816-running.md) + - Hi3516开发板 + - [安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md) + - [编写“Hello World”程序](quickstart-lite-steps-hi3516-application-framework.md) + - [编译](quickstart-lite-steps-hi3516-building.md) + - [烧录](quickstart-lite-steps-hi3516-burn.md) + - [运行](quickstart-lite-steps-hi3516-running.md) +- 常见问题 + - [hb安装异常](quickstart-lite-faq-hb.md) + - [编译异常](quickstart-lite-faq-compose.md) + - [烧录异常](quickstart-lite-faq-burning.md) +- 附录 + - 开发板介绍 + - [Hi3861开发板介绍](quickstart-lite-introduction-hi3861.md) + - [Hi3516开发板介绍](quickstart-lite-introduction-hi3516.md) + - [轻量和小型系统快速入门(IDE方式)](quickstart-lite-ide-directory.md) + - [参考信息](quickstart-lite-reference.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md deleted file mode 100644 index c79a3ade616dd8de0935d8b02c7769d24a1fe823..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md +++ /dev/null @@ -1,104 +0,0 @@ -# 使用安装包方式搭建编译环境 - - -使用安装包方式搭建Ubuntu编译环境步骤如下: - -1. 安装必要的库和工具:编译所需的必要工具和库(如打包、镜像制作等) -2. 安装hb:OpenHarmony编译构建命令行工具 -3. 安装LLVM\(仅OpenHarmony\_v1.x分支/标签需要\) - -想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建使用指南](../subsystems/subsys-build-mini-lite.md)。 - -## 安装必要的库和工具 - -使用如下apt-get命令安装编译所需的必要的库和工具: - -``` -sudo apt-get install build-essential gcc g++ make libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi cpio device-tree-compiler libncurses5 libncurses5-dev libncursesw5 openjdk-8-jre default-jre default-jdk python3.8 python3-pip -``` ->![](../public_sys-resources/icon-note.gif) **说明:** ->以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: ->- Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 ->- java要求java8及以上版本,此处以java8为例。 - -## 安装hb - -1. 运行如下命令安装hb - - ``` - python3 -m pip install --user ohos-build - ``` - -2. 设置环境变量 - - ``` - vim ~/.bashrc - ``` - - 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - - ``` - export PATH=~/.local/bin:$PATH - ``` - - 执行如下命令更新环境变量。 - - ``` - source ~/.bashrc - ``` - -3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: - - ``` - usage: hb - - OHOS build system - - positional arguments: - {build,set,env,clean} - build Build source code - set OHOS build settings - env Show OHOS build env - clean Clean output - - optional arguments: - -h, --help show this help message and exit - ``` - - ->![](../public_sys-resources/icon-notice.gif) **须知:** ->若安装hb的过程中遇到问题,请参见下文[常见问题](quickstart-lite-env-setup-faqs.md)进行解决。 - -## 安装LLVM\(仅OpenHarmony\_v1.x分支/标签需要\) - ->![](../public_sys-resources/icon-notice.gif) **须知:** ->如果下载的源码为OpenHarmony\_v1.x分支/标签, 请按下面的步骤安装9.0.0版本的llvm。 ->如果下载的源码为Master及非OpenHarmony\_v1.x分支/标签,可直接跳过本小节,hb会自动下载最新的llvm。 - -1. 打开Linux编译服务器终端。 -2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar)。 -3. 解压LLVM安装包至\~/llvm路径下。 - - ``` - tar -zxvf llvm.tar -C ~/ - ``` - -4. 设置环境变量。 - - ``` - vim ~/.bashrc - ``` - - 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 - - ``` - export PATH=~/llvm/bin:$PATH - ``` - -5. 生效环境变量。 - - ``` - source ~/.bashrc - ``` - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-reference.md b/zh-cn/device-dev/quick-start/quickstart-lite-reference.md new file mode 100644 index 0000000000000000000000000000000000000000..d8a7f6dfaed2d4b7755224d10d1d971740a40d5b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-reference.md @@ -0,0 +1,69 @@ +# 参考信息 + + +## 使用build.sh脚本编译源码 + + +1. 进入源码根目录,执行如下命令进行版本编译。 + + ``` + ./build.sh --product-name name --ccache + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > _name_为产品名称,例如Hi3516DV300、rk3568等。 + +2. 检查编译结果。编译完成后,log中显示如下: + + ``` + post_process + =====build name successful. + ``` + + 编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在out/{device_name}/packages/phone/images/ 目录下。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-standard-large.md)。 + + +## 配置代理 + + +### 配置Python代理 + +1. 新建代理配置文件。 + + ``` + mkdir ~/.pipvim ~/.pip/pip.conf + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + [global] + index-url = http://代理网址 + trusted-host = 可信任的镜像地址 + timeout = 120 + ``` + + +### 配置NPM代理 + +1. 新建代理配置文件。 + + ``` + vim ~/.npmrc + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + registry=http://代理网址 + strict-ssl=false + ``` + +3. 将以下内容添加到.bashrc中并保存退出。 + + ``` + export NPM_REGISTRY=http://代理网址 + source .bashrc + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md deleted file mode 100644 index 36c5fee703c5bf9c93f85a4a6bc228bf25a57f37..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md +++ /dev/null @@ -1,54 +0,0 @@ -# 获取源码 - -- [前提条件](#section21887149017) -- [操作步骤](#section349724435812) - -## 前提条件 - -1. 注册码云gitee账号。 -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 -3. 安装[git客户端](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. 安装码云repo工具,可以执行如下命令。 - - ``` - curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -## 操作步骤 - ->![](../public_sys-resources/icon-note.gif) **说明:** ->Master主干为开发分支,开发者可通过Master主干获取最新特性。发布版本代码相对比较稳定,开发者可基于发布版本代码进行商用功能开发。 - -- **OpenHarmony主干代码获取** - - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - 方式二:通过repo + https下载。 - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **OpenHarmony发布版本代码获取** - - OpenHarmony发布版本获取源码方式请参考[Release-Notes](../get-code/../../release-notes/Readme.md)。 - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md index 59780d7a7ce22fa96a79c1e8d258bfbb9681a598..928049b41efe3db8ca86b6b36dd276421ec285d6 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md @@ -1,121 +1,139 @@ -# 新建应用程序 - -下方将通过修改源码的方式展示如何编写简单程序,输出“Hello OHOS!”。请在[获取源码](quickstart-lite-sourcecode-acquire.md)章节下载的源码目录中进行下述操作。 - -1. 新建目录及源码。 - - 新建**applications/sample/camera/apps/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - - ``` - #include - - int main(int argc, char **argv) - { - printf("\n************************************************\n"); - printf("\n\t\tHello OHOS!\n"); - printf("\n************************************************\n\n"); - - return 0; - } - ``` - -2. 新建编译组织文件。 - - 新建**applications/sample/camera/apps/BUILD.gn**文件,内容如下所示: - - ``` - import("//build/lite/config/component/lite_component.gni") - lite_component("hello-OHOS") { - features = [ ":helloworld" ] - } - executable("helloworld") { - output_name = "helloworld" - sources = [ "src/helloworld.c" ] - include_dirs = [] - defines = [] - cflags_c = [] - ldflags = [] - } - ``` - -3. 添加新组件。 - - 修改文件**build/lite/components/applications.json**,添加组件hello\_world\_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - ``` - { - "components": [ - { - "component": "camera_sample_communication", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/communication" - ], - "targets": [ - "//applications/sample/camera/communication:sample" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##start## - { - "component": "hello_world_app", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/apps" - ], - "targets": [ - "//applications/sample/camera/apps:hello-OHOS" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##end## - { - "component": "camera_sample_app", - "description": "Camera related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/launcher", - "applications/sample/camera/cameraApp", - "applications/sample/camera/setting", - "applications/sample/camera/gallery", - "applications/sample/camera/media" - ], - ``` - -4. 修改单板配置文件。 - - 修改文件**vendor/hisilicon/hispark\_taurus/config.json**,新增hello\_world\_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - ``` - { - "subsystem": "applications", - "components": [ - { "component": "camera_sample_app", "features":[] }, - { "component": "camera_sample_ai", "features":[] }, - ##start## - { "component": "hello_world_app", "features":[] }, - ##end## - { "component": "camera_screensaver_app", "features":[] } - ] - }, - ``` +# 编写“Hello World”程序 +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下: + + + +``` +applications/sample/hello +│── BUILD.gn +└── src + └── helloworld.c +``` + + +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 新建目录及源码。 + + 新建**applications/sample/hello/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + + int main(int argc, char **argv) + { + printf("\n\n"); + printf("\n\t\tHello OHOS!\n"); + printf("\n\n\n"); + + return 0; + } + ``` + +2. 新建编译组织文件。 + + 新建**applications/sample/hello/BUILD.gn**文件,内容如下所示: + + + ``` + import("//build/lite/config/component/lite_component.gni") + lite_component("hello-OHOS") { + features = [ ":helloworld" ] + } + executable("helloworld") { + output_name = "helloworld" + sources = [ "src/helloworld.c" ] + } + ``` + +3. 添加新组件。 + + 修改文件**build/lite/components/applications.json**,添加组件hello_world_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "components": [ + { + "component": "camera_sample_communication", + "description": "Communication related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/communication" + ], + "targets": [ + "//applications/sample/camera/communication:sample" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##start## + { + "component": "hello_world_app", + "description": "hello world samples.", + "optional": "true", + "dirs": [ + "applications/sample/hello" + ], + "targets": [ + "//applications/sample/hello:hello-OHOS" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##end## + { + "component": "camera_sample_app", + "description": "Camera related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/launcher", + "applications/sample/camera/cameraApp", + "applications/sample/camera/setting", + "applications/sample/camera/gallery", + "applications/sample/camera/media" + ], + ``` + +4. 修改单板配置文件。 + + 修改文件**vendor/hisilicon/hispark_taurus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "subsystem": "applications", + "components": [ + { "component": "camera_sample_app", "features":[] }, + { "component": "camera_sample_ai", "features":[] }, + ##start## + { "component": "hello_world_app", "features":[] }, + ##end## + { "component": "camera_screensaver_app", "features":[] } + ] + }, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md index c1fa7209c911e04aa113c238ff03d2eb5744fb7e..7282aba0078c2a2a1475e153085f28a5cec9254d 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-building.md @@ -1,27 +1,52 @@ -# 编译 +# 编译 -下方将介绍如何使用Hi3516开发板进行编译。使用安装包方式与docker方式搭建Ubuntu编译环境,编译步骤相同。 -1. 请进入源码根目录,执行如下命令进行编译: +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](../quick-start/quickstart-lite-reference.md)。 - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果使用Docker方式搭建编译环境,请在[获取Docker环境](quickstart-lite-docker-environment.md#section15666113905015)中进入的Docker构建环境中,执行如下命令进行编译。 - ``` - hb set(设置编译路径) - .(选择当前路径) - 选择ipcamera_hispark_taurus并回车 - hb build -f(执行编译) - ``` +请进入源码根目录,执行如下命令进行编译: - **图 1** Hi3516编译设置图例-Docker方式 - ![](figures/Hi3516编译设置图例-Docker方式.png "Hi3516编译设置图例-Docker方式") -2. 编译结束后,出现“ipcamera\_hispark\_taurus build success”字样,则证明构建成功。 +1. 设置编译路径。 + + ``` + hb set + ``` - >![](../public_sys-resources/icon-notice.gif) **须知:** - >烧录相关文件获取路径: - >结果文件:out/hispark\_taurus/ipcamera\_hispark\_taurus。 - >U-boot文件:device/hisilicon/hispark\_taurus/sdk\_liteos/uboot/out/boot/u-boot-hi3516dv300.bin。 +2. 选择当前路径。 + + ``` + . + ``` +3. 在hisilicon下选择ipcamera_hispark_taurus并回车。 +4. 执行编译。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 + + + ``` + hb build -f + ``` + + + **图1** Hi3516编译设置图例 + + ![zh-cn_image_0000001271594749](figures/zh-cn_image_0000001271594749.png) + +5. 编译结束后,出现“build success”字样,则证明构建成功。 + + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 烧录相关文件获取路径: + > + > - 编译结果文件及日志文件:out/hispark_taurus/ipcamera_hispark_taurus。 + > + > - U-boot文件:device/board/hisilicon/hispark_taurus/uboot/out/boot/u-boot-hi3516dv300.bin。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md index 413680008e32110206e7cb3f2ccfdea634931468..909d3e44fc71fa645d3b6aea691f7db1dce42d46 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md @@ -1,93 +1,104 @@ -# 烧录 +# 烧录 -- [前提条件](#section762111572589) -- [使用网口烧录](#section12323175612487) -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 +Hi3516DV300支持USB烧录、网口烧录和串口烧录三种方式,本文采用USB方式进行烧录。相关操作在Windows环境下进行 。 -DevEco Device Tool以插件方式运行,基于Visual Studio Code进行扩展,用户可点击Visual Studio Code左侧栏的![](figures/2021-01-27_170334.png)图标打开DevEco Device Tool。 -Hi3516开发板的代码烧录支持USB烧录、网口烧录和串口烧录三种方式。此处仅以网口烧录为例进行说明,其它方式请参考[Hi3516DV300开发板烧录](https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3516-upload-0000001052148681#section1760842019292)。 +### 导入源码 -## 前提条件 +在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](../quick-start/quickstart-lite-env-setup.md)的情况下,您还需要通过以下步骤导入源码后,方可进行烧录。 -1. 在DevEco Device Tool工具中点击**Import Project**导入新建应用程序章节修改后的源码文件。 +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - ![](figures/import-project.png) + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) -2. 选择源码导入时,系统会提示该工程不是DevEco Device Tool工程,点击**Import**。 +2. 选择要导入的源码目录(需要访问Ubuntu下的源码目录),点击**Import**打开。 - ![](figures/import-project-confirm.png) + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 -3. MCU选择HiSilicom\_Arm下的Hi3516DV300,Board选择hi3516dv300,Framework选择Hb,然后点击**Import**完成导入。 + ![zh-cn_image_0000001271791385](figures/zh-cn_image_0000001271791385.png) - ![](figures/hi3516-import-projects.png) +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) -## 使用网口烧录 +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 -1. 请连接好电脑和待烧录开发板,需要同时连接串口、网口和电源,具体可参考[Hi3516DV300开发板介绍](https://device.harmonyos.com/cn/docs/documentation/guide/quickstart-lite-introduction-hi3516-0000001152041033)。 -2. 查看并记录对应的串口号。 + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。此处选择ipcamera_hispark_taurus。 - Windows系统,打开设备管理器查看并记录对应的串口号,或在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 + ![zh-cn_image_0000001227711014](figures/zh-cn_image_0000001227711014.png) - ![](figures/record-the-serial-port-number.png) +6. 点击**Open**打开工程或源码。 - Linux系统,在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - ![](figures/Snap22.png) +### 烧录 -3. 在QUICK ACCESS \> DevEco Home \> Projects中,点击**Settings**打开工程配置界面。 +完成源码导入后,通过以下步骤进行烧录: - ![](figures/zh-cn_image_0000001222969587.png) +1. 请连接好电脑和待烧录开发板,需要同时连接串口和USB口,具体可参考[Hi3516DV300开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)。 -4. 在“hi3516dv300”页签,设置烧录选项,包括upload\_partitions、upload\_port和upload\_protocol。 +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - upload\_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 - - upload\_port:选择已查询的串口号。 - - upload\_protocol:选择烧录协议,固定选择“hiburn-net”。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 - ![](figures/zh-cn_image_0000001177474882.png) + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) -5. 检查和设置连接开发板后的网络适配器的IP地址信息,设置方法请参考[设置Hi3516DV300网口烧录的IP地址信息](https://device.harmonyos.com/cn/docs/documentation/guide/set_ipaddress-0000001141825075)。 -6. 设置网口烧录的IP地址信息,设置如下选项: + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 - - upload\_net\_server\_ip:选择步骤6中设置的IP地址信息。例如192.168.1.2 - - upload\_net\_client\_mask:设置开发板的子网掩码,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如255.255.255.0 - - upload\_net\_client\_gw:设置开发板的网关,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如192.168.1.1 - - upload\_net\_client\_ip:设置开发板的IP地址,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如192.168.1.3 +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 - ![](figures/ip-address-information.png) + ![zh-cn_image_0000001216516128](figures/zh-cn_image_0000001216516128.png) -7. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 - 1. 在“hi3516dv300\_fastboot”页签,在New Option选项中选择需要修改的项,例如partition\_bin(烧录文件路径)、partition\_addr(烧录文件起始地址)、partition\_length(烧录文件分区长度)等。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 - ![](figures/zh-cn_image_0000001222994321.png) +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 - 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) - >![](../public_sys-resources/icon-note.gif) **说明:** - >在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 - ![](figures/zh-cn_image_0000001223185957.png) + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 + - upload_port:选择已查询到的串口号。 + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 - 3. 按照相同的方法修改kernel、rootfs和userfs的烧录文件信息。 + ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) -8. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 -9. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3516dv300下的**Upload**按钮,启动烧录。 +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 - ![](figures/hi3516-upload-start-burning.png) + 1. 在“hi3516dv300_fastboot”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 -10. 启动烧录后,显示如下提示信息时,请重启开发板(下电再上电)。 + ![zh-cn_image_0000001198889702](figures/zh-cn_image_0000001198889702.png) - ![](figures/hi3516-restart-the-development-board.png) + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 -11. 重新上电后,界面提示如下信息时,表示烧录成功。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - ![](figures/hi3516-burning-succeeded-net.png) + ![zh-cn_image_0000001243290907](figures/zh-cn_image_0000001243290907.png) -12. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 + 3. 按照相同的方法修改kernel、rootfs和userfs的烧录文件信息。 +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击hi3516dv300下的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您是第一次在工作台烧录Hi3516DV300/Hi3518EV300开发板,可能烧录失败,提示“not find the Devices”,然后根据[Hi3516DV300/Hi3518EV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)进行处理后再重新烧录。 + + ![zh-cn_image_0000001267231481](figures/zh-cn_image_0000001267231481.png) + +9. 在终端窗口显示如下提示信息时,按住复位键,插拔USB线,最后松开复位键启动烧录。 + + ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) + + 启动烧录后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) + +10. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md deleted file mode 100644 index 73982f145d22b78070f1e519b6273ffce983a803..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md +++ /dev/null @@ -1,181 +0,0 @@ -# 常见问题 - -- [烧写选择串口后提示“Error: Opening COMxx: Access denied”](#section627268185113) -- [Windows电脑与单板网络连接失败](#section195391036568) -- [烧写失败](#section571164016565) -- [编译构建过程中,提示找不到“python”](#section1039835245619) -- [串口无回显](#section14871149155911) - -## 烧写选择串口后提示“Error: Opening COMxx: Access denied” - -- **现象描述** - - 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 - - **图 1** 打开串口失败图 - ![](figures/打开串口失败图.png "打开串口失败图") - -- **可能原因** - - 串口已经被占用。 - -- **解决办法** - -1. 按图依次选择下拉框,查找带有serial-xx的终端。 - - **图 2** 查找是否存在占用串口的终端 - ![](figures/查找是否存在占用串口的终端.png "查找是否存在占用串口的终端") - -2. 点击标号中的垃圾桶图标,关闭串口。 - - **图 3** 关闭串口终端 - ![](figures/关闭串口终端.png "关闭串口终端") - -3. 重新点击烧写,选择串口并开始烧写程序。 - - **图 4** 重新启动烧写任务 - - - ![](figures/changjian1.png) - - -## Windows电脑与单板网络连接失败 - -- **现象描述** - - 点击烧写并选择串口后,无法获取文件。 - - **图 5** 网络不通,单板无法获取文件图 - ![](figures/网络不通-单板无法获取文件图.png "网络不通-单板无法获取文件图") - -- **可能原因** - - 单板网络与Windows电脑不联通。 - - Windows电脑防火墙未允许Visual Studio Code联网。 - -- **解决方法** - -1. 检查网线是否连接。 -2. 点击Windows防火墙。 - - **图 6** 网络防火墙设置图 - ![](figures/网络防火墙设置图.png "网络防火墙设置图") - -3. 点击“允许应用通过防火墙”。 - - **图 7** 防火墙和网络保护界面图 - ![](figures/防火墙和网络保护界面图.png "防火墙和网络保护界面图") - -4. 查找Visual Studio Code应用。 - - **图 8** 查找Visual Studio Code应用图 - ![](figures/查找Visual-Studio-Code应用图.png "查找Visual-Studio-Code应用图") - -5. 勾选Visual Studio Code的专用和公用网络的访问权限。 - - **图 9** 允许Visual Studio Code应用访问网络 - ![](figures/允许Visual-Studio-Code应用访问网络.png "允许Visual-Studio-Code应用访问网络") - - -## 烧写失败 - -- **现象描述** - - 点击烧写并选择串口后,出现无法烧写的情况。 - -- **可能原因** - - 安装IDE插件DevEco后未重启。 - -- **解决方法** - - 重启IDE。 - - -## 编译构建过程中,提示找不到“python” - -- **现象描述** - - ![](figures/zh-cn_image_0000001216693913.png) - -- **可能原因**1 - - 没有装python。 - -- **解决办法**1 - - 请使用如下命令安装Python,下方以Python3.8为例。 - - ``` - sudo apt-get install python3.8 - ``` - - -- **可能原因**2 - - usr/bin目录下没有python软链接。 - - ![](figures/zh-cn_image_0000001217013865.png) - -- **解决办法**2 - - 请运行以下命令: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - 例: - - ![](figures/zh-cn_image_0000001216693915.png) - - -## 串口无回显 - -- **现象描述** - - 串口显示已连接,重启单板后,回车无任何回显。 - -- **可能原因1** - - 串口连接错误。 - -- **解决办法** - - 修改串口号。 - - 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按镜像运行内[步骤1](#section627268185113)修改串口号。 - - -- **可能原因2** - - 单板U-boot被损坏。 - -- **解决办法** - - 烧写U-boot。 - - 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 - - -1. 获取引导文件U-boot。 - - >![](../public_sys-resources/icon-notice.gif) **须知:** - >单板的U-boot文件请在开源包中获取: - >Hi3516DV300:device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin - >Hi3518EV300:device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin - -2. 根据USB烧写步骤烧写U-boot文件。 - - 按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_upload-0000001052148681)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 - -3. 烧写完成后,登录串口如下图所示。 - - **图 10** U-boot烧写完成串口显示图 - ![](figures/U-boot烧写完成串口显示图.png "U-boot烧写完成串口显示图") - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md index 143115b9dbe1c3d9f300ca57d64cddb99901b709..416307927de465db6c9cecae1c85e63d1f06e46d 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md @@ -1,33 +1,51 @@ -# 运行 +# 运行 -- [镜像运行](#section11324753143912) -- [下一步学习](#section9712145420182) -## 镜像运行 +## 启动系统 在完成Hi3516DV300的烧录后,还需要设置BootLoader引导程序,才能运行OpenHarmony系统。 -1. 在Hi3516DV300任务中,点击**Configure bootloader(Boot OS)**进行配置即可。 +1. 在Hi3516DV300任务中,点击Configure bootloader(Boot OS)进行配置即可。 - >![](../public_sys-resources/icon-note.gif) **说明:** - >DevEco Device Tool针对Hi3516DV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > DevEco Device Tool针对Hi3516DV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 - ![](figures/bootloader.png) + ![zh-cn_image_0000001209906547](figures/zh-cn_image_0000001209906547.png) -2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 +2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 - ![](figures/reset_success.png) + ![zh-cn_image_0000001210385161](figures/zh-cn_image_0000001210385161.png) -3. 在任务栏点击**Monitor**按钮,启动串口工具。 +3. 在任务栏点击**Monitor**按钮,启动串口工具。 - ![](figures/monitor.png) + ![zh-cn_image_0000001164506870](figures/zh-cn_image_0000001164506870.png) -4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 +4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 - ![](figures/reboot_success.png) + ![zh-cn_image_0000001198626874](figures/zh-cn_image_0000001198626874.png) -## 下一步学习 +## 运行“Hello World” -恭喜您,已完成Hi3516的快速上手!建议您下一步进入[带屏摄像头产品开发](../guide/device-iotcamera.md)的学习 。 +系统启动成功后,取源码out目录下的helloworld可执行文件放入系统的bin目录,通过以下步骤运行“Hello World”。 +1. 在启动界面进入bin目录。 + + ``` + cd bin + ``` + +2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 + + ``` + ./helloworld + ``` + + 界面打印“Hello World!”,程序运行成功。 + + ![zh-cn_image_0000001271234769](figures/zh-cn_image_0000001271234769.png) + + +## 下一步学习 + +恭喜您,已完成Hi3516DV300的快速上手!建议您下一步进入[带屏摄像头产品开发](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-camera.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md index 7bd1c393c6ab4d72261b29bdc0581142afe149c4..7ca83ab6a0b16495f32fefcf01f8590a72e8ab74 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md @@ -1,70 +1,30 @@ -# 安装开发板环境 +# 安装Hi3516开发板环境 -- [Hi3516工具要求](#section179175261196) - - [硬件要求](#section5840424125014) - - [软件要求](#section965634210501) -- [安装Linux服务器工具](#section182916865219) - - [安装编译依赖基础软件(仅Ubuntu 20+需要)](#section45512412251) - - [安装文件打包工具及Java虚拟机环境](#section16199102083717) +## Hi3516工具要求 -## Hi3516工具要求 +### 硬件要求 -### 硬件要求 +- Hi3516DV300 IoT Camera开发板 -- Hi3516DV300 IoT Camera开发板 -- USB转串口线、网线(Linux工作台通过USB转串口线、网线与Hi3516DV300 开发板连接) +- USB转串口线、网线(Linux工作台通过USB转串口线、网线与Hi3516DV300 开发板连接) -### 软件要求 ->![](../public_sys-resources/icon-notice.gif) **须知:** ->本节描述安装包方式搭建编译环境的操作步骤。如果使用Docker方式安装编译环境,请跳过此章节,直接从[新建应用程序](quickstart-lite-steps-hi3516-application-framework.md)开始操作。 +### 软件要求 -Hi3516开发板对Linux服务器通用环境配置需要的工具及其用途如下表所示。 +Hi3516DV300开发板对Linux服务器通用环境配置需要的工具及其用途如下表所示。 -**表 1** Linux服务器开发工具及用途 + **表1** Linux服务器开发工具及用途 - - - - - - - - - - - - - - - -

开发工具

-

用途

-

编译基础软件包(仅ubuntu 20+需要)

-

编译依赖的基础软件包

-

dosfstools、mtools、mtd-utils

-

文件打包工具

-

Java 虚拟机环境

-

编译、调试和运行Java程序

-
+| 开发工具 | 用途 | +| -------- | -------- | +| dosfstools、mtools、mtd-utils | 文件打包工具 | +| Java虚拟机环境 | 编译、调试和运行Java程序 | -## 安装Linux服务器工具 -### 安装编译依赖基础软件(仅Ubuntu 20+需要) +## 安装Linux服务器工具 -执行以下命令进行安装: - -``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev -``` - -### 安装文件打包工具及Java虚拟机环境 - -运行如下命令,安装dosfstools、mtools、mtd-utils、Java运行时环境(JRE)和Java sdk 开发工具包。 - -``` -sudo apt-get install dosfstools mtools mtd-utils default-jre default-jdk -``` +Hi3516DV300依赖以下工具:dosfstools、mtools、mtd-utils、Java运行时环境(JRE)和Java sdk 开发工具包。 +上述工具已在[安装必要的库和工具](../quick-start/quickstart-lite-env-setup.md#安装必要的库和工具)环节完成安装,此处无需再进行安装。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516.md index eb5f4ee338bd2644a0aa4136a1d9028797c58376..4d978f73224a46cdc9b9d9573232b2ec30725418 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516.md @@ -1,15 +1,13 @@ -# Hi3516开发板 +# Hi3516开发板 -- **[安装开发板环境](quickstart-lite-steps-hi3516-setting.md)** -- **[新建应用程序](quickstart-lite-steps-hi3516-application-framework.md)** -- **[编译](quickstart-lite-steps-hi3516-building.md)** +- **[安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md)** -- **[烧录](quickstart-lite-steps-hi3516-burn.md)** +- **[编写“Hello World”程序](quickstart-lite-steps-hi3516-application-framework.md)** -- **[运行](quickstart-lite-steps-hi3516-running.md)** - -- **[常见问题](quickstart-lite-steps-hi3516-faqs.md)** +- **[编译](quickstart-lite-steps-hi3516-building.md)** +- **[烧录](quickstart-lite-steps-hi3516-burn.md)** +- **[运行](quickstart-lite-steps-hi3516-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-application-framework.md deleted file mode 100644 index c6011e5a5659f9e345f0f904c436ffa9b35a996b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-application-framework.md +++ /dev/null @@ -1,120 +0,0 @@ -# 新建应用程序 - -下方将通过修改源码的方式展示如何编写简单程序,输出“Hello OHOS!”。请在[获取源码](quickstart-lite-sourcecode-acquire.md)章节下载的源码目录中进行下述操作。 - -1. 新建目录及源码。 - - 新建**applications/sample/camera/apps/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。 - - ``` - #include - - int main(int argc, char **argv) - { - printf("\n************************************************\n"); - printf("\n\t\tHello OHOS!\n"); - printf("\n************************************************\n\n"); - - return 0; - } - ``` - -2. 新建编译组织文件。 - - 新建**applications/sample/camera/apps/BUILD.gn**文件,内容如下所示: - - ``` - import("//build/lite/config/component/lite_component.gni") - lite_component("hello-OHOS") { - features = [ ":helloworld" ] - } - executable("helloworld") { - output_name = "helloworld" - sources = [ "src/helloworld.c" ] - include_dirs = [] - defines = [] - cflags_c = [] - ldflags = [] - } - ``` - -3. 添加新组件。 - - 修改文件**build/lite/components/applications.json**,添加组件hello\_world\_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - ``` - { - "components": [ - { - "component": "camera_sample_communication", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/communication" - ], - "targets": [ - "//applications/sample/camera/communication:sample" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##start## - { - "component": "hello_world_app", - "description": "Communication related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/apps" - ], - "targets": [ - "//applications/sample/camera/apps:hello-OHOS" - ], - "rom": "", - "ram": "", - "output": [], - "adapted_kernel": [ "liteos_a" ], - "features": [], - "deps": { - "components": [], - "third_party": [] - } - }, - ##end## - { - "component": "camera_sample_app", - "description": "Camera related samples.", - "optional": "true", - "dirs": [ - "applications/sample/camera/launcher", - "applications/sample/camera/cameraApp", - "applications/sample/camera/setting", - "applications/sample/camera/gallery", - "applications/sample/camera/media" - ], - ``` - -4. 修改单板配置文件。 - - 修改文件**vendor/hisilicon/hispark\_aries/config.json**,新增hello\_world\_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): - - ``` - { - "subsystem": "applications", - "components": [ - ##start## - { "component": "hello_world_app", "features":[] }, - ##end## - { "component": "camera_sample_app", "features":[] } - - ] - }, - ``` - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-building.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-building.md deleted file mode 100644 index c97f546c9c3466b999b2b3ddb45b05647d1cd16f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-building.md +++ /dev/null @@ -1,26 +0,0 @@ -# 编译 - -下方将介绍如何使用Hi3518开发板进行编译。使用安装包方式与docker方式搭建Ubuntu编译环境,编译命令相同。 - -1. 请进入源码根目录,执行如下命令进行编译: - - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果使用Docker方式搭建编译环境,请在[获取Docker环境](quickstart-lite-docker-environment.md#section15666113905015)中进入的Docker构建环境中,执行如下命令进行编译。 - - ``` - hb set(设置编译路径) - .(选择当前路径) - 选择ipcamera_hispark_aries并回车 - hb build -f(执行编译) - ``` - - **图 1** Hi3518编译设置图例-Docker方式 - ![](figures/Hi3518编译设置图例-Docker方式.png "Hi3518编译设置图例-Docker方式") - -2. 编译结束后,出现“ipcamera\_hispark\_aries build success”字样,则证明构建成功。 - ->![](../public_sys-resources/icon-notice.gif) **须知:** ->烧录相关文件获取路径: ->结果文件:out/hispark\_aries/ipcamera\_hispark\_aries。 ->U-boot文件:device/hisilicon/hispark\_aries/sdk\_liteos/uboot/out/boot/u-boot-hi3518ev300.bin。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-burn.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-burn.md deleted file mode 100644 index b66d785c004816ddc8635dada0c6a5d826b6dbf7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-burn.md +++ /dev/null @@ -1,93 +0,0 @@ -# 烧录 - -- [前提条件](#section14614124417580) -- [使用串口烧录](#section195291211181215) - -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 - -DevEco Device Tool以插件方式运行,基于Visual Studio Code进行扩展,用户可点击Visual Studio Code左侧栏的![](figures/2021-01-27_170334.png)图标打开DevEco Device Tool。 - -Hi3518EV300开发板的代码烧录支持USB烧录和串口烧录两种方式,其中: - -- **Windows系统:支持USB烧录和串口烧录。** -- **Linux系统:支持串口烧录**。 - -Hi3861V100在Windows和Linux环境下的烧录操作完全一致,区别仅在于DevEco Device Tool环境搭建不同。 - -此处仅以Linux系统下串口烧录方式为例进行说明。 - -## 前提条件 - -1. 在DevEco Device Tool工具中点击**Import Project**导入新建应用程序章节修改后的源码文件。 - - ![](figures/import-project.png) - -2. 选择源码导入时,系统会提示该工程不是DevEco Device Tool工程,点击**Import**。 - - ![](figures/import-project-confirm.png) - -3. MCU选择HiSilicom\_Arm下的Hi3518EV300,Board选择hi3518ev300,Framework选择Hb,然后点击**Import**完成导入。 - - ![](figures/hi3518-import-projects.png) - - -## 使用串口烧录 - -1. 请连接好电脑和待烧录开发板,需要同时连接串口和电源口,具体可参考[Hi3518EV300开发板介绍](https://device.harmonyos.com/cn/docs/documentation/guide/quickstart-lite-introduction-hi3518-0000001105201138)。 -2. 查看并记录对应的串口号。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 - - Windows系统,打开设备管理器查看并记录对应的串口号,或在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - - ![](figures/record-the-serial-port-number.png) - - Linux系统,在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - - ![](figures/Snap22.png) - -3. 在QUICK ACCESS \> DevEco Home \> Projects中,点击**Settings**打开工程配置界面。 - - ![](figures/zh-cn_image_0000001222981447.png) - -4. 在“hi3518ev300”页签,设置烧录选项,包括upload\_port、upload\_partitions和upload\_protocol。 - - - upload\_port:选择已查询的串口号。 - - upload\_protocol:选择烧录协议,固定选择“hiburn-serial”。 - - upload\_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 - - ![](figures/Snap24.png) - -5. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 - 1. 在“hi3518ev300\_fastboot”页签,在New Option选项中选择需要修改的项,例如partition\_bin(烧录文件路径)、partition\_addr(烧录文件起始地址)、partition\_length(烧录文件分区长度)等。 - - ![](figures/zh-cn_image_0000001177301516.png) - - 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,遵循以下原则: - >- 要求设置的烧录分区大小,要大于待烧录文件的大小。 - >- 同时,各烧录文件的分区地址设置不能出现重叠。 - >- 总的烧录分区大小不能超过16MB。 - - ![](figures/zh-cn_image_0000001222781271.png) - - 3. 按照相同的方法修改kernel、footfs和userfs的烧录文件信息。 - -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 -7. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3518ev300下的**Upload**按钮,启动烧录。 - - ![](figures/zh-cn_image_0000001117329380.png) - -8. 启动烧录后,显示如下提示信息时,请重启开发板(下电再上电)。 - - ![](figures/zh-cn_image_0000001074287476.png) - -9. 重新上电后,界面提示如下信息时,表示烧录成功。 - - ![](figures/zh-cn_image_0000001073838982.png) - -10. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md deleted file mode 100644 index 32b4edfc04f2249f891885620bb7792c8d5e5260..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md +++ /dev/null @@ -1,168 +0,0 @@ -# 常见问题 - -- [烧写选择串口后提示失败](#section1498892119619) -- [Windows电脑与单板网络连接失败](#section8512971816) -- [烧写失败](#section1767804111198) -- [编译构建过程中,提示找不到“python”](#zh-cn_topic_0000001053466255_section1039835245619) -- [串口无回显](#zh-cn_topic_0000001053466255_section14871149155911) - -## 烧写选择串口后提示失败 - -- **现象描述** - - 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 - - **图 1** 打开串口失败图 - ![](figures/打开串口失败图-1.png "打开串口失败图-1") - -- **可能原因** - - 串口已经被占用。 - -- **解决办法** - -1. 按图依次选择下拉框,查找带有serial-xx的终端。 - - **图 2** 查找是否存在占用串口的终端 - ![](figures/查找是否存在占用串口的终端-2.png "查找是否存在占用串口的终端-2") - -2. 点击标号中的垃圾桶图标,关闭串口。 - - **图 3** 关闭串口终端 - ![](figures/关闭串口终端-3.png "关闭串口终端-3") - -3. 重新点击烧写,选择串口并开始烧写程序。 - - **图 4** 重新启动烧写任务 - - - ![](figures/changjian1-4.png) - - -## Windows电脑与单板网络连接失败 - -- **现象描述** - - 点击烧写并选择串口后,无法获取文件。 - - **图 5** 网络不通,单板无法获取文件图 - ![](figures/网络不通-单板无法获取文件图-5.png "网络不通-单板无法获取文件图-5") - -- **可能原因** - - 单板网络与Windows电脑不联通。 - - Windows电脑防火墙未允许Visual Studio Code联网。 - -- **解决方法** - -1. 检查网线是否连接。 -2. 点击Windows防火墙。 - - **图 6** 网络防火墙设置图 - ![](figures/网络防火墙设置图-6.png "网络防火墙设置图-6") - -3. 点击“允许应用通过防火墙”。 - - **图 7** 防火墙和网络保护界面图 - ![](figures/防火墙和网络保护界面图-7.png "防火墙和网络保护界面图-7") - -4. 查找Visual Studio Code应用。 - - **图 8** 查找Visual Studio Code应用图 - ![](figures/查找Visual-Studio-Code应用图-8.png "查找Visual-Studio-Code应用图-8") - -5. 勾选Visual Studio Code的专用和公用网络的访问权限。 - - **图 9** 允许Visual Studio Code应用访问网络 - ![](figures/允许Visual-Studio-Code应用访问网络-9.png "允许Visual-Studio-Code应用访问网络-9") - - -## 烧写失败 - -- **现象描述** - - 点击烧写并选择串口后,出现无法烧写的情况。 - -- **可能原因** - - 安装IDE插件DevEco后未重启。 - -- **解决方法** - - 重启IDE。 - - -## 编译构建过程中,提示找不到“python” - -- **现象描述** - - ![](figures/zh-cn_image_0000001171774086.png) - - -- **可能原因** - - usr/bin目录下没有python软链接。 - - ![](figures/zh-cn_image_0000001171615534.png) - -- **解决办法** - - 请运行以下命令: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - 例: - - ![](figures/zh-cn_image_0000001216535401.png) - - -## 串口无回显 - -- **现象描述** - - 串口显示已连接,重启单板后,回车无任何回显。 - -- **可能原因1** - - 串口连接错误。 - -- **解决办法** - - 修改串口号。 - - 请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按镜像运行内[步骤1](#section1498892119619)修改串口号。 - - -- **可能原因2** - - 单板U-boot被损坏。 - -- **解决办法** - - 烧写U-boot。 - - 若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。 - - -1. 获取引导文件U-boot。 - - >![](../public_sys-resources/icon-notice.gif) **须知:** - >单板的U-boot文件请在开源包中获取: - >Hi3516DV300:device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin - >Hi3518EV300:device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin - -2. 根据USB烧写步骤烧写U-boot文件。 - - 按照[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/documentation/guide/hi3518_upload-0000001057313128)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。 - -3. 烧写完成后,登录串口如下图所示。 - - ![](figures/zh-cn_image_0000001216535397.png) - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md deleted file mode 100644 index fdded7a71dfb67fa6c81e2f64b607192bb183e36..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md +++ /dev/null @@ -1,33 +0,0 @@ -# 运行 - -- [镜像运行](#section1081111115589) -- [下一步学习](#section9712145420182) - -## 镜像运行 - -在完成Hi3518EV300的烧录后,还需要设置BootLoader引导程序,才能运行OpenHarmony系统。 - -1. 在Hi3518EV300任务中,点击**Configure bootloader(Boot OS)**进行配置即可。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >DevEco Device Tool针对Hi3518EV300开发板的BootLoader设置进行了适配,无需开发者手动修改。 - - ![](figures/hi3518-bootloader.png) - -2. 提示如下图中的重启开发板的提示信息时,重启开发板,然后在控制台输出“SUCCESS”表示设置成功。 - - ![](figures/hi3518-reset-success.png) - -3. 在任务栏点击**Monitor**按钮,启动串口工具。 - - ![](figures/hi3518-monitor.png) - -4. 当界面打印回显信息,点击Enter按钮,直到界面显示OHOS \#信息,表示系统启动成功。 - - ![](figures/hi3518-reboot-success.png) - - -## 下一步学习 - -恭喜您,已完成Hi3518的快速上手!建议您下一步进入[无屏摄像头产品开发](../guide/device-iotcamera.md)的学习 。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md deleted file mode 100644 index 61f1469a59a001430fdda4216b0face7e1544a5f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md +++ /dev/null @@ -1,71 +0,0 @@ -# 安装开发板环境 - -- [Hi3518环境搭建](#section1724111409282) - - [硬件要求](#section487353718276) - - [软件要求](#section17315193935817) - -- [安装Linux服务器工具](#section8831868501) - - [安装编译依赖基础软件(仅Ubuntu 20+需要)](#section25911132141020) - - [安装文件打包工具](#section390214473129) - - -## Hi3518环境搭建 - -### 硬件要求 - -- Hi3518EV300 IoT Camera开发板 -- USB转串口线、网线(Linux工作台通过USB转串口线、网线与开发板连接) - -### 软件要求 - ->![](../public_sys-resources/icon-notice.gif) **须知:** ->本节描述安装包方式搭建编译环境的操作步骤。如果是Docker方式安装编译环境,请跳过此章节,从[新建应用程序](quickstart-lite-steps-hi3518-application-framework.md)开始操作。 - -Hi3518开发板对Linux服务器通用环境配置需要的工具及其获取途径如下表所示。 - -**表 1** Linux服务器开发工具及获取途径 - - - - - - - - - - - - - - - - -

开发工具

-

用途

-

获取途径

-

编译基础软件包(仅ubuntu 20+需要)

-

编译依赖的基础软件包

-

通过互联网获取

-

dosfstools、mtools、mtd-utils

-

文件打包工具

-

通过apt-get install安装

-
- -## 安装Linux服务器工具 - -### 安装编译依赖基础软件(仅Ubuntu 20+需要) - -执行以下命令进行安装: - -``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev -``` - -### 安装文件打包工具 - -运行如下命令,安装dosfstools,mtools,mtd-utils。 - -``` -sudo apt-get install dosfstools mtools mtd-utils -``` - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518.md deleted file mode 100644 index ea8759f0fefc2fdab01292b753816cadf574d472..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518.md +++ /dev/null @@ -1,15 +0,0 @@ -# Hi3518开发板 - -- **[安装开发板环境](quickstart-lite-steps-hi3518-setting.md)** - -- **[新建应用程序](quickstart-lite-steps-hi3518-application-framework.md)** - -- **[编译](quickstart-lite-steps-hi3518-building.md)** - -- **[烧录](quickstart-lite-steps-hi3518-burn.md)** - -- **[运行](quickstart-lite-steps-hi3518-running.md)** - -- **[常见问题](quickstart-lite-steps-hi3518-faqs.md)** - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md new file mode 100644 index 0000000000000000000000000000000000000000..4d87208d9e71ecedc29d01ef693feacbbf2cb760 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md @@ -0,0 +1,19 @@ +# 运行 + + +## 运行结果 + +示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: + + +``` +ready to OS start +FileSystem mount ok. +wifi init success! +[DEMO] Hello world. +``` + + +## 下一步学习 + +恭喜,您已完成Hi3861 WLAN模组快速上手!建议您下一步进入[WLAN产品开发](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/guide/device-wlan.md)的学习 。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-application-framework.md index 8e8f9716f0c4639c8a3aecab9c6d0d5851fe5726..f9adf40d8b20a2fd6ff4610a3b1416805bf7e581 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-application-framework.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-application-framework.md @@ -1,77 +1,141 @@ -# 新建应用程序 - -下方将通过修改源码的方式展示如何编写简单程序,输出“Hello world.”。请在[获取源码](quickstart-lite-sourcecode-acquire.md)章节下载的源码目录中进行下述操作。 - -1. 确定目录结构。 - - 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 - - 例如:在app下新增业务my\_first\_app,其中hello\_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: - - ``` - . - └── applications - └── sample - └── wifi-iot - └── app - │── my_first_app - │ │── hello_world.c - │ └── BUILD.gn - └── BUILD.gn - ``` - -2. 编写业务代码。 - - 新建./applications/sample/wifi-iot/app/my\_first\_app下的hello\_world.c文件,在hello\_world.c中新建业务入口函数HelloWorld,并实现业务逻辑。并在代码最下方,使用OpenHarmony启动恢复模块接口SYS\_RUN\(\)启动业务。(SYS\_RUN定义在ohos\_init.h文件中) - - ``` - #include - #include "ohos_init.h" - #include "ohos_types.h" - - void HelloWorld(void) - { - printf("[DEMO] Hello world.\n"); - } - SYS_RUN(HelloWorld); - ``` - -3. 编写用于将业务构建成静态库的BUILD.gn文件。 - - 新建./applications/sample/wifi-iot/app/my\_first\_app下的BUILD.gn文件,并完成如下配置。 - - 如[步骤1](#li5479332115116)所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。 - - ``` - static_library("myapp") { - sources = [ - "hello_world.c" - ] - include_dirs = [ - "//utils/native/lite/include" - ] - } - ``` - - - static\_library中指定业务模块的编译结果,为静态库文件libmyapp.a,开发者根据实际情况完成填写。 - - sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//"则表示绝对路径(此处为代码根路径),若不包含"//"则表示相对路径。 - - include\_dirs中指定source所需要依赖的.h文件路径。 - -4. 编写模块BUILD.gn文件,指定需参与构建的特性模块。 - - 配置./applications/sample/wifi-iot/app/BUILD.gn文件,在features字段中增加索引,使目标模块参与编译。features字段指定业务模块的路径和目标,以my\_first\_app举例,features字段配置如下。 - - ``` - import("//build/lite/config/component/lite_component.gni") - - lite_component("app") { - features = [ - "my_first_app:myapp", - ] - } - ``` - - - my\_first\_app是相对路径,指向./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn。 - - myapp是目标,指向./applications/sample/wifi-iot/app/my\_first\_app/BUILD.gn中的static\_library\("myapp"\)。 - - +# 编写“Hello World”程序 + + +下方将通过修改源码的方式展示如何编写简单程序,输出“Hello world”。请在下载的源码目录中进行下述操作。 + + +1. 确定目录结构。 + + 开发者编写业务时,务必先在./applications/sample/wifi-iot/app路径下新建一个目录(或一套目录结构),用于存放业务源码文件。 + + 例如:在app下新增业务my_first_app,其中hello_world.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: + + + ``` + . + └── applications + └── sample + └── wifi-iot + └── app + └── my_first_app + │── hello_world.c + └── BUILD.gn + ``` + +2. 编写业务代码。 + + 新建./applications/sample/wifi-iot/app/my_first_app下的hello_world.c文件,在hello_world.c中新建业务入口函数HelloWorld,并实现业务逻辑。并在代码最下方,使用OpenHarmony启动恢复模块接口SYS_RUN()启动业务。(SYS_RUN定义在ohos_init.h文件中) + + ``` + #include + #include "ohos_init.h" + #include "ohos_types.h" + + void HelloWorld(void) + { + printf("[DEMO] Hello world.\n"); + } + SYS_RUN(HelloWorld); + ``` + +3. 编写用于将业务构建成静态库的BUILD.gn文件。 + + 新建./applications/sample/wifi-iot/app/my_first_app下的BUILD.gn文件,并完成如下配置。 + + 如步骤1所述,BUILD.gn文件由三部分内容(目标、源文件、头文件路径)构成,需由开发者完成填写。 + + + ``` + static_library("myapp") { + sources = [ + "hello_world.c" + ] + include_dirs = [ + "//utils/native/lite/include" + ] + } + ``` + + - static_library中指定业务模块的编译结果,为静态库文件libmyapp.a,开发者根据实际情况完成填写。 + - sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//"则表示绝对路径(此处为代码根路径),若不包含"//"则表示相对路径。 + - include_dirs中指定source所需要依赖的.h文件路径。 + +4. 添加新组件。 + + 修改文件**build/lite/components/applications.json**,添加组件hello_world_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "components": [ + { + "component": "camera_sample_communication", + "description": "Communication related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/communication" + ], + "targets": [ + "//applications/sample/camera/communication:sample" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_a" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##start## + { + "component": "hello_world_app", + "description": "hello world samples.", + "optional": "true", + "dirs": [ + "applications/sample/wifi-iot/app/my_first_app" + ], + "targets": [ + "//applications/sample/wifi-iot/app/my_first_app:myapp" + ], + "rom": "", + "ram": "", + "output": [], + "adapted_kernel": [ "liteos_m" ], + "features": [], + "deps": { + "components": [], + "third_party": [] + } + }, + ##end## + { + "component": "camera_sample_app", + "description": "Camera related samples.", + "optional": "true", + "dirs": [ + "applications/sample/camera/launcher", + "applications/sample/camera/cameraApp", + "applications/sample/camera/setting", + "applications/sample/camera/gallery", + "applications/sample/camera/media" + ], + ``` + +5. 修改单板配置文件。 + + 修改文件**vendor/hisilicon/hispark_pegasus/config.json**,新增hello_world_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行): + + + ``` + { + "subsystem": "applications", + "components": [ + ##start## + { "component": "hello_world_app", "features":[] }, + ##end## + { "component": "wifi_iot_sample_app", "features":[] } + ] + }, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md index d112146c32ec9f335ee9f5c542239799c03aadcb..a7cc08cb1c8a12b394b459fd678200c2da5e3696 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md @@ -1,72 +1,47 @@ -# 编译 +# 编译 -- [编译(Docker方式搭建环境)](#section681942105819) -- [编译(安装包方式搭建环境)](#section17726113335715) -本节描述如何进行Hi3861 开发板的编译,根据上方搭建Ubuntu环境方式的不同,编译方式也有所区别。 +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](../quick-start/quickstart-lite-reference.md)。 -- 如果Ubuntu编译环境通过Docker方式安装,请参见下方[编译(Docker方式搭建环境)](#section681942105819)。 -- 如果Ubuntu编译环境通过安装包方式安装,请参见下方[编译(安装包方式搭建环境)](#section17726113335715)。 -## 编译(Docker方式搭建环境) +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: -1. 请在[获取Docker环境](quickstart-lite-docker-environment.md#section15666113905015)中进入的Docker构建环境中,执行如下命令进行编译: - ``` - hb set(设置编译路径) - .(选择当前路径) - 选择wifiiot_hispark_pegasus@hisilicon并回车 - hb build -f(执行编译) - ``` +1. 设置编译路径。 + + ``` + hb set + ``` - **图 1** Hi3861编译设置图例-Docker方式 - ![](figures/Hi3861编译设置图例-Docker方式.png "Hi3861编译设置图例-Docker方式") +2. 选择当前路径。 + + ``` + . + ``` -2. 编译结束后,出现“wifiiot\_hispark\_pegasus build success”字样,则证明构建成功。 +3. 在hisilicon下选择wifiiot_hispark_pegasus并回车。 - >![](../public_sys-resources/icon-notice.gif) **须知:** - >烧录结果文件文件获取路径:out/hispark\_pegasus/wifiiot\_hispark\_pegasus。 +4. 执行编译。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 -## 编译(安装包方式搭建环境) + + ``` + hb build -f + ``` -1. 打开DevEco Device Tool工具,点击“View \> Terminal”,进入终端界面。 + **图1** Hi3861编译设置图例 - **图 2** IDE终端工具打开方法 - - - ![](figures/1.png) - -2. 进入代码根路径,并在终端窗口,执行脚本命令“hb set”、“.”,选择需要编译的版本“wifiiot\_hispark\_pegasus”。 - - **图 3** 在终端界面选择目标构建版本示意图 - - - ![](figures/3.png) - -3. 执行“hb build”启动版本构建。 - - **图 4** 在终端界面执行编译命令示意图 - - - ![](figures/4.png) - -4. 编译结束后,如果出现“wifiiot\_hispark\_pegasus build success”字样,则证明构建成功,如下图所示。 - - **图 5** 编译成功示意图 - - - ![](figures/5.png) - -5. 构建成功后,会在./out/wifiiot/路径中生成以下文件,使用如下命令可以查看,至此编译构建流程结束。 - - ``` - ls -l out/hispark_pegasus/wifiiot_hispark_pegasus/ - ``` - - **图 6** 编译文件存放目录示意图 - - - ![](figures/3-0.png) + ![zh-cn_image_0000001226634716](figures/zh-cn_image_0000001226634716.png) +5. 编译结束后,出现“build success”字样,则证明构建成功。 + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 编译结果文件及编译日志获取路径:out/hispark_pegasus/wifiiot_hispark_pegasus。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md index 4d1cce51f9334ee770b7e102b7bae1db0e3a070f..d2139896825a1d36bb79261511d034cac533a649 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md @@ -1,80 +1,90 @@ -# 烧录 +# 烧录 -- [前提条件](#section1535374111495) -- [使用串口烧录](#section5551201122719) -烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 +在Windows下通过串口烧录Hi3861 WLAN模组。 -DevEco Device Tool以插件方式运行,基于Visual Studio Code进行扩展,用户可点击Visual Studio Code左侧栏的![](figures/2021-01-27_170334.png)图标打开DevEco Device Tool。 -**Hi3861V100开发板支持串口烧录方式,Linux系统串口烧录协议为hiburn-serial。**具体操作步骤如下: +### 导入源码 -## 前提条件 +在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](../quick-start/quickstart-lite-env-setup.md)的情况下,您还需要通过以下步骤导入源码后,方可进行烧录。 -1. 在DevEco Device Tool工具中点击**Import Project**导入新建应用程序章节修改后的源码文件。 +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 - ![](figures/import-project.png) + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) -2. 选择源码导入时,系统会提示该工程不是DevEco Device Tool工程,点击**Import**。 +2. 选择要导入的源码目录(需要访问Ubuntu下的源码目录),点击**Import**打开。 - ![](figures/import-project-confirm.png) + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 -3. MCU选择Hi3861,Board选择Hi3861,Framework选择Hb,然后点击**Import**完成导入。 + ![zh-cn_image_0000001227549226](figures/zh-cn_image_0000001227549226.png) - ![](figures/hi3861-import-projects.png) +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) -## 使用串口烧录 +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 -1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](https://device.harmonyos.com/cn/docs/documentation/guide/quickstart-lite-introduction-hi3861-0000001105041324)[Hi3861V100开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md)。 -2. 查看并记录对应的串口号。 + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果对应的串口异常,请根据[Hi3861V100开发板串口驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/hi3861-drivers-0000001058153433)安装USB转串口的驱动程序。 +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。此处选择wifiiot_hispark_pegasus。 - Window系统,打开设备管理器查看并记录对应的串口号,或在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 + ![zh-cn_image_0000001272109325](figures/zh-cn_image_0000001272109325.png) - ![](figures/hi3861-record-the-serial-port-number.png) +6. 点击**Open**打开工程或源码。 - Linux系统,在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - ![](figures/Snap23.png) +### 烧录 -3. 在QUICK ACCESS \> DevEco Home \> Projects中,点击**Settings**打开工程配置界面。 +完成源码导入后,通过以下步骤进行烧录: - ![](figures/zh-cn_image_0000001222999125.png) +1. 请连接好电脑和待烧录开发板,需要连接USB口,具体可参考[Hi3861V100开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3861.md)。 -4. 在“hi3861”页签,设置烧录选项,包括upload\_port、upload\_protocol和upload\_partitions。 +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 - - upload\_port:选择已查询的串口号。 - - upload\_protocol:选择烧录协议,选择“hiburn-serial”。 - - upload\_partitions:选择待烧录的文件,默认选择hi3861\_app。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 - ![](figures/zh-cn_image_0000001177798424.png) + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) -5. 检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。 - 1. 在“hi3861\_app”页签,在New Option选项中选择需要修改的项,例如partition\_bin(烧录文件路径)、partition\_addr(烧录文件起始地址)、partition\_length(烧录文件分区长度)等。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 - ![](figures/zh-cn_image_0000001177480146.png) +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 - 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + ![zh-cn_image_0000001216274840](figures/zh-cn_image_0000001216274840.png) - >![](../public_sys-resources/icon-note.gif) **说明:** - >在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3861V100开发板串口驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/hi3861-drivers-0000001058153433)安装USB转串口的驱动程序。 - ![](figures/zh-cn_image_0000001223000051.png) +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 -7. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 + ![zh-cn_image_0000001198943768](figures/zh-cn_image_0000001198943768.png) - ![](figures/hi3861-upload.png) +5. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 -8. 启动烧录后,显示如下提示信息时,请按开发板上的RST按钮重启开发板。 + - upload_port:选择已查询的串口号。 + - upload_protocol:选择烧录协议,选择“hiburn-serial”。 + - upload_partitions:选择待烧录的文件,默认选择hi3861_app。 - ![](figures/zh-cn_image_0000001174595590.png) + ![zh-cn_image_0000001243704061](figures/zh-cn_image_0000001243704061.png) -9. 重新上电后,界面提示如下信息时,表示烧录成功。 +6. 检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。 - ![](figures/hi3861-burning-succeeded.png) + 在“hi3861_app”页签,在New Option选项中选择partition_bin(烧录文件路径),然后设置待烧录文件的地址。 + ![zh-cn_image_0000001260919759](figures/zh-cn_image_0000001260919759.png) +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 + + ![zh-cn_image_0000001216440138](figures/zh-cn_image_0000001216440138.png) + +9. 启动烧录后,显示如下提示信息时,请按开发板上的RST按钮重启开发板。 + + ![zh-cn_image_0000001198466090](figures/zh-cn_image_0000001198466090.png) + +10. 重新上电后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001216761476](figures/zh-cn_image_0000001216761476.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md index 650fe58a81a2a6c6abd971c07ab222c299638ec5..15b35d82ffd79fd8830ea582e268ddc8272901c9 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md @@ -1,19 +1,22 @@ -# 调试验证 +# 调试验证 -- [printf打印](#section42891145143811) -- [根据asm文件进行问题定位](#section754719373917) -完成烧录之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 +完成烧录及联网之后,用户可根据需要进行调试验证。目前调试验证的方法有以下两种,开发者可以根据具体业务情况选择。 + + +1. 通过printf打印日志 + +2. 通过asm文件定位panic问题 -1. 通过printf打印日志 -2. 通过asm文件定位panic问题 由于本示例业务简单,采用printf打印日志的调试方式即可。下方将介绍这两种调试手段的使用方法。 -## printf打印 + +## printf打印 代码中增加printf维测,信息会直接打印到串口上。开发者可在业务关键路径或业务异常位置增加日志打印,如下所示: + ``` void HelloWorld(void) { @@ -21,13 +24,14 @@ void HelloWorld(void) } ``` -## 根据asm文件进行问题定位 -系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 +## 根据asm文件进行问题定位 + 系统异常退出时,会在串口上打印异常退出原因调用栈信息,如下文所示。通过解析异常栈信息可以定位异常位置。 + ``` =======KERNEL PANIC======= -**********************Call Stack********************* +**Call Stack* Call Stack 0 -- 4860d8 addr:f784c Call Stack 1 -- 47b2b2 addr:f788c Call Stack 2 -- 3e562c addr:f789c @@ -35,27 +39,27 @@ Call Stack 3 -- 4101de addr:f78ac Call Stack 4 -- 3e5f32 addr:f78cc Call Stack 5 -- 3f78c0 addr:f78ec Call Stack 6 -- 3f5e24 addr:f78fc -********************Call Stack end******************* +Call Stack end*** ``` -为解析上述调用栈信息,需要使用到Hi3861\_wifiiot\_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 - -1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) -2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名 信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 +为解析上述调用栈信息,需要使用到Hi3861_wifiiot_app.asm文件,该文件记录了代码中函数在Flash上的符号地址以及反汇编信息。asm文件会随版本打包一同构建输出,存放在./out/wifiiot/路径下。 - ``` - Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB - Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data - Call Stack 2 -- 3e562c addr:f789c - Call Stack 3 -- 4101de addr:f78ac - Call Stack 4 -- 3e5f32 addr:f78cc - Call Stack 5 -- 3f78c0 addr:f78ec - Call Stack 6 -- 3f5e24 addr:f78fc - ``` +1. 将调用栈CallStack信息保存到txt文档中,以便于编辑。(可选) -3. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 +2. 打开asm文件,并搜索CallStack中的地址,列出对应的函数名信息。通常只需找出前几个栈信息对应的函数,就可明确异常代码方向。 + + ``` + Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB + Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data + Call Stack 2 -- 3e562c addr:f789c + Call Stack 3 -- 4101de addr:f78ac + Call Stack 4 -- 3e5f32 addr:f78cc + Call Stack 5 -- 3f78c0 addr:f78ec + Call Stack 6 -- 3f5e24 addr:f78fc + ``` - ![](figures/zh-cn_image_0000001185334336.png) +3. 根据以上调用栈信息,可以定位WadRecvCB函数中出现了异常。 -4. 完成代码排查及修改。 + ![zh-cn_image_0000001271354733](figures/zh-cn_image_0000001271354733.png) +4. 完成代码排查及修改。 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md deleted file mode 100644 index 3bb3f5cef0edb16f7b512623eaa8277d2174de58..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md +++ /dev/null @@ -1,315 +0,0 @@ -# 常见问题 - -- [编译构建过程中,提示“No module named 'Crypto'”](#section982315398121) -- [编译构建过程中,提示“No module named 'ecdsa'”](#section102035451216) -- [编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”](#section4498158162320) -- [编译构建过程中,提示找不到“-lgcc”](#section11181036112615) -- [编译构建过程中,提示找不到“python”](#section1571810194619) -- [编译构建过程中,提示找不到“python3”](#section108385316482) -- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](#section1221016541119) -- [安装python3过程中,提示“-bash: make: command not found”](#section1913477181213) -- [安装python3过程中,提示“zlib not available”](#section108211415131210) -- [安装python3过程中,提示“No module named '\_ctypes'”](#section2062268124) -- [安装 kconfiglib时,遇到lsb\_release错误](#section691681635814) - -## 编译构建过程中,提示“No module named 'Crypto'” - -- **现象描述** - - 编译构建过程中出现以下错误: - - ``` - ModuleNotFoundError: No module named 'Crypto' - ``` - - -- **可能原因** - - 环境中未安装“Crypto”。 - - -- **解决办法** - - 方法1:通过命令“pip3 install Crypto”,在线安装。 - - 方法2:离线安装。 - - 通过网页[https://pypi.org/project/pycrypto/\#files](https://pypi.org/project/pycrypto/#files),下载源码。 - - ![](figures/zh-cn_image_0000001171615542.png) - - 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 - - 完成上述安装后,重新构建。 - - -## 编译构建过程中,提示“No module named 'ecdsa'” - -- **现象描述** - - 编译构建过程中出现以下错误: - - ``` - ModuleNotFoundError:No module named 'ecdsa' - ``` - - -- **可能原因** - - 环境中未安装“ecdsa”。 - - -- **解决办法** - - 方法1:通过命令“pip3 install ecdsa”,在线安装。 - - 方法2:离线安装 - - 通过网页[https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files),下载安装包。 - - ![](figures/zh-cn_image_0000001171455574.png) - - 将安装包放置Linux服务器中,并安装“pip3 install ecdsa-0.15-py2.py3-none-any.whl”。 - - 完成上述安装后,重新构建。 - - -## 编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0” - -- **现象描述** - - 编译构建过程中出现以下错误: - - ``` - Could not find a version that satisfies the requirement six>=1.9.0 - ``` - - -- **可能原因** - - 环境中未安装合适的“six”。 - - -- **解决办法** - - 方法1:通过命令“pip3 install six”,在线安装。 - - 方法2:离线安装。 - - 通过网页[https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files),下载安装包。 - - ![](figures/zh-cn_image_0000001217013871.png) - - 将源码放置在Linux服务器中,并安装“pip3 install six-1.14.0-py2.py3-none-any.whl”。 - - 完成上述安装后,重新构建。 - - -## 编译构建过程中,提示找不到“-lgcc” - -- **现象描述** - - 编译构建过程中出现以下错误: - - ``` - riscv32-unknown-elf-ld: cannot find -lgcc - ``` - - -- **可能原因** - - 交叉编译器gcc\_riscv32的PATH添加错误,如下,在"bin"后多添加了一个“/”,应该删除。 - - ``` - ~/gcc_riscv32/bin/:/data/toolchain/ - ``` - - -- **解决办法** - - 重新修改gcc\_riscv32的PATH,将多余的“/”删除。 - - ``` - ~/gcc_riscv32/bin:/data/toolchain/ - ``` - - -## 编译构建过程中,提示找不到“python” - -- **现象描述** - - 编译构建过程中出现以下错误: - - ``` - -bash: /usr/bin/python: No such file or directory - ``` - - -- **可能原因**1 - - 没有装python。 - -- **解决办法** - - 请使用如下命令安装Python,下方以Python3.8为例。 - - ``` - sudo apt-get install python3.8 - ``` - -- **可能原因2** - - usr/bin目录下没有python软链接 - - ![](figures/zh-cn_image_0000001171774098.png) - -- **解决办法** - - 请运行以下命令添加软链接: - - ``` - # cd /usr/bin/ - # which python3 - # ln -s /usr/local/bin/python3 python - # python --version - ``` - - 例: - - ![](figures/zh-cn_image_0000001171934032.png) - - -## 编译构建过程中,提示找不到“python3” - -- **现象描述** - - ![](figures/11.png) - - -- **可能原因** - - 没有装python3。 - -- **解决办法** - - 请使用如下命令安装Python3。 - - ``` - sudo apt-get install python3.8 - ``` - - -## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” - -- **现象描述** - - 安装python3过程中出现以下错误: - - ``` - configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details - ``` - -- **可能原因** - - 环境中未安装“gcc”。 - -- **解决办法** - 1. 通过命令“apt-get install gcc”在线安装。 - 2. 完成后,重新安装python3。 - - -## 安装python3过程中,提示“-bash: make: command not found” - -- **现象描述** - - 安装python3过程中出现以下错误: - - ``` - -bash: make: command not found - ``` - -- **可能原因** - - 环境中未安装“make”。 - -- **解决办法** - 1. 通过命令“apt-get install make”在线安装。 - 2. 完成后,重新安装python3。 - - -## 安装python3过程中,提示“zlib not available” - -- **现象描述** - - 安装python3过程中出现以下错误: - - ``` - zipimport.ZipImportError: can't decompress data; zlib not avaliable - ``` - -- **可能原因** - - 环境中未安装“zlib”。 - -- **解决办法** - - 方法1:通过命令“apt-get install zlib”在线安装。 - - 方法2:如果软件源中没有该软件,请从“www.zlib.net”下载版本代码,并离线安装。 - - ![](figures/10.png) - - 完成下载后,通过以下命令安装: - - ``` - # tar xvf zlib-1.2.11.tar.gz - # cd zlib-1.2.11 - # ./configure - # make && make install - ``` - - 完成后,重新安装python3。 - - -## 安装python3过程中,提示“No module named '\_ctypes'” - -- **现象描述** - - 安装python3过程中出现以下错误: - - ``` - ModuleNotFoundError:No module named ‘_ctypes’ - ``` - - -- **可能原因** - - 环境中未安装“libffi”和“libffi-devel”。 - - -- **解决办法** - - 1、通过命令“apt-get install libffi\* -y”,在线安装。 - - 2、完成后,重新安装python3。 - - -## 安装 kconfiglib时,遇到lsb\_release错误 - -- **现象描述** - - 安装kconfiglib过程中遇到如下错误打印: - - ``` - subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. - ``` - -- **可能原因** - - lsb\_release模块基于的python版本与现有python版本不一致。 - -- **解决办法** - - 执行"find / -name lsb\_release",找到lsb\_release位置并删除,如:"sudo rm -rf /usr/bin/lsb\_release"。 - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md new file mode 100644 index 0000000000000000000000000000000000000000..60dc010af2f0624002d5ccb493b652859976d941 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-netconfig.md @@ -0,0 +1,44 @@ +# 联网 + + +完成版本编译及烧录后,下面开始介绍如何在串口终端上执行AT命令,使Hi3861 WLAN模组联网。 + + +1. 保持Windows工作台和WLAN模组的连接状态,在DevEco Device Tool最下方,点击“DevEco:Serial Monitor”按钮。 + + **图1** 打开DevEco Device Tool串口终端示意图 + + ![zh-cn_image_0000001227114644](figures/zh-cn_image_0000001227114644.png) + +2. 复位Hi3861 WLAN模组,终端界面显示“ready to OS start”,则启动成功。 + + **图2** Hi3861 WLAN模组复位成功示意图 + + ![zh-cn_image_0000001226794704](figures/zh-cn_image_0000001226794704.png) + +3. 在串口终端中,依次执行如下AT命令,启动STA模式,连接指定AP热点,并开启DHCP功能。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 开发板启动后,串口会打印测试用例信息,待测试用例信息打印完成后再执行AT指令,否则AT指令会被测试用例信息覆盖。 + + + + ``` + AT+STARTSTA # 启动STA模式 + AT+SCAN # 扫描周边AP + AT+SCANRESULT # 显示扫描结果 + AT+CONN="SSID",,2,"PASSWORD" # 连接指定AP,其中SSID/PASSWORD为待连接的热点名称和密码 + AT+STASTAT # 查看连接结果 + AT+DHCP=wlan0,1 # 通过DHCP向AP请求wlan0的IP地址 + ``` + +4. 查看Hi3861 WLAN模组与网关联通是否正常,如下图所示。 + + ``` + AT+IFCFG # 查看模组接口IP + AT+PING=X.X.X.X # 检查模组与网关的联通性,其中X.X.X.X需替换为实际的网关地址 + ``` + + **图3** Hi3861 WLAN模组联网成功示意图 + + ![zh-cn_image_0000001226954648](figures/zh-cn_image_0000001226954648.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md deleted file mode 100644 index a8e7c64c69f5c3e406634f5d3b256c7f4eda647d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md +++ /dev/null @@ -1,20 +0,0 @@ -# 运行 - -- [运行结果](#section18115713118) -- [下一步学习](#section9712145420182) - -## 运行结果 - -示例代码编译、烧录、运行、调测后,重启开发板后将自动在界面输出如下结果: - -``` -ready to OS start -FileSystem mount ok. -wifi init success! -[DEMO] Hello world. -``` - -## 下一步学习 - -恭喜,您已完成Hi3861开发板快速上手!建议您下一步进入[WLAN产品开发](../guide/device-wlan-led-control.md)的学习 。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md index 8296fe1831a1bfa2f4b80a99e3139e33248087cb..6f4c6cd02deb67e1186371221525b7bbf1e77cf3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md @@ -1,297 +1,262 @@ -# 安装开发板环境 +# 安装Hi3861开发板环境 -- [Hi3861工具要求](#section466851916410) - - [硬件要求](#section19202111020215) - - [软件要求](#section727451210318) -- [安装Linux编译工具](#section497484245614) - - [安装编译依赖基础软件(仅Ubuntu 20+需要)](#section45512412251) - - [安装Scons](#section7438245172514) - - [安装python模块](#section88701892341) - - [安装gcc\_riscv32(WLAN模组类编译工具链)](#section34435451256) +## Hi3861工具要求 -## Hi3861工具要求 +### 硬件要求 -### 硬件要求 +- Linux工作台 -- Linux工作台 -- Hi3861开发板 -- USB Type-C线(Linux工作台通过USB与Hi3861开发板连接) +- Hi3861 WLAN模组 -### 软件要求 +- USB Type-C线(Linux工作台通过USB与Hi3861开发板连接) ->![](../public_sys-resources/icon-notice.gif) **须知:** ->本节描述采用安装包方式安装相关工具的操作步骤。如果使用Docker方式安装,无需安装[表1](#table6299192712513)中的相关工具,请直接从[新建应用程序](quickstart-lite-steps-hi3861-application-framework.md)开始操作。 -Hi3861开发板需要的工具如下表所示。 +### 软件要求 -**表 1** Hi3861开发板需要安装的工具 - - - - - - - - - - - - - - - - - - -

开发工具

-

用途

-

编译基础软件包(仅ubuntu 20+需要)

-

编译依赖的基础软件包

-

SCons3.0.4+

-

编译构建工具

-

python模块:setuptools、kconfiglib、pycryptodome、six、ecdsa

-

编译构建工具

-

gcc riscv32

-

编译构建工具

-
+Hi3861 WLAN模组需要的工具如下表所示。 -## 安装Linux编译工具 -### 安装编译依赖基础软件(仅Ubuntu 20+需要) + **表1** Hi3861 WLAN模组需要安装的编译工具 -执行以下命令进行安装: +| 开发工具 | 用途 | +| -------- | -------- | +| SCons3.0.4+ | 编译构建工具 | +| python模块:setuptools、kconfiglib、pycryptodome、six、ecdsa | 编译构建工具 | +| gcc riscv32 | 编译构建工具 | -``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev -``` -### 安装Scons +## 安装编译工具 -1. 运行如下命令,安装SCons安装包。 +编译Hi3861 WLAN模组需要一些特定的编译工具,在Ubuntu下通过以下步骤安装。 - ``` - python3 -m pip install scons - ``` - -2. 运行如下命令,查看是否安装成功。如果安装成功,查询结果下图所示。 - - ``` - scons -v - ``` - **图 1** SCons安装成功界面,版本要求3.0.4以上 - ![](figures/SCons安装成功界面-版本要求3-0-4以上.png "SCons安装成功界面-版本要求3-0-4以上") - - -### 安装python模块 - -1. 运行如下命令,安装python模块setuptools。 - - ``` - pip3 install setuptools - ``` +### 安装Scons -2. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 - - **命令行方式:** +1. 运行如下命令,安装SCons安装包。 + + ``` + python3 -m pip install scons + ``` - ``` - sudo pip3 install kconfiglib - ``` +2. 运行如下命令,查看是否安装成功。如果安装成功,查询结果下图所示。 + + ``` + scons -v + ``` - - **安装包方式:** - 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 + **图1** SCons安装成功界面,版本要求3.0.4以上 - 下载路径:“[https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files)” + ![zh-cn_image_0000001271234749](figures/zh-cn_image_0000001271234749.png) - 1. 运行如下命令,安装.whl文件。 - ``` - sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl - ``` +### 安装python模块 +1. 运行如下命令,安装python模块setuptools。 + + ``` + pip3 install setuptools + ``` -3. 安装pycryptodome,任选如下一种方式。 +2. 安装GUI menuconfig工具(Kconfiglib),建议安装Kconfiglib 13.2.0+版本,任选如下一种方式。 - 安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。 + - **命令行方式:** + + ``` + sudo pip3 install kconfiglib + ``` + - **安装包方式:** - - **命令行方式:** + 1. 下载.whl文件(例如:kconfiglib-13.2.0-py2.py3-none-any.whl)。 - ``` - sudo pip3 install pycryptodome - ``` + 下载路径:“[https://pypi.org/project/kconfiglib#files](https://pypi.org/project/kconfiglib#files)” - - **安装包方式:** - 1. 下载.whl文件(例如:pycryptodome-3.9.9-cp38-cp38-manylinux1\_x86\_64.whl)。 + 2. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl + ``` - 下载路径:“[https://pypi.org/project/pycryptodome/\#files](https://pypi.org/project/pycryptodome/#files)”。 +3. 安装pycryptodome,任选如下一种方式。 - 1. 运行如下命令,安装.whl文件。 + 安装升级文件签名依赖的Python组件包,包括:pycryptodome、six、ecdsa。安装ecdsa依赖six,请先安装six,再安装ecdsa。 - ``` - sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl - ``` + - **命令行方式:** + + ``` + sudo pip3 install pycryptodome + ``` + + - **安装包方式:** + 1. 下载.whl文件(例如:pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl)。 -4. 安装six,任选如下一种方式。 - - **命令行方式:** + 下载路径:“[https://pypi.org/project/pycryptodome/#files](https://pypi.org/project/pycryptodome/#files)”。 - ``` - sudo pip3 install six --upgrade --ignore-installed six - ``` + 2. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl + ``` - - **安装包方式:** - 1. 下载.whl文件(例如:six-1.12.0-py2.py3-none-any.whl)。 +4. 安装six,任选如下一种方式。 - 下载路径:“[https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files)” + - **命令行方式:** + + ``` + sudo pip3 install six --upgrade --ignore-installed six + ``` - 1. 运行如下命令,安装.whl文件。 + - **安装包方式:** - ``` - sudo pip3 install six-1.12.0-py2.py3-none-any.whl - ``` + 1. 下载.whl文件(例如:six-1.12.0-py2.py3-none-any.whl)。 + 下载路径:“[https://pypi.org/project/six/#files](https://pypi.org/project/six/#files)” -5. 安装ecdsa,任选如下一种方式。 - - **命令行方式:** + 2. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install six-1.12.0-py2.py3-none-any.whl + ``` - ``` - sudo pip3 install ecdsa - ``` +5. 安装ecdsa,任选如下一种方式。 - - **安装包方式:** - 1. 下载.whl文件(例如:ecdsa-0.14.1-py2.py3-none-any.whl)。 - - 下载路径:“[https://pypi.org/project/ecdsa/\#files](https://pypi.org/project/ecdsa/#files)” - - 1. 运行如下命令,安装.whl文件。 - - ``` - sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl - ``` - - - - -### 安装gcc\_riscv32(WLAN模组类编译工具链) - ->![](../public_sys-resources/icon-notice.gif) **须知:** ->- Hi3861开发板平台仅支持使用libgcc运行时库的静态链接,不建议开发者使用libgcc运行时库的动态链接,以免产品需遵从GPLV3许可证。 ->- 通过下述步骤2-15,我们编译好了gcc\_riscv32 镜像,提供给开发者[直接下载](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz)使用。直接下载 gcc\_riscv32 镜像的开发者可省略下述2-15步。 - -1. 打开Linux编译服务器终端。 -2. 环境准备,请安装"gcc, g++, bison, flex, makeinfo"软件,确保工具链能正确编译。 - - ``` - sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install flex bison && sudo apt-get install texinfo - ``` + - **命令行方式:** + + ``` + sudo pip3 install ecdsa + ``` -3. 下载riscv-gnu-toolchain交叉编译工具链。 + - **安装包方式:** - ``` - git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git - ``` + 1. 下载.whl文件(例如:ecdsa-0.14.1-py2.py3-none-any.whl)。 -4. 打开文件夹riscv-gnu-toolchain,先删除空文件夹,以防止下载newlib,binutils,gcc时冲突。 + 下载路径:“[https://pypi.org/project/ecdsa/#files](https://pypi.org/project/ecdsa/#files)” - ``` - cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc - ``` + 2. 运行如下命令,安装.whl文件。 + + ``` + sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl + ``` -5. 下载riscv-newlib-3.0.0。 - ``` - git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git - ``` +### 安装gcc_riscv32(WLAN模组类编译工具链) -6. 下载riscv-binutils-2.31.1。 +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> - Hi3861开发板平台仅支持使用libgcc运行时库的静态链接,不建议开发者使用libgcc运行时库的动态链接,以免产品需遵从GPLV3许可证。 +> +> - 通过下述步骤2-14,我们编译好了gcc_riscv32镜像,提供给开发者[直接下载](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz)使用。直接下载gcc_riscv32镜像的开发者可省略下述2-14步。 - ``` - git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git - ``` +1. 打开Linux编译服务器终端。 -7. 下载riscv-gcc-7.3.0。 +2. 下载riscv-gnu-toolchain交叉编译工具链。 + + ``` + git clone --recursive https://gitee.com/mirrors/riscv-gnu-toolchain.git + ``` - ``` - git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc - ``` +3. 打开文件夹riscv-gnu-toolchain,先删除空文件夹,以防止下载newlib,binutils,gcc时冲突。 + + ``` + cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc + ``` -8. 添加riscv-gcc-7.3.0补丁。 +4. 下载riscv-newlib-3.0.0。 + + ``` + git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git + ``` - 访问gcc官方补丁链接[89411](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2),[86724](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3),按照补丁链接中要求的修改,手动将变更添加到对应的.c和.h文件中,注意由于patch版本与下载的gcc版本有所偏差,行数有可能对应不上,请自行查找patch中的关键字定位到对应行。 +5. 下载riscv-binutils-2.31.1。 + + ``` + git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git + ``` -9. 下载[GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2),并解压安装。 +6. 下载riscv-gcc-7.3.0。 + + ``` + git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc + ``` - ``` - tar -xvf gmp-6.1.2.tar.bz2 && mkdir build_gmp && cd build_gmp && ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2 --disable-shared --enable-cxx && make && make install - ``` +7. 添加riscv-gcc-7.3.0补丁。 -10. 下载[mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz),并解压安装。 + 访问gcc官方补丁链接[89411](https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=026216a753ef0a757a9e368a59fa667ea422cf09;hp=2a23a1c39fb33df0277abd4486a3da64ae5e62c2),[86724](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/graphite.h;h=be0a22b38942850d88feb159603bb846a8607539;hp=4e0e58c60ab83f1b8acf576e83330466775fac17;hb=b1761565882ed6a171136c2c89e597bc4dd5b6bf;hpb=fbd5f023a03f9f60c6ae36133703af5a711842a3),按照补丁链接中要求的修改,手动将变更添加到对应的.c和.h文件中,注意由于patch版本与下载的gcc版本有所偏差,行数有可能对应不上,请自行查找patch中的关键字定位到对应行。 - ``` - tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install - ``` +8. 下载[GMP 6.1.2](https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2),并解压安装。 + + ``` + tar -xvf gmp-6.1.2.tar.bz2 && mkdir build_gmp && cd build_gmp && ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2 --disable-shared --enable-cxx && make && make install + ``` -11. 下载[mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz) ,并解压安装。 +9. 下载[mpfr-4.0.2 ](https://www.mpfr.org/mpfr-4.0.2/mpfr-4.0.2.tar.gz),并解压安装。 + + ``` + tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install + ``` +10. 下载[mpc-1.1.0](https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz) ,并解压安装。 + ``` tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install ``` -12. 打开文件夹riscv-gnu-toolchain,新建工具链输出目录。 - +11. 打开文件夹riscv-gnu-toolchain,新建工具链输出目录。 + ``` cd /opt && mkdir gcc_riscv32 ``` -13. 编译binutils。 - +12. 编译binutils。 + ``` mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. ``` -14. 编译newlib。 - +13. 编译newlib。 + ``` mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd .. ``` -15. 编译gcc。 - +14. 编译gcc。 + ``` mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install ``` -16. 设置环境变量。 +15. 设置环境变量。 - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果直接采用编译好的riscv32 gcc包,请先执行以下命令将压缩包解压到根目录: - >``` - >tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~ - >``` + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果直接采用编译好的riscv32 gcc包,请先执行以下命令将压缩包解压到根目录: + > + > ``` + > tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~ + > ``` + + ``` vim ~/.bashrc ``` 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + ``` export PATH=~/gcc_riscv32/bin:$PATH ``` -17. 生效环境变量。 - +16. 生效环境变量。 + ``` source ~/.bashrc ``` -18. Shell命令行中输入如下命令,如果能正确显示编译器版本号,表明编译器安装成功。 - +17. Shell命令行中输入如下命令,如果能正确显示编译器版本号,表明编译器安装成功。 + ``` riscv32-unknown-elf-gcc -v ``` - - diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md index 7d6e71a329f877022e8b3ce559ff25c09aa18a06..4266d6e5ea673b59b90ac19c571c1c6be397ab4d 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md @@ -1,17 +1,17 @@ -# Hi3861开发板 +# Hi3861开发板 -- **[安装开发板环境](quickstart-lite-steps-hi3861-setting.md)** -- **[新建应用程序](quickstart-lite-steps-hi3861-application-framework.md)** -- **[编译](quickstart-lite-steps-hi3861-building.md)** +- **[安装Hi3861开发板环境](quickstart-lite-steps-hi3861-setting.md)** -- **[烧录](quickstart-lite-steps-hi3861-burn.md)** +- **[编写“Hello World”程序](quickstart-lite-steps-hi3861-application-framework.md)** -- **[调试验证](quickstart-lite-steps-hi3861-debug.md)** +- **[编译](quickstart-lite-steps-hi3861-building.md)** -- **[运行](quickstart-lite-steps-hi3861-running.md)** +- **[烧录](quickstart-lite-steps-hi3861-burn.md)** -- **[常见问题](quickstart-lite-steps-hi3861-faqs.md)** +- **[联网](quickstart-lite-steps-hi3861-netconfig.md)** +- **[调试验证](quickstart-lite-steps-hi3861-debug.md)** +- **[运行](quickstart-lite-steps-hi3816-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps.md index 43f31a4215b9d7d8fe75b01bd7c15bcec91b0c48..c3ae5aed824239b7decd4e8e99c82bffb9f2a557 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps.md @@ -1,9 +1,7 @@ -# 运行“Hello World” +# 运行“Hello World” -- **[Hi3861开发板](quickstart-lite-steps-hi3861.md)** -- **[Hi3516开发板](quickstart-lite-steps-hi3516.md)** - -- **[Hi3518开发板](quickstart-lite-steps-hi3518.md)** +- **[Hi3861开发板](quickstart-lite-steps-hi3861.md)** +- **[Hi3516开发板](quickstart-lite-steps-hi3516.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-lite.md b/zh-cn/device-dev/quick-start/quickstart-lite.md index 8fb31f485fa0783889855941e8f0ac1beb2df47c..42672e839b58c3da87fdb9092dba39cd1fa6b65a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite.md @@ -1,11 +1,7 @@ -# 轻量和小型系统入门 +# 轻量和小型系统入门 -- **[轻量与小型系统入门概述](quickstart-lite-overview.md)** -- **[搭建轻量与小型系统环境](quickstart-lite-env-setup.md)** - -- **[运行“Hello World”](quickstart-lite-steps.md)** - -- **[附录](quickstart-lite-introduction.md)** +- **[轻量和小型系统快速入门-IDE](quickstart-lite-ide-directory.md)** +- **[轻量和小型系统快速入门-安装包](quickstart-lite-package-directory.md)** diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-appendix-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-standard-appendix-hi3516.md deleted file mode 100644 index 632fb20062a69a44f98fdf81542a5d15475ff3a3..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-appendix-hi3516.md +++ /dev/null @@ -1,40 +0,0 @@ -# Hi3516开发板介绍 - -- [开发板简介](#zh-cn_topic_0000001053666242_section047719215429) -- [开发板规格](#zh-cn_topic_0000001053666242_section15192203316533) - -## 开发板简介 - -Hi3516DV300是新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP\(Image Signal Processor\)、H.265视频压缩编码器、高性能NNIE引擎,在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 - -**图 1** Hi3516单板正面外观图 -![](figures/Hi3516单板正面外观图.png "Hi3516单板正面外观图") - -## 开发板规格 - -**表 1** Hi3516开发板规格清单 - - - - - - - - - - - - - -

规格类型

-

规格清单

-

处理器及内部存储

-
  • Hi3516DV300芯片
  • DDR3 1GB
  • eMMC4.5,8GB容量
-

外部器件

-
  • 以太网口
  • 音频视频
    • 1路语音输入
    • 1路单声道(AC_L)输出,接3W功放(LM4871)
    • MicroHDMI(1路HDMI 1.4)
    -
  • 摄像头
    • 传感器IMX335
    • 镜头M12,焦距4mm,光圈1.8
    -
  • 显示屏
    • LCD连接器(2.35寸)
    • LCD连接器(5.5寸)
    -
  • 外部器件及接口
    • SD卡接口
    • JTAG/I2S接口
    • ADC接口
    • 舵机接口
    • Grove连接器
    • USB2.0(Type C)
    • 功能按键3个,2个用户自定义按键,1个升级按键
    • LED指示灯,绿灯,红灯
    -
-
- diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-appendix-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-standard-appendix-rk3568.md deleted file mode 100644 index 331ba010211463a5703d1be2dc3f71f1932b8df8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-appendix-rk3568.md +++ /dev/null @@ -1,3 +0,0 @@ -# RK3568开发板介绍 - -参见:[润和HH-SCDAYU200开发套件](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/README.md)。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-appendix.md b/zh-cn/device-dev/quick-start/quickstart-standard-appendix.md index 7eaf5733743a9f3688c10c0d99952235df1f89b9..8111fe8a4a24cc37c4f96e690a3180d90015e1d3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-appendix.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-appendix.md @@ -1,7 +1,7 @@ -# 附录 +# 附录 -- **[Hi3516开发板介绍](quickstart-standard-appendix-hi3516.md)** -- **[RK3568开发板介绍](quickstart-standard-appendix-rk3568.md)** +- **[开发板介绍](quickstart-standard-board-introduction.md)** +- **[参考信息](quickstart-standard-reference.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md new file mode 100644 index 0000000000000000000000000000000000000000..15aec7eb2652f98587fd2756d50f3bf87a1dbe8c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3516.md @@ -0,0 +1,20 @@ +# Hi3516开发板介绍 + + +## 开发板简介 + +Hi3516DV300是新一代行业专用Smart HD IP摄像机SOC,集成新一代ISP(Image Signal Processor)、H.265视频压缩编码器、高性能NNIE引擎,在低码率、高画质、智能处理和分析、低功耗等方面引领行业水平。 + + **图1** Hi3516单板正面外观图 + + ![zh-cn_image_0000001226922318](figures/zh-cn_image_0000001226922318.png) + + +## 开发板规格 + + **表1** Hi3516开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3516DV300芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 1路语音输入
  - 1路单声道(AC_L)输出,接3W功放(LM4871)
  - MicroHDMI(1路HDMI 1.4)
- 摄像头
  - 传感器IMX335
  - 镜头M12,焦距4mm,光圈1.8
- 显示屏
  - LCD连接器(2.35寸)
  - LCD连接器(5.5寸)
- 外部器件及接口
  - SD卡接口
  - JTAG/I2S接口
  - ADC接口
  - 舵机接口
  - Grove连接器
  - USB2.0(Type C)
  - 功能按键3个,2个用户自定义按键,1个升级按键
  - LED指示灯,绿灯,红灯 | diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md new file mode 100644 index 0000000000000000000000000000000000000000..f712d144eceaee81bc401c33b95cee5f5622617a --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-rk3568.md @@ -0,0 +1,41 @@ +# RK3568开发板介绍 + + +## 开发板简介 + +RK3568开发板基于Rockchip RK3568芯片,集成双核心架构GPU以及高效能NPU;搭载四核64位Cortex-A55处理器,采用22nm先进工艺,主频高达2.0GHz;支持蓝牙、Wi-Fi、音频、视频和摄像头等功能,拥有丰富的扩展接口,支持多种视频输入输出接口;配置双千兆自适应RJ45以太网口,可满足NVR、工业网关等多网口产品需求。 + + **图1** RK3568开发板正面 + + ![zh-cn_image_0000001271442261](figures/zh-cn_image_0000001271442261.png) + + **图2** RK3568开发板背面 + + ![zh-cn_image_0000001226602394](figures/zh-cn_image_0000001226602394.png) + + +## 开发板规格 + + **表1** RK3568开发板规格说明 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| 显示接口 | - 1×HDMI2.0(Type-A)接口,支持4K/60fps输出
- 2×MIPI接口,支1920\*1080\@60fps输出
- 1×eDP接口,支持2K\@60fps输出 | +| 音频接口 | - 1×8ch I2S/TDM/PDM
- 1×HDMI音频输出
- 1×喇叭输出
- 1×耳机输出
- 1×麦克风,板载音频输入 | +| 以太网 | 2×GMAC(10/100/1000M) | +| 无线网络 | SDIO接口,支持WIFI6 5G/2.5G,BT4.2 | +| 摄像头接口 | MIPI-CSI2,1x4-lane/2x2-lane\@2.5Gbps/lane | +| USB | - 2×USB2.0 Host,Type-A
- 1×USB3.0 Host,Type-A
- 1×USB3.0 OTG | +| PCIe | 1×2Lanes PCIe3.0 Connector (RC Mode) | +| SATA | 1×SATA3.0 Connector | +| SDMMC | 1×Micro SD Card3.0 | +| 按键 | - 1×Vol+/Recovery
- 1×Reset
- 1×Power
- 1×Vol-
- 1×Mute | +| 调试 | 1×调试串口 | +| RTC | 1×RTC | +| IR | 1×IR | +| 三色灯 | 3×LED | +| G-sensor | 1×G-sensor | +| FAN | 1×Fan | +| 扩展接口 | 20Pin扩展接口包括:
- 2×ADC接口
- 2×I2C接口
- 7×GPIO口(或者3×gpio + 4×uart信号)
- 3×VCC电源(12V、3.3V、5V) | +| 底板尺寸 | 180mm×130mm | +| PCB规格 | 4 层板 | diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction.md new file mode 100644 index 0000000000000000000000000000000000000000..23dc0e0349cb6a55d41c75dc5979ec4317b14929 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction.md @@ -0,0 +1,7 @@ +# 开发板介绍 + + + +- **[Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md)** + +- **[RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-docker.md b/zh-cn/device-dev/quick-start/quickstart-standard-docker.md new file mode 100644 index 0000000000000000000000000000000000000000..f1e5c764a287fcde725b1f6dcc6819f86aff1d7f --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-docker.md @@ -0,0 +1,13 @@ +# 标准系统快速入门(安装包方式) + + + +- **[标准系统入门概述](quickstart-standard-overview.md)** + +- **[搭建标准系统环境](quickstart-standard-env-setup.md)** + +- **[运行“Hello World”](quickstart-standard-running.md)** + +- **[常见问题](quickstart-standard-faqs.md)** + +- **[附录](quickstart-standard-appendix.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md index e211b8ba3126aa456ab25efd42272f9d5019250d..3ae52558f2b7b18b5f5880a7cf706b2600e76fed 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md @@ -1,73 +1,381 @@ -# 开发环境准备 +# 搭建标准系统环境 -- [系统要求](#zh-cn_topic_0000001072959308_section1865184385215) -- [安装DevEco Device Tool](#zh-cn_topic_0000001072959308_section86587531620) -DevEco Device Tool Ubuntu版本支持OpenHarmony源码开发、编译、烧录的一站式开发环境,因此,本章节为您介绍在Ubuntu环境下,如何搭建一套完整的可视化开发环境。 +## 系统要求 -## 系统要求 +- Windows系统要求:Windows10 64位系统。 -- Ubuntu18及以上版本,内存推荐16 GB及以上。 -- 系统的用户名不能含有中文字符。 -- 只能使用普通用户角色搭建开发环境。 +- Ubuntu系统要求:Ubuntu18.04及以上版本,内存推荐16 GB及以上。 -## 安装DevEco Device Tool +- Windows系统和Ubuntu系统的用户名不能包含中文字符。 -DevEco Device Tool基于Visual Studio Code进行扩展,在Visual Studio Code上以插件方式运行,Visual Studio Code版本为1.60及以上。同时,DevEco Device Tool还依赖Python工具,并要求Python为3.8\~3.9版本。 +- Windows和Ubuntu上安装的DevEco Device Tool为3.0 Release版本。 -在安装过程中,DevEco Device Tool会自动检查Visual Studio Code和Python,如果检测到Visual Studio Code、Python未安装或版本不符合要求,安装程序会自动安装Visual Studio Code和Python。 -1. 将Ubuntu Shell环境修改为bash。 - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 +## 安装必要的库和工具 - ``` - ls -l /bin/sh - ``` +编译OpenHarmony需要一些库和工具,可以通过以下步骤进行安装。 - ![](figures/zh-cn_image_0000001194078294.png) +相应操作在Ubuntu环境中进行。 - 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 +1. 使用如下apt-get命令安装后续操作所需的库和工具: + + ``` + sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales + ``` - ``` - sudo dpkg-reconfigure dash - ``` + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: + > + > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 + > + > - java要求java8及以上版本,此处以java8为例。 - ![](figures/zh-cn_image_0000001238878219.png) +2. 将python 3.8设置为默认python版本。 -2. 下载[DevEco Device Tool 3.0 Beta2](https://device.harmonyos.com/cn/ide#download_beta)Linux版本,下载时,请先使用华为开发者帐号进行登录后下载。如未注册华为开发者账号,请先[注册](https://developer.huawei.com/consumer/cn/doc/start/registration-and-verification-0000001053628148)。 -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.200.zip为软件包名称,请根据实际进行修改。 + 查看python 3.8的位置: - ``` - unzip devicetool-linux-tool-3.0.0.300.zip - ``` + + ``` + which python3.8 + ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 + 将python和python3切换为python3.8: + + ``` + sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 + sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置 + ``` - ``` - chmod u+x devicetool-linux-tool-3.0.0.300.sh - ``` -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 +## 安装DevEco Device Tool - >![](../public_sys-resources/icon-note.gif) **说明:** - >安装过程中,会自动检查Visual Studio Code和Python是否安装,且版本符合要求,其中Visual Studio Code为1.60及以上版本,Python为3.8\~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 +通过Windows系统远程访问Ubuntu环境进行烧录等操作,需要先在Windows和Ubuntu下分别安装DevEco Device Tool。 - ``` - sudo ./devicetool-linux-tool-3.0.0.300.sh -- --install-plugins - ``` +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> DevEco Device Tool 是OpenHarmony的一站式开发工具,支持源码开发、编译、烧录,调测等,本文主要用其远端链接Ubuntu环境进行烧录和运行。 - 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - ![](figures/zh-cn_image_0000001239348791.png) +### 安装Window版本DevEco Device Tool -5. 安装完成后,在Ubuntu左下角的![](figures/zh-cn_image_0000001075566984.png)中,启动Visual Studio Code。 -6. 启动Visual Studio Code,DevEco Device Tool运行依赖C/C++、CodeLLDB插件,请点击Visual Studio Code左侧的![](figures/button.png)按钮,分别搜索和安装C/C++、CodeLLDB插件。 +1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Windows版。 - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果在插件市场安装C/C++和CodeLLDB插件不成功,可手动下载插件后进行安装,具体请参考:[离线安装C/C++和CodeLLDB插件](https://device.harmonyos.com/cn/docs/documentation/guide/offline_plugin_install-0000001074376846)。 +2. 解压DevEco Device Tool压缩包,双击安装包程序,点击Next进行安装。 - ![](figures/deveco-device-tool-install-sucessful.png) +3. 设置DevEco Device Tool的安装路径,建议安装到非系统盘符,点击**Next**。 -7. 重启Visual Studio Code,点击![](figures/zh-cn_image_0000001239226427.png)进入DevEco Device Tool工具界面。至此,DevEco Device Tool Ubuntu开发环境安装完成。![](figures/zh-cn_image_0000001194668634.png) + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现如下错误提示时,请点击“Ignore”继续安装,该错误不影响新版本的安装。 + > + > ![zh-cn_image_0000001239275843](figures/zh-cn_image_0000001239275843.png) + ![zh-cn_image_0000001270076961](figures/zh-cn_image_0000001270076961.png) + +4. 根据安装向导提示,勾选要自动安装的软件。 + + 1. 在弹出VSCode installation confirm页面,勾选“Install VScode 1.62.2automatically”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 + + ![zh-cn_image_0000001237801283](figures/zh-cn_image_0000001237801283.png) + + 2. 在弹出的Python select page选择“Download from Huawei mirror”,点击**Next**。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 + + ![zh-cn_image_0000001193983334](figures/zh-cn_image_0000001193983334.png) + +5. 在以下界面点击**Next**,进行软件下载和安装。 + + ![zh-cn_image_0000001239634067](figures/zh-cn_image_0000001239634067.png) + +6. 继续等待DevEco Device Tool安装向导自动安装DevEco Device Tool插件,直至安装完成,点击**Finish**,关闭DevEco Device Tool安装向导。 + + ![zh-cn_image_0000001239650137](figures/zh-cn_image_0000001239650137.png) + +7. 打开Visual Studio Code,进入DevEco Device Tool工具界面。至此,DevEco Device Tool Windows开发环境安装完成。 + + ![zh-cn_image_0000001225760456](figures/zh-cn_image_0000001225760456.png) + + +### 安装Ubuntu版本DevEco Device Tool + +1. 将Ubuntu Shell环境修改为bash。 + + 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash。 + + ``` + ls -l /bin/sh + ``` + + ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) + + 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 + + ``` + sudo dpkg-reconfigure dash + ``` + + ![zh-cn_image_0000001243641075](figures/zh-cn_image_0000001243641075.png) + +2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download)Linux版本。 + +3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 + + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.400.zip为软件包名称,请根据实际进行修改。 + + ``` + unzip devicetool-linux-tool-3.0.0.400.zip + ``` + + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + ``` + chmod u+x devicetool-linux-tool-3.0.0.400.sh + ``` + +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.400.sh请根据实际进行修改。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 安装过程中,会自动检查Python是否安装,且要求Python为3.8~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 + + + ``` + sudo ./devicetool-linux-tool-3.0.0.400.sh + ``` + + 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 + + ![zh-cn_image_0000001198722374](figures/zh-cn_image_0000001198722374.png) + + +## 配置Windows远程访问Ubuntu环境 + + +### 安装SSH服务并获取远程访问的IP地址 + +1. 在Ubuntu系统中,打开终端工具,执行如下命令安装SSH服务。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 + + + ``` + sudo apt-get install openssh-server + ``` + +2. 执行如下命令,启动SSH服务。 + + ``` + sudo systemctl start ssh + ``` + +3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 + + ``` + ifconfig + ``` + + ![zh-cn_image_0000001215737140](figures/zh-cn_image_0000001215737140.png) + + +### 安装Remote SSH + +1. 打开Windows系统下的Visual Studio Code,点击![zh-cn_image_0000001239080359](figures/zh-cn_image_0000001239080359.png),在插件市场的搜索输入框中输入“remote-ssh”。 + + ![zh-cn_image_0000001193920448](figures/zh-cn_image_0000001193920448.png) + +2. 点击Remote-SSH的**Install**按钮,安装Remote-SSH。安装成功后,在**INSTALLED**下可以看到已安装Remote-SSH。 + + ![zh-cn_image_0000001238880335](figures/zh-cn_image_0000001238880335.png) + + +### 远程连接Ubuntu环境 + +1. 打开Windows系统的Visual Studio Code,点击![zh-cn_image_0000001238760373](figures/zh-cn_image_0000001238760373.png),在REMOTE EXOPLORER页面点击+按钮。 + + ![zh-cn_image_0000001215878922](figures/zh-cn_image_0000001215878922.png) + +2. 在弹出的SSH连接命令输入框中输入“ssh _username_\@_ip_address_”,其中ip_address为要连接的远程计算机的IP地址,username为登录远程计算机的帐号。 + + ![zh-cn_image_0000001215879750](figures/zh-cn_image_0000001215879750.png) + +3. 在弹出的输入框中,选择SSH configuration文件,选择默认的第一选项即可。 + + ![zh-cn_image_0000001260519729](figures/zh-cn_image_0000001260519729.png) + +4. 在SSH TARGETS中,找到远程计算机,点击![zh-cn_image_0000001194080414](figures/zh-cn_image_0000001194080414.png),打开远程计算机。 + + ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) + +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 + + ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) + + 连接成功后,等待在远程计算机.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 + + +### 注册访问Ubuntu环境的公钥 + +在完成以上操作后,您就可以通过Windows远程连接Ubuntu环境进行开发了,但在使用过程中,需要您频繁的输入远程连接密码来进行连接。为解决该问题,您可以使用SSH公钥来进行设置。 + +1. 打开Git bash命令行窗口,执行如下命令,生成SSH公钥,请注意,在执行命令过程中,请根据界面提示进行操作。username和ip请填写连接Ubuntu系统时需要的参数。 + + ``` + ssh-keygen -t rsa + ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip + ``` + + ![zh-cn_image_0000001271532317](figures/zh-cn_image_0000001271532317.png) + +2. 在Visual Studio Code中,点击远程连接的设置按钮,并选择打开config文件。 + + ![zh-cn_image_0000001226034634](figures/zh-cn_image_0000001226034634.png) + +3. 在config配置文件中添加SSK Key文件信息,如下图所示,然后保存即可。 + + ![zh-cn_image_0000001270356233](figures/zh-cn_image_0000001270356233.png) + + +## 获取源码 + +在Ubuntu环境下通过以下步骤拉取OpenHarmony源码。 + + +### 准备工作 + +1. 注册码云gitee帐号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装git客户端和git-lfs。(上述工具已在安装必要的库和工具小节安装。如已安装,请忽略) + + 更新软件源: + + ``` + sudo apt-get update + ``` + + 通过以下命令安装: + + ``` + sudo apt-get install git git-lfs + ``` + +4. 配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +5. 执行如下命令安装码云repo工具。 + + ``` + curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### 获取源码 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> Master主干为开发分支,开发者可通过Master主干获取最新特性。发布分支代码相对比较稳定,开发者可基于发布分支代码进行商用功能开发。 + +- **OpenHarmony主干代码获取** + + 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + + 方式二:通过repo + https下载。 + + + ``` + repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- **OpenHarmony发布分支代码获取** + + OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)。 + + +### 执行prebuilts + + 在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。 + +``` +bash build/prebuilts_download.sh +``` + + +## 安装编译工具 + +hb是OpenHarmony的编译工具,可通过以下步骤在Ubuntu下进行安装。想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-build.md)。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 如需安装代理,请参考[配置代理](../quick-start/quickstart-standard-reference.md#配置代理)。 + + +1. 运行如下命令安装hb并更新至最新版本 + + ``` + pip3 install --user build/lite + ``` + +2. 设置环境变量 + + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/.local/bin:$PATH + ``` + + 执行如下命令更新环境变量。 + + ``` + source ~/.bashrc + ``` + +3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: + + ``` + usage: hb + + OHOS build system + + positional arguments: + {build,set,env,clean} + build Build source code + set OHOS build settings + env Show OHOS build env + clean Clean output + + optional arguments: + -h, --help show this help message and exit + ``` + + +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** +> - 可采用以下命令卸载hb: +> +> ``` +> pip3 uninstall ohos-build +> ``` +> +> - 若安装hb的过程中遇到问题,请参见下文[常见问题](../quick-start/quickstart-standard-faq-hb.md)进行解决。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..8cf38f261f4d8e637a7d91dcf3c1e2c635817260 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-faq-burning.md @@ -0,0 +1,96 @@ +# 烧录异常 + + +## 烧写选择串口后提示“Error: Opening COMxx: Access denied” + +- **现象描述** + + 点击烧写并选择串口后,出现Error: Opening COMxx: Access denied。 + + **图1** 打开串口失败图 + + ![zh-cn_image_0000001271202461](figures/zh-cn_image_0000001271202461.png) + +- **可能原因** + + 串口已经被占用。 + +- **解决办法** + +1. 按图依次选择下拉框,查找带有serial-xx的终端。 + + **图2** 查找是否存在占用串口的终端 + + ![zh-cn_image_0000001271202473](figures/zh-cn_image_0000001271202473.png) + +2. 点击标号中的垃圾桶图标,关闭串口。 + + **图3** 关闭串口终端 + + ![zh-cn_image_0000001271202469](figures/zh-cn_image_0000001271202469.png) + +3. 重新点击烧写,选择串口并开始烧写程序。 + + **图4** 重新启动烧写任务 + + ![zh-cn_image_0000001271562449](figures/zh-cn_image_0000001271562449.png) + + +## Windows电脑与单板网络连接失败 + +- **现象描述** + + 点击烧写并选择串口后,无法获取文件。 + + **图5** 网络不通,单板无法获取文件图 + + ![zh-cn_image_0000001226922306](figures/zh-cn_image_0000001226922306.png) + +- **可能原因** + + 单板网络与Windows电脑不联通。 + + Windows电脑防火墙未允许Visual Studio Code联网。 + +- **解决方法** + +1. 检查网线是否连接。 + +2. 点击Windows防火墙。 + + **图6** 网络防火墙设置图 + + ![zh-cn_image_0000001227082322](figures/zh-cn_image_0000001227082322.png) + +3. 点击“允许应用通过防火墙”。 + + **图7** 防火墙和网络保护界面图 + + ![zh-cn_image_0000001271202457](figures/zh-cn_image_0000001271202457.png) + +4. 查找Visual Studio Code应用。 + + **图8** 查找Visual Studio Code应用图 + + ![zh-cn_image_0000001271562445](figures/zh-cn_image_0000001271562445.png) + +5. 勾选Visual Studio Code的专用和公用网络的访问权限。 + + **图9** 允许Visual Studio Code应用访问网络 + + ![zh-cn_image_0000001271442273](figures/zh-cn_image_0000001271442273.png) + + +## 烧写失败 + +- **现象描述** + + 点击烧写并选择串口后,出现无法烧写的情况。 + +- **可能原因** + + 安装IDE插件DevEco后未重启。 + +- **解决方法** + + 重启IDE。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md b/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md new file mode 100644 index 0000000000000000000000000000000000000000..b131626e75438b292390fa0315a83ec6d4cc3225 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-faq-compose.md @@ -0,0 +1,182 @@ +# 编译异常 + + +## Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg” + +- **现象描述** + + Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg" + +- **可能原因** + + python3 apt安装兼容性问题。 + +- **解决办法** + + 执行如下命令重新安装python3-apt。 + + + ``` + sudo apt-get remove python3-apt + sudo apt-get install python3-apt + ``` + + +## 编译构建过程中,提示找不到“python” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + -bash: /usr/bin/python: No such file or directory + ``` + +- **可能原因**1 + + 没有装python。 + +- **解决办法** + + 请使用如下命令安装Python,下方以Python3.8为例。 + + + ``` + sudo apt-get install python3.8 + ``` + +- **可能原因2** + + usr/bin目录下没有python软链接 + + ![zh-cn_image_0000001226922322](figures/zh-cn_image_0000001226922322.png) + +- **解决办法** + + 请运行以下命令添加软链接: + + + ``` + # cd /usr/bin/ + # which python3 + # ln -s /usr/local/bin/python3 python + # python --version + ``` + + 例: + + ![zh-cn_image_0000001271562453](figures/zh-cn_image_0000001271562453.png) + + +## 编译构建过程中,提示找不到“python3” + +- **现象描述** + + ![zh-cn_image_0000001226602414](figures/zh-cn_image_0000001226602414.png) + +- **可能原因** + + 没有装python3。 + +- **解决办法** + + 请使用如下命令安装Python3。 + + + ``` + sudo apt-get install python3.8 + ``` + + +## 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details + ``` + +- **可能原因** + + 环境中未安装“gcc”。 + +- **解决办法** + + 1. 通过命令“apt-get install gcc”在线安装。 + 2. 完成后,重新安装python3。 + + +## 安装python3过程中,提示“-bash: make: command not found” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + -bash: make: command not found + ``` + +- **可能原因** + + 环境中未安装“make”。 + +- **解决办法** + + 1. 通过命令“apt-get install make”在线安装。 + 2. 完成后,重新安装python3。 + + +## 安装python3过程中,提示“No module named '_ctypes'” + +- **现象描述** + + 安装python3过程中出现以下错误: + + + ``` + ModuleNotFoundError:No module named ‘_ctypes’ + ``` + +- **可能原因** + + 环境中未安装“libffi”和“libffi-devel”。 + +- **解决办法** + + 1. 通过命令“apt-get install libffi\* -y”,在线安装。 + 2. 完成后,重新安装python3。 + + +## 编译构建过程中,提示“No module named 'Crypto'” + +- **现象描述** + + 编译构建过程中出现以下错误: + + + ``` + ModuleNotFoundError: No module named 'Crypto' + ``` + +- **可能原因** + + 环境中未安装“Crypto”。 + +- **解决办法** + + 方法1:通过命令“pip3 install Crypto”,在线安装。 + + 方法2:离线安装。 + + 通过网页[https://pypi.org/project/pycrypto/#files](https://pypi.org/project/pycrypto/#files),下载源码。 + + ![zh-cn_image_0000001227082334](figures/zh-cn_image_0000001227082334.png) + + 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 + + 完成上述安装后,重新构建。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md b/zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md new file mode 100644 index 0000000000000000000000000000000000000000..9accfa1781e1ae816c3d304f005e942809ffcf2c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-faq-hb.md @@ -0,0 +1,71 @@ +# hb安装异常 + + +## hb安装过程中出现乱码、段错误 + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 + +- **可能原因** + pip版本过低。 + +- **解决办法** + 执行如下命令升级pip。 + + + ``` + python3 -m pip install -U pip + ``` + + +## hb安装过程中提示"cannot import 'sysconfig' from 'distutils'" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" + +- **可能原因** + 缺少distutils模块。 + +- **解决办法** + 执行如下命令安装。 + + + ``` + sudo apt-get install python3.8-distutils + ``` + + +## hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux_distribution'" + +- **可能原因** + python3 pip安装兼容性问题。 + +- **解决办法** + 执行如下命令重新安装pip。 + + + ``` + sudo apt remove python3-pip + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + + +## hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build" + +- **现象描述** + 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" + +- **可能原因** + 可能是网络环境较差导致的安装失败。 + +- **解决办法** + 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 + 2. 若网络正常,请尝试指定临时pypi源的方式安装: + + ``` + python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-faqs.md b/zh-cn/device-dev/quick-start/quickstart-standard-faqs.md index ceb23edfe59b48dfc36d540e01025f6ed289e313..ad373a5074d14b506847d3fa0fe0bb96aa6bc616 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-faqs.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-faqs.md @@ -1,24 +1,9 @@ -# 常见问题 +# 常见问题 -- [编译构建过程中,提示"ImportError: No module named apt\_pkg"](#section1864714601214) -## 编译构建过程中,提示"ImportError: No module named apt\_pkg" -- **现象描述** - - Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt\_pkg"。 - -- **可能原因** - - python3 apt安装兼容性问题。 - -- **解决办法** - - 执行如下命令重新安装python3-apt。 - - ``` - sudo apt-get remove python3-apt - sudo apt-get install python3-apt - ``` +- **[hb安装异常](quickstart-standard-faq-hb.md)** +- **[编译异常](quickstart-standard-faq-compose.md)** +- **[烧录异常](quickstart-standard-faq-burning.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md b/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md new file mode 100644 index 0000000000000000000000000000000000000000..9ca9bac3fd5dabcc59ec76a46edf3f56de7da6f5 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md @@ -0,0 +1,22 @@ +## 标准系统快速入门(IDE方式) +- [标准系统入门概述](quickstart-ide-standard-overview.md) + - 准备标准系统环境 + - [搭建Windows+Ubuntu混合开发环境](quickstart-ide-standard-env-setup-win-ubuntu.md) + - [获取源码](quickstart-ide-standard-sourcecode-acquire.md) + - [创建源码工程](quickstart-ide-standard-create-project.md) + - 运行“Hello World” + - Hi3516开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-hi3516-create.md) + - [编译](quickstart-ide-standard-running-hi3516-build.md) + - [烧录](quickstart-ide-standard-running-hi3516-burning.md) + - [运行](quickstart-ide-standard-running-hi3516-running.md) + - RK3568开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) + - [编译](quickstart-ide-standard-running-rk3568-build.md) + - [烧录](quickstart-ide-standard-running-rk3568-burning.md) + - [运行](quickstart-ide-standard-running-rk3568-running.md) + - 附录 + - 开发板介绍 + - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) + - [RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md) + - [轻量和小型系统快速入门(安装包方式)](quickstart-lite-package-directory.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-ide.md b/zh-cn/device-dev/quick-start/quickstart-standard-ide.md new file mode 100644 index 0000000000000000000000000000000000000000..2ed882b00d00880d47609b4c05b1cd983ecafa4b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-ide.md @@ -0,0 +1,13 @@ +# 标准系统快速入门-IDE + + + +- **[标准系统入门概述](quickstart-ide-standard-overview.md)** + +- **[准备标准系统环境](quickstart-ide-standard-env-setup.md)** + +- **[创建源码工程](quickstart-ide-standard-create-project.md)** + +- **[运行“Hello World”](quickstart-ide-standard-running.md)** + +- **[附录](quickstart-ide-standard-appendix.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md index 6fd5b2c9ba337e34e6e877fa03b8ad09fa443abd..c3e39d1ca784e4c584d62008c10b7efb9622f1a3 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md @@ -1,23 +1,40 @@ -# 标准系统入门简介 +# 标准系统入门概述 -- [快速入门流程](#section7825218111517) -开发者可通过本文快速掌握OpenHarmony标准系统的环境搭建、编译、烧录、运行等操作。标准系统的开发有以下两种方法: +## 简介 -- 使用Windows环境进行开发和烧录,使用Linux环境进行编译。 -- 统一使用Linux环境进行开发、编译和烧录。 +OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文,开发者可以快速熟悉OpenHarmony标准系统的环境搭建、编译、烧录、调测以及运行“Hello World”等。 -因目前Windows系统不支持编译,暂时无法全部使用Windows环境进行开发,开发者可根据使用习惯选择合适的开发方法。 +考虑到开发者的开发习惯,OpenHarmony为开发者提供了以下两种入门指导: -本文将介绍第二种方法,**所有操作均在Linux环境下进行**。 +- IDE方式:完全采用IDE(DevEco Device Tool)进行一站式开发,编译依赖工具的安装及编译、烧录、运行都通过IDE进行操作。 -## 快速入门流程 +- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。 + OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。 -标准系统快速入门流程如下图所示,其中编译源码环节可根据实际情况选择docker方式或安装包方式其中一种即可。 +本文采用安装包方式进行介绍,习惯使用DevEco Device Tool的开发者可参考[标准系统快速入门(IDE方式)](../quick-start/quickstart-standard-ide.md)。 ->![](../public_sys-resources/icon-note.gif) **说明:** ->Docker环境已经封装了相关编译工具,开发者在使用该Docker环境时可以省去Ubuntu编译环境及开发板环境的的搭建操作。 -**图 1** 标准系统快速入门流程 -![](figures/标准系统快速入门流程.png "标准系统快速入门流程") +## 开发环境 +开发者通常习惯采用Windows+Ubuntu环境进行OpenHarmony开发: + +- Windows:用于源码开发、烧录等。 + +- Ubuntu:用于源码编译。 + +本文将介绍如何基于Windows+Ubuntu环境进行OpenHarmony的开发。 + + +## 开发板 + +本文选取了两款典型开发板:Hi3516DV300、RK3516,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction.md),开发者可根据需要自行购买开发板。 + + +## 开发流程 + +标准系统快速入门流程如下图所示。 + + **图1** 标准系统快速入门开发流程 + + ![zh-cn_image_0000001227082314](figures/zh-cn_image_0000001227082314.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md b/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md new file mode 100644 index 0000000000000000000000000000000000000000..0472dae64b11083fb2772b78a13ca6964282ba05 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md @@ -0,0 +1,24 @@ +## 标准系统快速入门(安装包方式) +- [标准系统入门概述](quickstart-standard-overview.md) +- [搭建标准系统环境](quickstart-standard-env-setup.md) +- 运行“Hello World” + - Hi3516开发板 + - [编写“Hello World”程序](quickstart-standard-running-hi3516-create.md) + - [编译](quickstart-standard-running-hi3516-build.md) + - [烧录](quickstart-standard-running-hi3516-burning.md) + - [运行](quickstart-standard-running-hi3516-running.md) + - RK3568开发板 + - [编写“Hello World”程序](quickstart-standard-running-rk3568-create.md) + - [编译](quickstart-standard-running-rk3568-build.md) + - [烧录](quickstart-standard-running-rk3568-burning.md) + - [运行](quickstart-standard-running-rk3568-running.md) +- 常见问题 + - [hb安装异常](quickstart-standard-faq-hb.md) + - [编译异常](quickstart-standard-faq-compose.md) + - [烧录异常](quickstart-standard-faq-burning.md) +- 附录 + - 开发板介绍 + - [Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md) + - [RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md) + - [标准系统快速入门(IDE方式)](quickstart-standard-ide-directory.md) + - [参考信息](quickstart-standard-reference.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-reference.md b/zh-cn/device-dev/quick-start/quickstart-standard-reference.md new file mode 100644 index 0000000000000000000000000000000000000000..d8a7f6dfaed2d4b7755224d10d1d971740a40d5b --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-reference.md @@ -0,0 +1,69 @@ +# 参考信息 + + +## 使用build.sh脚本编译源码 + + +1. 进入源码根目录,执行如下命令进行版本编译。 + + ``` + ./build.sh --product-name name --ccache + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > _name_为产品名称,例如Hi3516DV300、rk3568等。 + +2. 检查编译结果。编译完成后,log中显示如下: + + ``` + post_process + =====build name successful. + ``` + + 编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在out/{device_name}/packages/phone/images/ 目录下。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-standard-large.md)。 + + +## 配置代理 + + +### 配置Python代理 + +1. 新建代理配置文件。 + + ``` + mkdir ~/.pipvim ~/.pip/pip.conf + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + [global] + index-url = http://代理网址 + trusted-host = 可信任的镜像地址 + timeout = 120 + ``` + + +### 配置NPM代理 + +1. 新建代理配置文件。 + + ``` + vim ~/.npmrc + ``` + +2. 在文件中写入如下代理信息并保存退出。 + + ``` + registry=http://代理网址 + strict-ssl=false + ``` + +3. 将以下内容添加到.bashrc中并保存退出。 + + ``` + export NPM_REGISTRY=http://代理网址 + source .bashrc + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md index d4655fadc0f86988fcb18b087d554a683945d4af..3866dcba6003f1d12c0d4324298838c557633ba7 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md @@ -1,104 +1,48 @@ -# 源码编译 +# 编译 -- [使用Docker方式获取编译工具链](#section181431248132513) - - [执行prebuilts](#section111934551605) - - [安装Docker](#section1466184743915) - - [获取Docker环境](#section615912103552) -- [使用安装包方式获取编译工具链](#section65647482593) - - [安装依赖工具](#section83441888010) - - [执行prebuilts](#section6389714142011) +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](../quick-start/quickstart-standard-reference.md)。 -- [编译](#section92391739152318) -安装编译工具链后,即可对源码进行编译。在Linux环境下获取编译工具链有以下两种方式,二者选其一即可: +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: -1. Docker方式 - OpenHarmony标准系统为开发者提供的Docker环境已经将对应的编译工具链进行了封装,开发者可省略对应工具的安装。 +1. 设置编译路径。 + + ``` + hb set + ``` -2. 安装包方式 +2. 选择当前路径。 + + ``` + . + ``` - 使用安装包方式获取编译工具链时,开发者需自行安装相应的依赖工具。 +3. 在built-in下选择Hi3516DV300并回车。 +4. 执行编译。 -## 使用Docker方式获取编译工具链 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 -### 执行prebuilts + + ``` + hb build -f + ``` -在源码根目录下执行脚本,安装编译器及二进制工具。 + + **图1** Hi3516编译设置图例 -``` -bash build/prebuilts_download.sh -``` + ![zh-cn_image_0000001271562433](figures/zh-cn_image_0000001271562433.png) -### 安装Docker - -请参考[官方指导](https://docs.docker.com/engine/install/)。 - -### 获取Docker环境 - -1. 获取Docker镜像。 - - ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - -2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 - - ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - - -## 使用安装包方式获取编译工具链 - -### 安装依赖工具 - -请在终端中输入如下命令安装编译相关的依赖工具: - -``` -sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby libncurses5 libncurses5-dev libncursesw5 openjdk-8-jre default-jre default-jdk -``` - ->![](../public_sys-resources/icon-note.gif) **说明:** ->以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中: ->- Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。 ->- java要求java8及以上版本,此处以java8为例。 - -### 执行prebuilts - -在源码根目录下执行脚本,安装编译器及二进制工具。 - -``` -bash build/prebuilts_download.sh -``` - -## 编译 - -1. 进入源码根目录,执行如下命令进行版本编译。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >使用Docker方式获取编译工具链的,请直接通过[获取Docker环境](#section615912103552)最后一步进入的Docker构建环境执行如下命令。 - - ``` - ./build.sh --product-name Hi3516DV300 --ccache - ``` - -2. 检查编译结果。编译完成后,log中显示如下: - - ``` - build system image successful. - =====build Hi3516DV300 successful. - ``` - - 编译所生成的文件都归档在out/\{device\_name\}/目录下,结果镜像输出在out/\{device\_name\}/packages/phone/images/ 目录下。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-standard-large.md)。 - -3. 编译源码完成,请进行镜像烧录,具体请参见[镜像烧录](quickstart-standard-running-hi3516-burn.md)。 - ->![](../public_sys-resources/icon-note.gif) **说明:** ->若使用Docker环境进行编译,执行exit命令即可退出Docker。 +5. 编译结束后,出现“build success”字样,则证明构建成功。 + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 编译结果文件及编译日志文件获取路径:out/hi3516dv300。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burn.md deleted file mode 100644 index e7b30db8d635a94a4b23e27a8364d1c5fc3171d4..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burn.md +++ /dev/null @@ -1,101 +0,0 @@ -# 镜像烧录 - -- [前提条件](#section1956213516576) -- [使用网口烧录](#section14587120161217) - -标准系统烧录,在DevEco Device Tool V2.2 Beta1及以上版本支持,下方烧录操作均在DevEco Device Tool中进行。 - -DevEco Device Tool以插件方式运行,基于Visual Studio Code进行扩展,用户可点击Visual Studio Code左侧栏的![](figures/2021-01-27_170334-10.png)图标打开DevEco Device Tool。 - -Hi3516DV300支持烧录标准系统,其烧录方式包括USB烧录、网口烧录和串口烧录三种方式,其中: - -- **Windows系统:支持USB烧录、网口烧录和串口烧录**。 -- **Linux系统:支持串口烧录和网口烧录。** - -同一种烧录方式(如网口烧录),在Windows和Linux环境下的烧录操作完全一致,区别仅在于DevEco Device Tool环境搭建不同。 - -下方以Linux系统下,USB烧录方式为例进行OpenHarmony标准系统烧录,其他两种烧录方式请参照[Hi3516DV300烧录指导](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_upload-0000001052148681)。 - -## 前提条件 - -1. 在DevEco Device Tool工具中点击**Import Project**导入新建应用程序章节修改后的源码文件。 - - ![](figures/import-project.png) - -2. 选择源码导入时,系统会提示该工程不是DevEco Device Tool工程,点击**Import**。 - - ![](figures/import-project-confirm.png) - -3. MCU选择**HiSilicon\_Arm\_Linux**下的Hi3516DV300,Board选择hi3516dv300,Framework选择“Ohos-sources”,然后点击**Import**完成导入。 - - ![](figures/hisilicon-arm-linux.png) - - -## 使用USB口烧录 - -1. 请连接好电脑和待烧录开发板,需要同时连接串口和USB口,具体可参考[Hi3516DV300开发板介绍](https://device.harmonyos.com/cn/docs/documentation/guide/quickstart-lite-introduction-hi3516-0000001152041033)[Hi3516DV300开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)。 -2. 查看并记录对应的串口号。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 - - Windows系统,打开设备管理器查看并记录对应的串口号,或在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - - ![](figures/record-the-serial-port-number.png) - - Linux系统,在DevEco Device Tool中,点击QUICK ACCESS \> DevEco Home \> Device,查看并记录对应的串口号。 - - ![](figures/Snap22.png) - -3. 在QUICK ACCESS \> DevEco Home \> Projects中,点击**Settings**打开工程配置界面。 - - ![](figures/zh-cn_image_0000001177608370.png) - -4. 在“hi3516dv300”页签,设置烧录选项,包括upload\_partitions、upload\_port和upload\_protocol。 - - - upload\_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、boot、updater、misc、system、vendor和userdata。 - - upload\_port:选择已查询的串口号。 - - upload\_protocol:选择烧录协议,固定选择“hiburn-usb”。 - - ![](figures/zh-cn_image_0000001177478136.png) - -5. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、boot、updater、misc、system、vendor和userdata。 - 1. 在“hi3516dv300\_fastboot”页签,在New Option选项中选择需要修改的项,例如partition\_bin(烧录文件路径)、partition\_addr(烧录文件起始地址)、partition\_length(烧录文件分区长度)等。 - - ![](figures/zh-cn_image_0000001222997983.png) - - 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 - - ![](figures/zh-cn_image_0000001222794413.png) - - 3. 按照相同的方法修改boot、updater和misc的烧录文件信息。 - -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 -7. 点击**Open**打开工程文件,然后在“PROJECT TASKS”中,点击fastboot下的**Erase**按钮,擦除U-Boot。 - - ![](figures/zh-cn_image_0000001163045527.png) - -8. 执行**Erase**擦除操作后,显示如下提示信息时,请重启开发板(插拔USB连线)。 - - ![](figures/zh-cn_image_0000001114129426.png) - -9. 重新上电后,显示如下信息时,表示擦除U-Boot成功。 - - ![](figures/zh-cn_image_0000001113969536.png) - -10. 擦除完成后,点击hi3516dv300下的**Upload**按钮,启动烧录。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >如果您是第一次在工作台烧录Hi3516DV300/Hi3518EV300开发板,可能烧录失败,提示“not find the Devices”,请根据[Hi3516DV300/Hi3518EV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)进行处理后再重新烧录。 - - ![](figures/1-11.png) - -11. 启动烧录后,界面提示如下信息时,表示烧录成功。 - - ![](figures/zh-cn_image_0000001160649343.png) - -12. 烧录完成后,请根据标准系统镜像运行进行下一步操作,完成系统启动。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..80f0d61561042ffd8f19f91de9176899ea6f2623 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-burning.md @@ -0,0 +1,104 @@ +# 烧录 + + +在Windows下采用USB烧录方式进行Hi3516DV300的烧录,具体步骤如下: + + +### 导入源码 + +在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](../quick-start/quickstart-standard-env-setup.md)的情况下,您还需要通过以下步骤导入源码后,方可进行烧录。 + +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 + + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) + +2. 选择要导入的源码目录(需要访问Ubuntu下的源码目录),点击**Import**打开。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 + + ![zh-cn_image_0000001227711882](figures/zh-cn_image_0000001227711882.png) + +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) + +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 + + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) + +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。此处选择Hi3516DV300。 + + ![zh-cn_image_0000001271912277](figures/zh-cn_image_0000001271912277.png) + +6. 点击**Open**打开工程或源码。 + + +### 烧录 + +完成源码导入后,通过以下步骤进行烧录: + +1. 请连接好电脑和待烧录开发板,需要同时连接串口和USB口,具体可参考[Hi3516DV300开发板介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)。 + +2. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +3. 在DevEco Device Tool中,点击QUICK ACCESS > DevEco Home > Device,查看并记录对应的串口号。 + + ![zh-cn_image_0000001216516128](figures/zh-cn_image_0000001216516128.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001198566364](figures/zh-cn_image_0000001198566364.png) + +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 + - upload_port:选择已查询到的串口号。 + - upload_protocol:选择烧录协议,固定选择“hiburn-usb”。 + + ![zh-cn_image_0000001223190441](figures/zh-cn_image_0000001223190441.png) + +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:fastboot、kernel、rootfs和userfs。 + + 1. 在“hi3516dv300_fastboot”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zh-cn_image_0000001198889702](figures/zh-cn_image_0000001198889702.png) + + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![zh-cn_image_0000001243290907](figures/zh-cn_image_0000001243290907.png) + + 3. 按照相同的方法修改kernel、rootfs和userfs的烧录文件信息。 + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击hi3516dv300下的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您是第一次在工作台烧录Hi3516DV300/Hi3518EV300开发板,可能烧录失败,提示“not find the Devices”,然后根据[Hi3516DV300/Hi3518EV300开发板USB驱动安装](https://device.harmonyos.com/cn/docs/documentation/guide/usb_driver-0000001058690393)进行处理后再重新烧录。 + + ![zh-cn_image_0000001267231481](figures/zh-cn_image_0000001267231481.png) + +9. 在终端窗口显示如下提示信息时,按住复位键,插拔USB线,最后松开复位键启动烧录。 + + ![zh-cn_image_0000001114129426](figures/zh-cn_image_0000001114129426.png) + + 启动烧录后,界面提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001160649343](figures/zh-cn_image_0000001160649343.png) + +10. 烧录成功后,请根据镜像运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md index 1a6786fdd740ca930ac1d38f525acbb594909cfd..b0cef24b4d2dba209ff14b954380a9e5061f91fc 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md @@ -1,130 +1,162 @@ -# 创建应用程序 +# 编写“Hello World”程序 -下方将通过修改源码的方式展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 -这里演示在原有applications子系统下,添加hello部件以及该部件下的helloworld模块。 +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 示例完整目录如下。 + ``` -applications/standard/hello -├── helloworld -│ ├── BUILD.gn -│ ├── include +applications/sample/hello +│ │── BUILD.gn +│ │── include │ │ └── helloworld.h -│ └── src -│ └── helloworld.c -├── ohos.build -│ +│ │── src +│ │ └── helloworld.c +│ └── bundle.json +build +└── subsystem_config.json productdefine/common └── products - └── Hi3516DV300.json + └── Hi3568DV300.json ``` -下方为新建应用程序步骤,请在[获取源码](quickstart-standard-sourcecode-acquire.md)章节下载的源码目录中进行下述操作: - -1. 新建目录及源码。 - - 新建applications/standard/hello/helloworld/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - - ``` - #include - #include "helloworld.h" - - int main(int argc, char **argv) - { - HelloPrint(); - return 0; - } - - void HelloPrint() - { - printf("\n************************************************\n"); - printf("\n\t\tHello World!\n"); - printf("\n************************************************\n"); - } - ``` - - 再添加头文件applications/standard/hello/helloworld/include/helloworld.h,代码如下所示。 - - ``` - #ifndef HELLOWORLD_H - #define HELLOWORLD_H - #ifdef __cplusplus - #if __cplusplus - extern "C" { - #endif - #endif - - void HelloPrint(); - - #ifdef __cplusplus - #if __cplusplus - } - #endif - #endif - #endif // HELLOWORLD_H - ``` - -2. 新建编译组织文件。 - 1. 新建applications/standard/hello/helloworld/BUILD.gn文件,内容如下所示: - - ``` - import("//build/ohos.gni") # 导入编译模板 - ohos_executable("helloworld") { # 可执行模块 - sources = [ # 模块源码 - "src/helloworld.c" - ] - include_dirs = [ # 模块依赖头文件目录 - "include" - ] - cflags = [] - cflags_c = [] - cflags_cc = [] - ldflags = [] - configs = [] - deps =[] # 部件内部依赖 - - part_name = "hello" # 所属部件名称,必选 - install_enable = true # 是否默认安装(缺省默认不安装),可选 - } - ``` - - 2. 新建applications/standard/hello/ohos.build文件,添加hello部件描述,内容如下所示。 - - ``` - { - "subsystem": "applications", # 子系统名 - "parts": { # 包含部件 - "hello": { # 新建部件名 - "version": "1.0.0", # 版本 - "variants": [ # 变种版本 - "wearable", - "phone" - ], - "module_list": [ # 部件包含模块的gn目标 - "//applications/standard/hello/helloworld:helloworld" - ], - "inner_kits": [ # 提供给其他部件的接口 - ], - "test_list": [ # 测试用例 - ] - } - } - } - ``` - - ohos.build文件包含两个部分,第一部分subsystem说明该子系统的名称,parts定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module\_list,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test\_list中说明,inner\_kits与test\_list没有也可以不添加。 - -3. 修改产品配置文件。 - - 在productdefine\\common\\products\\Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 - - ``` - "usb:usb_manager_native":{}, - "applications:prebuilt_hap":{}, - "applications:hello":{}, - "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, - ``` - +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + + +1. 创建目录,编写业务代码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + + void HelloPrint(); + + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + + 在productdefine/common/products/Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 + + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-run.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-run.md deleted file mode 100644 index b801df89a5f7eeeda319ea722e6ffeba040b38ff..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-run.md +++ /dev/null @@ -1,60 +0,0 @@ -# 镜像运行 - -- [启动系统](#section85351839162211) -- [运行“Hello World”](#section137849131182) -- [下一步](#section5600113114323) - -## 启动系统 - -烧录完成后通过以下步骤运行系统: - ->![](../public_sys-resources/icon-note.gif) **说明:** ->初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 - -1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 - - ![](figures/open-the-serial-port-tool.png) - -2. 重启开发板,在倒计时结束前,按任意键进入系统。 - - ![](figures/press-any-key-to-enter-the-system.gif) - -3. 通过以下两条命令设置启动参数。 - - ``` - setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; - ``` - - ``` - setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' - ``` - - ![](figures/setenv-bootargs.png) - -4. 保存参数设置。 - - ``` - save - ``` - - ![](figures/Save-the-parameter-settings.png) - -5. 重启开发板,完成系统启动。 - - ``` - reset - ``` - - ![](figures/start-the-system.png) - - -## 运行“Hello World” - -设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,即出现“Hello World!”字样。 - -![](figures/zh-cn_image_0000001193533352.png) - -## 下一步 - -恭喜!您已经完成了OpenHarmony标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md new file mode 100644 index 0000000000000000000000000000000000000000..a301e4b48d19b93e814cc020bbb22cde359e8768 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-running.md @@ -0,0 +1,58 @@ +# 运行 + + +## 启动系统 + +烧录完成后在Windows下通过以下步骤启动系统: + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 + +1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 + + ![zh-cn_image_0000001226762374](figures/zh-cn_image_0000001226762374.png) + +2. 重启开发板,在倒计时结束前,按任意键进入系统。 + + ![zh-cn_image_0000001271442265](figures/zh-cn_image_0000001271442265.gif) + +3. 通过以下两条命令设置启动参数。 + + ``` + setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; + ``` + + + ``` + setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' + ``` + + ![zh-cn_image_0000001271322437](figures/zh-cn_image_0000001271322437.png) + +4. 保存参数设置。 + + ``` + save + ``` + + ![zh-cn_image_0000001271562437](figures/zh-cn_image_0000001271562437.png) + +5. 重启开发板,完成系统启动。 + + ``` + reset + ``` + + ![zh-cn_image_0000001226762378](figures/zh-cn_image_0000001226762378.png) + + +## 运行“Hello World” + +设备启动后打开串口工具,在任意目录下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + +![zh-cn_image_0000001226602398](figures/zh-cn_image_0000001226602398.png) + + +## 下一步 + +恭喜!您已经完成了OpenHarmony标准系统的快速入门,接下来可[开发一个小示例](../guide/device-clock-guide.md),进一步熟悉OpenHarmony的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516.md index d8e2bdb1ee493e70111bec7fe5fd95dcbc952c42..303c5d6366355b18ea0425b680197450e86338b1 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516.md @@ -1,11 +1,11 @@ -# Hi3516开发板 +# Hi3516开发板 -- **[创建应用程序](quickstart-standard-running-hi3516-create.md)** -- **[源码编译](quickstart-standard-running-hi3516-build.md)** -- **[镜像烧录](quickstart-standard-running-hi3516-burn.md)** +- **[编写“Hello World”程序](quickstart-standard-running-hi3516-create.md)** -- **[镜像运行](quickstart-standard-running-hi3516-run.md)** +- **[编译](quickstart-standard-running-hi3516-build.md)** +- **[烧录](quickstart-standard-running-hi3516-burning.md)** +- **[运行](quickstart-standard-running-hi3516-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md index 2b414676249d306a6f1717ca220822836f7f0d13..012bddd93e100155da1cd8e68ec9f3e9de688d53 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md @@ -1,102 +1,48 @@ -# 源码编译 +# 编译 -- [使用Docker方式获取编译工具链](#section181431248132513) - - [执行prebuilts](#section111934551605) - - [安装Docker](#section1466184743915) - - [获取Docker环境](#section615912103552) -- [使用安装包方式获取编译工具链](#section65647482593) - - [安装依赖工具](#section83441888010) - - [执行prebuilts](#section6389714142011) +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](../quick-start/quickstart-standard-reference.md)。 -- [编译](#section92391739152318) -安装编译工具链后,即可对源码进行编译。在Linux环境下获取编译工具链有以下两种方式,二者选其一即可: +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: -1. Docker方式 - OpenHarmony标准系统为开发者提供的Docker环境已经将对应的编译工具链进行了封装,开发者可省略对应工具的安装。 +1. 设置编译路径。 + + ``` + hb set + ``` -2. 安装包方式 +2. 选择当前路径。 + + ``` + . + ``` - 使用安装包方式获取编译工具链时,开发者需自行安装相应的依赖工具。 +3. 在built-in下选择rk3568并回车。 +4. 执行编译。 -## 使用Docker方式获取编译工具链 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 -### 执行prebuilts + + ``` + hb build -f + ``` -在源码根目录下执行脚本,安装编译器及二进制工具。 + + **图1** RK3568编译设置图例 -``` -bash build/prebuilts_download.sh -``` + ![zh-cn_image_0000001226922302](figures/zh-cn_image_0000001226922302.png) -### 安装Docker - -请参考[官方指导](https://docs.docker.com/engine/install/)。 - -### 获取Docker环境 - -1. 获取Docker镜像。 - - ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 - ``` - -2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 - - ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 - ``` - - -## 使用安装包方式获取编译工具链 - -### 安装依赖工具 - -请在终端中输入如下命令安装编译相关的依赖工具: - -``` -sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby -``` - ->![](../public_sys-resources/icon-note.gif) **说明:** ->以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中Python要求安装Python 3.7及以上版本,此处以Python 3.8为例。 - -### 执行prebuilts - -在源码根目录下执行脚本,安装编译器及二进制工具。 - -``` -bash build/prebuilts_download.sh -``` - -## 编译 - -1. 进入源码根目录,执行如下命令进行版本编译。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >使用Docker方式获取编译工具链的,请直接通过[获取Docker环境](#section615912103552)最后一步进入的Docker构建环境执行如下命令。 - - ``` - ./build.sh --product-name rk3568 --ccache - ``` - -2. 检查编译结果。编译完成后,log中显示如下: - - ``` - post_process - =====build rk3568 successful. - ``` - - 编译所生成的文件都归档在out/\{device\_name\}/目录下,结果镜像输出在out/\{device\_name\}/packages/phone/images/ 目录下。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-standard-large.md)。 - -3. 编译源码完成,请进行镜像烧录,具体请参见[镜像烧录](quickstart-standard-running-hi3516-burn.md)。 - ->![](../public_sys-resources/icon-note.gif) **说明:** ->若使用Docker环境进行编译,执行exit命令即可退出Docker。 +5. 编译结束后,出现“rk3568 build success”字样,则证明构建成功。 + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 编译结果文件及编译日志文件获取路径:out/rk3568。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burn.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burn.md deleted file mode 100644 index 50dc908d39bcae333b23cfef1181a00925aa32c2..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burn.md +++ /dev/null @@ -1,4 +0,0 @@ -# 镜像烧录 - -请参考:[HiHope\_DAYU200烧写工具及指南](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/HiHope-DAYU200%E9%95%9C%E5%83%8F%E7%83%A7%E5%BD%95%E6%8C%87%E5%8D%97.pdf)。 - diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..fcf0dea2d2dbb788f3f45999ea3b9acdc961dfe5 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md @@ -0,0 +1,91 @@ +# 烧录 + + +在Windows环境下通过以下步骤进行RK3568的烧录: + + +### 导入源码 + +在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](../quick-start/quickstart-standard-env-setup.md)的情况下,您还需要通过以下步骤导入源码后,方可进行烧录。 + +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 + + ![zh-cn_image_0000001171426014](figures/zh-cn_image_0000001171426014.png) + +2. 选择要导入的源码目录(需要访问Ubuntu下的源码目录),点击**Import**打开。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 工程存储路径不能包含中文字符、空格。如果工程存储路径包含中文字符或空格,可能导致编译失败。 + + ![zh-cn_image_0000001272032361](figures/zh-cn_image_0000001272032361.png) + +3. 如果您打开的目录不是DevEco Device Tool工程,则会出现如下提示框,点击**Import**。 + + ![zh-cn_image_0000001135394334](figures/zh-cn_image_0000001135394334.png) + +4. 在Select Project type界面,选择**Import from OpenHarmony Source**。 + + ![zh-cn_image_0000001215743910](figures/zh-cn_image_0000001215743910.png) + +5. 在Import Project界面,选择**Product**后,会自动填充对应的MCU、Board、company和kernel信息,然后**ohosVersion**选择对应的OpenHarmony源码版本。此处选择rk3568。 + + ![zh-cn_image_0000001227712350](figures/zh-cn_image_0000001227712350.png) + +6. 点击**Open**打开工程或源码。 + + +### 烧录 + +完成源码导入后,通过以下步骤进行烧录: + +1. [下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe,双击DriverInstall.exe打开安装程序,点击“驱动安装”按钮,按提示安装USB驱动。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果已经安装旧版本的烧写工具,请先点击"驱动卸载"按钮卸载驱动,然后再点击"驱动安装"按钮安装驱动。 + +2. 请连接好电脑和待烧录开发板,连接USB接口。 + +3. 在DevEco Device Tool中,选择REMOTE DEVELOPMENT > Local PC,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261315939](figures/zh-cn_image_0000001261315939.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001261515989](figures/zh-cn_image_0000001261515989.png),则点击绿色连接进行按钮。 + + ![zh-cn_image_0000001261395999](figures/zh-cn_image_0000001261395999.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 该操作仅在远程模式(Windows+Ubuntu混合开发环境)中需要设置,如果采用本地模式(Windows开发环境或Ubuntu开发环境),则请跳过该步骤。 + +4. 打开DevEco Device Tool,在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zh-cn_image_0000001239661509](figures/zh-cn_image_0000001239661509.png) + +5. 在“hh_scdy200”页签,设置烧录选项,包括upload_partitions和upload_protocol。 + + - upload_partitions:选择待烧录的文件。 + - upload_protocol:选择烧录协议,固定选择“upgrade”。 + + ![zh-cn_image_0000001194504874](figures/zh-cn_image_0000001194504874.png) + +6. 分别检查待烧录文件的烧录信息,DevEco Device Tool已预置默认的烧录文件信息,可根据实际情况进行调整。待烧录文件包括:loader、parameter、uboot、boot_linux、system、vendor和userdata。 + + 1. 在“hh_scdy200_loader”页签,在New Option选项中选择需要修改的项,例如partition_bin(烧录文件路径)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zh-cn_image_0000001224173270](figures/zh-cn_image_0000001224173270.png) + + 2. 然后在Partition Options中,分别修改上述步骤中选择的修改项。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + ![zh-cn_image_0000001268653461](figures/zh-cn_image_0000001268653461.png) + + 3. 按照相同的方法修改parameter、uboot、boot_linux、system、vendor和userdata的烧录文件信息。 + +7. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 + +8. 点击工程的Open按钮,打开工程文件,点击![zh-cn_image_0000001239221905](figures/zh-cn_image_0000001239221905.png)图标,打开DevEco Device Tool界面,在“PROJECT TASKS”中,点击hh_scdy200下的**Upload**按钮,启动烧录。 + + ![zh-cn_image_0000001194821710](figures/zh-cn_image_0000001194821710.png) + +9. 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 + + ![zh-cn_image_0000001194984912](figures/zh-cn_image_0000001194984912.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md index 13b2b54d7bb549d10768b1481c8448bb4ac93a75..bc6621662aac5fb40b2972a8f603decbc9b50682 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md @@ -1,139 +1,160 @@ -# 创建应用程序 +# 编写“Hello World”程序 -下方将通过修改源码的方式展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 -这里演示新建examples子系统,添加hello部件以及该部件下的helloworld模块。 +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 -示例完整目录如下。 +## 示例目录 + + 示例完整目录如下。 + ``` -applications/standard/hello -├── helloworld -│ ├── BUILD.gn -│ ├── include +applications/sample/hello +│ │── BUILD.gn +│ │── include │ │ └── helloworld.h -│ └── src -│ └── helloworld.c -├── ohos.build +│ │── src +│ │ └── helloworld.c +│ └── bundle.json build -├── subsystem_config.json +└── subsystem_config.json productdefine/common └── products └── rk3568.json ``` -下方为新建应用程序步骤,请在[获取源码](quickstart-standard-sourcecode-acquire.md)章节下载的源码目录中进行下述操作: - -1. 新建目录及源码。 - - 新建applications/standard/hello/helloworld/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 - - ``` - #include - #include "helloworld.h" - - int main(int argc, char **argv) - { - HelloPrint(); - return 0; - } - - void HelloPrint() - { - printf("\n************************************************\n"); - printf("\n\t\tHello World!\n"); - printf("\n************************************************\n"); - } - ``` - - 再添加头文件applications/standard/hello/helloworld/include/helloworld.h,代码如下所示。 - - ``` - #ifndef HELLOWORLD_H - #define HELLOWORLD_H - #ifdef __cplusplus - #if __cplusplus - extern "C" { - #endif - #endif - - void HelloPrint(); - - #ifdef __cplusplus - #if __cplusplus - } - #endif - #endif - #endif // HELLOWORLD_H - ``` - -2. 新建编译组织文件。 - 1. 新建applications/standard/hello/helloworld/BUILD.gn文件,内容如下所示: - - ``` - import("//build/ohos.gni") # 导入编译模板 - ohos_executable("helloworld") { # 可执行模块 - sources = [ # 模块源码 - "src/helloworld.c" - ] - include_dirs = [ # 模块依赖头文件目录 - "include" - ] - cflags = [] - cflags_c = [] - cflags_cc = [] - ldflags = [] - configs = [] - deps =[] # 部件内部依赖 - - part_name = "hello" # 所属部件名称,必选 - install_enable = true # 是否默认安装(缺省默认不安装),可选 - } - ``` - - 2. 新建applications/standard/hello/ohos.build文件,添加hello部件描述,内容如下所示。 - - ``` - { - "subsystem": "examples", - "parts": { - "hello": { - "version": "1.0.0", - "variants": [ - "wearable", - "phone" - ], - "module_list": [ - "//applications/standard/hello:helloworld" - ], - "inner_kits": [], - "test_list": [] - } - } - } - ``` - - ohos.build文件包含两个部分,第一部分subsystem说明该子系统的名称,parts定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module\_list,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test\_list中说明,inner\_kits与test\_list没有也可以不添加。 - -3. 修改子系统配置文件。 - - 在build/subsystem_config.json中添加examples子系统配置。 - ``` - "examples": { - "path": "applications/standard/hello", - "name": "examples" - }, - ``` - -4. 修改产品配置文件。 - - 在productdefine/common/products/rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 - - ``` - "usb:usb_manager_native":{}, - "applications:prebuilt_hap":{}, - "examples:hello":{}, - "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, - ``` - +## 开发步骤 + +请在源码目录中通过以下步骤创建“Hello World”应用程序: + +1. 创建目录,编写业务代码。 + + 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。 + + + ``` + #include + #include "helloworld.h" + + int main(int argc, char **argv) + { + HelloPrint(); + return 0; + } + + void HelloPrint() + { + printf("\n\n"); + printf("\n\t\tHello World!\n"); + printf("\n\n"); + } + ``` + + 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。 + + + ``` + #ifndef HELLOWORLD_H + #define HELLOWORLD_H + #ifdef __cplusplus + #if __cplusplus + extern "C" { + #endif + #endif + + void HelloPrint(); + + #ifdef __cplusplus + #if __cplusplus + } + #endif + #endif + #endif // HELLOWORLD_H + ``` + +2. 新建编译组织文件。 + + 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示: + + ``` + import("//build/ohos.gni") # 导入编译模板 + ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 + } + ``` + + 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。 + + ``` + { + "name": "@ohos/hello", + "description": "Hello world example.", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "applications/sample/hello" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hello", + "subsystem": "sample", + "syscap": [], + "features": [], + "adapted_system_type": [ "mini", "small", "standard" ], + "rom": "10KB", + "ram": "10KB", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//applications/sample/hello:helloworld" + ], + "inner_kits": [], + "test": [] + } + } + } + ``` + + bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。 + +3. 修改子系统配置文件。 + + 在build/subsystem_config.json中添加新建的子系统的配置。 + + + ``` + "sample": { + "path": "applications/sample/hello", + "name": "sample" + }, + ``` + +4. 修改产品配置文件。 + + 在productdefine/common/products/rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 + + ``` + "usb:usb_manager_native":{}, + "applications:prebuilt_hap":{}, + "sample:hello":{}, + "wpa_supplicant-2.9:wpa_supplicant-2.9":{}, + ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-run.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-run.md deleted file mode 100644 index fabebb6161db161a54afd127ec832dd47230019c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-run.md +++ /dev/null @@ -1,23 +0,0 @@ -# 镜像运行 - -- [启动系统](#section646361191511) -- [运行“Hello World”](#section11845976150) - -## 启动系统 - -镜像烧录完成并连接电源线之后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 - -**图 1** 系统启动效果图 -![](figures/系统启动效果图.jpg "系统启动效果图") - -## 运行“Hello World” - -- 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 - - ![](figures/rk3568-run-configuration.png) - -- 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,即出现“Hello World!”字样。 - - ![](figures/rk3568-helloworld.png) - - diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md new file mode 100644 index 0000000000000000000000000000000000000000..b0d37ed79bc85026f6e0b966090cb2aca4c0d0d1 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-running.md @@ -0,0 +1,21 @@ +# 运行 + + +## 启动系统 + +镜像烧录完成重启开发板后,系统将会自动启动。开发板附带的屏幕呈现以下界面,表明系统已运行成功。 + + **图1** 系统启动效果图 + + ![zh-cn_image_0000001226602406](figures/zh-cn_image_0000001226602406.jpg) + + +## 运行“Hello World” + +1. 设备启动后打开串口工具(以putty为例),波特率设置为1500000,连接设备。 + + ![zh-cn_image_0000001226922310](figures/zh-cn_image_0000001226922310.png) + +2. 打开串口后,在任意目录(以设备根目录为例)下输入命令helloworld后回车,界面打印“Hello World!”,程序运行成功。 + + ![zh-cn_image_0000001271202465](figures/zh-cn_image_0000001271202465.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568.md index d8f0538282014cf2f84ee26a190f5e10433d2a75..4640773e970682786fdf58b55670bce9757b06d7 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568.md @@ -1,11 +1,11 @@ -# RK3568开发板 +# RK3568开发板 -- **[创建应用程序](quickstart-standard-running-rk3568-create.md)** -- **[源码编译](quickstart-standard-running-rk3568-build.md)** -- **[镜像烧录](quickstart-standard-running-rk3568-burn.md)** +- **[编写“Hello World”程序](quickstart-standard-running-rk3568-create.md)** -- **[镜像运行](quickstart-standard-running-rk3568-run.md)** +- **[编译](quickstart-standard-running-rk3568-build.md)** +- **[烧录](quickstart-standard-running-rk3568-burning.md)** +- **[运行](quickstart-standard-running-rk3568-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running.md index 5f631ce529b527058bf980de50de8d5f4eebd433..0844235c1c6346ad9bf532c8dddd0fec14754d75 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running.md @@ -1,7 +1,7 @@ -# 运行“Hello World” +# 运行“Hello World” -- **[Hi3516开发板](quickstart-standard-running-hi3516.md)** -- **[RK3568开发板](quickstart-standard-running-rk3568.md)** +- **[Hi3516开发板](quickstart-standard-running-hi3516.md)** +- **[RK3568开发板](quickstart-standard-running-rk3568.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md b/zh-cn/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md deleted file mode 100644 index d50e92dca75b2b228a03149c0d0f3fb6c30f8865..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-standard-sourcecode-acquire.md +++ /dev/null @@ -1,51 +0,0 @@ -# 获取源码 - -### 前提条件 - -1. 注册码云gitee账号。 -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 -3. 安装[git客户端](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 - - ``` - git config --global user.name "yourname" - git config --global user.email "your-email-address" - git config --global credential.helper store - ``` - -4. 安装码云repo工具,可以执行如下命令。 - - ``` - curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 - chmod a+x /usr/local/bin/repo - pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests - ``` - - -### 获取方式 - ->![](../public_sys-resources/icon-note.gif) **说明:** ->Master主干为开发分支,开发者可通过Master主干获取最新特性。发布版本代码相对比较稳定,开发者可基于发布版本代码进行商用功能开发。 - -- **OpenHarmony主干代码获取** - - 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 - - ``` - repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - - 方式二:通过repo + https下载。 - - ``` - repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify - repo sync -c - repo forall -c 'git lfs pull' - ``` - -- **OpenHarmony发布版本代码获取** - - OpenHarmony发布版本获取源码方式请参考[Release-Notes](../get-code/../../release-notes/Readme.md)。 - - diff --git a/zh-cn/device-dev/quick-start/quickstart-standard.md b/zh-cn/device-dev/quick-start/quickstart-standard.md index b98e7a307dcc2ea67b0bd01434e5860496ce26a1..a304f1ddab4ac35c2657ac704060a9c9d4435d54 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard.md @@ -1,15 +1,7 @@ -# 标准系统入门 +# 标准系统入门 -- **[标准系统入门简介](quickstart-standard-overview.md)** -- **[标准系统开发环境准备(仅Hi3516需要)](quickstart-standard-env-setup.md)** - -- **[获取源码](quickstart-standard-sourcecode-acquire.md)** - -- **[运行“Hello World”](quickstart-standard-running.md)** - -- **[常见问题](quickstart-standard-faqs.md)** - -- **[附录](quickstart-standard-appendix.md)** +- **[标准系统快速入门-IDE](quickstart-standard-ide-directory.md)** +- **[标准系统快速入门-安装包](quickstart-standard-package-directory.md)** diff --git a/zh-cn/device-dev/quick-start/quickstart.md b/zh-cn/device-dev/quick-start/quickstart.md index 5ab9867ff455695acd09b4325c016a46cae44dc8..972e164668031a7002dcf2c5f38b02d89ef65b6e 100644 --- a/zh-cn/device-dev/quick-start/quickstart.md +++ b/zh-cn/device-dev/quick-start/quickstart.md @@ -1,7 +1,7 @@ -# 快速入门 +# 快速入门 -- **[轻量和小型系统入门](quickstart-lite.md)** -- **[标准系统入门](quickstart-standard.md)** +- **[轻量和小型系统入门](quickstart-lite.md)** +- **[标准系统入门](quickstart-standard.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 2b2082482827996a282ca733eadaccebc5605fbb..99e4a005a5fb3aa6c2f54cba978f9433c5868dbb 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -93,6 +93,9 @@ - [HiSysEvent订阅指导](subsys-dfx-hisysevent-listening.md) - [HiSysEvent查询指导](subsys-dfx-hisysevent-query.md) - [HiSysEvent工具使用指导](subsys-dfx-hisysevent-tool.md) + - [HiDumper开发指导](subsys-dfx-hidumper.md) + - [HiChecker开发指导](subsys-dfx-hichecker.md) + - [Faultlogger开发指导](subsys-dfx-faultlogger.md) - [研发工具链](subsys-toolchain.md) - [bytrace使用指导](subsys-toolchain-bytrace-guide.md) - [hdc\_std 使用指导](subsys-toolchain-hdc-guide.md) diff --git a/zh-cn/device-dev/subsystems/figure/zh-cn_image_0000001261812333.png b/zh-cn/device-dev/subsystems/figure/zh-cn_image_0000001261812333.png new file mode 100644 index 0000000000000000000000000000000000000000..76fd15e43b8ccf8566ed55cc0592d3f3e6580319 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figure/zh-cn_image_0000001261812333.png differ diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md index f93fcf62bb5cb58aa6873e0191ac86627acd5532..3b7bf98c4fef6bbca3378d34a988616459cd1254 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @@ -8,7 +8,7 @@ AI引擎框架包含client、server和common三个主要模块,其中client提 AI引擎框架各模块之间的代码依赖关系如下[图1](#fig171811112818)所示: -**图 1** ****AI引擎代码依赖关系 +**图1** AI引擎代码依赖关系 ![](figure/插件依赖-(2).jpg) diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md b/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md new file mode 100644 index 0000000000000000000000000000000000000000..cd6ef1c3831c09109bc4e6ef4c883b5f99fd0b5d --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md @@ -0,0 +1,268 @@ +# Faultlogger开发指导 + + +## 概述 + + +### 功能简介 + +Faultlogger是OpenHarmony为开发者提供的一个维测日志框架,能够为应用、元能力、系统服务进程崩溃故障提供统一检测、日志采集、日志存储、日志上报功能,为应用崩溃故障提供详细的维测日志用以辅助故障定位。 + +FaultLogger承载OpenHarmony系统上的故障记录功能,按照服务对象不同分别运行在两个部件中: + +- Hiview部件中的服务:服务于应用层和native层的功能模块,功能是分类管理系统中发生的各类故障信息,并为模块提供查询故障的API。 + +- Faultloggerd部件中的服务:服务于崩溃进程,功能是收集C/C++运行时异常的守护进程和获取进程调用栈。 + +基于Faultlogger服务,进程崩溃的处理流程如下图所示: + + **图1** 进程崩溃处理流程图 + +![zh-cn_image_0000001261812333](figure/zh-cn_image_0000001261812333.png) + +1. 进程安装信号处理器后,通过DFX_SignalHandler函数检测并响应进程崩溃异常信号; + +2. SignalHandler检测到异常信号后Fork出子进程,并运行ProcessDump程序开始dump崩溃进程和线程的堆栈信息; + +3. ProcessDump程序在读取异常堆栈信息后将日志写入到Faultloggerd中的临时存储目录,进而生成完整的崩溃日志; + +4. Faultloggerd根据需要将故障通过Hiview提供的AddFaultLog()接口进行上报,hiview将处理生成简化的崩溃日志,并上报Hisysevent事件。 + +基于这样的设计,在资源有限的小型系统上可只部署Faultloggerd,也依然可以获取用于定位崩溃问题的日志。 + + +### 使用场景 + +Faultloggerd意在为开发者在开发测试过程中遇到的崩溃或卡死问题提供一种简单轻量的定位手段。 + +主要包含以下应用场景: + + **表1** Faultloggerd模块应用场景 + +| 场景描述 | 使用工具 | 使用方式 | +| -------- | -------- | -------- | +| 了解函数的调用顺序 | DumpCatcher API | 参见:[使用DumpCatcher获取调用栈](#使用dumpcatcher获取调用栈) | +| 应用卡死/CPU占用高 | ProcessDump | 参见:[使用ProcessDump获取调用栈](#使用processdump获取调用栈) | +| 进程未处理信号崩溃 | 崩溃日志和addr2line工具 | 参见:[基于崩溃日志对问题进行定位](#基于崩溃日志对问题进行定位) | + + +## 使用DumpCatcher获取调用栈 + + +### 接口说明 + +DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 + + **表2** DumpCatcher接口说明 + +| 类 | 方法 | 描述 | +| -------- | -------- | -------- | +| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string& msg) |   接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
  输入参数:
- pid:目标进程号;
- tid:目标线程号,如果需要回栈进程中的所有线程,则tid设定为0;
  输出参数:
- msg:如果回栈成功,则通过msg返回调用栈信息。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 当调用此接口的进程id与目标pid不一致时需要调用者是管理员(system,root)用户。当抓取非本用户组进程调用栈时还需具备读取对方/proc/pid/maps及ptrace到对方进程的权限。 + + +### 开发实例 + + +系统应用开发者可以用DumpCatcher在自己的应用中获取指定进程(线程)的调用栈。下文以dumpcatcherdemo模块使用DumpCatcher接口获取调用栈作为实例进行讲解。 + + +1. 编译构建文件添加dumpcatcher依赖:以/base/hiviewdfx/faultloggerd/example/BUILD.gn为例,在include_dirs中添加DfxDumpCatcher头文件路径,并在deps中添加“//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher”模块依赖。 + + ``` + import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") + import("//build/ohos.gni") + + config("dumpcatcherdemo_config") { + visibility = [ ":*" ] + + include_dirs = [ + ".", + "//utils/native/base/include", + "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include/", # 添加dumpcatcher头文件路径 + ] + } + + ohos_executable("dumpcatcherdemo") { sources = [ "dump_catcher_demo.cpp" ] configs = [ ":dumpcatcherdemo_config" ] deps = [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # 添加dumpcathcer模块依赖 "//utils/native/base:utils", ] external_deps = [ "hilog_native:libhilog" ] install_enable = true part_name = "faultloggerd" subsystem_name = "hiviewdfx" + } + ``` + +2. 头文件定义用到的函数:以/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.h为例,本样例代码中,通过调用栈深度测试的测试函数来构造一个指定深度的调用栈。 + + ``` + #ifndef DUMP_CATCHER_DEMO_H + #define DUMP_CATCHER_DEMO_H + + #include + + #define NOINLINE __attribute__((noinline)) + + // 定义该宏函数用于自动生成函数调用链 + #define GEN_TEST_FUNCTION(FuncNumA, FuncNumB) \ + __attribute__((noinline)) int TestFunc##FuncNumA() \ + { \ + return TestFunc##FuncNumB(); \ + } + + // 调用栈深度测试的测试函数 + int TestFunc0(void); + int TestFunc1(void); + int TestFunc2(void); + int TestFunc3(void); + int TestFunc4(void); + int TestFunc5(void); + int TestFunc6(void); + int TestFunc7(void); + int TestFunc8(void); + int TestFunc9(void); + int TestFunc10(void); + + #endif // DUMP_CATCHER_DEMO_H + ``` + +3. 在源文件中调用DumpCatch接口:以/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.cpp为例,引用dfx_dump_catcher.h头文件,声明DfxDumpCatcher对象,通过宏函数构造函数调用链,并最后调用DumpCatch接口方法,传入需要抓取调用栈的进程号、线程号。 + + ``` + #include "dump_catcher_demo.h" + + #include + #include + #include + // dfx_dump_catcher.h头文件引入 + #include "dfx_dump_catcher.h" + using namespace std; + + NOINLINE int TestFunc10(void) + { + OHOS::HiviewDFX::DfxDumpCatcher dumplog; + string msg = ""; + bool ret = dumplog.DumpCatch(getpid(), gettid(), msg); // 调用DumpCatch接口获取调用栈 + if (ret) { + cout << msg << endl; + } + return 0; + } + + // 通过宏函数自动生成函数调用链 + GEN_TEST_FUNCTION(0, 1) + GEN_TEST_FUNCTION(1, 2) + GEN_TEST_FUNCTION(2, 3) + GEN_TEST_FUNCTION(3, 4) + GEN_TEST_FUNCTION(4, 5) + GEN_TEST_FUNCTION(5, 6) + GEN_TEST_FUNCTION(6, 7) + GEN_TEST_FUNCTION(7, 8) + GEN_TEST_FUNCTION(8, 9) + GEN_TEST_FUNCTION(9, 10) + + int main(int argc, char *argv[]) + { + TestFunc0(); + return 0; + } + ``` + + +## 使用ProcessDump获取调用栈 + + +### 工具说明 + +ProcessDump是一个抓取调用栈的命令行工具,在OpenHarmony系统中可直接使用,该工具通过-p、-t参数指定进程和线程,命令执行后在命令行窗口打印指定进程的线程栈信息。 + + **表3** ProcessDump命令行工具使用说明 + +| 工具名称 | 命令行工具路径 | 执行命令 | 描述 | +| -------- | -------- | -------- | -------- | +| processdump | /system/bin | - processdump -p [pid]
- processdump -p [pid] -t [tid] | **参数说明:**
- -p [pid]:打印指定进程下面的所有线程栈信息。
- -p [pid] -t [tid]:打印指定进程下面的指定线程信息。
**返回值说明:**
如果栈信息解析成功,则将信息显示到标准输出;失败则打印错误信息。 | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 此工具需要在root下使用,或调用者有权限ptrace到目标进程,并读取目标进程的smaps。 + + +### 使用实例 + +通过processdump命令行工具打印hiview进程的调用栈。 + + +``` +# ps -A | grep hiview + 114 ? 00:00:00 hiview +# processdump -p 114 -t 114 +Tid:114, Name:hiview +#00 pc 0000000000089824(00000000b6f44824) /system/lib/ld-musl-arm.so.1(ioctl+68) +#01 pc 000000000002a709(00000000b6c56709) /system/lib/libipc_core.z.so(_ZN4OHOS15BinderConnector11WriteBinderEmPv+16) +#02 pc 000000000002ba75(00000000b6c57a75) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker18TransactWithDriverEb+224) +#03 pc 000000000002bb37(00000000b6c57b37) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker13StartWorkLoopEv+22) +#04 pc 000000000002c211(00000000b6c58211) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker10JoinThreadEb+36) +#05 pc 0000000000038d07(00000000004bcd07) /system/bin/hiview(_ZNSt3__h6vectorINS_9sub_matchINS_11__wrap_iterIPKcEEEENS_9allocatorIS6_EEE8__appendEj+596) +#06 pc 0000000000028655(00000000004ac655) /system/bin/hiview +#07 pc 00000000000c2b08(00000000b6f7db08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) +#08 pc 00000000000285f4(00000000004ac5f4) /system/bin/hiview +#09 pc 0000000000028580(00000000004ac580) /system/bin/hiview +``` + + +## 基于崩溃日志对问题进行定位 + +开发者可以通过faultloggerd生成的崩溃堆栈日志进行问题定位。本章节将主要介绍如何利用addr2line工具进行崩溃问题定位。 + +1. 程序自崩溃或构造崩溃。 + 例如将如下代码植入自己的代码中,调用触发一个无效内存访问故障(SIGSEGV)。 + + + ``` + NOINLINE int TriggerSegmentFaultException() + { + printf("test TriggerSegmentFaultException \n"); + // 为构造崩溃,强制进行类型转换 + int *a = (int *)(&RaiseAbort); + *a = SIGSEGV; + return 0; + } + ``` + +2. 获取崩溃函数调用栈日志。 + 因为存在未处理的异常,进程会在 /data/log/faultlog/temp路径下生成临时的日志文件,其命名规则为: + + + ``` + cppcrash-pid-time + ``` + + 获取其生成的调用栈如下: + + + ``` + Pid:816 + Uid:0 + Process name:./crasher + Reason:Signal:SIGSEGV(SEGV_ACCERR)@0x0042d33d + Fault thread Info: + Tid:816, Name:crasher + r0:0042d33d r1:0000000b r2:1725d4c4 r3:b6f9fa84 + r4:bec97e69 r5:b6fc0268 r6:0042d661 r7:bec97d60 + r8:00000000 r9:00000000 r10:00000000 + fp:bec97d20 ip:00000020 sp:bec97cd0 lr:b6f9fae4 pc:0042d32c + + #00 pc 000000000000332c(000000000042d32c) /data/crasher(TriggerSegmentFaultException+15) + #01 pc 00000000000035c7(000000000042d5c7) /data/crasher(ParseAndDoCrash+277) + #02 pc 0000000000003689(000000000042d689) /data/crasher(main+39) + #03 pc 00000000000c3b08(00000000b6fbbb08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) + #04 pc 00000000000032f8(000000000042d2f8) /data/crasher(_start_c+112) + #05 pc 0000000000003284(000000000042d284) /data/crasher(_start+32) + ``` + +3. 利用addr2line工具进行调用栈分析。 + 使用addr2line工具根据偏移地址解析行号: + + + ``` + root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 000332c + base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57 + ``` + + 这个崩溃是由赋值给一块不可写的区域导致的,代码行为dfx_crasher.c文件的57行,修改后可以避免发生此崩溃。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md new file mode 100644 index 0000000000000000000000000000000000000000..6c76bc9a0644905ddabe6635665062e4c978e868 --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hichecker.md @@ -0,0 +1,112 @@ +# HiChecker开发指导 + + +## 概述 + +HiChecker是OpenHarmony提供的用于检测代码错误使用方式和运行结果的一种检测框架,可在应用和系统开发阶段用于运行时的缺陷扫描。 + +本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。 + + +## 开发指导 + + +### 场景介绍 + +HiChecker的主要作用是给基于OpenHarmony的应用(包含系统和三方应用)开发者提供一套检测工具,用来检测应用程序开发过程中容易被人忽略的部分问题,包括应用关键线程调用耗时函数、应用进程中事件出现分发、执行超时以及应用进程中元能力资源泄露等,检测到的问题以日志记录或进程崩溃等形式展现出来以便开发者发现并修改相关问题。 + + +### 接口说明 + +HiChecker提供的主要接口及功能如下: + + **表1** HiChecker函数接口 + +| **类** | **方法(包括返回值、方法名、参数列表)** | **描述** | +| -------- | -------- | -------- | +| HiChecker | uint_64_t RULE_CAUTION_PRINT_LOG
= 1<<63; | 告警规则,当有告警时记录日志。 | +| uint_64_t RULE_CAUTION_TRIGGER_CRASH = 1<<62; | 告警规则,当有告警时让应用退出。 | +| uint_64_t RULE_THREAD_CHECK_SLOW_PROCESS = 1; | 检测规则,检测是否有耗时函数被调用。 | +| uint_64_t RULE_CHECK_SLOW_EVENT = 1<<32; | 检测规则,检测有事件分发或处理超过规定的时间阈值。 | +| uint_64_t RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33; | 检测规则,检测ability泄露。 | +| AddRule(uint_64_t rule) : void | 添加一条或者多条规则到系统,系统根据添加的规则进行检测或反馈。 | +| RemoveRule(uint_64_t rule) : void | 删除一组规则,删除的规则后续将不再生效。 | +| GetRule() : uint_64_t | 获取当前线程规则、进程规则、告警规则的合集。 | +| Contains(uint_64_t rule) : bool | 当前已添加的规则集中是否包含了某一个特定的规则, 如果传入的rule是线程级别的rule,仅查询当前线程中是否包含。 | +| NotifySlowProcess(std::string tag) : void | 通知有慢处理,通知系统当前代码调用了耗时较长的慢处理流程,以告知应用重要线程中尽量避开直接调用。 | +| NotifySlowEvent(std::string tag) : void | 通知发生事件分发超时或执行超时。 | +| NotifyAbilityConnectionLeak(Caution caution) : void | 通知发生AbilityConnection泄露。 | +| Caution | GetTriggerRule() : uint_64_t | 获取触发当前告警的检测规则。 | +| GetCautionMsg() : std::string | 获取更多辅助信息。 | +| GetStackTrace() : std::string | 获取告警触发时的堆栈信息。 | + + +### 开发实例 + +C++使用示例 + +1. 在使用hichecker功能相关的代码文件中,包含hichecker头文件: + + ``` + #include "hichecker.h" + ``` + + 如果非DFX子系统,需要加上HiviewDFX域。 + + + ``` + using namespace OHOS::HiviewDFX; + ``` + + 通过静态调用使用相关接口。 + + + ``` + HiChecker::AddRule(Rule::RULE_THREAD_CHECK_SLOW_PROCESS); //添加一条规则 + HiChecker::AddRule(Rule::RULE_CHECK_SLOW_EVENT | Rule::RULE_CAUTION_PRINT_LOG); //添加多条规则 + HiChecker::Contains(Rule::RULE_CAUTION_PRINT_LOG); // true + HiChecker::GetRule(); //RULE_THREAD_CHECK_SLOW_PROCESS | RULE_CHECK_SLOW_EVENT | RULE_CAUTION_PRINT_LOG + ``` + + 当规则被触发时,根据添加的告警规则执行告警(默认为写日志)。 + + - RULE_CAUTION_PRINT_LOG + 日志输出触发告警的规则、线程ID、线程名、堆栈等信息。 + + - RULE_CAUTION_TRIGGER_CRASH + 进程直接退出,日志输出退出提示以及辅助信息。 + + 通知接口的使用: + + - NotifySlowProcess(std::string tag) + 通知系统当前代码调用了耗时较长的慢处理流程,入参示例: + + + ``` + “threadId:xx,threadName:xx,actualTime:xx,delayTime:xx“ + ``` + + - NotifySlowEvent(std::string tag) + 通知发生事件分发超时或执行超时,入参示例: + + + ``` + “threadId:xx,threadName:xx,eventName:xx,actualTime:xx,delayTime:xx“ + ``` + + - NotifyAbilityConnectionLeak(Caution caution) + 通知发生AbilityConnection泄露,入参示例:传入一个Caution实例。 + + + ``` + Caution caution(Rule::RULE_CHECK_ABILITY_CONNECTION_LEAK , cautionMessage, stackTrace) + // cautionMessage与其它通知接口类似 + // stackTrace为发生泄露时的堆栈信息 + ``` + +2. 编译设置,在引入hichecker相关模块的BUILD.gn里增加子系统依赖: + + ``` + include_dirs = [ "//base/hiviewdfx/interfaces/innerkits/libhichecker/include" ] + external_deps = [ "hichecker_native:libhichecker" ] + ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md new file mode 100644 index 0000000000000000000000000000000000000000..9e4a91ff9294a4dfd58117a1e976a0c7c39074ea --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md @@ -0,0 +1,183 @@ +# HiDumper开发指导 + + +## 概述 + + +### 功能简介 + +HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。 + +本章节内容对大型系统类设备(参考内存≥1GiB)、标准系统类设备(参考内存≥128MiB)适用。 + + +### 源码目录说明 + + +``` +/base/hiviewdfx/hidumper +├── frameworks # 框架代码 +│ ├── native # 导出功能核心代码 +│ │ │── inlude # 头文件目录 +│ │ │── src # 源文件目录 +│ │ │── common # 通用功能代码 +│ │ │── executor # 导出过程执行器代码 +│ │ │── factory # 跟进导出项生成导出执行器 +│ │ │── manager # 导出管理核心代码 +│ │ │── util # 工具类源代码 +│── sa_profile # Hidumper sa属性文件 +│── services # Hidumper服务源码 +│ │── native # 服务C++源码 +│ │── zidl # 通讯功能源码目录 +│ │ │── include # 通讯功能头文件 +│ │ │── src # 通讯功能源代码 +├── test # 测试用例目录 +│ ├── unittest # 单元测试代码 +│ ├── moduletest # 模块级别测试代码 +``` + + +## 使用指导 + + +### 命令参数说明 + + **表1** HiDumper命令参数说明 + +| 选项 | **描述** | +| -------- | -------- | +| -h | 帮助信息 | +| -t [timeout] | 超时时间,单位:秒。默认值是30s。如果设置为0表示无超时限定。 | +| -lc | 系统信息簇列表 | +| -ls | 系统元能力列表 | +| -c | 导出系统簇信息 | +| -c [base system] | 以base或system标签区分的系统簇信息导出 | +| -s | 导出全部系统元能力信息 | +| -s [SA0 SA1] | 导出SA0、SA1等元能力id对应的元能力信息 | +| -s [SA] -a ['-h'] | 以-h为参数导出SA指定的系统元能力信息 | +| -e | 导出Faultlog模块生成的崩溃日志 | +| --net | 导出网络信息 | +| --storage | 导出存储信息 | +| -p | 导出进程列表及全部进程信息 | +| -p [pid] | 导出指定进程号的进程全部信息 | +| --cpuusage [pid] | 导出CPU使用信息;如果指定pid则导出该进程的CPU使用信息 | +| --cpufreq | 导出实际的CPU频率 | +| --mem [pid] | 导出内存使用信息;如果指定pid则导出该进程的内存使用信息 | +| --zip | 将导出信息压缩到固定文件夹下 | + + +### 使用实例 + +HiDumper可以为开发者导出系统当前基本信息,通过这些基本信息可以定位分析问题。给子服务和元能力传递复杂参数时,参数需要在双引号中。 + +具体步骤如下: + +1. 进入设备命令行,输入hidumper -h获取基本信息介绍,功能语法介绍。 + + ``` + hidumper -h + ``` + +2. 输入hidumper -lc获取系统信息分类列表。 + + ``` + hidumper -lc + ``` + +3. 输入hidumper -c获取系统base、system等所有分类信息。 + + ``` + hidumper -c + ``` + +4. 输入 hidumper -c [base | system] 按 base 或 system 分类获取系统簇信息 + + ``` + hidumper -c base + hidumper -c system + ``` + +5. 输入 hidumper -ls 命令获取系统中元能力列表 + + ``` + hidumper -ls + ``` + +6. 输入 hidumper -s 命令获取系统全部元能力信息 + + ``` + hidumper -s + ``` + +7. 运行 hidumper -s 3301 -a "-h" 命令获取id为3301的元能力的帮助 + + ``` + hidumper -s 3301 -a "-h" + ``` + +8. 运行 hidumper -s 3008命令获取id为3008的元能力的全部信息 + + ``` + hidumper -s 3008 + ``` + +9. 运行 hidumper -e 命令获取Faultlog模块生成的崩溃历史信息 + + ``` + hidumper -e + ``` + +10. 运行 hidumper --net 命令获取网络信息 + + ``` + hidumper --net + ``` + +11. 运行 hidumper --storage 命令获取存储相关信息 + + ``` + hidumper --storage + ``` + +12. 运行 hidumper -p 命令获取进程信息,包括进程、线程的列表和信息 + + ``` + hidumper -p + ``` + +13. 运行 hidumper -p 1024 命令获取pid为1024的进程信息 + + ``` + hidumper -p 1024 + ``` + +14. 运行 hidumper --cpuusage [pid] 命令获取CPU的使用信息;如果指定了进程的pid,则只获取该进程的CPU使用信息 + + ``` + hidumper --cpuusage + hidumper --cpuusage 1024 + ``` + +15. 运行 hidumper --cpufreq 命令获取每一个CPU核实际运行的频率 + + ``` + hidumper --cpufreq + ``` + +16. 运行 hidumper --mem [pid] 命令获取全部的内存使用信息;如果指定进程的pid,只获取该进程的内存使用情况 + + ``` + hidumper --mem [pid] + ``` + +17. 运行 hidumper --zip 命令压缩信息数据到/data/dumper目录下 + + ``` + hidumper --zip + ``` + +18. 运行 hidumper -t timeout 命令设置超时时间,单位:秒。默认值是30s。如果设置为0表示无超时限定。 + + ``` + hidumper -t [timeout] + ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index 01bb60ea61e09e854ab1e25c7bf702cb3f94091f..81785b1a3c6568cb93307ad1aa99081eea395f59 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -103,18 +103,25 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接 通过HiSysEventManager类提供的AddEventListener接口注册回调对象,完成对HiSysEvent的订阅: ``` - auto demoListener = std::make_shared(); - // 事件标签规则订阅,规则类型为默认的全词匹配类型 - ListenerRule tagRule("dfx"); - // 事件标签规则订阅,规则类型为正则匹配类型 - ListenerRule regRule("dfx.*", RuleType::REGULAR); - // 事件领域及事件名称规则订阅,规则类型为前缀匹配类型 - ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); - std::vector sysRules; - sysRules.push_back(tagRule); - sysRules.push_back(regRule); - sysRules.push_back(domainNameRule); - HiSysEventManager::AddEventListener(demoListener, sysRules); + std::shared_ptr demoListener = nullptr; + try { + demoListener = std::make_shared(); + } catch(...) { + // 智能指针获取失败异常处理 + } + if (demoListener != nullptr) { + // 事件标签规则订阅,规则类型为默认的全词匹配类型 + ListenerRule tagRule("dfx"); + // 事件标签规则订阅,规则类型为正则匹配类型 + ListenerRule regRule("dfx.*", RuleType::REGULAR); + // 事件领域及事件名称规则订阅,规则类型为前缀匹配类型 + ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); + std::vector sysRules; + sysRules.push_back(tagRule); + sysRules.push_back(regRule); + sysRules.push_back(domainNameRule); + HiSysEventManager::AddEventListener(demoListener, sysRules); + } ``` 2. 编译配置 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 60ffefa6e229e360586778fcd78155086a7619bd..d467ec4e62033d8ee421e69fda5ec4bee634c78a 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -86,10 +86,17 @@ C++接口实例。 } // namespace OHOS // 调用查询接口获取HiSysEvent事件 - auto queryCallBack = std::make_shared(); - struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector mRules; - HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack); + std::shared_ptr queryCallBack = nullptr; + try { + queryCallBack = std::make_shared(); + } catch (...) { + // 智能指针获取失败处理 + } + if (queryCallBack != nullptr) { + struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); + std::vector rules; + HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack); + } ``` 2. 编译设置: diff --git a/zh-cn/device-dev/subsystems/subsys-xts-guide.md b/zh-cn/device-dev/subsystems/subsys-xts-guide.md index e1a9d3ac5ab2ca751c653c550ef1b282c3d40469..54a4b6ae1d0927eb16dcf106b9707eb4346d5789 100644 --- a/zh-cn/device-dev/subsystems/subsys-xts-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-xts-guide.md @@ -1,24 +1,9 @@ -# XTS认证用例开发指导 - -- [简介](#section465982318513) -- [系统类型](#section125090457443) -- [目录](#section161941989596) -- [约束](#section119744591305) -- [使用说明](#section137768191623) -- [用例开发指导](#section3695134065513) - - [C语言用例开发编译指导(适用于轻量系统产品用例开发)](#section198193336544) - - [C语言用例执行指导(适用于轻量系统产品用例开发)](#section13820233175418) - - [C++语言用例开发编译指导(适用于小型系统、标准系统用例开发)](#section3822123311540) - - [C++语言用例执行指导(适用于小型系统、标准系统用例开发)](#section128222336544) - - [JS语言用例开发指导(适用于标准系统)](#section159801435165220) - - [JS语言用例编译打包指导(适用于标准系统)](#section445519106559) - -- [全量编译指导(适用于标准系统)](#section1519992743415) -- [全量用例执行指导(适用于小型系统、标准系统)](#section118149111426) +# XTS测评用例开发指导 + ## 简介 -XTS子系统是OpenHarmony生态认证测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套件,后续会拓展dcts(device compatibility test suite)设备兼容性测试套件等。 +XTS子系统是OpenHarmony兼容性测评套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套件,后续会拓展dcts(device compatibility test suite)设备兼容性测试套件等。 XTS子系统当前包括acts与tools软件包: diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 0922cb5bd7255a7884abca2baf287062b59af3b5..8a5da11e3299ce3dba951cd7bb5eb26afe7a57b1 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -1,61 +1,57 @@ +# OpenHarmony设备开发文档 - [设备开发导读](device-dev-guide.md) + - 快速开始 - - 轻量和小型系统入门 - - [轻量与小型系统入门概述](quick-start/quickstart-lite-overview.md) - - 搭建轻量与小型系统环境 - - [搭建系统环境概述](quick-start/quickstart-lite-env-setup-overview.md) - - [开发环境准备](quick-start/quickstart-lite-env-prepare.md) - - [获取源码](quick-start/quickstart-lite-sourcecode-acquire.md) - - [使用安装包方式搭建编译环境](quick-start/quickstart-lite-package-environment.md) - - [使用Docker方式搭建编译环境](quick-start/quickstart-lite-docker-environment.md) - - [常见问题](quick-start/quickstart-lite-env-setup-faqs.md) - - 运行“Hello World” - - Hi3861开发板 - - [安装开发板环境](quick-start/quickstart-lite-steps-hi3861-setting.md) - - [新建应用程序](quick-start/quickstart-lite-steps-hi3861-application-framework.md) - - [编译](quick-start/quickstart-lite-steps-hi3861-building.md) - - [烧录](quick-start/quickstart-lite-steps-hi3861-burn.md) - - [调试验证](quick-start/quickstart-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-lite-steps-hi3861-running.md) - - [常见问题](quick-start/quickstart-lite-steps-hi3861-faqs.md) - - Hi3516开发板 - - [安装开发板环境](quick-start/quickstart-lite-steps-hi3516-setting.md) - - [新建应用程序](quick-start/quickstart-lite-steps-hi3516-application-framework.md) - - [编译](quick-start/quickstart-lite-steps-hi3516-building.md) - - [烧录](quick-start/quickstart-lite-steps-hi3516-burn.md) - - [运行](quick-start/quickstart-lite-steps-hi3516-running.md) - - [常见问题](quick-start/quickstart-lite-steps-hi3516-faqs.md) - - Hi3518开发板 - - [安装开发板环境](quick-start/quickstart-lite-steps-hi3518-setting.md) - - [新建应用程序](quick-start/quickstart-lite-steps-hi3518-application-framework.md) - - [编译](quick-start/quickstart-lite-steps-hi3518-building.md) - - [烧录](quick-start/quickstart-lite-steps-hi3518-burn.md) - - [运行](quick-start/quickstart-lite-steps-hi3518-running.md) - - [常见问题](quick-start/quickstart-lite-steps-hi3518-faqs.md) - - 附录 - - [Hi3861开发板介绍](quick-start/quickstart-lite-introduction-hi3861.md) - - [Hi3516开发板介绍](quick-start/quickstart-lite-introduction-hi3516.md) - - [Hi3518开发板介绍](quick-start/quickstart-lite-introduction-hi3518.md) - - 标准系统入门 - - [标准系统入门简介](quick-start/quickstart-standard-overview.md) - - [标准系统开发环境准备(仅Hi3516需要)](quick-start/quickstart-standard-env-setup.md) - - [获取源码](quick-start/quickstart-standard-sourcecode-acquire.md) - - 运行“Hello World” - - Hi3516开发板 - - [创建应用程序](quick-start/quickstart-standard-running-hi3516-create.md) - - [编译](quick-start/quickstart-standard-running-hi3516-build.md) - - [烧录](quick-start/quickstart-standard-running-hi3516-burn.md) - - [运行](quick-start/quickstart-standard-running-hi3516-run.md) - - RK3568开发板 - - [创建应用程序](quick-start/quickstart-standard-running-rk3568-create.md) - - [编译](quick-start/quickstart-standard-running-rk3568-build.md) - - [烧录](quick-start/quickstart-standard-running-rk3568-burn.md) - - [运行](quick-start/quickstart-standard-running-rk3568-run.md) - - [常见问题](quick-start/quickstart-standard-faqs.md) - - 附录 - - [Hi3516开发板介绍](quick-start/quickstart-standard-appendix-hi3516.md) - - [RK3568开发板介绍](quick-start/quickstart-standard-appendix-rk3568.md) + - 轻量和小型系统快速入门(IDE方式) + - [轻量与小型系统入门概述](quick-start/quickstart-ide-lite-overview.md) + - 准备轻量与小型系统环境 + - [搭建Windows+Ubuntu混合开发环境](quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md) + - [获取源码](quick-start/quickstart-ide-lite-sourcecode-acquire.md) + - [创建源码工程](quick-start/quickstart-ide-lite-create-project.md) + - 运行“Hello World” + - Hi3861开发板 + - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3861-application-framework.md) + - [编译](quick-start/quickstart-ide-lite-steps-hi3861-building.md) + - [烧录](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) + - [联网](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) + - [调试验证](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) + - [运行](quick-start/quickstart-ide-lite-steps-hi3816-running.md) + - Hi3516开发板 + - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md) + - [编译](quick-start/quickstart-ide-lite-steps-hi3516-building.md) + - [烧录](quick-start/quickstart-ide-lite-steps-hi3516-burn.md) + - [运行](quick-start/quickstart-ide-lite-steps-hi3516-running.md) + - 附录 + - 开发板介绍 + - [Hi3861开发板介绍](quick-start/quickstart-ide-lite-introduction-hi3861.md) + - [Hi3516开发板介绍](quick-start/quickstart-ide-lite-introduction-hi3516.md) + - [轻量和小型系统快速入门(安装包方式)](quick-start/quickstart-lite-package-directory.md) + + - 标准系统快速入门(IDE方式) + - [标准系统入门概述](quick-start/quickstart-ide-standard-overview.md) + - 准备标准系统环境 + - [搭建Windows+Ubuntu混合开发环境](quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md) + - [获取源码](quick-start/quickstart-ide-standard-sourcecode-acquire.md) + - [创建源码工程](quick-start/quickstart-ide-standard-create-project.md) + - 运行“Hello World” + - Hi3516开发板 + - [编写“Hello World”程序](quick-start/quickstart-ide-standard-running-hi3516-create.md) + - [编译](quick-start/quickstart-ide-standard-running-hi3516-build.md) + - [烧录](quick-start/quickstart-ide-standard-running-hi3516-burning.md) + - [运行](quick-start/quickstart-ide-standard-running-hi3516-running.md) + - RK3568开发板 + - [编写“Hello World”程序](quick-start/quickstart-ide-standard-running-rk3568-create.md) + - [编译](quick-start/quickstart-ide-standard-running-rk3568-build.md) + - [烧录](quick-start/quickstart-ide-standard-running-rk3568-burning.md) + - [运行](quick-start/quickstart-ide-standard-running-rk3568-running.md) + - 附录 + - 开发板介绍 + - [Hi3516开发板介绍](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) + - [RK3568开发板介绍](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) + - [标准系统快速入门(安装包方式)](quick-start/quickstart-standard-package-directory.md) + + - [获取源码](get-code/sourcecode-acquire.md) - 兼容性与安全 @@ -106,9 +102,7 @@ - [CMake方式组织编译的库移植](porting/porting-thirdparty-cmake.md) - [Makefile方式组织编译的库移植](porting/porting-thirdparty-makefile.md) - - 轻量系统芯片移植案例 - - - [带屏解决方案之恒玄芯片移植案例](porting/porting-bes2600w-on-minisystem-display-demo.md) + - [轻量系统芯片移植案例](porting/porting-bes2600w-on-minisystem-display-demo.md) - 子系统开发 @@ -146,8 +140,7 @@ - [LMS调测](kernel/kernel-mini-memory-lms.md) - 附录 - [内核编码规范](kernel/kernel-mini-appx-code.md) - - 基本数据结构 - - [双向链表](kernel/kernel-mini-appx-data-list.md) + - [双向链表](kernel/kernel-mini-appx-data-list.md) - 标准库支持 - [CMSIS支持](kernel/kernel-mini-appx-lib-cmsis.md) - [POSIX支持](kernel/kernel-mini-appx-lib-posix.md) @@ -291,8 +284,7 @@ - [开发板Patch使用指导](kernel/kernel-standard-patch.md) - [Linux内核编译与构建指导](kernel/kernel-standard-build.md) - 内核增强特性 - - 内存管理 - - [Enhanced SWAP特性介绍](kernel/kernel-standard-mm-eswap.md) + - [Enhanced SWAP特性介绍](kernel/kernel-standard-mm-eswap.md) - 任务调度 - [关联线程组调度](kernel/kernel-standard-sched-rtg.md) - [CPU轻量级隔离](kernel/kernel-standard-sched-cpuisolation.md) @@ -306,16 +298,17 @@ - [HDF开发实例](driver/driver-hdf-sample.md) - 平台驱动开发 - [ADC](driver/driver-platform-adc-develop.md) + - [DAC](driver/driver-platform-dac-develop.md) - [GPIO](driver/driver-platform-gpio-develop.md) - [HDMI](driver/driver-platform-hdmi-develop.md) - [I2C](driver/driver-platform-i2c-develop.md) - [I3C](driver/driver-platform-i3c-develop.md) - - [MIPI-CSI](driver/driver-platform-mipicsi-develop.md) - - [MIPI-DSI](driver/driver-platform-mipidsi-develop.md) + - [MIPI CSI](driver/driver-platform-mipicsi-develop.md) + - [MIPI DSI](driver/driver-platform-mipidsi-develop.md) - [MMC](driver/driver-platform-mmc-develop.md) - [PIN](driver/driver-platform-pin-develop.md) - [PWM](driver/driver-platform-pwm-develop.md) - - [REGULATOR](driver/driver-platform-regulator-develop.md) + - [Regulator](driver/driver-platform-regulator-develop.md) - [RTC](driver/driver-platform-rtc-develop.md) - [SDIO](driver/driver-platform-sdio-develop.md) - [SPI](driver/driver-platform-spi-develop.md) @@ -323,27 +316,31 @@ - [WatchDog](driver/driver-platform-watchdog-develop.md) - 平台驱动使用 - [ADC](driver/driver-platform-adc-des.md) + - [DAC](driver/driver-platform-dac-des.md) - [GPIO](driver/driver-platform-gpio-des.md) - [HDMI](driver/driver-platform-hdmi-des.md) - [I2C](driver/driver-platform-i2c-des.md) - [I3C](driver/driver-platform-i3c-des.md) - - [MIPI-CSI](driver/driver-platform-mipicsi-des.md) - - [MIPI-DSI](driver/driver-platform-mipidsi-des.md) + - [MIPI CSI](driver/driver-platform-mipicsi-des.md) + - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PIN](driver/driver-platform-pin-des.md) - [PWM](driver/driver-platform-pwm-des.md) - - [REGULATOR](driver/driver-platform-regulator-des.md) + - [Regulator](driver/driver-platform-regulator-des.md) - [RTC](driver/driver-platform-rtc-des.md) - [SDIO](driver/driver-platform-sdio-des.md) - [SPI](driver/driver-platform-spi-des.md) - [UART](driver/driver-platform-uart-des.md) - - [WATCHDOG](driver/driver-platform-watchdog-des.md) + - [WatchDog](driver/driver-platform-watchdog-des.md) - 外设驱动使用 - [LCD](driver/driver-peripherals-lcd-des.md) - - [TOUCHSCREEN](driver/driver-peripherals-touch-des.md) - - [SENSOR](driver/driver-peripherals-sensor-des.md) + - [Touchscreen](driver/driver-peripherals-touch-des.md) + - [Sensor](driver/driver-peripherals-sensor-des.md) - [WLAN](driver/driver-peripherals-external-des.md) - - [AUDIO](driver/driver-peripherals-audio-des.md) + - [Audio](driver/driver-peripherals-audio-des.md) - [USB](driver/driver-peripherals-usb-des.md) - - [CAMERA](driver/driver-peripherals-camera-des.md) + - [Camera](driver/driver-peripherals-camera-des.md) + - [Vibrator](driver/driver-peripherals-vibrator-des.md) + - [Light](driver/driver-peripherals-light-des.md) - 编译构建 - [轻量和小型系统编译构建指导](subsystems/subsys-build-mini-lite.md) - [标准系统编译构建指导](subsystems/subsys-build-standard-large.md) @@ -393,13 +390,13 @@ - [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md) - [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md) - Sensor服务 - - [Sensor服务子系概述](subsystems/subsys-sensor-overview.md) - - [Sensor服务子系使用指导](subsystems/subsys-sensor-guide.md) - - [Sensor服务子系使用实例](subsystems/subsys-sensor-demo.md) + - [Sensor服务概述](subsystems/subsys-sensor-overview.md) + - [Sensor服务使用指导](subsystems/subsys-sensor-guide.md) + - [Sensor服务使用实例](subsystems/subsys-sensor-demo.md) - USB服务子系统 - - [USB服务子系统概述](subsystems/subsys-usbservice-overview.md) - - [USB服务子系统使用指导](subsystems/subsys-usbservice-guide.md) - - [USB服务子系统使用实例](subsystems/subsys-usbservice-demo.md) + - [USB服务概述](subsystems/subsys-usbservice-overview.md) + - [USB服务使用指导](subsystems/subsys-usbservice-guide.md) + - [USB服务使用实例](subsystems/subsys-usbservice-demo.md) - 用户程序框架 - [概述](subsystems/subsys-application-framework-overview.md) - [搭建环境](subsystems/subsys-application-framework-envbuild.md) @@ -436,6 +433,9 @@ - [HiSysEvent订阅指导](subsystems/subsys-dfx-hisysevent-listening.md) - [HiSysEvent查询指导](subsystems/subsys-dfx-hisysevent-query.md) - [HiSysEvent工具使用指导](subsystems/subsys-dfx-hisysevent-tool.md) + - [HiDumper开发指导](subsystems/subsys-dfx-hidumper.md) + - [HiChecker开发指导](subsystems/subsys-dfx-hichecker.md) + - [Faultlogger开发指导](subsystems/subsys-dfx-faultlogger.md) - 专题 - HPM Part diff --git a/zh-cn/glossary.md b/zh-cn/glossary.md new file mode 100644 index 0000000000000000000000000000000000000000..3d1cd4dcbc14f79ec45a76ad14ba2cf2ab1d6f50 --- /dev/null +++ b/zh-cn/glossary.md @@ -0,0 +1,96 @@ +# 术语 + +## A + +- ### Ability + + 应用的重要组成部分,是应用所具备能力的抽象。Ability是系统调度应用的最小单元,是能够完成一个独立功能的组件,一个应用可以包含一个或多个Ability。 + + +- ### AMS + + Ability Manager Service,Ability管理服务。 + +- ### ArkCompiler + + 方舟编译器,是OpenHarmony内置的组件化、可配置的多语言编译和运行平台,包含编译器、工具链、运行时等关键部件,支持高级语言在多种芯片平台的编译与运行,并支撑OpenHarmony标准操作系统及其应用和服务运行在手机、个人电脑、平板、电视、汽车和智能穿戴等多种设备上的需求。 + +- ### ArkUI + + 方舟开发框架,是一套极简、高性能、跨设备应用设计研发的UI开发框架,支撑开发者高效地构建跨设备应用UI界面。详情可参考[方舟开发框架开发指导](application-dev/ui/arkui-overview.md)。 + + +## B + +- ### BMS + + Bundle Manager Service,包管理服务。 + + +## D + +- ### DevEco Studio for Embedded + + 嵌入式设备开发IDE。 + +- ### DMS + + Distributed Management Service,分布式管理服务。 + + +## F + +- ### FA + + Feature Ability,是FA模型的Ability框架下具有UI界面的Ability类型,用于与用户进行交互。Feature Ability唯一对应一种模板,即Page模板(Page Ability)。 + +- ### FA模型 + + 两种Ability框架模型结构的其中一种。是Ability框架在API 8及更早版本采用FA模型。FA模型将Ability分为[FA(Feature Ability)](#fa)和[PA(Particle Ability)](#pa)两种类型,其中FA支持Page Ability模板,PA支持Service ability、Data ability、以及Form ability模板。详情可参考[FA模型综述](application-dev/ability/fa-brief.md)。 + + +## H + +- ### HAP + + OpenHarmony Ability Package,一个HAP文件包含应用的所有内容,由代码、资源、三方库及应用配置文件组成,其文件后缀名为.hap。 + +- ### HCS + + HDF Configuration Source是HDF驱动框架的配置描述语言,是为了实现配置代码与驱动代码解耦,以及便于配置的管理而设计的一种Key-Value为主体的文本格式。 + + +- ### HC-GEN + + HDF Configuration Generator是HCS配置转换工具,可以将HDF配置文件转换为软件可读取的文件格式。 + + +- ### HDF + + Hardware Driver Foundation,硬件驱动框架,用于提供统一外设访问能力和驱动开发、管理框架。 + + +## I + +- ### IDN + + Intelligent Distributed Networking,是OpenHarmony特有的分布式组网能力单元。开发者可以通过IDN获取分布式网络内的设备列表和设备状态信息,以及注册分布式网络内设备的在网状态变化信息。 + + +## P + +- ### PA + + Particle Ability,是在FA模型的Ability框架下无界面的Ability,主要为Feature Ability提供服务与支持,例如作为后台服务提供计算能力,或作为数据仓库提供数据访问能力。Particle Ability有三种模板,分别为Service模板(Service Ability)、Data模板(Data Ability)、以及Form模板(Form Ability)。 + + +## S + +- ### Super virtual device,超级虚拟终端 + + 亦称超级终端,通过分布式技术将多个终端的能力进行整合,存放在一个虚拟的硬件资源池里,根据业务需要统一管理和调度终端能力,来对外提供服务。 + +- ### System Type,系统类型 + - Mini System,轻量系统:面向MCU类处理器,例如ARM Cortex-M、RISC-V 32位的设备,资源极其有限,参考内存≥128KiB,提供丰富的近距连接能力以及丰富的外设总线访问能力。典型产品有智能家居领域的联接类模组、传感器设备等。 + - Small System,小型系统:面向应用处理器,例如Arm Cortex-A的设备,参考内存≥1MiB,提供更高的安全能力,提供标准的图形框架,提供视频编解码的多媒体能力。典型产品有智能家居领域的IPCamera、电子猫眼、路由器以及智慧出行域的行车记录仪等。 + - Standard System,标准系统:面向应用处理器,例如Arm Cortex-A的设备,参考内存≥128MiB,提供增强的交互能力,提供3D GPU以及硬件合成能力,提供更多控件以及动效更丰富的图形能力,提供完整的应用框架。典型产品有高端的冰箱显示屏等。 \ No newline at end of file diff --git "a/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" index 15996408cf13e888a3b960d4bc9c6da28a1d72a9..e96fd69cbdfcae4099cbe7833b5fe0ab4f14277f 100644 --- "a/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" @@ -415,17 +415,17 @@ AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。 ## 涉及仓 -AI子系统 +[AI子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/AI%E4%B8%9A%E5%8A%A1%E5%AD%90%E7%B3%BB%E7%BB%9F.md) -ai_engine +[ai_engine](https://gitee.com/openharmony/ai_engine) 依赖仓: -build\_lite +[build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README_zh.md) -distributedschedule\_services\_samgr\_lite +[distributedschedule\_samgr\_lite](https://gitee.com/openharmony/distributedschedule_samgr_lite/blob/master/README_zh.md) -startup\_init\_lite +[startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README_zh.md) ## AI引擎开发导航 diff --git "a/zh-cn/readme/JS-UI\346\241\206\346\236\266\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/JS-UI\346\241\206\346\236\266\345\255\220\347\263\273\347\273\237.md" index 64c95f65baa12572c6593d655f70fe8789e3ec05..500913347a584ca5753d2abd7394f044e3c159e5 100644 --- "a/zh-cn/readme/JS-UI\346\241\206\346\236\266\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/JS-UI\346\241\206\346\236\266\345\255\220\347\263\273\347\273\237.md" @@ -112,9 +112,9 @@ JS UI开发框架源代码在/foundation/ace下,目录结构如下图所示: **JS UI框架子系统** -ace\_ace\_engine +[ace\_ace\_engine](https://gitee.com/openharmony/ace_ace_engine) -ace\_ace\_engine\_lite +[ace\_ace\_engine\_lite](https://gitee.com/openharmony/ace_engine_lite) -ace\_napi +[ace\_napi](https://gitee.com/openharmony/ace_napi) diff --git "a/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" index 9e2c6040e91c245b637479d7ee7361b7e448fca2..7d38c96d3b7922a2fb1996c274d3fd81bde82f7d 100644 --- "a/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" @@ -29,7 +29,7 @@ 各模块介绍: -- View:应用组件,包括UIView、UIViewGoup、UIButton、UILabel、UILabelButton、UIList、UISlider等。 +- View:应用组件,包括UIView、UIViewGroup、UIButton、UILabel、UILabelButton、UIList、UISlider等。 - Animator:动画模块,开发者可以自定义动画。 - Layout:布局控件,包括Flexlayout、GridLayout、ListLayout等。 - Transform:图形变换模块,包括旋转、平移、缩放等。 diff --git "a/zh-cn/readme/\347\263\273\347\273\237\345\272\224\347\224\250.md" "b/zh-cn/readme/\347\263\273\347\273\237\345\272\224\347\224\250.md" index 366d216b2668838070aade40cf765714f7d70194..57c770c8168eccc7bc3355c2103f137120484c80 100644 --- "a/zh-cn/readme/\347\263\273\347\273\237\345\272\224\347\224\250.md" +++ "b/zh-cn/readme/\347\263\273\347\273\237\345\272\224\347\224\250.md" @@ -13,26 +13,49 @@ 1. 桌面:提供了基本的已安装应用的展示功能和人机交互界面,是所有应用的入口。 2. SystemUI:包含导航栏和系统状态栏两部分,导航栏提供基本页面导航功能、状态栏提供系统状态显示,如时间、充电状态等。 3. 设置:提供了关于设备,应用管理,亮度设置等功能。 +4. 联系人:提供了拨号盘、通话记录查看/删除、联系人列表、详情查看和新建联系人等功能。 +5. 短信:提供了信息查看、发送短信、接收短信、短信送达报告、删除短信等功能。 +6. 通话:提供了语音通话接听和挂断,移动数据开关等功能。 +7. 相机:提供了预览、拍照、缩略图显示、跳转大图浏览等功能。 +8. 图库:提供了图片、视频和相册的管理、浏览、显示、编辑操作等功能。 + +注意: +OpenHarmony 3.1 Release版本,仅图库系统应用代码可配套发布的IDE、SDK编译成功。其他系统应用代码仍在适配优化中,预计2022-04-30完成,实际支持以最终发布版本为准。 ## 目录 ``` -/applications/standard/ +/applications/ ├── launcher # 桌面应用代码仓。 ├── systemui # SystemUI应用代码。 ├── settings # 设置应用代码仓。 ├── hap # 系统应用二进制仓。 +├── contacts # 联系人应用代码仓。 +├── mms # 短信应用代码仓。 +├── call # 通话应用代码仓。 +├── camera # 相机应用代码仓。 +├── photos # 图库应用代码仓。 ``` ## 相关仓 **系统应用** -applications\_standard\_settings +applications\_settings + +applications\_launcher + +applications\_systemui + +applications\_hap + +applications\_contacts + +applications\_mms -applications\_standard\_launcher +applications\_call -applications\_standard\_systemui +applications\_camera -applications\_standard\_hap +applications\_photos diff --git a/zh-cn/release-notes/OpenHarmony-v3.1-release.md b/zh-cn/release-notes/OpenHarmony-v3.1-release.md new file mode 100755 index 0000000000000000000000000000000000000000..34ef7c9881f22fd647f3b7a43bacf5b8f7873dad --- /dev/null +++ b/zh-cn/release-notes/OpenHarmony-v3.1-release.md @@ -0,0 +1,250 @@ +# OpenHarmony 3.1 Release + + +## 版本概述 + +当前版本在OpenHarmony 3.1 Beta的基础上,更新支持以下能力: + +**标准系统基础能力增强** + +本地基础音视频播放能力、视频硬编解码、相机基础预览、拍摄能力。 + +RenderService新渲染框架、2D/3D绘制能力、新的动画和显示效果框架。 + +窗口管理新框架,提供更加灵活的窗口框架能力,支持全屏、分屏、窗口化形态,支持跨窗口拖拽能力。 + +display管理能力,支持分屏,并增强亮灭屏管理能力;支持窗口动画和效果。 + +鼠标、键盘、触摸板的基本功能支持,常见传感器加速度、陀螺仪、霍尔、马达振动等的基本能力支持。 + +语言区域选择、新增/增强国际化特性、系统资源、rawfile资源。 + +时间时区同步的支持管理能力、新增对剪贴板、锁屏服务、静态壁纸、下载服务管理能力的支持。 + +系统服务状态监控功能、新增跨设备oncall能力(跨设备启动FA能力)、长时、短时及延迟任务调度能力。 + +内存管理功能增强、电源管理基本功能支持、增进程调度功能增强等特性。 + +本地帐号、域帐号与本地帐号绑定功能,分布式帐号ID派生和状态管理功能,本地应用权限管理、分布式权限的管理能力。 + +Wi-Fi STA、AP、P2P相关基本能力以及JS API、新增蓝牙BR、SPP、BLE相关的能力以及JS API、新增位置服务子系统,提供位置服务框架能力。 + +**标准系统分布式能力增强** + +分布式软总线网络切换组网、P2P连接、流传输、蓝牙等能力。 + +支持硬件互助 ,资源共享,支持镜像和扩展投屏等。 + +设备上下线和PIN码认证等增强功能,存储管理、应用沙箱隔离、公共数据沙箱隔离等能力,支持分布式数据库,分布式数据对象,支持本地数据库访问和跨应用数据库访问等能力。 + +**标准系统应用程序框架能力增强** + +ArkUI自定义绘制能力和Lottie动画能力、键盘、鼠标交互操作能力。 + +声明式Web组件、XComponent组件能力。 + +卡片能力,提供卡片添加、删除、刷新等基础能力。 + +多用户能力,提供适应多端的基础JS工具链及运行时能力,对多HAP安装、隐式查询、多用户、权限管理的基本功能支持,支持分布式通知,通知模板功能。 + +**标准系统应用能力增强** + +系统应用构建,包含系统桌面、SystemUI、系统设置、相机、图库、通话、联系人、信息、备忘录、文件选择器、输入法等应用支持。 + + +## 配套关系 + + **表1** 版本软件和工具配套关系 + +| 软件 | 版本 | 备注 | +| -------- | -------- | -------- | +| OpenHarmony | 3.1 Release | NA | +| SDK | Ohos_sdk 3.1 Release  (API Version 8 ) | NA | +| HUAWEI DevEco Studio(可选) | 3.0 Beta3 for OpenHarmony | OpenHarmony应用开发推荐使用 | +| HUAWEI DevEco Device Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用 | + + +## 源码获取 + + +### 前提条件 + +1. 注册码云gitee账号。 + +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 + +3. 安装[git客户端](https://gitee.com/link?target=https%3A%2F%2Fgit-scm.com%2Fbook%2Fzh%2Fv2%2F%25E8%25B5%25B7%25E6%25AD%25A5-%25E5%25AE%2589%25E8%25A3%2585-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. 安装码云repo工具,可以执行如下命令。 + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### 通过repo获取 + +**方式一(推荐)** + +通过repo + ssh 下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 + + +``` +repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1-Release --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + +**方式二** + +通过repo + https 下载。 + + +``` +repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1-Release --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + +### 从镜像站点获取 + +**表2** 获取源码路径 + +| 版本源码 | **版本信息** | **下载站点** | **SHA256校验码** | +| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 全量代码(标准、轻量和小型系统) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/code-v3.1-Release.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/code-v3.1-Release.tar.gz.sha256) | +| Hi3516标准系统解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_hi3516.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_hi3516.tar.gz.sha256) | +| RK3568标准系统解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_rk3568.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_rk3568.tar.gz.sha256) | +| Hi3861轻量系统解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_pegasus.tar.gz.sha256) | +| Hi3516轻量系统解决方案-LiteOS(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus.tar.gz.sha256) | +| Hi3516轻量系统解决方案-Linux(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus_linux.tar.gz.sha256) | +| 标准系统SDK包(Mac) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/ohos-sdk-mac.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/ohos-sdk-mac.tar.gz.sha256) | +| 标准系统SDK包(Windows\Linux) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/ohos-sdk.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/ohos-sdk.tar.gz.sha256) | +| 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/harmonyos/os/2.0/tool_chain/) | - | + + + + +## 更新说明 + +本版本在OpenHarmony 3.1 Beta的基础上有如下变更。 + + +### 特性变更 + +**表3** 版本新增特性表 + +| 子系统名称 | 标准系统 | 轻量、小型系统 | +| -------- | -------- | -------- | +| 资源调度 | - 新增长时、短时及延迟任务调度能力。
- 新增提醒后台代理能力。
主要涉及如下需求:
I4QT41【新增特性】提醒代理管理
I4QU0W【新增特性】短时任务后台管理
I4QT3S【新增特性】长时任务管理
I4QU0P【新增特性】延迟任务调度
I4QT45【新增特性】查询指定时间范围内的应用使用历史统计数据 | NA | +| 多模输入 | - 新增对鼠标、键盘、触摸板的基本功能支持。
- 新增全屏手势的事件订阅能力。
主要涉及如下需求:
I4WWRZ 【多模】鼠标按键功能
I4WWS0 【多模】鼠标滚轮功能
I4WWSR 【多模】按键基本功能
I4WWT8 【多模】触摸板基本功能
I4WWSN 【多模】订阅单系统按键输入事件 | NA | +| 系统服务管理 | - 新增系统服务状态监控功能。
- 增动态加载本地系统服务功能。
- 新增DeviceProfile增删改查及同步功能。
- 新增DeviceProfile事件注册功能。
- 新增迁移框架对分布式对象、应用栈信息迁移的能力。
- 新增跨设备oncall能力(跨设备启动FA能力)。
- 新增实时获取远端设备任务、快照信息能力。
主要涉及如下需求:
I4MBRV 【samgr】系统服务状态监控
I4MBRY 【samgr】系统服务进程管理
I4NY1T 【device_profile】订阅profile信息变化
I4NY1W 【device_profile】向业务端提供同步profile能力
I4NY1X 【device_profile】提供查询远程设备profile记录功能
I4OGD1 【新增特性】【DMS】支持组件间跨设备的onCall调用
I4OGCK 【增强特性】框架等待分布式对象同步完成后返回迁移结果
I4OGCL 【增强特性】【框架】迁移数据保存
I4OGCN 【增强特性】【DMS】根据指定设备发起迁移能力,接收迁移结果
I4OGCM 【新增特性】【任务管理】提供获取实时任务接口 | I4TS0Z 【新增】轻量系统samgr支持远程服务管理 | +| 分布式硬件 | - 新增分布式硬件子系统,包括分布式硬件管理框架、分布式相机,分布式屏幕三个代码仓。
- 完善设备管理功能,提供周边设备发现,上下线和PIN码认证等增强功能。
主要涉及如下需求:
I4PZE7 【增强特性】支持周边不可信设备的发现
I4PZDZ 【增强特性】支持帐号无关设备的PIN码认证
I4PZDY 【增强特性】支持可信设备列表查询、上下线监听
I4WVOC 【新增特性】分布式硬件使能/去使能和动态加载
I4WVMX 【新增特性】分布式硬件接入管理
I4WW6U 【新增特性】支持分布式Screen的镜像/扩展显示 | I4XSUZ 【新增特性】轻量系统支持设备管理基础功能 | +| 电源子系统 | 对于标准系统:
新增电源管理、电池管理、热管理、耗电统计的基本功能支持。
主要涉及如下需求:
I40IRO 【电源管理】支持休眠和混合睡眠模式
I412F4 【电源管理】支持省电模式
I4MBRL 【电源管理】支持显示相关的能耗调节
I4MBRM 【电源管理】支持接近光控制锁,通话时通过接近光控制亮灭屏的特性
I4OEOZ 【电源管理】监控输入亮屏输入事件,并根据输入事件进行亮、灭屏
I4OEQT 【电源管理】不亮屏检测
I4QGI0 【电源管理】长按power Key弹出关机界面
I410YD 【电池管理】支持关机充电特性
I410Y1 【电池管理】电池温度异常关机保护
I4GY9U 【热管理】支持内核温控服务
I4GYAF 【热管理】支持用户层和服务温控服务
I4GYBV 【热管理】提供温升监控接口
I4GYCD 【耗电统计】支持软件耗电统计
I4GYCN 【耗电统计】支持硬件耗电统计
I4GYDQ 【耗电统计】支持耗电详情记录 | NA | +| 帐号子系统 | - 新增支持本地帐号(也称为系统帐号)的声明周期管理功能,包括本地帐号的创建、切换、删除、订阅、查询、修改等功能
- 新增分布式帐号ID派生和状态管理功能,在分布式帐号登录时派生唯一的帐号ID并将其与当前本地帐号唯一绑定,在分布式帐号登出或token失效时解除与本地帐号的绑定关系。
- 新增域帐号与本地帐号绑定功能,根据传入的域帐号信息自动创建本地帐号并与其唯一绑定。
- 新增本地帐号辅助管理工具:acm命令,可通过acm create/delete/switch/dump等命令对本地帐号进行增删改查,通过acm --help查看对应指令说明。
I4JBFB 支持分布式组网帐号状态管理
I4JBEK 支持分布式组网帐号ID的派生
I4IU6N 支持本地多用户基础信息管理
I4IU5W 支持os_account_standard部件本地多用户生命周期管理需求
I4IU5G 支持本地多用户辅助管理工具
I4IU3V 支持域帐户和本地用户关联
I4IU3B 支持本地多用户启动、停止、切换动作
I4IU33 支持本地多用户功能设置与内容修改 | NA | +| 内核子系统 | - 新增内存管理功能增强特性,提高内存使用效率,包括CMA复用、内存共享接口,增强swap等。
- 新增进程调度功能增强特性,提高cpu资源的使用效率,增强滑动场景的资源供给,包括cpu热插拔及轻量级隔离,绘帧线程优先供给机制等。
- 支持最新的内核安全漏洞补丁修复,及其他安全增强机制,如支持tokenid配置及查询等。
主要涉及如下需求:
I4MBTN【新增特性】支持CMA复用特性
I4MBTO【新增特性】支持内存占用分类查询
I4LKQ0【新增特性】cpuset与cpu热插拔解耦
I4QE9K【新增特性】提供内核态驱动与用户态之间、用户态与用户态之间的内核共享能力
I4LRGQ【新增特性】OpenHarmony内核基线使能
I4RXQ3【新增特性】内存管理基础特性
I4TEGS【新增特性】F2FS末端性能优化
I4SRVK【新增特性】支持CPU轻量级隔离特性
I4SE2N【新增特性】支持按照用户维度进行内存资源管控的能力
I4VMGZ【新增特性】支持基础FPS智能感知调度功能
I4U089【新增特性】内核调度支持绘帧线程优先供给机制
I4OWTZ【外部依赖】内核实现进程的tokenID设置 | NA | +| 包管理子系统 | - 新增对多HAP安装、隐式查询、多用户、权限管理的基本功能支持。
- 新增DBMS、跨设备同步等分布式能力的支持
- 新增zlib Native SDK支持
主要涉及如下需求:
I4MBSD【新增特性】支持多hap包安装
I4MBSG【增强特性】安装包信息查询
I4PKY7【新增特性】跨设备信息同步
I4PKY8【新增特性】跨设备信息查询
I4PKYK【增强特性】启动扫描
I4PKYI【新增特性】提供清除数据的能力
I4PKYM【新增特性】支持多用户创建
I4QA3D【增强特性】新增zlib解压、压缩数据native接口
I4SIH9【新增特性】应用申请权限管理 | NA | +| 位置服务子系统 | - 新增位置服务子系统,提供位置服务框架能力。
- 位置服务框架支持GNSS基本定位、GNSS围栏、GNSS Batching、网络定位能力、地理编码转换等能力框架服务。
主要涉及如下需求:
I4XXIH 【location_gnss】供GNSS性能提升的相关辅助信息请求和注入能力
I4XXIG 【location_gnss】提供GNSS硬件功耗统计以及功耗优化能力
I4XXIF【location_gnss】提供GNSS基本定位功能
I4XXIC【location_gnss】提供GNSS Batching的能力
I4XXIB【location_gnss】支持GNSS参数设置和信息上报功能
I4XXI8【location_locator】支持位置服务的安全管理能力
I4XXI7【location_locator】提供位置服务隐私的安全保障能力
I4XXI5【location_locator】支持管理多个定位请求,支持多应用同时请求定位
I4XXI4【location_locator】支持位置服务定位管理功能
I4XXI3【location_geofence】支持GNSS芯片相关的地理围栏功能
I4XXI0【location_geocode】支持经纬度和地址互相转换
I4XXHZ【location_network】支持网络定位能力
I4XXHW【location_gnss】支持GNSS辅助协议 | NA | +| 基础通信子系统 | - 新增WiFi STA、AP、P2P相关基本能力以及JS API,优化了STA、AP、P2P基本能力的连接体验。
- 新增蓝牙BR、SPP、BLE相关的能力以及JS API。
主要涉及如下需求:
**WiFi**:
I4XXFG 【新增特性】支持WiFi功耗统计以及功耗优化能力
I4XXFF 【新增特性】提供WiFi P2P基本能力
I4XXFB【新增特性】支持P2P magiclink连接特性
I4XXF7【新增特性】支持SoftAP 5G及信道自动选择
I4MBRI 【新增特性】支持SoftAP基础特性
I4MBRH【新增特性】支持STA基础特性
**蓝牙**:
I4XXGC【bluetooth_standard】支持蓝牙BR/EDR的基本能力
I4XXFT【bluetooth_standard】提供A2DP profile相关能力以及JS API
I4XXFP【bluetooth_standard】支持蓝牙BLE相关的基本能力
I4XXFL【bluetooth_standard】支持蓝牙SPP能力,提供BR的数据传输能力
| NA | +| 元能力子系统 | - 新增卡片能力、Zidl工具支持C++服务端客户端代码自动生成、元能力测试框架、命令行工具能力增强。
- 新增多用户能力、任务栈重构、部件化解耦、应用常驻进程、应用异常检测增强、环境变化通知能力。
主要涉及如下需求:
I4PCM4 【新增特性】上下文提供应用/Hap包/组件信息查询能力
I4PCPP 【新增特性】上下文适配多用户
I4PCPV 【新增特性】提供指定用户启动组件的系统接口
I4PCQP 【新增特性】支持singleuser的运行模式
I4PCQU 【新增特性】启动初始化默认用户
I4PCGY 【增强特性】新增卡片开发基类
I4PCH9 【增强特性】通过配置文件配置服务卡片
I4PCLL 【新增特性】JS提供的应用级别上下文
I4PCLN 【新增特性】Abilty的状态恢复
I4PCP1 【新增特性】应用运行信息查询
I4PCPG 【增强特性】支持系统环境变化通知
I4PCR8 【增强特性】支持常驻进程开机启动
I4PCV4 【新增特性】支持任务切换
I4PCVZ 【新增特性】支持指定displayId启动Ability
I4PCW3 【增强特性】pendingwant机制支持跨设备启动通用组件
I4PCH4 【新增特性】卡片支持多用户
I4PCM1 【新增特性】提供ce/de级上下文
I4PCVN 【新增特性】支持任务快照获取和更新
I4PPW6 【增强特性】指定窗口模式启动组件
I4PC3R 【新增特性】提供卡片开发基础能力
I4PQ0M 【增强特性】上下文提供消息发送和监听能力
II4PQ13 【增强特性】上下文提供权限校验及权限申请接口
I4PQ1E 【增强特性】支持常驻进程异常恢复
I4PQ1O 【新增特性】支持NewWant
I4PCPI 【增强特性】支持系统环境查询
I4PCRL 【新增特性】测试框架整体功能
I4PCVU 【新增特性】通用组件call调用 | NA | +| 无障碍软件服务子系统 | - 新增界面信息交换机制内部实现;
- 新增无障碍配置信息读取。
主要涉及如下需求:
I4X2EM【新增特性 信息交换机制】按键拦截
I4X2EN【新增特性 信息交换机制】支持上报窗口节点信息
I4X2ET【新增特性 信息交换机制】支持控件节点信息上报
I4X2EV【新增特性 信息交换机制】焦点查询
I4X2EY【新增特性 信息交换机制】无障碍事件列表
I4X2EZ【新增特性 信息交换机制】无障碍事件信息
I4X2F0【新增特性 信息交换机制】无障碍动作发起
I4X2F1【新增特性 信息交换机制】辅助应用列表查询
I4X2F2【新增特性 信息交换机制】辅助应用状态查询与监听
I4X2F3【新增特性 信息交换机制】手势模拟
I4X2F4【新增特性 信息交换机制】触摸拦截
I4X2EO【新增特性 无障碍服务管理】目标应用连接
I4X2EP【新增特性 无障碍服务管理】辅助应用连接
I4X2ER【新增特性 无障碍服务管理】辅助应用更新
I4X2ES【新增特性 无障碍服务管理】无障碍字幕配置 | NA | +| 媒体子系统 | - 新增支持本地基础音视频播放和录制能力,支持视频硬编解码,支持主流音视频codec与封装格式,并易于生态厂商扩展。
- 新增支持相机基础预览、拍摄、录像能力,及分布式相机预览、拍摄能力。
主要涉及如下需求:
I4WYPP【audio_standard部件】支持蓝牙音频播放
I4WYK8【audio_standard部件】支持Opensles基础播放接口
I4WYW4【增强特性】支持相机会话管理
I4WYVE【增强特性】支持基础拍照模式下的拍照功能
I4WZ8G【新增特性】图片基础解码框架
I4X5E1【新增特性】支持视频软解功能
I4X552【新增特性】支持本地音视频播放
I4X5Q9【新增特性】分布式媒体库-缩略图同步
I4X5L5【新增特性】基础媒体数据库 | NA | +| 图形子系统 | - 构建了图形RenderService新渲染框架。
- 提供了2D/3D绘制能力支持。
- 支持新的动画框架。
主要涉及如下需求:
I4MBTY【render_service部件】【新增特性】新增UI框架渲染后端特性
I4RKT3【composer部件】提供合成和送显的能力
I4ZCGG【drawing部件】提供图形Native SDK能力
I4RKSW【drawing部件】提供3D 图形能力支持Native SDK能力
I4MBTW【animation部件】提供基础动画框架 | NA | +| 窗口子系统 | - 构建了窗口管理新框架,提供更加灵活的窗口框架能力,支持全屏、分屏、窗口化形态,支持跨窗口拖拽能力。
- 提供了display管理能力,支持分屏,并增强亮灭屏管理能力。
主要涉及如下需求:
I4R308【增强特性】:提供应用窗口创建管理能力,单个应用的多个Ability实例可以创建多个主窗口
I4R309【增强特性】:提供应用窗口创建管理能力,支持启动窗口时设定窗口显示策略;提供窗口显示策略状态给应用(分屏、全屏、自由窗口)
I4R30D【新增特性】:应用主窗口支持自由窗口显示,平铺和层叠布局
I4R9P0【新增规格】:增强特性:
1. 提供Display管理能力
2. 提供通过物理屏幕插入拔出创建和销毁Display的能力
3. 提供多Display映射管理能力
I4ZEKH【新增特性】:支持亮屏灭屏流程:
1. 支持从电源管理发起的休眠、唤醒、亮屏、灭屏请求
2. 支持收到请求后调用Render Server接口实现对对应的亮屏、灭屏、调整屏幕亮度操作 | NA | +| 网络管理子系统 | I4XXHU【增强特性】支持TCP/UDP Socket
I4XXHT【增强特性】支持http 1.1/https/http2
I4XXHS【增强特性】支持对Wi-Fi/蜂窝网络连接的管理和切换
I4XXHP【增强特性】支持DNS解析和配置
I4XXHN【增强特性】支持网络连接状态查询和网络连接状态变化通知
I4XXHH【wpa_supplicant】提供基于NL80211的wpa、p2p能力
I4XXHG【wpa_supplicant】提供magiclink能力 | NA | +| MSDP子系统 | I4WWRO【msdp】device_status部件标准化 | NA | +| 全球化子系统 | - 新增支持语言区域选择。
- 新增/增强支持国际化特性(单复数、字符串排序、电话号码处理、日历&本地历法、度量衡体系和格式化、时间段格式化、字母表检索、unicode字符属性、断词断行)。
- 新增支持系统资源。
- 新增支持rawfile资源。
主要涉及如下需求:
I4MBR0 【增强特性】区域表示和属性
I4MBR1 【增强特性】单复数支持
I4MBR2 【增强特性】字符串排序
I4MBR3 【增强特性】电话号码处理
I4MBR7 【新增特性】日历&本地历法
I4MBR5 【新增特性】度量衡体系和格式化
I4MBQZ 【增强特性】时间段格式化
I4MBR4 【新增特性】字母表检索
I4MBR8 【增强特性】unicode字符属性
I4MBR9 【增强特性】断词断行
I4MBRA 【新增特性】系统资源管理
I4MBRB 【新增特性】rawfile资源管理
I4R2YA 【新增特性】新增资源管理Native SDK接口 | NA | +| 软总线子系统 | - 新增对网络切换组网能力的支持
- 新增对蓝牙能力的支持
- 新增对蓝牙文件传输能力的支持
- 新增对流传输能力的支持
- 新增对P2P连接能力的支持
- 支持基于P2P连接的文件和流传输的能力
主要涉及如下需求:
I4MBS0 【新增特性】【组网】软总线支持网络切换组网
I4XXEL 【增强特性】软总线支持蓝牙
I4XXEX 【传输】文件传输(蓝牙)
I4XXEO 【增强特性】【传输】文件传输增强(NSTACK组件能力)
I4XXEV 【新增特性】【传输】流传输增强(NSTACK组件能力增强)
I4XXEN 【新增特性】【组网】软总线组网支持P2P连接
I4XXEP 【新增特性】【连接】软总线支持P2P连接
I4XXES 【新增特性】【传输】软总线支持P2P文件传输
I4XXET 【新增特性】【传输】软总线支持P2P流传输 | NA | +| ArkUI子系统 | - 新增键盘、鼠标交互操作
- 新增声明式Web组件能力
- 新增声明式XComponent组件能力
- 新增声明式Canvas2D绘制能力与OffscreenCanvas离屏绘制能力
- 新增富文本显示能力
- 新增多种功能组件
- 增强多种组件自定义能力
- 增强调测能力
主要涉及如下需求:
I4MBV7 【新增规格】滚动条样式自定义能力
I4MBVO 【新增特性】Popup组件增加内容自定义规格
I4MBVP 【新增特性】Canvas绘制能力支持
I4MBVR 【新增特性】触摸响应热区设置
I4MBVS 【新增特性】Lottie动画支持
I4MBVU 【新增特性】Menu组件增加内容自定义规格
I4MBVV 【新增特性】Swipe手势特性
I4MBV9 【新增规格】Tabs组件新增TabBar内容自定义规格
I4MBVA 【新增规格】Navigation组件新增标题栏设置规格
I4MBVC 【新增规格】工具栏组件增加内容自定义能力规格
I4WTQY 【新增特性】线性占比显示控件特性支持
I4MBV3 【新增规格】样式设置特性增加组件多态样式设置规格
I4MBV5 【新增规格】字母索引条组件增加提示菜单内容扩展规格
I4WTQ2 【新增规格】List组件增加内容拖拽能力规格
I4WTQ4 【新增规格】Grid组件增加内容拖拽能力规格
I4WYNA 【新增规格】Dialog弹窗组件特性增强:支持自定义位置弹窗
I4WTQX 【新增特性】图案密码组件特性支持
I4QC4N 【新增规格】Select组件支持
I4QC4O 【新增规格】TextInput组件能力增强
I4WTPY 【新增规格】文本组件支持鼠标拖拽选择文字规格
I4WTRS 【新增特性】XComponent组件特性支持声明式范式规格
I4WTR9 【新增特性】鼠标按键、滚轮事件支持
I4WTQI 【新增规格】拖拽能力增加鼠标拖拽规格
I4RCRC 【新增特性】样式状态编译转换支持
I4WTPS 【新增规格】新增Touch事件支持多点触控信息
I4RCRF 【新增特性】新增自定义组件支持访问子组件数据
I4X27K 【新增特性】新增侧边栏组件
I4RA0G 【新增规格】卡片支持鼠标悬停事件
I4WTQV 【新增特性】增加场景数据存储特性
I4RCRK 【DFX】ArkUI 框架超时检测机制
I4RCJ8 【IDE工具支持】渲染流水线耗时打印
I4RCRM 【IDE工具支持】交互事件回调耗时打印
I4WTR7 【新增特性】Web组件能力支持
I4WTRA 【新增特性】路由信息分布式迁移支持
I4X29K 【新增特性】ContextMenu组件支持
I4WTQJ 【新增规格】输入组件键盘快捷键支持
I4WTQK 【新增特性】鼠标双击选字
I4WTPG 【新增规格】基础动画参数配置增强
I4X26M 【新增规格】列表容器支持鼠标框选和键盘鼠标组合键多选功能
I4X26Y 【新增规格】网格容器支持鼠标框选和键盘鼠标组合键多选功能
I4WTR8 【新增特性】焦点设置支持
I4U5XM 【新增规格】ArkUI Loader支持JS文件条件编译能力
I4WTQN 【新增特性】新增RichText标签 | NA | +| 程序访问控制子系统 | - 新增对本地应用权限的定义、管理、授权、查询、鉴权功能的支持。
- 新增对分布式权限的管理、查询、鉴权、同步功能的支持。
主要涉及如下需求:
I4WVMH 【新增规格】系统的应用权限初始化预置定义
I4WVO9  【新增规格】应用权限申请列表查询
I4WVPH  【新增规格】AT同步服务基本框架
I4WVPV  【新增规格】本地权限校验接口和机制
I4WVQT  【新增规格】native的Token创建和更新机制
I4WVR3  【新增规格】应用权限的设置接口和机制
I4WVRG 【新增规格】AT管理服务基本框架
I4WVRR 【新增规格】Hap应用token查询接口
I4WVS6  【新增规格】Hap应用的Token信息删除机制
I4WVSI   【新增规格】Hap应用的Token创建和更新机制
I4TYDA  【新增规格】token信息跨设备同步
I4TYCV  【新增规格】设备上线时的native进程的token信息同步
I4V02K  【新增规格】主体设备上应用授权状态更新同步
I4V02Y  【新增规格】主体设备上应用卸载时同步
I4V032  【新增规格】应用权限管理界面实现
I4V038  【新增规格】实现通过应用权限管理界面设置应用权限
I4TYCK  【新增规格】分布式权限校验接口和机制
I4TYDO 【新增规格】设备下线时的token信息删除
I4SEZD  【新增规格】动态权限弹窗界面实现
I4SEZ7  【动态权限设置】实现动态权限授权机制 | NA | +| 语言编译运行时子系统 | - 语言编译运行时:提供适应多端的基础JS工具链及运行时,端侧提供JS引擎支撑应用运行。
- TS/JS公共基础库:TS/JS公共基础类库提供基础功能及TS/JS多线程能力
- TS/JS/C/C++工具链:支持开发者开发调试调优的基本需求
- Lite Actor:轻量化Actor模型,共享字节码及虚拟机内部基础设施,优化目前JS引擎的实现,优化内存占用、提升启动性能。
- High Perf Partial GC:方舟GC支持并发标记、并行标记、懒清理,减少50%的GC停顿时间,改善用户体验。
  主要涉及如下需求:
  I4W7ZR【新增规格】内存管理分配回收功能/HPP GC性能调优
  I4P7F7【语言编译运行时,图形图像,DRF】Native SDK整体集成
  I4WWKK【增强特性】Actor轻量化1.0 | NA | +| 升级服务子系统 | - 升级服务子系统各部件的标准化
- 支持syscap机制
主要涉及如下需求:
I4WXHW【部件化专项】升级服务子系统部件标准化
I4XXH6【SysCap】升级服务子系统支持SysCap机制 | NA | +| Misc软件服务子系统 | - 新增时间时区同步的支持管理能力的支持
- 新增对剪切板数据项进行进行查询、设置、删除、替换等能力的支持
- 新增对锁屏服务管理能力的支持
- 新增对静态壁纸管理能力的支持
- 新增对下载服务管理能力的支持
主要涉及如下需求:
I4U2WR 新增特性:时间时区同步管理
I4ZTTE【新增特性】剪贴板数据项-支持将剪贴板数据项强制转换为文本
I4ZTTO【新增特性】剪贴板数据-支持增加获取、删除、替换剪贴板数据中的数据项;支持查询与设置剪贴板数据属性
I4ZTTZ【新增特性】系统剪贴板-支持获取、清理、查询剪贴板的剪贴板数据;支持剪贴板内容变化通知
I4ZTZC【新增特性】锁屏管理服务-支撑多用户场景
I4ZTZT【新增特性】锁屏管理服务-支撑系统开机、亮灭屏场景
I4ZU1S【新增特性】静态壁纸
I4ZTXT【request部件】下载管理-支持新建、移除、修改、查询下载任务、支持暂停、恢复下载任务、支持监听下载任务进度、下载状态变更通知;下载管理服务,提供系统下载管理DataAbility,处理下载任务数据的持久化,提供系统下载管理服务,处理应用接口权限检查、执行http下载和处理下载异常 | NA | +| 轻内核子系统 | NA | 对于轻量系统:
I4RD3H M核增加了signal、pipe、poll、select等POSIX接口
I4Q9OQ 支持Cortex-M55架构
I4Q9F2 支持动态加载机制
I4RD2M 内核部件化 | +| 文件管理子系统 | - 支持基础文件系统ext4/f2fs能力及相关工具,支持分布式文件系统跨设备文件访问能力。
- 支持设备存储管理功能,包括文件加密、空间管理与统计、多用户空间管理、外卡挂载管理等能力。
- 增强应用数据保护,建立应用沙箱隔离机制;优化用户数据管理,包括用户数据沙箱隔离安全性增强、用户文件访问框架与接口。
- 基础文件操作API能力补齐,包括statfs占用空间统计、文件访问异步接口等能力。
主要涉及如下需求:
I4RDNG【新增特性】【local_file_system】支持ext4/f2fs等用户态工具的能力
I4RFBD【新增特性】【local_file_system】支持fat/exfat/ntfs等可插拔文件系统能力
I4TTN8【新增特性】支持分布式文件系统的基础功能
I4TTNG【新增特性】支持数据分类设备分级,控制数据流转规格
I4TTGR【新增特性】【storage_manager部件】文件加密特性使能
I4TTHQ【新增特性】支持外部存储访问需求
I4TTJN【新增特性】支持外卡设备相关事件分发特性
I4TTJV【新增特性】支持卷信息查询和管理特性
I4XXIR【新增特性】响应多用户创建删除,进行用户目录创建和删除
I4XXIY【新增特性】支持应用占用空间统计特性
I4SNSU【新增特性】支持应用沙箱隔离能力
I4XXIX【新增特性】支持file picker需要的JS API文件接口需求
I4MBS2【新增特性】支持statfs API能力需求 | NA | +| 事件通知子系统 | - 新增支持多用户。
- 新增支持分布式通知。
- 新增通知模板功能。
主要涉及如下需求:
I4PBOK 【新增特性】通知支持多用户
I4PBP7 【新增特性】支持应用发送模板通知(调试能力)
I4PBPE 【新增特性】支持进度条通知
I4PBPM 【增强特性】分布式通知支持流控
I4PBRM 【新增特性】支持其他设备的通知点击后在本设备跳转
I4PBRW 【新增特性】支持设备级的分布式通知使能控制
I4PBSE 【新增特性】支持通知管理应用设置和查询应用级的分布式通知使能
I4PBSP 【新增特性】支持应用设置分布式通知能力是否使能
I4PBT7 【新增特性】分布式通知同步
I4PBU3 【新增特性】分布式通知联动取消
I4PBUU 【新增规格】 支持通过config.json静态配置公共事件,支持通过wokscheduler静态拉起订阅者
I4PBV9 【新增规格】 支持静态订阅者管控
I4WTGK 【新增特性】支持模板通知注册、查询和发送
I4PBSZ 【新增特性】根据设备状态决策通知是否提醒
I4PBBV 【新增特性】事件耗时调用
I4PD0O 【特性增强】通知发送使能能力增强
I4PBQ1 【增强特性】分布式通知能力支持dump命令
I4PBR0 【新增特性】支持其他设备的通知点击后在跨设备跳转
I4PC2S 【新增特性】公共事件支持多用户特性 | NA | +| 泛Sensor服务子系统 | - 新增常见传感器加速度、陀螺仪、霍尔等的数据上报。
- 新增马达振动的基本能力。
- 新增通用算法能力和地磁场算法能力。
主要涉及如下需求:
I4WWTG【miscdevice部件】Miscdevice支持周边依赖
I4WWTF【sensor部件】Sensor支持周边依赖
I4WWTD【sensor部件】支持通用的算法接口
I4MBRQ【sensor部件】地磁场水平强度、总强度
I4MBRP【sensor部件】地磁场偏角和倾角 | NA | +| 分布式数据管理 | - 新增对分布式数据对象能力的支持,分布式能力覆盖内存JS对象;新增分布式关系型数据管理能力,支持直接基于关系型表数据同步
- 新增按条件数据同步&订阅能力,数据同步更精准
- 新增文件上传功能支持
- 构建数据加密和安全分级能力,完善数据流转过程的安全管控,支持多用户同步与隔离
主要涉及如下需求:
I4IBPH【distributed_kv_store】分布式数据服务缺失功能补齐
I4MBRS【distributed_kv_store】分布式数据库支持按谓词查询条件进行数据库记录的跨设备同步和订阅
I4MBRU【RDB】支持数据库加密
I4NZVP【distributed_kv_store】提供分布式数据库JS API
I4HAMI【data_share_ability】支持跨应用订阅数据库的变化
I4NZP6【RDB】增加多表查询能力
I4FZ6B【RDB】提供事务能力
I4HAMI 【data_share_ability】支持跨应用订阅数据库的变化
I4PNX7  【分布式RDB】数据存储需求
I4HAMD【data_share_ability】支持对数据访问方式的控制
I4H4FH 【distributed_kv_store】分布式数据库支持分类分级
I4H3M8【新增特性】分布式数据对象支持复杂类型
I4HAMD【data_share_ability】支持对数据访问方式的控制
I4PO00【分布式RDB】数据同步需求
I4OTW6【distributed_kv_store】分布式数据库Query支持InKeys谓词
I4RGFY【DataShare】基于ExtensionAbility新框架重构并提供单设备上跨应用数据共享能力
I4H4FR【distributed_kv_store】支持多用户数据隔离和共享
I4RGFY【DataShare】基于ExtensionAbility新框架重构并提供单设备上跨应用数据共享能力
I4XXGF【request部件】文件上传功能 | 对于轻量、小型系统:
分布式数据对象支持小型系统设备
主要涉及如下需求:
I4H3JJ分布式对象支持小型系统设备 | +| DFX子系统 | 新增系统和应用Watchdog检测,NativeCrash、JSCrash日志采集能力。
新增JS应用异常行为检测模式能力。
新增系统和进程状态信息导出能力,JS App获取底层内存、CPU、虚拟机信息的能力能力。
新增分布式跟踪调试能力。
增强流水日志、系统事件、应用事件能力。
主要涉及如下需求:
I4PJE3【新增特性】Standard设备上的hidumper框架和工具
I4MBRE【hiperf部件】性能数据计数统计
I4U0KP【profiler部件】cpu profiler功能
I4PJE5【新增特性】支持JS app native内存信息调试调优能力
I4Q6AQ【新增特性】Watchdog机制
I4U0JZ【新增特性】供OpenHarmony hisysevent系统事件管理
I4Q6B6【增强特性】支持HiTrace JS接口
I4Q6AY【新增特性】在OpenHarmony上提供检测模式框架和检测模式基本功能 | NA | +| 驱动子系统 | - 持续增强HDF框架能力,包括hcs配置解析、电源管理等机制;
- 针对HDI管理框架,新增支持共享内存队列、HDI服务按需启动;
- 新增用户态PLATFORM接口,支持用户态驱动开发;
- 外设模块扩展200+HDI接口定义,涵盖显示、音频、相机、传感器、电源、USB等功能模块,使设备接口数量达到600+,为系统提供更多的硬件访问能力。
主要涉及如下需求:
I4HPR7【增强特性】提供hcs宏式解析接口
I4LZZF【增强特性】支持同步/异步电源管理调用
I4QEKH【新增特性】提供共享内存相关HDI能力
I4QEKI【新增特性】驱动开发工具支持标准系统驱动开发
I4QEKZ【新增特性】支持用户态平台驱动接口
I4QEKL【新增特性】基于HDF驱动框架构建统一的平台驱动对象模型
I4QELC【新增特性】支持UHDF类进程按需启动
I4QEKJ【新增特性】HDI接口适配linux-input驱动
I4QEKM【新增特性】提供power HDI接口能力
I4QEKK【新增特性】基于HDF驱动框架提供硬件TIMER驱动
I4QEKP【新增特性】基于HDF驱动框架提供light驱动能力
I4MBTP【增强特性】传感器驱动模型能力增强
I4MBTQ【增强特性】传感器器件驱动能力增强
I4MBTR【增强特性】Display HDI针对标准系统的参考实现
I4MBTS【新增特性】HDF-Input设备能力丰富
I4QEKP【新增特性】基于HDF驱动框架提供light驱动能力
I4QEKQ【新增特性】Display HDI接口实现服务化
I4QEL2【增强特性】马达驱动模型能力增强
I4XXGZ【新增特性】基于HDF驱动框架提供计步器Sensor驱动能力 | 对于轻量、小型系统:
提供HCS宏式解析接口,编译节省配置所占内存
主要涉及如下需求:
I4TFTB【新增特性】轻量系统新增HCS宏式解析接口 | +| USB服务子系统 | - 构建了完整的USB服务管理框架,包括host、device功能模块。
- 支持Port切换功能,实现不同功能模式的切换。
- 提供了USB JS API接口,支持应用开发。
- 定义并实现了USB HDI,提供规范的USB驱动能力访问接口。
主要涉及如下需求:
I4MBRK【新增特性】USB服务JS接口实现
I4QEKV【新增特性】USB服务 HDI接口实现
I4QEKN【新增特性】USB Device功能实现
I4QEKO【新增特性】USB Host功能实现
I4QEL6【新增特性】USB Port功能实现 | NA | +| 编译构建子系统 | - 新增归一的部件定义和编译。
- 新增统一的编译框架,包括统一的gn模板、统一的部件配置、统一的产品配置、统一的编译命令和统一的编译流程。
- 新增支持Native SDK编译发布。
- 新增编译系统支持Kconfig配置框架。
- 扩展增强了hb能力,包括统一使用hb编译入口、编译构建日志按级别显示和hb命令安装、集成及扩展支持。
- 制定gn编码规范和最佳实践指导。 | 对于轻量、小型系统,特性变更同标准系统。 | +| 测试子系统 | - 新增OpenHarmony自动化测试框架能力,支持单元/UI基础测试脚本编写运行能力。
- 新增OpenHarmony-wukong工具,支持整机/单应用级别随机事件注入压测能力。
- 新增SmartPerf性能测试工具,支持基础性能数据如FPS、CPU、内存等采集展示能力。
- 完善测试调度框架能力,新增自动化用例执行配置、执行设配管理能力。
- 新增DCTS兼容性测试套件,支持分布式软总线、分布式数据兼容测试。
- 增强ACTS、HATS兼容性测试套件,覆盖3.1 Release新增对外公共JS API和HDF API。
主要涉及如下需求:
I4XXCR 【测试框架】界面自动化测试
I4XXCV 【测试框架】TS开发者测试框架
I4XXCW 【测试框架】JS应用开发者测试框架
I4XXD0 【测试框架】执行器设备管理
I4XXCX 【测试框架】测试流水线测试套执行报表
I4XXCZ 【测试框架】用例配置管理
I4XXD0 【测试框架】执行器设备管理
I4XGLQ 【新增特性】UI随机压测工具
I4XXD7 【认证测试】DCTS3.1分布式兼容性测试套件 | NA | +| 启动子系统 | - 新增支持进程分组及并行启动。
- 新增支持按需启动SA服务、UHDF服务或者根据热插拔事件启动服务。
- 新增支持为服务创建socket或者为退出的进程代持fd。
- 统一init的维护命令为begetctl。
- 完善进程退出后的回收策略,支持核心进程退出后重启;非核心进程频繁挂死时隔离。
主要涉及如下需求:
I4UTCF【新增特性】进程分组及并行启动基础框架
I4UGE9 添加bootchart功能
I4UP28 动态文件selinux标签适配
I4UTCO 【增强特性】支持app进程孵化能力增强
I4UTCY 【增强特性】appspawn支持孵化的应用进程回收
I4RXJ2 【新增规格】统一init维护命令
I4RXJ9 【新增特性】支持服务类进程按需启动
I4TNBV 【新增规格】进程启动配置能力增强
I4PD3K 进程退出后的回收处理策略配置能力增强 | NA | +| 用户IAM子系统 | - 新增实现多用户身份管理和用户身份认证功能特性;
- 新增统一用户身体认证框架,支持管理各种认证方式
- 新增支持口令认证功能
- 新增支持人脸认证功能
主要涉及如下需求:
I4RG55【新增规格】【user_idm】支持用户本地认证凭据信息查询
I4RG5R【新增规格】【user_idm】支持删除用户时,删除该用户的身份认证凭据
I4RG8W 【新增规格】【pin_auth】支持用户本地口令录入
I4RG91【新增规格】【pin_auth】支持用户本地口令认证
I4RGWU【新增规格】【pin_auth】支持用户本地口令删除
I4TSK7 【新增规格】【face_auth】支持用户本地人脸删除
I4TSJE【新增规格】【face_auth】支持用户本地人脸录入
I4TSJY【新增规格】【face_auth】支持用户本地人脸认证 | NA | +| 安全基础能力子系统 | - 新增实现设备安全等级管理框架,提供组网内指定设备的安全等级查询。
- 新增数据跨设备流转时的管控策略,满足终端内部数据处理、流转时的数据安全管控提供基础的底座机制。
- 新增提供统一的秘钥管理服务,为系统应用和上层业务提供本地秘钥全生命周期的管理。
- 新增支持OpenHarmony使能设备互信认证能力,为系统的设备安全连接提供保障。
主要涉及如下需求:
I4RTYU【新增特性】【服务】支持被组网内其它设备查询自己的设备安全等级信息
I4RTYW【新增特性】【服务】支持获取自己或者组网内其它设备的设备安全等级信息
I4TJFZ【增强特性】DeviceAuth部件支持设备间互信关系认证的多用户隔离,使用指定系统用户下管理的互信关系进行认证
I4TJG1【增强特性】DeviceAuth部件实现互信群组数据多实例,支持指定用户的数据查询。
I4TJG3【增强特性】DeviceAuth部件支持帐号无关点对点信任关系建立、解除的多用户数据隔离
I4TT8L【新增规格】HUKS提供三段式密钥管理接口
I4TYEM【新增规格】HUKS支持安全等级凭据的导入签发及验证
I4TYFI【新增规格】HUKS在删除子用户情况下,需要删除相关的密钥数据
I4TYFR【新增规格】HUKS在删除应用的情况下,HUKS需要删除相关的密钥数据
I4TYFA【新增规格】HUKS支持密钥应用基于APP UID的访问隔离
I4TYF1【新增规格】HUKS支持key attestation和id attestation
I4SAI0【新增特性】提供DataTransitMgrLib部件,支持数据跨设备流转时的管控策略 | NA | +| 应用子系统 | 系统应用提供了OpenHarmony标准系统上的部分应用,如桌面、SystemUI、设置等,为开发者提供了构建标准系统应用的具体实例,这些应用支持在所有标准系统设备上使用。
- 桌面:提供了基本的已安装应用的展示功能和人机交互界面,是所有应用的入口。
- SystemUI:包含导航栏和系统状态栏两部分,导航栏提供基本页面导航功能、状态栏提供系统状态显示,如时间、充电状态等。
- 设置:提供了关于设备,应用管理,亮度设置等功能。
- 联系人:提供了拨号盘、通话记录查看/删除、联系人列表、详情查看和新建联系人等功能。
- 短信:提供了信息查看、发送短信、接收短信、短信送达报告、删除短信等功能。
- 通话:提供了语音通话接听和挂断,移动数据开关等功能。
- 相机:提供了预览、拍照、缩略图显示、跳转大图浏览等功能。
- 图库:提供了图片、视频和相册的管理、浏览、显示、编辑操作等功能。
- 输入法:提供硬键盘输入、编辑框选择文本变化、光标位置变化反馈等功能。
  说明:OpenHarmony 3.1 Release版本,仅图库系统应用代码可配套发布的IDE、SDK编译成功。 | NA | + + +API变更请参考: + + +_[JS API 差异报告](api-change/v3.1-Release/js-apidiff-v3.1-release.md)_ + + +_[Native API差异报告](api-change/v3.1-Release/native-apidiff-v3.1-release.md)_ + + +### 芯片及开发板适配 + +芯片及开发板适配状态请参考[SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard_cn.md)信息。 + + +### Samples + +**表4** 新增Samples + +| 子系统 | 名称 | 简介 | 开发语言 | +| -------- | -------- | -------- | -------- | +| 电话服务 | [短信服务](https://gitee.com/openharmony/app_samples/tree/master/Telephony/Message) | 本示例展示了电话服务中发送短信的功能。 | eTS | +| 电话服务 | [网络搜索](https://gitee.com/openharmony/app_samples/tree/master/Telephony/RadioTech) | 本示例通过eTS来展示电话服务中网络搜索功能,包含无线接入技术、网络状态、选网模式、ISO国家码、信号强度信息列表及Radio是否打开。 | eTS | +| 设备管理 | [系统电源管理](https://gitee.com/openharmony/app_samples/tree/master/common/PowerManager) | 本示例展示了关机、重启以及检测亮灭屏状态的功能。 | eTS | +| 设备管理 | [传感器](https://gitee.com/openharmony/app_samples/tree/master/device/SenSor) | 本示例采用了传感器接口中的方向传感器,实现了指南针的效果。 | eTS | +| 设备管理 | [设备管理](https://gitee.com/openharmony/app_samples/tree/master/device/DeviceManager) | 本示例展示了在eTS中DeviceManager接口的使用,包括获取授信设备列表,设备扫描,设备认证,设备状态订阅。 | eTS | +| 帐号管理 | [应用帐号管理](https://gitee.com/openharmony/app_samples/tree/master/Account/AppAccountManager) | 本示例选择应用进行注册/登录,并设置帐号相关信息,简要说明应用帐号管理相关功能。 | eTS | +| ArkUI | [web](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Web) | 本示例主要展示了web的功能页面。 | eTS | +| ArkUI | [拖拽](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Drag) | 本示例主要展示了拖拽操作的功能。 | eTS | +| ArkUI | [动画](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/ArkUIAnimation) | 本示例通过点击按钮触发动画,向用户展示属性动画与显示动画的效果。 | eTS | +| 数据管理 | [分布式数据库-结果集和谓词查询](https://gitee.com/openharmony/app_samples/tree/master/data/DDMQuery) | 本示例展示了分布式数据管理中,如何通过构建query对象, 查询kvstore中的数据,获取结果集。 | eTS | +| 数据管理 | [关系型数据库](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) | 本示例展示了在eTS中关系型数据库的使用,包括增、删、改、查等操作。 | eTS | +| 事件 | [后台代理提醒](https://gitee.com/openharmony/app_samples/tree/master/Notification/AlarmClock) | 本示例通过模拟闹钟来展示后台代理提醒的使用方法。 | eTS | +| 事件 | [事件通知](https://gitee.com/openharmony/app_samples/tree/master/Notification/Emitter) | 本示例主要展示进程内事件通知,用户通过选择对应商品并提交订单后在订单列表显示所选商品。 | eTS | +| 通信与连接 | [RPC通信](https://gitee.com/openharmony/app_samples/tree/master/Communication/RPC) | 本示例展示了同一设备中前后台的数据交互,用户前台选择相应的商品与数目,后台计算出结果,回传给前台展示。 | eTS | +| 通信与连接 | [WLAN](https://gitee.com/openharmony/app_samples/tree/master/Communication/Wlan) | 本示例展示了在eTS中WLAN的基本使用,包括禁用和启用WLAN、WLAN扫描和获取扫描结果、WLAN状态监听、WiFi连接状态监听、获取IP信息、获取国家码、判断设备是否支持WLAN相关特性。 | eTS | +| 媒体服务 | [录音机Demo](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) | 本示例展示媒体服务中音频录制和播放功能的使用。 | eTS | +| 媒体服务 | [多媒体Demo](https://gitee.com/openharmony/app_samples/tree/master/media/MultiMedia) | 本示例展示如何在eTS中调用相机拍照和录像,以及如何使用媒体库接口进行媒体文件的增、删、改、查操作。 | eTS | + +请访问[Samples](https://gitee.com/openharmony/app_samples)仓了解更多信息。 + + +## 修复缺陷列表 + +**表5** 修复缺陷ISSUE列表 + +| ISSUE单 | 问题描述 | +| -------- | -------- | +| [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | 【hdf/camera】RK3568单板跑camera HDI用例失败 | +| [I4OECR](https://gitee.com/openharmony/ark_js_runtime/issues/I4OECR) | XTS运行报ark异常栈(低概率问题) | +| [I4OBTW](https://gitee.com/openharmony/aafwk_standard/issues/I4OBTW) | 全量执行XTS用例,安装应用后出现批量aa start 失败,影响社区流水线稳定性测试 | +| [I4OLHF](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLHF?from=project-issue) | 【ArkUI子系统】 由进程com.amsst.amsMissionSnapshotTest导致测试进程异常 | +| [I4OLUK](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLUK) | 【ArkUI子系统】 由进程com.ohos.systemui导致进程栈异常 | + + +## 遗留缺陷列表 + +**表6** 遗留缺陷列表 + +| ISSUE | 问题描述 | 影响 | 计划解决日期 | +| -------- | -------- | -------- | -------- | +| [I4NRS5](https://gitee.com/openharmony/kernel_linux_5.10/issues/I4NRS5) | 【内核子系统】存在cve漏洞 | Linux内核还未发布补丁,暂时挂起,待社区发布补丁后升级同步。 | 待社区发布补丁 | +| [I4UUFR](https://gitee.com/openharmony/third_party_e2fsprogs/issues/I4UUFR) | 本地编译构建Hi3516开发板版本镜像 | 编译Hi3516版本时偶现编译失败,重新下载代码可恢复。 | 2022-04-30 | +| [I4RJU8](https://e.gitee.com/open_harmony/issues/list?issue=I4RJU8) | Hi3516标准系统camera 预览黑屏 | 影响标准系统Hi3516 camera预览功能。 | 2022-05-30 | +| [I4Z3G9](https://e.gitee.com/open_harmony/issues/list?issue=I4Z3G9) | 【图形子系统】【RK3568】打开沉浸式主窗口和在主窗口上打开辅助窗口出现闪屏 | 打开沉浸式主窗口和在主窗口上打开辅助窗口出现闪屏,影响体验。 | 2022-04-15 | +| [I50EBB](https://gitee.com/openharmony/docs/issues/I50EBB?from=project-issue) | 【Hi3516烧录】标准系统Hi3516镜像无法通过IDE烧录 | 仅在IDE版本上Ubuntu环境烧录不成功。
**规避方案:** 通过remote方式在Windows上烧录。
**后续方案:**
改成Windows+Ubuntu混合模式,在Windows界面操作远程的Ubuntu开发、编译、调试;烧录自动回传到Windows上进行。 | 2022-04-30 | diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index d40a73d8785ef056c10a13926d70dc64689aae07..89084fe567535e0a0a190bbeb696d25a3bde438e 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -1,5 +1,6 @@ # OpenHarmony Release Notes ## OpenHarmony 3.x Releases +- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](OpenHarmony-v3.1-beta.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) diff --git a/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md b/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md deleted file mode 100644 index 570a1c598c434e7aed19caab163158370a293eb3..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md +++ /dev/null @@ -1,16 +0,0 @@ -# ChangeLog -**关键的接口/组件变更** -## XXX子系统 -### cl.rpc.1 sendRequest返回值类型变更 - -#### 变更影响 -…… - -#### 关键的接口/组件变更 -**模块** -**接口** -**变更后接口** -…… - -#### 适配指导 -…… diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ability.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ability.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..099ecf9f3b762aeee0795ebb62af347783c54569 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ability.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ability.md @@ -1,14 +1,169 @@ -# xxx子系统JS API变更 +# 元能力子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,元能力子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| featureability | FeatureAbility | static getDeviceList(flag: number): Promise; | 新增 | +| customizeData | CustomizeData | extra: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly entityType: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly uid: number; | 新增 | +| applicationInfo | ApplicationInfo | readonly accessTokenId: number; | 新增 | +| applicationInfo | ApplicationInfo | readonly removable: boolean; | 新增 | +| applicationInfo | ApplicationInfo | readonly metaData: Map>; | 新增 | +| applicationInfo | ApplicationInfo | readonly codePath: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly moduleInfos: Array; | 新增 | +| shellCmdResult | ShellCmdResult | exitCode: number; | 新增 | +| shellCmdResult | ShellCmdResult | stdResult: String; | 新增 | +| ProcessRunningInfo | ProcessRunningInfo | bundleNames: Array; | 新增 | +| ProcessRunningInfo | ProcessRunningInfo | processName: string; | 新增 | +| ProcessRunningInfo | ProcessRunningInfo | uid: number; | 新增 | +| ProcessRunningInfo | ProcessRunningInfo | pid: number; | 新增 | +| BaseContext | BaseContext | stageMode: boolean; | 新增 | +| abilityDelegatorArgs | AbilityDelegatorArgs | testRunnerClassName: string; | 新增 | +| abilityDelegatorArgs | AbilityDelegatorArgs | testCaseNames: string; | 新增 | +| abilityDelegatorArgs | AbilityDelegatorArgs | parameters: {[key: string]: string}; | 新增 | +| abilityDelegatorArgs | AbilityDelegatorArgs | bundleName: string; | 新增 | +| abilityDelegator | AbilityDelegator | executeShellCommand(cmd: string, callback: AsyncCallback): void;
executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;
executeShellCommand(cmd: string, timeoutSecs?: number): Promise; | 新增 | +| abilityDelegator | AbilityDelegator | print(msg: string, callback: AsyncCallback): void;
print(msg: string): Promise; | 新增 | +| context | Context | printDrawnCompleted(callback: AsyncCallback): void;
printDrawnCompleted(): Promise; | 新增 | +| context | Context | isUpdatingConfigurations(callback: AsyncCallback): void;
isUpdatingConfigurations(): Promise; | 新增 | +| context | Context | getAbilityInfo(callback: AsyncCallback): void
getAbilityInfo(): Promise; | 新增 | +| context | Context | getApplicationContext(): Context; | 新增 | +| context | Context | getAppVersionInfo(callback: AsyncCallback): void
getAppVersionInfo(): Promise; | 新增 | +| context | Context | getHapModuleInfo(callback: AsyncCallback): void
getHapModuleInfo(): Promise; | 新增 | +| context | Context | getAppType(callback: AsyncCallback): void
getAppType(): Promise; | 新增 | +| context | Context | getOrCreateDistributedDir(): Promise;
getOrCreateDistributedDir(callback: AsyncCallback): void; | 新增 | +| context | Context | getCacheDir(callback: AsyncCallback): void;
getCacheDir(): Promise; | 新增 | +| context | Context | getFilesDir(callback: AsyncCallback): void;
getFilesDir(): Promise; | 新增 | +| context | Context | setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback): void
setWakeUpScreen(wakeUp: boolean): Promise; | 新增 | +| context | Context | setShowOnLockScreen(show: boolean, callback: AsyncCallback): void
setShowOnLockScreen(show: boolean): Promise; | 新增 | +| context | Context | setDisplayOrientation(orientation: DisplayOrientation, callback: AsyncCallback): void
setDisplayOrientation(orientation: DisplayOrientation): Promise; | 新增 | +| context | Context | getDisplayOrientation(callback: AsyncCallback): void
getDisplayOrientation(): Promise; | 新增 | +| appVersionInfo | AppVersionInfo | readonly versionName: string; | 新增 | +| appVersionInfo | AppVersionInfo | readonly versionCode: number; | 新增 | +| appVersionInfo | AppVersionInfo | readonly appName: string; | 新增 | +| dataAbilityHelper | PacMap | [key: string]: number \| string \| boolean \| Array \| null; | 新增 | +| dataAbilityHelper | DataAbilityHelper | executeBatch(uri: string, operations: Array, callback: AsyncCallback>): void;
executeBatch(uri: string, operations: Array): Promise>; | 新增 | +| dataAbilityHelper | DataAbilityHelper | call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void;
call(uri: string, method: string, arg: string, extras: PacMap): Promise; | 新增 | +| ohos.application.Want | Want | entities?: Array; | 新增 | +| ohos.application.Want | Want | parameters?: {[key: string]: any}; | 新增 | +| ohos.application.Want | Want | action?: string; | 新增 | +| ohos.application.Want | Want | flags?: number; | 新增 | +| ohos.application.Want | Want | type?: string; | 新增 | +| ohos.application.Want | Want | uri?: string; | 新增 | +| ohos.application.Want | Want | abilityName?: string; | 新增 | +| ohos.application.Want | Want | bundleName?: string; | 新增 | +| ohos.application.Want | Want | deviceId?: string; | 新增 | +| ohos.application.testRunner | TestRunner | onRun(): void; | 新增 | +| ohos.application.testRunner | TestRunner | onPrepare(): void; | 新增 | +| ohos.application.formProvider | formProvider | function updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback): void;
function updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise; | 新增 | +| ohos.application.formProvider | formProvider | function setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback): void;
function setFormNextRefreshTime(formId: string, minute: number): Promise; | 新增 | +| ohos.application.formInfo | FormParam | TEMPORARY_KEY = "ohos.extra.param.key.form_temporary" | 新增 | +| ohos.application.formInfo | FormParam | HEIGHT_KEY = "ohos.extra.param.key.form_height" | 新增 | +| ohos.application.formInfo | FormParam | WIDTH_KEY = "ohos.extra.param.key.form_width" | 新增 | +| ohos.application.formInfo | FormParam | MODULE_NAME_KEY = "ohos.extra.param.key.module_name" | 新增 | +| ohos.application.formInfo | FormParam | NAME_KEY = "ohos.extra.param.key.form_name" | 新增 | +| ohos.application.formInfo | FormParam | DIMENSION_KEY = "ohos.extra.param.key.form_dimension" | 新增 | +| ohos.application.formInfo | FormState | READY = 1 | 新增 | +| ohos.application.formInfo | FormState | DEFAULT = 0 | 新增 | +| ohos.application.formInfo | FormState | UNKNOWN = -1 | 新增 | +| ohos.application.formInfo | FormStateInfo | want: Want; | 新增 | +| ohos.application.formInfo | FormStateInfo | formState: FormState; | 新增 | +| ohos.application.formInfo | ColorMode | MODE_LIGHT = 1 | 新增 | +| ohos.application.formInfo | ColorMode | MODE_DARK = 0 | 新增 | +| ohos.application.formInfo | ColorMode | MODE_AUTO = -1 | 新增 | +| ohos.application.formInfo | FormType | JS = 1 | 新增 | +| ohos.application.formInfo | FormInfo | customizeData: {[key: string]: [value: string]}; | 新增 | +| ohos.application.formInfo | FormInfo | supportDimensions: Array; | 新增 | +| ohos.application.formInfo | FormInfo | defaultDimension: number; | 新增 | +| ohos.application.formInfo | FormInfo | updateDuration: number; | 新增 | +| ohos.application.formInfo | FormInfo | formConfigAbility: string; | 新增 | +| ohos.application.formInfo | FormInfo | scheduledUpdateTime: string; | 新增 | +| ohos.application.formInfo | FormInfo | relatedBundleName: string; | 新增 | +| ohos.application.formInfo | FormInfo | formVisibleNotify: boolean; | 新增 | +| ohos.application.formInfo | FormInfo | updateEnabled: boolean; | 新增 | +| ohos.application.formInfo | FormInfo | isDefault: boolean; | 新增 | +| ohos.application.formInfo | FormInfo | colorMode: ColorMode; | 新增 | +| ohos.application.formInfo | FormInfo | jsComponentName: string; | 新增 | +| ohos.application.formInfo | FormInfo | type: FormType; | 新增 | +| ohos.application.formInfo | FormInfo | description: string; | 新增 | +| ohos.application.formInfo | FormInfo | name: string; | 新增 | +| ohos.application.formInfo | FormInfo | abilityName: string; | 新增 | +| ohos.application.formInfo | FormInfo | moduleName: string; | 新增 | +| ohos.application.formInfo | FormInfo | bundleName: string; | 新增 | +| ohos.application.formError | FormError | ERR_IN_RECOVERY = 36 | 新增 | +| ohos.application.formError | FormError | ERR_FORM_DUPLICATE_ADDED = 31 | 新增 | +| ohos.application.formError | FormError | ERR_SYSTEM_RESPONSES_FAILED = 30 | 新增 | +| ohos.application.formError | FormError | ERR_FORM_FA_NOT_INSTALLED = 20 | 新增 | +| ohos.application.formError | FormError | ERR_FORM_NO_SUCH_DIMENSION = 19 | 新增 | +| ohos.application.formError | FormError | ERR_FORM_NO_SUCH_ABILITY = 18 | 新增 | +| ohos.application.formError | FormError | ERR_FORM_NO_SUCH_MODULE = 17 | 新增 | +| ohos.application.formError | FormError | ERR_MAX_SYSTEM_TEMP_FORMS = 16 | 新增 | +| ohos.application.formError | FormError | ERR_MAX_FORMS_PER_CLIENT = 15 | 新增 | +| ohos.application.formError | FormError | ERR_PROVIDER_DEL_FAIL = 14 | 新增 | +| ohos.application.formError | FormError | ERR_OPERATION_FORM_NOT_SELF = 13 | 新增 | +| ohos.application.formError | FormError | ERR_MAX_INSTANCES_PER_FORM = 12 | 新增 | +| ohos.application.formError | FormError | ERR_MAX_SYSTEM_FORMS = 11 | 新增 | +| ohos.application.formError | FormError | ERR_BIND_PROVIDER_FAILED = 10 | 新增 | +| ohos.application.formError | FormError | ERR_NOT_EXIST_ID = 9 | 新增 | +| ohos.application.formError | FormError | ERR_CFG_NOT_MATCH_ID = 8 | 新增 | +| ohos.application.formError | FormError | ERR_ADD_INVALID_PARAM = 7 | 新增 | +| ohos.application.formError | FormError | ERR_GET_LAYOUT_FAILED = 6 | 新增 | +| ohos.application.formError | FormError | ERR_GET_BUNDLE_FAILED = 5 | 新增 | +| ohos.application.formError | FormError | ERR_GET_INFO_FAILED = 4 | 新增 | +| ohos.application.formError | FormError | ERR_PERMISSION_DENY = 2 | 新增 | +| ohos.application.formError | FormError | ERR_COMMON = 1 | 新增 | +| ohos.application.formBindingData | FormBindingData | data: Object | 新增 | +| ohos.application.formBindingData | formBindingData | function createFormBindingData(obj?: Object \| string): FormBindingData; | 新增 | +| ohos.application.ConfigurationConstant | ColorMode | COLOR_MODE_LIGHT = 1 | 新增 | +| ohos.application.ConfigurationConstant | ColorMode | COLOR_MODE_DARK = 0 | 新增 | +| ohos.application.ConfigurationConstant | ColorMode | COLOR_MODE_NOT_SET = -1 | 新增 | +| ohos.application.Configuration | Configuration | colorMode: ConfigurationConstant.ColorMode; | 新增 | +| ohos.application.Configuration | Configuration | language: string; | 新增 | +| ohos.application.appManager | appManager | function getAppMemorySize(): Promise;
function getAppMemorySize(callback: AsyncCallback): void; | 新增 | +| ohos.application.appManager | appManager | function isRamConstrainedDevice(): Promise;
function isRamConstrainedDevice(callback: AsyncCallback): void; | 新增 | +| ohos.application.appManager | appManager | function getProcessRunningInfos(): Promise>;
function getProcessRunningInfos(callback: AsyncCallback>): void; | 新增 | +| ohos.application.appManager | appManager | function isRunningInStabilityTest(callback: AsyncCallback): void;
function isRunningInStabilityTest(): Promise; | 新增 | +| ohos.application.abilityDelegatorRegistry | AbilityLifecycleState | DESTROY | 新增 | +| ohos.application.abilityDelegatorRegistry | AbilityLifecycleState | BACKGROUND | 新增 | +| ohos.application.abilityDelegatorRegistry | AbilityLifecycleState | FOREGROUND | 新增 | +| ohos.application.abilityDelegatorRegistry | AbilityLifecycleState | CREATE | 新增 | +| ohos.application.abilityDelegatorRegistry | AbilityLifecycleState | UNINITIALIZED | 新增 | +| ohos.application.abilityDelegatorRegistry | abilityDelegatorRegistry | function getArguments(): AbilityDelegatorArgs; | 新增 | +| ohos.application.abilityDelegatorRegistry | abilityDelegatorRegistry | function getAbilityDelegator(): AbilityDelegator; | 新增 | +| ohos.abilityAccessCtrl | GrantStatus | PERMISSION_GRANTED = 0 | 新增 | +| ohos.abilityAccessCtrl | GrantStatus | PERMISSION_DENIED = -1 | 新增 | +| ohos.abilityAccessCtrl | AtManager | verifyAccessToken(tokenID: number, permissionName: string): Promise; | 新增 | +| ohos.abilityAccessCtrl | abilityAccessCtrl | function createAtManager(): AtManager; | 新增 | +| ohos.ability.wantConstant | Action | ACTION_APP_ACCOUNT_OAUTH = "ohos.account.appAccount.action.oauth" | 新增 | +| ohos.ability.wantConstant | Action | ACTION_VIDEO_CAPTURE = "ohos.want.action.videoCapture" | 新增 | +| ohos.ability.wantConstant | Action | ACTION_IMAGE_CAPTURE = "ohos.want.action.imageCapture" | 新增 | +| ohos.ability.particleAbility | ErrorCode | INVALID_PARAMETER = -1 | 新增 | +| ohos.ability.particleAbility | particleAbility | function disconnectAbility(connection: number, callback:AsyncCallback): void;
function disconnectAbility(connection: number): Promise; | 新增 | +| ohos.ability.particleAbility | particleAbility | function connectAbility(request: Want, options:ConnectOptions): number; | 新增 | +| ohos.ability.particleAbility | particleAbility | function cancelBackgroundRunning(callback: AsyncCallback): void;
function cancelBackgroundRunning(): Promise; | 新增 | +| ohos.ability.particleAbility | particleAbility | function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback): void;
function startBackgroundRunning(id: number, request: NotificationRequest): Promise; | 新增 | +| ohos.ability.featureAbility | featureAbility | function getWindow(callback: AsyncCallback): void;
function getWindow(): Promise; | 新增 | +| ohos.ability.errorCode | ErrorCode | NO_ERROR = 0 | 新增 | +| ohos.ability.errorCode | ErrorCode | INVALID_PARAMETER = -1 | 新增 | +| ohos.ability.errorCode | ErrorCode | ABILITY_NOT_FOUND = -2 | 新增 | +| ohos.ability.errorCode | ErrorCode | PERMISSION_DENY = -3 | 新增 | +| lifecycle | LifecycleData | call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback): void; | 新增 | +| lifecycle | LifecycleData | executeBatch?(ops: Array, callback: AsyncCallback>): void; | 新增 | +| lifecycle | LifecycleService | onReconnect?(want: Want): void; | 新增 | +| lifecycle | LifecycleApp | onMemoryLevel?(level: number): void; | 新增 | +| lifecycle | LifecycleApp | onNewWant?(want: Want): void; | 新增 | +| lifecycle | LifecycleApp | onActive?(): void; | 新增 | +| lifecycle | LifecycleApp | onInactive?(): void; | 新增 | +| lifecycle | LifecycleApp | onRestoreAbilityState?(inState: PacMap): void; | 新增 | +| lifecycle | LifecycleApp | onSaveAbilityState?(outState: PacMap): void; | 新增 | +| lifecycle | LifecycleForm | onAcquireFormState?(want: Want): formInfo.FormState; | 新增 | +| lifecycle | LifecycleForm | onDestroy?(formId: string): void; | 新增 | +| lifecycle | LifecycleForm | onEvent?(formId: string, message: string): void; | 新增 | +| lifecycle | LifecycleForm | onVisibilityChange?(newStatus: { [key: string]: number }): void; | 新增 | +| lifecycle | LifecycleForm | onUpdate?(formId: string): void; | 新增 | +| lifecycle | LifecycleForm | onCastToNormal?(formId: string): void; | 新增 | +| lifecycle | LifecycleForm | onCreate?(want: Want): formBindingData.FormBindingData; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-access-control.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-access-control.md deleted file mode 100644 index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-access-control.md +++ /dev/null @@ -1,14 +0,0 @@ -# xxx子系统JS API变更 - -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: - -## 接口变更 - -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..c3dbf5c1e5e29b56ba23e54ae3a5d6293db68fbd 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md @@ -1,14 +1,51 @@ -# xxx子系统JS API变更 +# 无障碍子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,无障碍子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.accessibility | EventInfo | itemCount?: number; | 新增 | +| ohos.accessibility | EventInfo | endIndex?: number; | 新增 | +| ohos.accessibility | EventInfo | currentIndex?: number; | 新增 | +| ohos.accessibility | EventInfo | beginIndex?: number; | 新增 | +| ohos.accessibility | EventInfo | lastContent?: string; | 新增 | +| ohos.accessibility | EventInfo | contents?: Array; | 新增 | +| ohos.accessibility | EventInfo | textMoveUnit?: TextMoveUnit; | 新增 | +| ohos.accessibility | EventInfo | triggerAction: Action; | 新增 | +| ohos.accessibility | EventInfo | description?: string; | 新增 | +| ohos.accessibility | EventInfo | pageId ?: number; | 新增 | +| ohos.accessibility | EventInfo | componentType?: string; | 新增 | +| ohos.accessibility | EventInfo | bundleName: string; | 新增 | +| ohos.accessibility | EventInfo | windowUpdateType?: WindowUpdateType; | 新增 | +| ohos.accessibility | EventInfo | type: EventType; | 新增 | +| ohos.accessibility | EventInfo | constructor(jsonObject); | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly eventTypes: Array; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly description: string; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly capabilities: Array; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly abilityTypes: Array; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly bundleName: string; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly name: string; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly id: string; | 新增 | +| ohos.accessibility | CaptionsStyle | windowColor: number \| string; | 新增 | +| ohos.accessibility | CaptionsStyle | backgroundColor: number \| string; | 新增 | +| ohos.accessibility | CaptionsStyle | fontEdgeType: CaptionsFontEdgeType; | 新增 | +| ohos.accessibility | CaptionsStyle | fontColor: number \| string; | 新增 | +| ohos.accessibility | CaptionsStyle | fontScale: number; | 新增 | +| ohos.accessibility | CaptionsStyle | fontFamily: CaptionsFontFamily; | 新增 | +| ohos.accessibility | CaptionsManager | off(type: 'styleChange', callback?: Callback): void; | 新增 | +| ohos.accessibility | CaptionsManager | off(type: 'enableChange', callback?: Callback): void; | 新增 | +| ohos.accessibility | CaptionsManager | on(type: 'styleChange', callback: Callback): void; | 新增 | +| ohos.accessibility | CaptionsManager | on(type: 'enableChange', callback: Callback): void; | 新增 | +| ohos.accessibility | CaptionsManager | style: CaptionsStyle; | 新增 | +| ohos.accessibility | CaptionsManager | enabled: boolean; | 新增 | +| ohos.accessibility | accessibility | function getCaptionsManager(): CaptionsManager; | 新增 | +| ohos.accessibility | accessibility | function off(type: 'touchGuideStateChange', callback?: Callback): void; | 新增 | +| ohos.accessibility | accessibility | function off(type: 'accessibilityStateChange', callback?: Callback): void; | 新增 | +| ohos.accessibility | accessibility | function on(type: 'touchGuideStateChange', callback: Callback): void; | 新增 | +| ohos.accessibility | accessibility | function on(type: 'accessibilityStateChange', callback: Callback): void; | 新增 | +| ohos.accessibility | accessibility | function sendEvent(event: EventInfo, callback: AsyncCallback): void;
function sendEvent(event: EventInfo): Promise; | 新增 | +| ohos.accessibility | accessibility | function getAbilityLists(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback>): void;
function getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise>; | 新增 | +| ohos.accessibility | accessibility | function isOpenTouchGuide(callback: AsyncCallback): void;
function isOpenTouchGuide(): Promise; | 新增 | +| ohos.accessibility | accessibility | function isOpenAccessibility(callback: AsyncCallback): void;
function isOpenAccessibility(): Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-account.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-account.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..295d765dad890f9437a71c1bf4b73c767a494c3c 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-account.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-account.md @@ -1,14 +1,112 @@ -# xxx子系统JS API变更 +# 账号子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,账号子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.account.osAccount | OsAccountType | GUEST | 新增 | +| ohos.account.osAccount | OsAccountType | NORMAL | 新增 | +| ohos.account.osAccount | OsAccountType | ADMIN = 0 | 新增 | +| ohos.account.osAccount | DomainAccountInfo | accountName: string; | 新增 | +| ohos.account.osAccount | DomainAccountInfo | domain: string; | 新增 | +| ohos.account.osAccount | OsAccountInfo | domainInfo: DomainAccountInfo; | 新增 | +| ohos.account.osAccount | OsAccountInfo | distributedInfo: distributedAccount.DistributedInfo; | 新增 | +| ohos.account.osAccount | OsAccountInfo | isCreateCompleted: boolean; | 新增 | +| ohos.account.osAccount | OsAccountInfo | isActived: boolean; | 新增 | +| ohos.account.osAccount | OsAccountInfo | serialNumber: number; | 新增 | +| ohos.account.osAccount | OsAccountInfo | lastLoginTime: number; | 新增 | +| ohos.account.osAccount | OsAccountInfo | createTime: number; | 新增 | +| ohos.account.osAccount | OsAccountInfo | photo: string; | 新增 | +| ohos.account.osAccount | OsAccountInfo | isVerified: boolean; | 新增 | +| ohos.account.osAccount | OsAccountInfo | constraints: Array; | 新增 | +| ohos.account.osAccount | OsAccountInfo | type: OsAccountType; | 新增 | +| ohos.account.osAccount | OsAccountInfo | localName: string; | 新增 | +| ohos.account.osAccount | OsAccountInfo | localId: number; | 新增 | +| ohos.account.osAccount | AccountManager | getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback): void;
getSerialNumberByOsAccountLocalId(localId: number): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void;
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getDistributedVirtualDeviceId(callback: AsyncCallback): void;
getDistributedVirtualDeviceId(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountTypeFromProcess(callback: AsyncCallback): void;
getOsAccountTypeFromProcess(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | queryCurrentOsAccount(callback: AsyncCallback): void;
queryCurrentOsAccount(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | queryActivatedOsAccountIds(callback: AsyncCallback>): void;
queryActivatedOsAccountIds(): Promise>; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountAllConstraints(localId: number, callback: AsyncCallback>): void;
getOsAccountAllConstraints(localId: number): Promise>; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback): void;
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback): void;
getOsAccountLocalIdFromUid(uid: number): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromProcess(callback: AsyncCallback): void;
getOsAccountLocalIdFromProcess(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | getCreatedOsAccountsCount(callback: AsyncCallback): void;
getCreatedOsAccountsCount(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | isOsAccountVerified(callback: AsyncCallback): void;
isOsAccountVerified(localId: number, callback: AsyncCallback): void;
isOsAccountVerified(localId?: number): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | isTestOsAccount(callback: AsyncCallback): void;
isTestOsAccount(): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback): void;
isOsAccountConstraintEnable(localId: number, constraint: string): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | isOsAccountActived(localId: number, callback: AsyncCallback): void;
isOsAccountActived(localId: number): Promise; | 新增 | +| ohos.account.osAccount | AccountManager | isMultiOsAccountEnable(callback: AsyncCallback): void;
isMultiOsAccountEnable(): Promise; | 新增 | +| ohos.account.osAccount | osAccount | function getAccountManager(): AccountManager; | 新增 | +| ohos.account.appAccount | Authenticator | authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | Authenticator | addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AuthenticatorCallback | onRequestRedirected: (request: Want) => void; | 新增 | +| ohos.account.appAccount | AuthenticatorCallback | onResult: (code: number, result: {[key: string]: any}) => void; | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_PERMISSION_DENIED = 10018 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE = 10017 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_UNSUPPORT_ACTION = 10016 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_TOKEN_TOO_MANY = 10015 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_TOKEN_NOT_EXIST = 10014 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_TIMEOUT = 10013 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_SESSION_NOT_EXIST = 10012 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_SERVICE_EXCEPTION = 10011 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_SERVICE_BUSY = 10010 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_LIST_TOO_LARGE = 10009 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_CANCELED = 10008 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST = 10007 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_NETWORK_EXCEPTION = 10006 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_INVALID_RESPONSE = 10005 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_INVALID_REQUEST = 10004 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_INVALID_PASSWORD = 10003 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION = 10002 | 新增 | +| ohos.account.appAccount | ResultCode | ERROR_ACCOUNT_NOT_EXIST = 10001 | 新增 | +| ohos.account.appAccount | ResultCode | SUCCESS = 0 | 新增 | +| ohos.account.appAccount | Constants | KEY_CALLER_BUNDLE_NAME = "callerBundleName" | 新增 | +| ohos.account.appAccount | Constants | KEY_CALLER_UID = "callerUid" | 新增 | +| ohos.account.appAccount | Constants | KEY_CALLER_PID = "callerPid" | 新增 | +| ohos.account.appAccount | Constants | KEY_SESSION_ID = "sessionId" | 新增 | +| ohos.account.appAccount | Constants | KEY_AUTH_TYPE = "authType" | 新增 | +| ohos.account.appAccount | Constants | KEY_ACTION = "action" | 新增 | +| ohos.account.appAccount | Constants | KEY_TOKEN = "token" | 新增 | +| ohos.account.appAccount | Constants | KEY_OWNER = "owner" | 新增 | +| ohos.account.appAccount | Constants | KEY_NAME = "name" | 新增 | +| ohos.account.appAccount | Constants | ACTION_AUTHENTICATE = "authenticate" | 新增 | +| ohos.account.appAccount | Constants | ACTION_ADD_ACCOUNT_IMPLICITLY = "addAccountImplicitly" | 新增 | +| ohos.account.appAccount | AuthenticatorInfo | labelId: number; | 新增 | +| ohos.account.appAccount | AuthenticatorInfo | iconId: number; | 新增 | +| ohos.account.appAccount | AuthenticatorInfo | owner: string; | 新增 | +| ohos.account.appAccount | OAuthTokenInfo | token: string; | 新增 | +| ohos.account.appAccount | OAuthTokenInfo | authType: string; | 新增 | +| ohos.account.appAccount | AppAccountInfo | name: string; | 新增 | +| ohos.account.appAccount | AppAccountInfo | owner: string; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAuthenticatorInfo(owner: string, callback: AsyncCallback): void;
getAuthenticatorInfo(owner: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAuthenticatorCallback(sessionId: string, callback: AsyncCallback): void;
getAuthenticatorCallback(sessionId: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getOAuthList(name: string, authType: string, callback: AsyncCallback>): void;
getOAuthList(name: string, authType: string): Promise>; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback>): void;
getAllOAuthTokens(name: string, owner: string): Promise>; | 新增 | +| ohos.account.appAccount | AppAccountManager | checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void;
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void;
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void;
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void;
setOAuthToken(name: string, authType: string, token: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void;
getOAuthToken(name: string, owner: string, authType: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | off(type: 'change', callback?: Callback>): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | on(type: 'change', owners: Array, callback: Callback>): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAssociatedData(name: string, key: string, callback: AsyncCallback): void;
getAssociatedData(name: string, key: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAccountExtraInfo(name: string, callback: AsyncCallback): void;
getAccountExtraInfo(name: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void;
getAccountCredential(name: string, credentialType: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAllAccounts(owner: string, callback: AsyncCallback>): void;
getAllAccounts(owner: string): Promise>; | 新增 | +| ohos.account.appAccount | AppAccountManager | getAllAccessibleAccounts(callback: AsyncCallback>): void;
getAllAccessibleAccounts(): Promise>; | 新增 | +| ohos.account.appAccount | AppAccountManager | setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback): void;
setAssociatedData(name: string, key: string, value: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback): void;
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback): void;
setAccountExtraInfo(name: string, extraInfo: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback): void;
setAccountCredential(name: string, credentialType: string, credential: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | checkAppAccountSyncEnable(name: string, callback: AsyncCallback): void;
checkAppAccountSyncEnable(name: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | enableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void;
enableAppAccess(name: string, bundleName: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | disableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void;
disableAppAccess(name: string, bundleName: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | deleteAccount(name: string, callback: AsyncCallback): void;
deleteAccount(name: string): Promise; | 新增 | +| ohos.account.appAccount | AppAccountManager | addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | addAccount(name: string, callback: AsyncCallback): void;
addAccount(name: string, extraInfo: string, callback: AsyncCallback): void;
addAccount(name: string, extraInfo?: string): Promise; | 新增 | +| ohos.account.appAccount | appAccount | function createAppAccountManager(): AppAccountManager; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ace.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ace.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..c6266dad44bb65a31ac56e71ba43a7d03ba59732 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ace.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-ace.md @@ -1,14 +1,53 @@ -# xxx子系统JS API变更 +# ArkUI子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,ArkUI子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 组件类型 | 组件名称 | 变更类型 | 变更说明 | +| ---------- | ----------------------------- | -------- | ------------------------------------------------------------ | +| 通用事件 | 焦点事件 onFocus/onBlur | 新增 | 新增焦点事件。 | +| 通用事件 | 鼠标事件 onHover/onMouse | 新增 | 新增鼠标事件。 | +| 通用事件 | 组件区域变化事件 onAreaChange | 新增 | 新增组件区域(包括大小和位置)变化事件。 | +| 通用属性 | 设置多态样式 stateStyles | 新增 | 新增组件多态样式设置。 | +| 通用属性 | 触摸热区设置 responseRegion | 新增 | 新增组件触摸热区设置。 | +| 通用属性 | 点击控制 touchable | 新增 | 新增设置组件是否可以被触摸。 | +| 通用属性 | 焦点控制 focusable | 新增 | 新增设置当前组件是否可以获焦。 | +| 通用属性 | Popup控制 bindPopup | 新增 | 新增popup自定义布局能力。 | +| 通用属性 | Menu控制 bindMenu | 新增 | 新增menu自定义布局能力。 | +| 通用属性 | 悬浮态效果 hoverEffect | 新增 | 新增设置当前组件悬停态下的悬浮效果。 | +| 通用手势 | SwipeGesture | 新增 | 新增滑动手势。 | +| 基础组件 | Image | 新增 | 新增syncLoad属性设置是否同步加载。 | +| 基础组件 | Swiper | 新增 | 新增cachedCount属性设置预加载子组件个数。 | +| 基础组件 | Swiper | 新增 | 新增disableSwipe属性禁用组件滑动切换功能。 | +| 基础组件 | Slider | 新增 | 新增垂直方向的滑动条。 | +| 基础组件 | TabContent | 新增 | 新增tabbar属性自定义布局能力。 | +| 基础组件 | Marquee | 新增 | 新增跑马灯组件。 | +| 基础组件 | Gauge | 新增 | 新增数据量规图表组件。 | +| 基础组件 | PluginComponent | 新增 | 新增插件组件。 | +| 基础组件 | TextArea | 新增 | 新增输入区域组件。 | +| 基础组件 | TextInput | 新增 | 新增输入框组件。 | +| 基础组件 | Toggle | 新增 | 新增状态组件。 | +| 容器组件 | List | 新增 | 新增列表项拖拽事件。 | +| 容器组件 | ScrollBar | 新增 | 新增滚动条组件。 | +| 容器组件 | Navigation | 新增 | 新增页面导航组件。 | +| 容器组件 | Stepper | 新增 | 新增步骤导航器组件。 | +| 容器组件 | StepperItem | 新增 | 新增步骤导航器导航项组件。 | +| 画布组件 | Canvas | 新增 | 新增画布组件。 | +| 画布组件 | Lottie | 新增 | 新增Lottie库的支持。 | +| 全局UI方法 | ActionSheet | 新增 | 新增列表选择弹窗。 | +| 基础组件 | Web | 新增 | 新增加载网页组件。 | +| 基础组件 | Checkbox | 新增 | 新增多选框组件,通常用于某选项的打开或关闭。 | +| 基础组件 | CheckboxGroup | 新增 | 新增多选框群组组件,用于控制多选框全选或者不全选状态。 | +| 基础组件 | DatePicker | 新增 | 新增选择日期的滑动选择器组件。 | +| 基础组件 | TextPicker | 新增 | 新增文本类滑动选择器组件。 | +| 基础组件 | PatternLock | 新增 | 新增图案密码锁组件,以宫格图案的方式输入密码,用于密码验证。 | +| 基础组件 | RichText | 新增 | 新增富文本组件,解析并显示HTML格式文本。 | +| 基础组件 | Search | 新增 | 新增搜索框组件,用于提供用户搜索内容的输入区域。 | +| 基础组件 | Select | 新增 | 新增下拉选择菜单组件,可以让用户在多个选项之间选择。 | +| 基础组件 | TextClock | 新增 | 新增文本时钟组件。 | +| 容器组件 | Refresh | 新增 | 新增下拉刷新容器组件。 | +| 容器组件 | SideBarContainer | 新增 | 新增侧边栏容器组件。 | +| 全局UI方法 | TextPickerDialog | 新增 | 新增文本滑动选择器弹窗。 | +| 全局UI方法 | TimePickerDialog | 新增 | 新增时间滑动选择器弹窗。 | +| 全局UI方法 | DatePickerDialog | 新增 | 新增日期滑动选择器弹窗。 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-battery.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-battery.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..ad0dc24796ad462bde3026b73e8e7a63c34249e4 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-battery.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-battery.md @@ -1,14 +1,20 @@ -# xxx子系统JS API变更 +# 电源服务子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,电源服务子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.thermal | thermal | function getThermalLevel(): ThermalLevel; | 新增 | +| ohos.thermal | thermal | function unsubscribeThermalLevel(callback?: AsyncCallback): void; | 新增 | +| ohos.thermal | thermal | function subscribeThermalLevel(callback: AsyncCallback): void; | 新增 | +| ohos.thermal | ThermalLevel | EMERGENCY = 6 | 新增 | +| ohos.thermal | ThermalLevel | WARNING = 5 | 新增 | +| ohos.thermal | ThermalLevel | OVERHEATED = 4 | 新增 | +| ohos.thermal | ThermalLevel | HOT = 3 | 新增 | +| ohos.thermal | ThermalLevel | WARM = 2 | 新增 | +| ohos.thermal | ThermalLevel | NORMAL = 1 | 新增 | +| ohos.thermal | ThermalLevel | COOL = 0 | 新增 | +| ohos.runninglock | runningLock | function createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback): void;
function createRunningLock(name: string, type: RunningLockType): Promise; | 新增 | +| ohos.runninglock | runningLock | function isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback): void;
function isRunningLockTypeSupported(type: RunningLockType): Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-bundle.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-bundle.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..6db6e57dad8047a67e61355bf79ef7349fed86a0 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-bundle.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-bundle.md @@ -1,14 +1,64 @@ -# xxx子系统JS API变更 +# 包管理子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,包管理子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| shortcutInfo | ShortcutInfo | readonly labelId: number; | 新增 | +| shortcutInfo | ShortcutInfo | readonly iconId: number; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly installTime : number; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly userId: number; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly iconId: number; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly labelId: number; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly elementName : ElementName; | 新增 | +| launcherAbilityInfo | LauncherAbilityInfo | readonly applicationInfo: ApplicationInfo; | 新增 | +| bundleInfo | BundleInfo | readonly reqPermissionStates: Array; | 新增 | +| bundleInfo | BundleInfo | readonly hapModuleInfos: Array; | 新增 | +| bundleInfo | BundleInfo | readonly abilityInfos: Array; | 新增 | +| abilityInfo | AbilityInfo | readonly enabled: boolean; | 新增 | +| abilityInfo | AbilityInfo | readonly metaData: Array; | 新增 | +| ohos.zlib | zlib | function unzipFile(inFile:string, outFile:string, options: Options): Promise; | 新增 | +| ohos.zlib | zlib | function zipFile(inFile:string, outFile:string, options: Options): Promise; | 新增 | +| ohos.zlib | Options | strategy?: CompressStrategy; | 新增 | +| ohos.zlib | Options | memLevel?: MemLevel; | 新增 | +| ohos.zlib | Options | level?: CompressLevel; | 新增 | +| ohos.zlib | MemLevel | MEM_LEVEL_DEFAULT = 8 | 新增 | +| ohos.zlib | MemLevel | MEM_LEVEL_MAX = 9 | 新增 | +| ohos.zlib | MemLevel | MEM_LEVEL_MIN = 1 | 新增 | +| ohos.zlib | CompressStrategy | COMPRESS_STRATEGY_FIXED = 4 | 新增 | +| ohos.zlib | CompressStrategy | COMPRESS_STRATEGY_RLE = 3 | 新增 | +| ohos.zlib | CompressStrategy | COMPRESS_STRATEGY_HUFFMAN_ONLY = 2 | 新增 | +| ohos.zlib | CompressStrategy | COMPRESS_STRATEGY_FILTERED = 1 | 新增 | +| ohos.zlib | CompressStrategy | COMPRESS_STRATEGY_DEFAULT_STRATEGY = 0 | 新增 | +| ohos.zlib | CompressLevel | COMPRESS_LEVEL_DEFAULT_COMPRESSION = -1 | 新增 | +| ohos.zlib | CompressLevel | COMPRESS_LEVEL_BEST_COMPRESSION = 9 | 新增 | +| ohos.zlib | CompressLevel | COMPRESS_LEVEL_BEST_SPEED = 1 | 新增 | +| ohos.zlib | CompressLevel | COMPRESS_LEVEL_NO_COMPRESSION = 0 | 新增 | +| ohos.zlib | ErrorCode | ERROR_CODE_ERRNO = -1 | 新增 | +| ohos.zlib | ErrorCode | ERROR_CODE_OK = 0 | 新增 | +| ohos.bundle | bundle | function isApplicationEnabled(bundleName: string, callback: AsyncCallback): void;
function isApplicationEnabled(bundleName: string): Promise; | 新增 | +| ohos.bundle | bundle | function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback): void;
function isAbilityEnabled(info: AbilityInfo): Promise; | 新增 | +| ohos.bundle | bundle | function getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback): void;
function getAbilityIcon(bundleName: string, abilityName: string): Promise; | 新增 | +| ohos.bundle | bundle | function getAbilityLabel(bundleName: string, abilityName: string, callback: AsyncCallback): void;
function getAbilityLabel(bundleName: string, abilityName: string): Promise; | 新增 | +| ohos.bundle | bundle | function getNameForUid(uid: number, callback: AsyncCallback) : void
function getNameForUid(uid: number) : Promise; | 新增 | +| ohos.bundle | bundle | function getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback): void;
function getAbilityInfo(bundleName: string, abilityName: string): Promise; | 新增 | +| ohos.bundle | InstallErrorCode | STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 | 新增 | +| ohos.bundle | InstallErrorCode | STATUS_INSTALL_PERMISSION_DENIED = 0x44 | 新增 | +| ohos.bundle | InstallErrorCode | STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43 | 新增 | +| ohos.bundle | InstallErrorCode | STATUS_FAILED_NO_SPACE_LEFT = 0x42 | 新增 | +| ohos.bundle | InstallErrorCode | STATUS_RECOVER_FAILURE_INVALID = 0x0D | 新增 | +| ohos.bundle | BundleOptions | userId?: number; | 新增 | +| ohos.bundle | ColorMode | LIGHT_MODE = 1 | 新增 | +| ohos.bundle | ColorMode | DARK_MODE = 0 | 新增 | +| ohos.bundle | ColorMode | AUTO_MODE = -1 | 新增 | +| ohos.bundle | BundleFlag | GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200 | 新增 | +| ohos.bundle | BundleFlag | GET_ABILITY_INFO_WITH_DISABLE = 0x00000100 | 新增 | +| ohos.bundle | BundleFlag | GET_ABILITY_INFO_SYSTEMAPP_ONLY = 0x00000080 | 新增 | +| ohos.bundle | BundleFlag | GET_APPLICATION_INFO_WITH_METADATA = 0x00000040 | 新增 | +| ohos.bundle | BundleFlag | GET_ABILITY_INFO_WITH_METADATA = 0x00000020 | 新增 | +| ohos.bundle | BundleFlag | GET_ALL_APPLICATION_INFO = 0xFFFF0000 | 新增 | +| ohos.bundle | BundleFlag | GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010 | 新增 | +| ohos.bundle | BundleFlag | GET_ABILITY_INFO_WITH_APPLICATION = 0x00000004 | 新增 | +| ohos.bundle | BundleFlag | GET_ABILITY_INFO_WITH_PERMISSION = 0x00000002 | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-communicate.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-communicate.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0c595eec7e6eeab687fe5cc056530752c028ebad 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-communicate.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-communicate.md @@ -1,14 +1,463 @@ -# xxx子系统JS API变更 +# 基础通信子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,基础通信子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| tagSession | TagSession | getMaxSendLength(): number; | 新增 | +| tagSession | TagSession | sendData(data: number[]): Promise;
sendData(data: number[], callback: AsyncCallback): void; | 新增 | +| tagSession | TagSession | getSendDataTimeout(): number; | 新增 | +| tagSession | TagSession | setSendDataTimeout(timeout: number): boolean; | 新增 | +| tagSession | TagSession | isTagConnected(): boolean; | 新增 | +| tagSession | TagSession | reset(): void; | 新增 | +| tagSession | TagSession | connectTag(): boolean; | 新增 | +| tagSession | TagSession | getTagInfo(): tag.TagInfo; | 新增 | +| nfctech | NfcVTag | getDsfId(): number; | 新增 | +| nfctech | NfcVTag | getResponseFlags(): number; | 新增 | +| nfctech | NfcFTag | getPmm(): number[]; | 新增 | +| nfctech | NfcFTag | getSystemCode(): number[]; | 新增 | +| nfctech | NfcBTag | getRespProtocol(): number[]; | 新增 | +| nfctech | NfcBTag | getRespAppData(): number[]; | 新增 | +| nfctech | NfcATag | getAtqa(): number[]; | 新增 | +| nfctech | NfcATag | getSak(): number; | 新增 | +| ohos.wifiext | PowerModel | THROUGH_WALL = 2 | 新增 | +| ohos.wifiext | PowerModel | GENERAL = 1 | 新增 | +| ohos.wifiext | PowerModel | SLEEPING = 0 | 新增 | +| ohos.wifiext | wifiext | function setPowerModel(model: PowerModel) : boolean | 新增 | +| ohos.wifiext | wifiext | function getPowerModel (): Promise;
function getPowerModel (callback: AsyncCallback): void; | 新增 | +| ohos.wifiext | wifiext | function getSupportedPowerModel(): Promise>;
function getSupportedPowerModel(callback: AsyncCallback>): void; | 新增 | +| ohos.wifiext | wifiext | function disableHotspot(): boolean; | 新增 | +| ohos.wifiext | wifiext | function enableHotspot(): boolean; | 新增 | +| ohos.wifi | GroupOwnerBand | GO_BAND_5GHZ = 2 | 新增 | +| ohos.wifi | GroupOwnerBand | GO_BAND_2GHZ = 1 | 新增 | +| ohos.wifi | GroupOwnerBand | GO_BAND_AUTO = 0 | 新增 | +| ohos.wifi | P2pDeviceStatus | UNAVAILABLE = 4 | 新增 | +| ohos.wifi | P2pDeviceStatus | AVAILABLE = 3 | 新增 | +| ohos.wifi | P2pDeviceStatus | FAILED = 2 | 新增 | +| ohos.wifi | P2pDeviceStatus | INVITED = 1 | 新增 | +| ohos.wifi | P2pDeviceStatus | CONNECTED = 0 | 新增 | +| ohos.wifi | WifiP2pLinkedInfo | groupOwnerAddr: string; | 新增 | +| ohos.wifi | WifiP2pLinkedInfo | isGroupOwner: boolean; | 新增 | +| ohos.wifi | WifiP2pLinkedInfo | connectState: P2pConnectState; | 新增 | +| ohos.wifi | P2pConnectState | CONNECTED = 1 | 新增 | +| ohos.wifi | P2pConnectState | DISCONNECTED = 0 | 新增 | +| ohos.wifi | WifiP2pGroupInfo | goIpAddress: string; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | clientDevices: WifiP2pDevice[]; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | frequency: number; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | networkId: number; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | groupName: string; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | interface: string; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | passphrase: string; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | ownerInfo: WifiP2pDevice; | 新增 | +| ohos.wifi | WifiP2pGroupInfo | isP2pGo: boolean; | 新增 | +| ohos.wifi | WifiP2PConfig | goBand: GroupOwnerBand; | 新增 | +| ohos.wifi | WifiP2PConfig | groupName: string; | 新增 | +| ohos.wifi | WifiP2PConfig | passphrase: string; | 新增 | +| ohos.wifi | WifiP2PConfig | netId: number; | 新增 | +| ohos.wifi | WifiP2PConfig | deviceAddress: string; | 新增 | +| ohos.wifi | WifiP2pDevice | groupCapabilitys: number; | 新增 | +| ohos.wifi | WifiP2pDevice | deviceStatus: P2pDeviceStatus; | 新增 | +| ohos.wifi | WifiP2pDevice | primaryDeviceType: string; | 新增 | +| ohos.wifi | WifiP2pDevice | deviceAddress: string; | 新增 | +| ohos.wifi | WifiP2pDevice | deviceName: string; | 新增 | +| ohos.wifi | ConnState | UNKNOWN | 新增 | +| ohos.wifi | ConnState | DISCONNECTED | 新增 | +| ohos.wifi | ConnState | DISCONNECTING | 新增 | +| ohos.wifi | ConnState | CONNECTED | 新增 | +| ohos.wifi | ConnState | OBTAINING_IPADDR | 新增 | +| ohos.wifi | ConnState | AUTHENTICATING | 新增 | +| ohos.wifi | ConnState | CONNECTING | 新增 | +| ohos.wifi | ConnState | SCANNING | 新增 | +| ohos.wifi | IpInfo | leaseDuration: number; | 新增 | +| ohos.wifi | IpInfo | serverIp: number; | 新增 | +| ohos.wifi | IpInfo | secondDns: number; | 新增 | +| ohos.wifi | IpInfo | primaryDns: number; | 新增 | +| ohos.wifi | IpInfo | netmask: number; | 新增 | +| ohos.wifi | IpInfo | gateway: number; | 新增 | +| ohos.wifi | IpInfo | ipAddress: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | connState: ConnState; | 新增 | +| ohos.wifi | WifiLinkedInfo | ipAddress: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | macAddress: string; | 新增 | +| ohos.wifi | WifiLinkedInfo | isRestricted: boolean; | 新增 | +| ohos.wifi | WifiLinkedInfo | isHidden: boolean; | 新增 | +| ohos.wifi | WifiLinkedInfo | frequency: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | linkSpeed: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | band: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | rssi: number; | 新增 | +| ohos.wifi | WifiLinkedInfo | bssid: string; | 新增 | +| ohos.wifi | WifiLinkedInfo | ssid: string; | 新增 | +| ohos.wifi | WifiScanInfo | channelWidth: number; | 新增 | +| ohos.wifi | WifiScanInfo | capabilities: string; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pDiscoveryChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pDiscoveryChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pPersistentGroupChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pPersistentGroupChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pPeerDeviceChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pPeerDeviceChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pDeviceChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pDeviceChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pConnectionChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pConnectionChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "p2pStateChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "p2pStateChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "hotspotStateChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "hotspotStateChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "wifiRssiChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "wifiRssiChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "wifiScanStateChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "wifiScanStateChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "wifiConnectionChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "wifiConnectionChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function off(type: "wifiStateChange", callback?: Callback): void; | 新增 | +| ohos.wifi | wifi | function on(type: "wifiStateChange", callback: Callback): void; | 新增 | +| ohos.wifi | wifi | function stopDiscoverDevices(): boolean; | 新增 | +| ohos.wifi | wifi | function startDiscoverDevices(): boolean; | 新增 | +| ohos.wifi | wifi | function p2pCancelConnect(): boolean; | 新增 | +| ohos.wifi | wifi | function p2pConnect(config: WifiP2PConfig): boolean; | 新增 | +| ohos.wifi | wifi | function removeGroup(): boolean; | 新增 | +| ohos.wifi | wifi | function createGroup(config: WifiP2PConfig): boolean; | 新增 | +| ohos.wifi | wifi | function getP2pPeerDevices(): Promise;
function getP2pPeerDevices(callback: AsyncCallback): void; | 新增 | +| ohos.wifi | wifi | function getCurrentGroup(): Promise;
function getCurrentGroup(callback: AsyncCallback): void; | 新增 | +| ohos.wifi | wifi | function getP2pLinkedInfo(): Promise;
function getP2pLinkedInfo(callback: AsyncCallback): void; | 新增 | +| ohos.wifi | wifi | function getCountryCode(): string; | 新增 | +| ohos.wifi | wifi | function getIpInfo(): IpInfo; | 新增 | +| ohos.wifi | wifi | function isFeatureSupported(featureId: number): boolean; | 新增 | +| ohos.wifi | wifi | function isConnected(): boolean; | 新增 | +| ohos.wifi | wifi | function getLinkedInfo(): Promise;
function getLinkedInfo(callback: AsyncCallback): void; | 新增 | +| ohos.wifi | wifi | function removeUntrustedConfig(config: WifiDeviceConfig): Promise;
function removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; | 新增 | +| ohos.wifi | wifi | function addUntrustedConfig(config: WifiDeviceConfig): Promise;
function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; | 新增 | +| ohos.nfc.tag | TagInfo | supportedProfiles: number[]; | 新增 | +| ohos.nfc.tag | tag | function getNfcVTag(tagInfo: TagInfo): NfcVTag | 新增 | +| ohos.nfc.tag | tag | function getNfcFTag(tagInfo: TagInfo): NfcFTag | 新增 | +| ohos.nfc.tag | tag | function getNfcBTag(tagInfo: TagInfo): NfcBTag | 新增 | +| ohos.nfc.tag | tag | function getNfcATag(tagInfo: TagInfo): NfcATag | 新增 | +| ohos.nfc.tag | tag | const MIFARE_ULTRALIGHT = 9; | 新增 | +| ohos.nfc.tag | tag | const MIFARE_CLASSIC = 8; | 新增 | +| ohos.nfc.tag | tag | const NDEF = 6; | 新增 | +| ohos.nfc.tag | tag | const NFC_V = 5; | 新增 | +| ohos.nfc.tag | tag | const NFC_F = 4; | 新增 | +| ohos.nfc.tag | tag | const ISO_DEP = 3; | 新增 | +| ohos.nfc.tag | tag | const NFC_B = 2; | 新增 | +| ohos.nfc.tag | tag | const NFC_A = 1; | 新增 | +| ohos.nfc.controller | nfcController | function getNfcState(): NfcState | 新增 | +| ohos.nfc.controller | nfcController | function isNfcOpen(): boolean | 新增 | +| ohos.nfc.controller | nfcController | function closeNfc(): boolean | 新增 | +| ohos.nfc.controller | nfcController | function openNfc(): boolean | 新增 | +| ohos.nfc.controller | nfcController | function off(type: "nfcStateChange", callback?: Callback): void | 新增 | +| ohos.nfc.controller | nfcController | function on(type: "nfcStateChange", callback: Callback): void | 新增 | +| ohos.nfc.controller | nfcController | function isNfcAvailable(): boolean | 新增 | +| ohos.nfc.controller | NfcState | STATE_TURNING_OFF = 4 | 新增 | +| ohos.nfc.controller | NfcState | STATE_ON = 3 | 新增 | +| ohos.nfc.controller | NfcState | STATE_TURNING_ON = 2 | 新增 | +| ohos.nfc.controller | NfcState | STATE_OFF = 1 | 新增 | +| ohos.nfc.cardEmulation | HceService | sendResponse(responseApdu: number[]): void; | 新增 | +| ohos.nfc.cardEmulation | HceService | on(type: "hceCmd", callback: AsyncCallback): void; | 新增 | +| ohos.nfc.cardEmulation | HceService | stopHCE(): boolean; | 新增 | +| ohos.nfc.cardEmulation | HceService | startHCE(aidList: string[]): boolean; | 新增 | +| ohos.nfc.cardEmulation | cardEmulation | function isSupported(feature: number): boolean; | 新增 | +| ohos.nfc.cardEmulation | FeatureType | ESE = 2 | 新增 | +| ohos.nfc.cardEmulation | FeatureType | UICC = 1 | 新增 | +| ohos.nfc.cardEmulation | FeatureType | HCE = 0 | 新增 | +| ohos.connectedTag | NfcRfType | NFC_RF_ENTER = 1 | 新增 | +| ohos.connectedTag | NfcRfType | NFC_RF_LEAVE = 0 | 新增 | +| ohos.connectedTag | connectedTag | function off(type: "notify", callback?:Callback): void; | 新增 | +| ohos.connectedTag | connectedTag | function on(type: "notify", callback: Callback): void; | 新增 | +| ohos.connectedTag | connectedTag | function writeNdefTag(data: string): Promise;
function writeNdefTag(data: string, callback: AsyncCallback): void; | 新增 | +| ohos.connectedTag | connectedTag | function readNdefTag(): Promise;
function readNdefTag(callback: AsyncCallback): void; | 新增 | +| ohos.connectedTag | connectedTag | function uninit(): boolean; | 新增 | +| ohos.connectedTag | connectedTag | function init(): boolean; | 新增 | +| ohos.bluetooth | ProfileId | PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4 | 新增 | +| ohos.bluetooth | ProfileId | PROFILE_A2DP_SOURCE = 1 | 新增 | +| ohos.bluetooth | PlayingState | STATE_PLAYING | 新增 | +| ohos.bluetooth | PlayingState | STATE_NOT_PLAYING | 新增 | +| ohos.bluetooth | StateChangeParam | state: ProfileConnectionState; | 新增 | +| ohos.bluetooth | StateChangeParam | deviceId: string; | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_PERSONAL_MOBILITY_DEVICE = 0x093C | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_GENERIC_HEALTH_MANAGER = 0x0938 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_ANKLE_PROSTHESIS = 0x0934 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_KNEE_PROSTHESIS = 0x0930 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_MEDICATION_MONITOR = 0x092C | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_PEAK_FLOW_MOITOR = 0x0928 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_BODY_COMPOSITION_ANALYZER = 0x0924 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_STEP_COUNTER = 0x0920 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_DATA_DISPLAY = 0x091C | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_PULSE_RATE = 0x0918 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_PULSE_OXIMETER = 0x0914 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_GLUCOSE = 0x0910 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_WEIGHING = 0x090C | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_THERMOMETER = 0x0908 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_BLOOD_PRESSURE = 0x0904 | 新增 | +| ohos.bluetooth | MajorMinorClass | HEALTH_UNCATEGORIZED = 0x0900 | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_GAME = 0x0814 | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_CONTROLLER = 0x0810 | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_DOLL_ACTION_FIGURE = 0x080C | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_VEHICLE = 0x0808 | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_ROBOT = 0x0804 | 新增 | +| ohos.bluetooth | MajorMinorClass | TOY_UNCATEGORIZED = 0x0800 | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_GLASSES = 0x0714 | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_HELMET = 0x0710 | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_JACKET = 0x070C | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_PAGER = 0x0708 | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_WRIST_WATCH = 0x0704 | 新增 | +| ohos.bluetooth | MajorMinorClass | WEARABLE_UNCATEGORIZED = 0x0700 | 新增 | +| ohos.bluetooth | MajorMinorClass | IMAGING_PRINTER = 0x0680 | 新增 | +| ohos.bluetooth | MajorMinorClass | IMAGING_SCANNER = 0x0640 | 新增 | +| ohos.bluetooth | MajorMinorClass | IMAGING_CAMERA = 0x0620 | 新增 | +| ohos.bluetooth | MajorMinorClass | IMAGING_DISPLAY = 0x0610 | 新增 | +| ohos.bluetooth | MajorMinorClass | IMAGING_UNCATEGORIZED = 0x0600 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_GESTURAL_INPUT = 0x0522 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_SCANNER_RFID = 0x0520 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_DIGITAL_PEN = 0x051C | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_CARD_READER = 0x0518 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_DIGITIZER_TABLET = 0x0514 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_SENSING_DEVICE = 0x0510 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_REMOTE_CONTROL = 0x05C0 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_GAMEPAD = 0x0508 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_JOYSTICK = 0x0504 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_UNCATEGORIZED = 0x0500 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_KEYBOARD_POINTING = 0x05C0 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_POINTING_DEVICE = 0x0580 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_KEYBOARD = 0x0540 | 新增 | +| ohos.bluetooth | MajorMinorClass | PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VIDEO_MONITOR = 0x0438 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_CAMCORDER = 0x0434 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VIDEO_CAMERA = 0x0430 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_VCR = 0x042C | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_HIFI_AUDIO = 0x0428 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_SET_TOP_BOX = 0x0424 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_CAR_AUDIO = 0x0420 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_HEADPHONES = 0x0418 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_LOUDSPEAKER = 0x0414 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_MICROPHONE = 0x0410 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_HANDSFREE = 0x0408 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404 | 新增 | +| ohos.bluetooth | MajorMinorClass | AUDIO_VIDEO_UNCATEGORIZED = 0x0400 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_NO_SERVICE = 0x03E0 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_83_TO_99_UTILIZED = 0x03C0 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_67_TO_83_UTILIZED = 0x03A0 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_60_TO_67_UTILIZED = 0x0380 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_33_TO_50_UTILIZED = 0x0360 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_17_TO_33_UTILIZED = 0x0340 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_1_TO_17_UTILIZED = 0x0320 | 新增 | +| ohos.bluetooth | MajorMinorClass | NETWORK_FULLY_AVAILABLE = 0x0300 | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_ISDN = 0x0214 | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_MODEM_OR_GATEWAY = 0x0210 | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_SMART = 0x020C | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_CORDLESS = 0x0208 | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_CELLULAR = 0x0204 | 新增 | +| ohos.bluetooth | MajorMinorClass | PHONE_UNCATEGORIZED = 0x0200 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_TABLET = 0x011C | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_WEARABLE = 0x0118 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_PALM_SIZE_PC_PDA = 0x0114 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_HANDHELD_PC_PDA = 0x0110 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_LAPTOP = 0x010C | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_SERVER = 0x0108 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_DESKTOP = 0x0104 | 新增 | +| ohos.bluetooth | MajorMinorClass | COMPUTER_UNCATEGORIZED = 0x0100 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_UNCATEGORIZED = 0x1F00 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_HEALTH = 0x0900 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_TOY = 0x0800 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_WEARABLE = 0x0700 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_IMAGING = 0x0600 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_PERIPHERAL = 0x0500 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_AUDIO_VIDEO = 0x0400 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_NETWORKING = 0x0300 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_PHONE = 0x0200 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_COMPUTER = 0x0100 | 新增 | +| ohos.bluetooth | MajorClass | MAJOR_MISC = 0x0000 | 新增 | +| ohos.bluetooth | BondState | BOND_STATE_BONDED = 2 | 新增 | +| ohos.bluetooth | BondState | BOND_STATE_BONDING = 1 | 新增 | +| ohos.bluetooth | BondState | BOND_STATE_INVALID = 0 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_LIMITED_DISCOVERABLE = 3 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_GENERAL_DISCOVERABLE = 2 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_CONNECTABLE = 1 | 新增 | +| ohos.bluetooth | ScanMode | SCAN_MODE_NONE = 0 | 新增 | +| ohos.bluetooth | SppType | SPP_RFCOMM | 新增 | +| ohos.bluetooth | BluetoothState | STATE_BLE_TURNING_OFF = 6 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_BLE_ON = 5 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_BLE_TURNING_ON = 4 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_TURNING_OFF = 3 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_ON = 2 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_TURNING_ON = 1 | 新增 | +| ohos.bluetooth | BluetoothState | STATE_OFF = 0 | 新增 | +| ohos.bluetooth | ProfileConnectionState | STATE_DISCONNECTING = 3 | 新增 | +| ohos.bluetooth | ProfileConnectionState | STATE_CONNECTED = 2 | 新增 | +| ohos.bluetooth | ProfileConnectionState | STATE_CONNECTING = 1 | 新增 | +| ohos.bluetooth | ProfileConnectionState | STATE_DISCONNECTED = 0 | 新增 | +| ohos.bluetooth | MatchMode | MATCH_MODE_STICKY = 2 | 新增 | +| ohos.bluetooth | MatchMode | MATCH_MODE_AGGRESSIVE = 1 | 新增 | +| ohos.bluetooth | ScanDuty | SCAN_MODE_LOW_LATENCY = 2 | 新增 | +| ohos.bluetooth | ScanDuty | SCAN_MODE_BALANCED = 1 | 新增 | +| ohos.bluetooth | ScanDuty | SCAN_MODE_LOW_POWER = 0 | 新增 | +| ohos.bluetooth | BondStateParam | state: BondState; | 新增 | +| ohos.bluetooth | BondStateParam | deviceId: string; | 新增 | +| ohos.bluetooth | DeviceClass | classOfDevice: number; | 新增 | +| ohos.bluetooth | DeviceClass | majorMinorClass: MajorMinorClass; | 新增 | +| ohos.bluetooth | DeviceClass | majorClass: MajorClass; | 新增 | +| ohos.bluetooth | PinRequiredParam | pinCode: string; | 新增 | +| ohos.bluetooth | PinRequiredParam | deviceId: string; | 新增 | +| ohos.bluetooth | SppOption | type: SppType; | 新增 | +| ohos.bluetooth | SppOption | secure: boolean; | 新增 | +| ohos.bluetooth | SppOption | uuid: string; | 新增 | +| ohos.bluetooth | ScanOptions | matchMode?: MatchMode; | 新增 | +| ohos.bluetooth | ScanOptions | dutyMode?: ScanDuty; | 新增 | +| ohos.bluetooth | ScanOptions | interval?: number; | 新增 | +| ohos.bluetooth | ScanFilter | serviceUuid?: string; | 新增 | +| ohos.bluetooth | ScanFilter | name?: string; | 新增 | +| ohos.bluetooth | ScanFilter | deviceId?: string; | 新增 | +| ohos.bluetooth | ServiceData | serviceValue: ArrayBuffer; | 新增 | +| ohos.bluetooth | ServiceData | serviceUuid: string; | 新增 | +| ohos.bluetooth | ManufactureData | manufactureValue: ArrayBuffer; | 新增 | +| ohos.bluetooth | ManufactureData | manufactureId: number; | 新增 | +| ohos.bluetooth | AdvertiseData | serviceData: Array; | 新增 | +| ohos.bluetooth | AdvertiseData | manufactureData: Array; | 新增 | +| ohos.bluetooth | AdvertiseData | serviceUuids: Array; | 新增 | +| ohos.bluetooth | AdvertiseSetting | connectable?: boolean; | 新增 | +| ohos.bluetooth | AdvertiseSetting | txPower?: number; | 新增 | +| ohos.bluetooth | AdvertiseSetting | interval?: number; | 新增 | +| ohos.bluetooth | ScanResult | data: ArrayBuffer; | 新增 | +| ohos.bluetooth | ScanResult | rssi: number; | 新增 | +| ohos.bluetooth | ScanResult | deviceId: string; | 新增 | +| ohos.bluetooth | BLEConnectChangedState | state: ProfileConnectionState; | 新增 | +| ohos.bluetooth | BLEConnectChangedState | deviceId: string; | 新增 | +| ohos.bluetooth | ServerResponse | value: ArrayBuffer; | 新增 | +| ohos.bluetooth | ServerResponse | offset: number; | 新增 | +| ohos.bluetooth | ServerResponse | status: number; | 新增 | +| ohos.bluetooth | ServerResponse | transId: number; | 新增 | +| ohos.bluetooth | ServerResponse | deviceId: string; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | serviceUuid: string; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | characteristicUuid: string; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | descriptorUuid: string; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | value: ArrayBuffer; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | needRsp: boolean; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | isPrep: boolean; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | offset: number; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | transId: number; | 新增 | +| ohos.bluetooth | DescriptorWriteReq | deviceId: string; | 新增 | +| ohos.bluetooth | DescriptorReadReq | serviceUuid: string; | 新增 | +| ohos.bluetooth | DescriptorReadReq | characteristicUuid: string; | 新增 | +| ohos.bluetooth | DescriptorReadReq | descriptorUuid: string; | 新增 | +| ohos.bluetooth | DescriptorReadReq | offset: number; | 新增 | +| ohos.bluetooth | DescriptorReadReq | transId: number; | 新增 | +| ohos.bluetooth | DescriptorReadReq | deviceId: string; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | serviceUuid: string; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | characteristicUuid: string; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | value: ArrayBuffer; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | needRsp: boolean; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | isPrep: boolean; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | offset: number; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | transId: number; | 新增 | +| ohos.bluetooth | CharacteristicWriteReq | deviceId: string; | 新增 | +| ohos.bluetooth | CharacteristicReadReq | serviceUuid: string; | 新增 | +| ohos.bluetooth | CharacteristicReadReq | characteristicUuid: string; | 新增 | +| ohos.bluetooth | CharacteristicReadReq | offset: number; | 新增 | +| ohos.bluetooth | CharacteristicReadReq | transId: number; | 新增 | +| ohos.bluetooth | CharacteristicReadReq | deviceId: string; | 新增 | +| ohos.bluetooth | NotifyCharacteristic | confirm: boolean; | 新增 | +| ohos.bluetooth | NotifyCharacteristic | characteristicValue: ArrayBuffer; | 新增 | +| ohos.bluetooth | NotifyCharacteristic | characteristicUuid: string; | 新增 | +| ohos.bluetooth | NotifyCharacteristic | serviceUuid: string; | 新增 | +| ohos.bluetooth | BLEDescriptor | descriptorValue: ArrayBuffer; | 新增 | +| ohos.bluetooth | BLEDescriptor | descriptorUuid: string; | 新增 | +| ohos.bluetooth | BLEDescriptor | characteristicUuid: string; | 新增 | +| ohos.bluetooth | BLEDescriptor | serviceUuid: string; | 新增 | +| ohos.bluetooth | BLECharacteristic | descriptors: Array; | 新增 | +| ohos.bluetooth | BLECharacteristic | characteristicValue: ArrayBuffer; | 新增 | +| ohos.bluetooth | BLECharacteristic | characteristicUuid: string; | 新增 | +| ohos.bluetooth | BLECharacteristic | serviceUuid: string; | 新增 | +| ohos.bluetooth | GattService | includeServices?: Array; | 新增 | +| ohos.bluetooth | GattService | characteristics: Array; | 新增 | +| ohos.bluetooth | GattService | isPrimary: boolean; | 新增 | +| ohos.bluetooth | GattService | serviceUuid: string; | 新增 | +| ohos.bluetooth | GattClientDevice | off(type: "BLEConnectionStateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattClientDevice | on(type: "BLEConnectionStateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattClientDevice | off(type: "BLECharacteristicChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattClientDevice | on(type: "BLECharacteristicChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattClientDevice | setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | setBLEMtuSize(mtu: number): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | getRssiValue(callback: AsyncCallback): void;
getRssiValue(): Promise; | 新增 | +| ohos.bluetooth | GattClientDevice | writeDescriptorValue(descriptor: BLEDescriptor): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | writeCharacteristicValue(characteristic: BLECharacteristic): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback): void;
readDescriptorValue(descriptor: BLEDescriptor): Promise; | 新增 | +| ohos.bluetooth | GattClientDevice | readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback): void;
readCharacteristicValue(characteristic: BLECharacteristic): Promise; | 新增 | +| ohos.bluetooth | GattClientDevice | getServices(callback: AsyncCallback>): void;
getServices(): Promise>; | 新增 | +| ohos.bluetooth | GattClientDevice | getDeviceName(callback: AsyncCallback): void;
getDeviceName(): Promise; | 新增 | +| ohos.bluetooth | GattClientDevice | close(): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | disconnect(): boolean; | 新增 | +| ohos.bluetooth | GattClientDevice | connect(): boolean; | 新增 | +| ohos.bluetooth | GattServer | off(type: "connectStateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | on(type: "connectStateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | off(type: "descriptorWrite", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | on(type: "descriptorWrite", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | off(type: "descriptorRead", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | on(type: "descriptorRead", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | off(type: "characteristicWrite", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | on(type: "characteristicWrite", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | off(type: "characteristicRead", callback?: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | on(type: "characteristicRead", callback: Callback): void; | 新增 | +| ohos.bluetooth | GattServer | sendResponse(serverResponse: ServerResponse): boolean; | 新增 | +| ohos.bluetooth | GattServer | notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean; | 新增 | +| ohos.bluetooth | GattServer | close(): void; | 新增 | +| ohos.bluetooth | GattServer | removeService(serviceUuid: string): boolean; | 新增 | +| ohos.bluetooth | GattServer | addService(service: GattService): boolean; | 新增 | +| ohos.bluetooth | GattServer | stopAdvertising(): void; | 新增 | +| ohos.bluetooth | GattServer | startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void; | 新增 | +| ohos.bluetooth | BLE | function off(type: "BLEDeviceFind", callback?: Callback>): void; | 新增 | +| ohos.bluetooth | BLE | function on(type: "BLEDeviceFind", callback: Callback>): void; | 新增 | +| ohos.bluetooth | BLE | function stopBLEScan(): void; | 新增 | +| ohos.bluetooth | BLE | function startBLEScan(filters: Array, options?: ScanOptions): void; | 新增 | +| ohos.bluetooth | BLE | function getConnectedBLEDevices(): Array; | 新增 | +| ohos.bluetooth | BLE | function createGattClientDevice(deviceId: string): GattClientDevice; | 新增 | +| ohos.bluetooth | BLE | function createGattServer(): GattServer; | 新增 | +| ohos.bluetooth | HandsFreeAudioGatewayProfile | off(type: "connectionStateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | HandsFreeAudioGatewayProfile | on(type: "connectionStateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | HandsFreeAudioGatewayProfile | disconnect(device: string): boolean; | 新增 | +| ohos.bluetooth | HandsFreeAudioGatewayProfile | connect(device: string): boolean; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | getPlayingState(device: string): PlayingState; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | off(type: "connectionStateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | on(type: "connectionStateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | disconnect(device: string): boolean; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | connect(device: string): boolean; | 新增 | +| ohos.bluetooth | BaseProfile | getDeviceState(device: string): ProfileConnectionState; | 新增 | +| ohos.bluetooth | BaseProfile | getConnectionDevices(): Array; | 新增 | +| ohos.bluetooth | bluetooth | function getProfile(profileId: ProfileId): A2dpSourceProfile \| HandsFreeAudioGatewayProfile; | 新增 | +| ohos.bluetooth | bluetooth | function off(type: "sppRead", clientSocket: number, callback?: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function on(type: "sppRead", clientSocket: number, callback: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function sppWrite(clientSocket: number, data: ArrayBuffer): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function sppCloseClientSocket(socket: number): void; | 新增 | +| ohos.bluetooth | bluetooth | function sppCloseServerSocket(socket: number): void; | 新增 | +| ohos.bluetooth | bluetooth | function sppConnect(device: string, option: SppOption, callback: AsyncCallback): void; | 新增 | +| ohos.bluetooth | bluetooth | function sppAccept(serverSocket: number, callback: AsyncCallback): void; | 新增 | +| ohos.bluetooth | bluetooth | function sppListen(name: string, option: SppOption, callback: AsyncCallback): void; | 新增 | +| ohos.bluetooth | bluetooth | function off(type: "stateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function on(type: "stateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function off(type: "pinRequired", callback?: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function on(type: "pinRequired", callback: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function off(type: "bondStateChange", callback?: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function on(type: "bondStateChange", callback: Callback): void; | 新增 | +| ohos.bluetooth | bluetooth | function off(type: "bluetoothDeviceFind", callback?: Callback>): void; | 新增 | +| ohos.bluetooth | bluetooth | function on(type: "bluetoothDeviceFind", callback: Callback>): void; | 新增 | +| ohos.bluetooth | bluetooth | function stopBluetoothDiscovery(): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function startBluetoothDiscovery(): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function getBluetoothScanMode(): ScanMode; | 新增 | +| ohos.bluetooth | bluetooth | function setBluetoothScanMode(mode: ScanMode, duration: number): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function setLocalName(name: string): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function setDevicePairingConfirmation(device: string, accept: boolean): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function getProfileConnState(profileId: ProfileId): ProfileConnectionState; | 新增 | +| ohos.bluetooth | bluetooth | function getPairedDevices(): Array; | 新增 | +| ohos.bluetooth | bluetooth | function getLocalName(): string; | 新增 | +| ohos.bluetooth | bluetooth | function disableBluetooth(): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function enableBluetooth(): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function getRemoteDeviceClass(deviceId: string): DeviceClass; | 新增 | +| ohos.bluetooth | bluetooth | function getRemoteDeviceName(deviceId: string): string; | 新增 | +| ohos.bluetooth | bluetooth | function pairDevice(deviceId: string): boolean; | 新增 | +| ohos.bluetooth | bluetooth | function getBtConnectionState(): ProfileConnectionState; | 新增 | +| ohos.bluetooth | bluetooth | function getState(): BluetoothState; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-complier-and-runtime.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-complier-and-runtime.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..2e95af448cf63bbb852ec368986d02458fbfb889 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-complier-and-runtime.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-complier-and-runtime.md @@ -1,14 +1,379 @@ -# xxx子系统JS API变更 +# 公共基础库子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,公共基础库子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.xml | XmlPullParser | parse(option: ParseOptions): void; | 新增 | +| ohos.xml | XmlPullParser | constructor(buffer: ArrayBuffer \| DataView, encoding?: string); | 新增 | +| ohos.xml | ParseOptions | tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean; | 新增 | +| ohos.xml | ParseOptions | attributeValueCallbackFunction?: (name: string, value: string) => boolean; | 新增 | +| ohos.xml | ParseOptions | tagValueCallbackFunction?: (name: string, value: string) => boolean; | 新增 | +| ohos.xml | ParseOptions | ignoreNameSpace?: boolean; | 新增 | +| ohos.xml | ParseOptions | supportDoctype?: boolean; | 新增 | +| ohos.xml | ParseInfo | getAttributeCount(): number; | 新增 | +| ohos.xml | ParseInfo | isWhitespace(): boolean; | 新增 | +| ohos.xml | ParseInfo | isEmptyElementTag(): boolean; | 新增 | +| ohos.xml | ParseInfo | getText(): string; | 新增 | +| ohos.xml | ParseInfo | getPrefix(): string; | 新增 | +| ohos.xml | ParseInfo | getNamespace(): string; | 新增 | +| ohos.xml | ParseInfo | getName(): string; | 新增 | +| ohos.xml | ParseInfo | getLineNumber(): number; | 新增 | +| ohos.xml | ParseInfo | getDepth(): number; | 新增 | +| ohos.xml | ParseInfo | getColumnNumber(): number; | 新增 | +| ohos.xml | EventType | WHITESPACE | 新增 | +| ohos.xml | EventType | ENTITY_REFERENCE | 新增 | +| ohos.xml | EventType | INSTRUCTION | 新增 | +| ohos.xml | EventType | DOCDECL | 新增 | +| ohos.xml | EventType | COMMENT | 新增 | +| ohos.xml | EventType | CDSECT | 新增 | +| ohos.xml | EventType | TEXT | 新增 | +| ohos.xml | EventType | END_TAG | 新增 | +| ohos.xml | EventType | START_TAG | 新增 | +| ohos.xml | EventType | END_DOCUMENT | 新增 | +| ohos.xml | EventType | START_DOCUMENT | 新增 | +| ohos.xml | XmlSerializer | setDocType(text: string): void; | 新增 | +| ohos.xml | XmlSerializer | setText(text: string): void; | 新增 | +| ohos.xml | XmlSerializer | setCDATA(text: string): void; | 新增 | +| ohos.xml | XmlSerializer | setComment(text: string): void; | 新增 | +| ohos.xml | XmlSerializer | setNamespace(prefix: string, namespace: string): void; | 新增 | +| ohos.xml | XmlSerializer | endElement(): void; | 新增 | +| ohos.xml | XmlSerializer | startElement(name: string): void; | 新增 | +| ohos.xml | XmlSerializer | setDeclaration(): void; | 新增 | +| ohos.xml | XmlSerializer | addEmptyElement(name: string): void; | 新增 | +| ohos.xml | XmlSerializer | setAttributes(name: string, value: string): void; | 新增 | +| ohos.xml | XmlSerializer | constructor(buffer: ArrayBuffer \| DataView, encoding?: string); | 新增 | +| ohos.util.Vector | Vector | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.Vector | Vector | copyToArray(array: Array): void; | 新增 | +| ohos.util.Vector | Vector | trimToCurrentLength(): void; | 新增 | +| ohos.util.Vector | Vector | toString(): string; | 新增 | +| ohos.util.Vector | Vector | increaseCapacityTo(newCapacity: number): void; | 新增 | +| ohos.util.Vector | Vector | isEmpty(): boolean; | 新增 | +| ohos.util.Vector | Vector | convertToArray(): Array; | 新增 | +| ohos.util.Vector | Vector | getCapacity(): number; | 新增 | +| ohos.util.Vector | Vector | setLength(newSize: number): void; | 新增 | +| ohos.util.Vector | Vector | clone(): Vector; | 新增 | +| ohos.util.Vector | Vector | clear(): void; | 新增 | +| ohos.util.Vector | Vector | subVector(fromIndex: number, toIndex: number): Vector; | 新增 | +| ohos.util.Vector | Vector | sort(comparator?: (firstValue: T, secondValue: T) => number): void; | 新增 | +| ohos.util.Vector | Vector | forEach(callbackfn: (value: T, index?: number, vector?: Vector) => void, thisArg?: Object): void; | 新增 | +| ohos.util.Vector | Vector | replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector) => T, thisArg?: Object): void; | 新增 | +| ohos.util.Vector | Vector | removeByRange(fromIndex: number, toIndex: number): void; | 新增 | +| ohos.util.Vector | Vector | getIndexFrom(element: T, index: number): number; | 新增 | +| ohos.util.Vector | Vector | getLastIndexFrom(element: T, index: number): number; | 新增 | +| ohos.util.Vector | Vector | getLastIndexOf(element: T): number; | 新增 | +| ohos.util.Vector | Vector | set(index: number, element: T): T; | 新增 | +| ohos.util.Vector | Vector | remove(element: T): boolean; | 新增 | +| ohos.util.Vector | Vector | removeByIndex(index: number): T; | 新增 | +| ohos.util.Vector | Vector | getLastElement(): T; | 新增 | +| ohos.util.Vector | Vector | getFirstElement(): T; | 新增 | +| ohos.util.Vector | Vector | getIndexOf(element: T): number; | 新增 | +| ohos.util.Vector | Vector | get(index: number): T; | 新增 | +| ohos.util.Vector | Vector | has(element: T): boolean; | 新增 | +| ohos.util.Vector | Vector | insert(element: T, index: number): void; | 新增 | +| ohos.util.Vector | Vector | add(element: T): boolean; | 新增 | +| ohos.util.Vector | Vector | length: number; | 新增 | +| ohos.util.Vector | Vector | constructor(); | 新增 | +| ohos.util.TreeSet | TreeSet | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.TreeSet | TreeSet | entries(): IterableIterator<[T, T]>; | 新增 | +| ohos.util.TreeSet | TreeSet | values(): IterableIterator; | 新增 | +| ohos.util.TreeSet | TreeSet | forEach(callbackfn: (value?: T, key?: T, set?: TreeSet) => void, thisArg?: Object): void;| 新增 | +| ohos.util.TreeSet | TreeSet | popLast(): T; | 新增 | +| ohos.util.TreeSet | TreeSet | popFirst(): T; | 新增 | +| ohos.util.TreeSet | TreeSet | getHigherValue(key: T): T; | 新增 | +| ohos.util.TreeSet | TreeSet | getLowerValue(key: T): T; | 新增 | +| ohos.util.TreeSet | TreeSet | getLastValue(): T; | 新增 | +| ohos.util.TreeSet | TreeSet | getFirstValue(): T; | 新增 | +| ohos.util.TreeSet | TreeSet | clear(): void; | 新增 | +| ohos.util.TreeSet | TreeSet | remove(value: T): boolean; | 新增 | +| ohos.util.TreeSet | TreeSet | add(value: T): boolean; | 新增 | +| ohos.util.TreeSet | TreeSet | has(value: T): boolean; | 新增 | +| ohos.util.TreeSet | TreeSet | isEmpty(): boolean; | 新增 | +| ohos.util.TreeSet | TreeSet | length: number; | 新增 | +| ohos.util.TreeSet | TreeSet | constructor(comparator?: (firstValue: T, secondValue: T) => boolean) | 新增 | +| ohos.util.TreeMap | TreeMap | [Symbol.iterator](): IterableIterator<[K, V]>; | 新增 | +| ohos.util.TreeMap | TreeMap | entries(): IterableIterator<[K, V]>; | 新增 | +| ohos.util.TreeMap | TreeMap | forEach(callbackfn: (value?: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void; | 新增 | +| ohos.util.TreeMap | TreeMap | replace(key: K, newValue: V): boolean; | 新增 | +| ohos.util.TreeMap | TreeMap | values(): IterableIterator; | 新增 | +| ohos.util.TreeMap | TreeMap | keys(): IterableIterator; | 新增 | +| ohos.util.TreeMap | TreeMap | getHigherKey(key: K): K; | 新增 | +| ohos.util.TreeMap | TreeMap | getLowerKey(key: K): K; | 新增 | +| ohos.util.TreeMap | TreeMap | clear(): void; | 新增 | +| ohos.util.TreeMap | TreeMap | remove(key: K): V; | 新增 | +| ohos.util.TreeMap | TreeMap | set(key: K, value: V): Object; | 新增 | +| ohos.util.TreeMap | TreeMap | setAll(map: TreeMap): void; | 新增 | +| ohos.util.TreeMap | TreeMap | getLastKey(): K; | 新增 | +| ohos.util.TreeMap | TreeMap | getFirstKey(): K; | 新增 | +| ohos.util.TreeMap | TreeMap | get(key: K): V; | 新增 | +| ohos.util.TreeMap | TreeMap | hasValue(value: V): boolean; | 新增 | +| ohos.util.TreeMap | TreeMap | hasKey(key: K): boolean; | 新增 | +| ohos.util.TreeMap | TreeMap | isEmpty(): boolean; | 新增 | +| ohos.util.TreeMap | TreeMap | length: number; | 新增 | +| ohos.util.TreeMap | TreeMap | constructor(comparator?: (firstValue: K, secondValue: K) => boolean); | 新增 | +| ohos.util.Stack | Stack | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.Stack | Stack | forEach(callbackfn: (value: T, index?: number, stack?: Stack) => void, thisArg?: Object): void; | 新增 | +| ohos.util.Stack | Stack | locate(element: T): number; | 新增 | +| ohos.util.Stack | Stack | push(item: T): T; | 新增 | +| ohos.util.Stack | Stack | pop(): T; | 新增 | +| ohos.util.Stack | Stack | peek(): T; | 新增 | +| ohos.util.Stack | Stack | isEmpty(): boolean; | 新增 | +| ohos.util.Stack | Stack | length: number; | 新增 | +| ohos.util.Stack | Stack | constructor(); | 新增 | +| ohos.util.Queue | Queue | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.Queue | Queue | forEach(callbackfn: (value: T, index?: number, Queue?: Queue) => void, thisArg?: Object): void; | 新增 | +| ohos.util.Queue | Queue | pop(): T; | 新增 | +| ohos.util.Queue | Queue | getFirst(): T; | 新增 | +| ohos.util.Queue | Queue | add(element: T): boolean; | 新增 | +| ohos.util.Queue | Queue | length: number; | 新增 | +| ohos.util.Queue | Queue | constructor(); | 新增 | +| ohos.util.PlainArray | PlainArray | [Symbol.iterator](): IterableIterator<[number, T]>; | 新增 | +| ohos.util.PlainArray | PlainArray | forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void; | 新增 | +| ohos.util.PlainArray | PlainArray | getValueAt(index: number): T; | 新增 | +| ohos.util.PlainArray | PlainArray | toString(): String; | 新增 | +| ohos.util.PlainArray | PlainArray | setValueAt(index: number, value: T): void; | 新增 | +| ohos.util.PlainArray | PlainArray | removeRangeFrom(index: number, size: number): number; | 新增 | +| ohos.util.PlainArray | PlainArray | removeAt(index: number): T; | 新增 | +| ohos.util.PlainArray | PlainArray | remove(key: number): T; | 新增 | +| ohos.util.PlainArray | PlainArray | getKeyAt(index: number): number; | 新增 | +| ohos.util.PlainArray | PlainArray | isEmpty(): boolean; | 新增 | +| ohos.util.PlainArray | PlainArray | getIndexOfValue(value: T): number; | 新增 | +| ohos.util.PlainArray | PlainArray | getIndexOfKey(key: number): number; | 新增 | +| ohos.util.PlainArray | PlainArray | get(key: number): T; | 新增 | +| ohos.util.PlainArray | PlainArray | has(key: number): boolean; | 新增 | +| ohos.util.PlainArray | PlainArray | clone(): PlainArray; | 新增 | +| ohos.util.PlainArray | PlainArray | clear(): void; | 新增 | +| ohos.util.PlainArray | PlainArray | add(key: number, value: T): void; | 新增 | +| ohos.util.PlainArray | PlainArray | length: number; | 新增 | +| ohos.util.PlainArray | PlainArray | constructor(); | 新增 | +| ohos.util.List | List | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.List | List | isEmpty(): boolean; | 新增 | +| ohos.util.List | List | convertToArray(): Array; | 新增 | +| ohos.util.List | List | replaceAllElements(callbackfn: (value: T, index?: number, list?: List) => T, thisArg?: Object): void; | 新增 | +| ohos.util.List | List | getSubList(fromIndex: number, toIndex: number): List; | 新增 | +| ohos.util.List | List | clear(): void; | 新增 | +| ohos.util.List | List | sort(comparator: (firstValue: T, secondValue: T) => number): void; | 新增 | +| ohos.util.List | List | forEach(callbackfn: (value: T, index?: number, List?: List) => void, thisArg?: Object): void; | 新增 | +| ohos.util.List | List | equal(obj: Object): boolean; | 新增 | +| ohos.util.List | List | set(index: number, element: T): T; | 新增 | +| ohos.util.List | List | getLast(): T; | 新增 | +| ohos.util.List | List | getFirst(): T; | 新增 | +| ohos.util.List | List | getLastIndexOf(element: T): number; | 新增 | +| ohos.util.List | List | remove(element: T): boolean; | 新增 | +| ohos.util.List | List | removeByIndex(index: number): T; | 新增 | +| ohos.util.List | List | getIndexOf(element: T): number; | 新增 | +| ohos.util.List | List | has(element: T): boolean; | 新增 | +| ohos.util.List | List | get(index: number): T; | 新增 | +| ohos.util.List | List | insert(element: T, index: number): void; | 新增 | +| ohos.util.List | List | add(element: T): boolean; | 新增 | +| ohos.util.List | List | length: number; | 新增 | +| ohos.util.List | List | constructor(); | 新增 | +| ohos.util.LinkedList | LinkedList | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.LinkedList | LinkedList | convertToArray(): Array; | 新增 | +| ohos.util.LinkedList | LinkedList | clone(): LinkedList; | 新增 | +| ohos.util.LinkedList | LinkedList | clear(): void; | 新增 | +| ohos.util.LinkedList | LinkedList | forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList) => void, thisArg?: Object): void; | 新增 | +| ohos.util.LinkedList | LinkedList | set(index: number, element: T): T; | 新增 | +| ohos.util.LinkedList | LinkedList | getLast(): T; | 新增 | +| ohos.util.LinkedList | LinkedList | getFirst(): T; | 新增 | +| ohos.util.LinkedList | LinkedList | getLastIndexOf(element: T): number; | 新增 | +| ohos.util.LinkedList | LinkedList | removeLastFound(element: T): boolean; | 新增 | +| ohos.util.LinkedList | LinkedList | removeFirstFound(element: T): boolean; | 新增 | +| ohos.util.LinkedList | LinkedList | remove(element: T): boolean; | 新增 | +| ohos.util.LinkedList | LinkedList | removeByIndex(index: number): T; | 新增 | +| ohos.util.LinkedList | LinkedList | getIndexOf(element: T): number; | 新增 | +| ohos.util.LinkedList | LinkedList | has(element: T): boolean; | 新增 | +| ohos.util.LinkedList | LinkedList | removeLast(): T; | 新增 | +| ohos.util.LinkedList | LinkedList | removeFirst(): T; | 新增 | +| ohos.util.LinkedList | LinkedList | addFirst(element: T): void; | 新增 | +| ohos.util.LinkedList | LinkedList | get(index: number): T; | 新增 | +| ohos.util.LinkedList | LinkedList | insert(index: number, element: T): void; | 新增 | +| ohos.util.LinkedList | LinkedList | add(element: T): boolean; | 新增 | +| ohos.util.LinkedList | LinkedList | length: number; | 新增 | +| ohos.util.LinkedList | LinkedList | constructor(); | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | isEmpty(): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | entries(): IterableIterator<[T, T]>; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | values(): IterableIterator; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | getValueAt(index: number): T; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | toArray(): Array; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | toString(): String; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | forEach(callbackfn: (value?: T, key?: T, set?: LightWeightSet) => void, thisArg?: Object): void; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | clear(): void; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | removeAt(index: number): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | remove(key: T): T; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | getIndexOf(key: T): number; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | increaseCapacityTo(minimumCapacity: number): void; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | equal(obj: Object): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | has(key: T): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | hasAll(set: LightWeightSet): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | addAll(set: LightWeightSet): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | add(obj: T): boolean; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | length: number; | 新增 | +| ohos.util.LightWeightSet | LightWeightSet | constructor(); | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | values(): IterableIterator; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | getValueAt(index: number): V; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | toString(): String; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | [Symbol.iterator](): IterableIterator<[K, V]>; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | setValueAt(index: number, newValue: V): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | clear(): void; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | removeAt(index: number): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | remove(key: K): V; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | set(key: K, value: V): Object; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | setAll(map: LightWeightMap): void; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | keys(): IterableIterator; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | getKeyAt(index: number): K; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | isEmpty(): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | getIndexOfValue(value: V): number; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | getIndexOfKey(key: K): number; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | get(key: K): V; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | entries(): IterableIterator<[K, V]>; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | increaseCapacityTo(minimumCapacity: number): void; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | hasValue(value: V): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | hasKey(key: K): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | hasAll(map: LightWeightMap): boolean; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | length: number; | 新增 | +| ohos.util.LightWeightMap | LightWeightMap | constructor(); | 新增 | +| ohos.util.HashSet | HashSet | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.HashSet | HashSet | entries(): IterableIterator<[T, T]>; | 新增 | +| ohos.util.HashSet | HashSet | values(): IterableIterator; | 新增 | +| ohos.util.HashSet | HashSet | forEach(callbackfn: (value?: T, key?: T, set?: HashSet) => void, thisArg?: Object): void; | 新增 | +| ohos.util.HashSet | HashSet | clear(): void; | 新增 | +| ohos.util.HashSet | HashSet | remove(value: T): boolean; | 新增 | +| ohos.util.HashSet | HashSet | add(value: T): boolean; | 新增 | +| ohos.util.HashSet | HashSet | has(value: T): boolean; | 新增 | +| ohos.util.HashSet | HashSet | isEmpty(): boolean; | 新增 | +| ohos.util.HashSet | HashSet | length: number; | 新增 | +| ohos.util.HashSet | HashSet | constructor(); | 新增 | +| ohos.util.HashMap | HashMap | [Symbol.iterator](): IterableIterator<[K, V]>; | 新增 | +| ohos.util.HashMap | HashMap | entries(): IterableIterator<[K, V]>; | 新增 | +| ohos.util.HashMap | HashMap | forEach(callbackfn: (value?: V, key?: K, map?: HashMap) => void, thisArg?: Object): void; | 新增 | +| ohos.util.HashMap | HashMap | replace(key: K, newValue: V): boolean; | 新增 | +| ohos.util.HashMap | HashMap | values(): IterableIterator; | 新增 | +| ohos.util.HashMap | HashMap | keys(): IterableIterator; | 新增 | +| ohos.util.HashMap | HashMap | clear(): void; | 新增 | +| ohos.util.HashMap | HashMap | remove(key: K): V; | 新增 | +| ohos.util.HashMap | HashMap | set(key: K, value: V): Object; | 新增 | +| ohos.util.HashMap | HashMap | setAll(map: HashMap): void; | 新增 | +| ohos.util.HashMap | HashMap | get(key: K): V; | 新增 | +| ohos.util.HashMap | HashMap | hasValue(value: V): boolean; | 新增 | +| ohos.util.HashMap | HashMap | hasKey(key: K): boolean; | 新增 | +| ohos.util.HashMap | HashMap | isEmpty(): boolean; | 新增 | +| ohos.util.HashMap | HashMap | length: number; | 新增 | +| ohos.util.HashMap | HashMap | constructor(); | 新增 | +| ohos.util.Deque | Deque | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.Deque | Deque | forEach(callbackfn: (value: T, index?: number, deque?: Deque) => void, thisArg?: Object): void; | 新增 | +| ohos.util.Deque | Deque | popLast(): T; | 新增 | +| ohos.util.Deque | Deque | popFirst(): T; | 新增 | +| ohos.util.Deque | Deque | getLast(): T; | 新增 | +| ohos.util.Deque | Deque | getFirst(): T; | 新增 | +| ohos.util.Deque | Deque | has(element: T): boolean; | 新增 | +| ohos.util.Deque | Deque | insertEnd(element: T): void; | 新增 | +| ohos.util.Deque | Deque | insertFront(element: T): void; | 新增 | +| ohos.util.Deque | Deque | length: number; | 新增 | +| ohos.util.Deque | Deque | constructor(); | 新增 | +| ohos.util | types | isWeakSet(value: Object): boolean; | 新增 | +| ohos.util | types | isWeakMap(value: Object): boolean; | 新增 | +| ohos.util | types | isUint32Array(value: Object): boolean; | 新增 | +| ohos.util | types | isUint16Array(value: Object): boolean; | 新增 | +| ohos.util | types | isUint8ClampedArray(value: Object): boolean; | 新增 | +| ohos.util | types | isUint8Array(value: Object): boolean; | 新增 | +| ohos.util | types | isTypedArray(value: Object): boolean; | 新增 | +| ohos.util | types | isSymbolObject(value: Object): boolean; | 新增 | +| ohos.util | types | isStringObject(value: Object): boolean; | 新增 | +| ohos.util | types | isSharedArrayBuffer(value: Object): boolean; | 新增 | +| ohos.util | types | isSetIterator(value: Object): boolean; | 新增 | +| ohos.util | types | isSet(value: Object): boolean; | 新增 | +| ohos.util | types | isRegExp(value: Object): boolean; | 新增 | +| ohos.util | types | isProxy(value: Object): boolean; | 新增 | +| ohos.util | types | isPromise(value: Object): boolean; | 新增 | +| ohos.util | types | isNumberObject(value: Object): boolean; | 新增 | +| ohos.util | types | isNativeError(value: Object): boolean; | 新增 | +| ohos.util | types | isModuleNamespaceObject(value: Object): boolean; | 新增 | +| ohos.util | types | isMapIterator(value: Object): boolean; | 新增 | +| ohos.util | types | isMap(value: Object): boolean; | 新增 | +| ohos.util | types | isInt32Array(value: Object): boolean; | 新增 | +| ohos.util | types | isInt16Array(value: Object): boolean; | 新增 | +| ohos.util | types | isInt8Array(value: Object): boolean; | 新增 | +| ohos.util | types | isGeneratorObject(value: Object): boolean; | 新增 | +| ohos.util | types | isGeneratorFunction(value: Object): boolean; | 新增 | +| ohos.util | types | isFloat64Array(value: Object): boolean; | 新增 | +| ohos.util | types | isFloat32Array(value: Object): boolean; | 新增 | +| ohos.util | types | isExternal(value: Object): boolean; | 新增 | +| ohos.util | types | isDate(value: Object): boolean; | 新增 | +| ohos.util | types | isDataView(value: Object): boolean; | 新增 | +| ohos.util | types | isBoxedPrimitive(value: Object): boolean; | 新增 | +| ohos.util | types | isBooleanObject(value: Object): boolean; | 新增 | +| ohos.util | types | isBigUint64Array(value: Object): boolean; | 新增 | +| ohos.util | types | isBigInt64Array(value: Object): boolean; | 新增 | +| ohos.util | types | isAsyncFunction(value: Object): boolean; | 新增 | +| ohos.util | types | isArrayBuffer(value: Object): boolean; | 新增 | +| ohos.util | types | isArgumentsObject(value: Object): boolean; | 新增 | +| ohos.util | types | isArrayBufferView(value: Object): boolean; | 新增 | +| ohos.util | types | isAnyArrayBuffer(value: Object): boolean; | 新增 | +| ohos.util | types | constructor(); | 新增 | +| ohos.util | Base64 | decodeSync(src: Uint8Array \| string): Uint8Array; | 新增 | +| ohos.util | Base64 | encodeToStringSync(src: Uint8Array): string; | 新增 | +| ohos.util | Base64 | encodeSync(src: Uint8Array): Uint8Array; | 新增 | +| ohos.util | LruBuffer | getCapacity(): number; | 新增 | +| ohos.util | LruBuffer | length:number | 新增 | +| ohos.util | RationalNumber | valueOf(): number; | 新增 | +| ohos.util.ArrayList | ArrayList | [Symbol.iterator](): IterableIterator; | 新增 | +| ohos.util.ArrayList | ArrayList | trimToCurrentLength(): void; | 新增 | +| ohos.util.ArrayList | ArrayList | increaseCapacityTo(newCapacity: number): void; | 新增 | +| ohos.util.ArrayList | ArrayList | isEmpty(): boolean; | 新增 | +| ohos.util.ArrayList | ArrayList | convertToArray(): Array; | 新增 | +| ohos.util.ArrayList | ArrayList | getCapacity(): number; | 新增 | +| ohos.util.ArrayList | ArrayList | clone(): ArrayList; | 新增 | +| ohos.util.ArrayList | ArrayList | clear(): void; | 新增 | +| ohos.util.ArrayList | ArrayList | subArrayList(fromIndex: number, toIndex: number): ArrayList; | 新增 | +| ohos.util.ArrayList | ArrayList | sort(comparator?: (firstValue: T, secondValue: T) => number): void; | 新增 | +| ohos.util.ArrayList | ArrayList | forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList) => void, thisArg?: Object): void; | 新增 | +| ohos.util.ArrayList | ArrayList | replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList) => T, thisArg?: Object): void; | 新增 | +| ohos.util.ArrayList | ArrayList | removeByRange(fromIndex: number, toIndex: number): void; | 新增 | +| ohos.util.ArrayList | ArrayList | getLastIndexOf(element: T): number; | 新增 | +| ohos.util.ArrayList | ArrayList | remove(element: T): boolean; | 新增 | +| ohos.util.ArrayList | ArrayList | removeByIndex(index: number): T; | 新增 | +| ohos.util.ArrayList | ArrayList | getIndexOf(element: T): number; | 新增 | +| ohos.util.ArrayList | ArrayList | has(element: T): boolean; | 新增 | +| ohos.util.ArrayList | ArrayList | insert(element: T, index: number): void; | 新增 | +| ohos.util.ArrayList | ArrayList | add(element: T): boolean; | 新增 | +| ohos.util.ArrayList | ArrayList | length: number; | 新增 | +| ohos.util.ArrayList | ArrayList | constructor(); | 新增 | +| ohos.uri | URI | ssp: string; | 新增 | +| ohos.uri | URI | authority: string; | 新增 | +| ohos.uri | URI | fragment: string; | 新增 | +| ohos.uri | URI | query: string; | 新增 | +| ohos.uri | URI | path: string; | 新增 | +| ohos.uri | URI | port: string; | 新增 | +| ohos.uri | URI | host: string; | 新增 | +| ohos.uri | URI | userInfo: string; | 新增 | +| ohos.uri | URI | scheme: string; | 新增 | +| ohos.uri | URI | normalize(): URI; | 新增 | +| ohos.uri | URI | checkIsAbsolute(): boolean; | 新增 | +| ohos.uri | URI | equals(other: URI): boolean; | 新增 | +| ohos.uri | URI | toString(): string | 新增 | +| ohos.uri | URI | constructor(uri: string); | 新增 | +| ohos.convertxml | ConvertXML | convert(xml: string, options?: ConvertOptions) : Object; | 新增 | +| ohos.convertxml | ConvertOptions | elementsKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | nameKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | typeKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | parentKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | commentKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | doctypeKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | cdataKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | textKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | attributesKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | instructionKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | declarationKey: string; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreText?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreDoctype?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreCDATA?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreComment?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreAttributes?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreInstruction?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | ignoreDeclaration?: boolean; | 新增 | +| ohos.convertxml | ConvertOptions | trim: boolean; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-config-policy.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-config-policy.md deleted file mode 100644 index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-config-policy.md +++ /dev/null @@ -1,14 +0,0 @@ -# xxx子系统JS API变更 - -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: - -## 接口变更 - -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-dfx.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-dfx.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..cbe08e0a2e50290c85ab96b2d673cb4a9d7c5071 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-dfx.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-dfx.md @@ -1,14 +1,82 @@ -# xxx子系统JS API变更 +# DFX子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,DFX子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.hiTraceMeter | hiTraceMeter | function traceByValue(name: string, count: number): void; | 新增 | +| ohos.hiTraceMeter | hiTraceMeter | function finishTrace(name: string, taskId: number): void; | 新增 | +| ohos.hiTraceMeter | hiTraceMeter | function startTrace(name: string, taskId: number): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function isValid(id: HiTraceId): boolean; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function createSpan(): HiTraceId; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function clearId(): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function setId(id: HiTraceId): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function getId(): HiTraceId; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function end(id: HiTraceId): void; | 新增 | +| ohos.hiTraceChain | hiTraceChain | function begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId; | 新增 | +| ohos.hiTraceChain | HiTraceId | flags?: number; | 新增 | +| ohos.hiTraceChain | HiTraceId | parentSpanId?: number; | 新增 | +| ohos.hiTraceChain | HiTraceId | spanId?: number; | 新增 | +| ohos.hiTraceChain | HiTraceId | chainId: bigint; | 新增 | +| ohos.hiTraceChain | HiTraceCommunicationMode | DEVICE = 3 | 新增 | +| ohos.hiTraceChain | HiTraceCommunicationMode | PROCESS = 2 | 新增 | +| ohos.hiTraceChain | HiTraceCommunicationMode | THREAD = 1 | 新增 | +| ohos.hiTraceChain | HiTraceCommunicationMode | DEFAULT = 0 | 新增 | +| ohos.hiTraceChain | HiTraceTracepointType | GENERAL = 4 | 新增 | +| ohos.hiTraceChain | HiTraceTracepointType | SR = 3 | 新增 | +| ohos.hiTraceChain | HiTraceTracepointType | SS = 2 | 新增 | +| ohos.hiTraceChain | HiTraceTracepointType | CR = 1 | 新增 | +| ohos.hiTraceChain | HiTraceTracepointType | CS = 0 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | D2D_TP_INFO = 1 << 6 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | FAILURE_TRIGGER = 1 << 5 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | DISABLE_LOG = 1 << 4 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | NO_BE_INFO = 1 << 3 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | TP_INFO = 1 << 2 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | DONOT_CREATE_SPAN = 1 << 1 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | INCLUDE_ASYNC = 1 | 新增 | +| ohos.hiTraceChain | HiTraceFlag | DEFAULT = 0 | 新增 | +| ohos.hilog | LogLevel | FATAL = 7 | 新增 | +| ohos.hilog | LogLevel | ERROR = 6 | 新增 | +| ohos.hilog | LogLevel | WARN = 5 | 新增 | +| ohos.hilog | LogLevel | INFO = 4 | 新增 | +| ohos.hilog | LogLevel | DEBUG = 3 | 新增 | +| ohos.hilog | hilog | function isLoggable(domain: number, tag: string, level: LogLevel) : boolean; | 新增 | +| ohos.hilog | hilog | function fatal(domain: number, tag: string, format: string, ...args: any[]) : void; | 新增 | +| ohos.hilog | hilog | function error(domain: number, tag: string, format: string, ...args: any[]) : void; | 新增 | +| ohos.hilog | hilog | function warn(domain: number, tag: string, format: string, ...args: any[]) : void; | 新增 | +| ohos.hilog | hilog | function info(domain: number, tag: string, format: string, ...args: any[]) : void; | 新增 | +| ohos.hilog | hilog | function debug(domain: number, tag: string, format: string, ...args: any[]) : void; | 新增 | +| ohos.hidebug | hidebug | function dumpHeapData(filename : string) : void; | 新增 | +| ohos.hidebug | hidebug | function stopProfiling() : void; | 新增 | +| ohos.hidebug | hidebug | function startProfiling(filename : string) : void; | 新增 | +| ohos.hidebug | hidebug | function getSharedDirty() : bigint; | 新增 | +| ohos.hidebug | hidebug | function getPss() : bigint; | 新增 | +| ohos.hidebug | hidebug | function getNativeHeapFreeSize() : bigint; | 新增 | +| ohos.hidebug | hidebug | function getNativeHeapAllocatedSize() : bigint; | 新增 | +| ohos.hidebug | hidebug | function getNativeHeapSize() : bigint; | 新增 | +| ohos.hichecker | hichecker | function contains(rule: bigint) : boolean; | 新增 | +| ohos.hichecker | hichecker | function getRule() : bigint; | 新增 | +| ohos.hichecker | hichecker | function removeRule(rule: bigint) : void; | 新增 | +| ohos.hichecker | hichecker | function addRule(rule: bigint) : void; | 新增 | +| ohos.hichecker | hichecker | const RULE_CHECK_ABILITY_CONNECTION_LEAK: 8589934592n; | 新增 | +| ohos.hichecker | hichecker | const RULE_THREAD_CHECK_SLOW_PROCESS: 1n; | 新增 | +| ohos.hichecker | hichecker | const RULE_CAUTION_TRIGGER_CRASH: 4611686018427387904n; | 新增 | +| ohos.hichecker | hichecker | const RULE_CAUTION_PRINT_LOG: 9223372036854775808n; | 新增 | +| ohos.faultLogger | FaultLogInfo | fullLog: string; | 新增 | +| ohos.faultLogger | FaultLogInfo | summary: string; | 新增 | +| ohos.faultLogger | FaultLogInfo | module: string; | 新增 | +| ohos.faultLogger | FaultLogInfo | reason: string; | 新增 | +| ohos.faultLogger | FaultLogInfo | timestamp: number; | 新增 | +| ohos.faultLogger | FaultLogInfo | type: FaultType; | 新增 | +| ohos.faultLogger | FaultLogInfo | uid: number; | 新增 | +| ohos.faultLogger | FaultLogInfo | pid: number; | 新增 | +| ohos.faultLogger | FaultLogger | function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback>) : void;
function querySelfFaultLog(faultType: FaultType) : Promise>; | 新增 | +| ohos.faultLogger | FaultType | APP_FREEZE = 4 | 新增 | +| ohos.faultLogger | FaultType | JS_CRASH = 3 | 新增 | +| ohos.faultLogger | FaultType | CPP_CRASH = 2 | 新增 | +| ohos.faultLogger | FaultType | NO_SPECIFIC = 0 | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..47513c750ffc9a63a72a8f14ee9e73a286376bd4 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md @@ -1,14 +1,111 @@ -# xxx子系统JS API变更 +# 分布式数据管理子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,分布式数据管理子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.data.rdb | RdbPredicates | inAllDevices(): RdbPredicates; | 新增 | +| ohos.data.rdb | RdbPredicates | inDevices(devices: Array): RdbPredicates; | 新增 | +| ohos.data.rdb | RdbStore | off(event:'dataChange', type: SubscribeType, observer: Callback>): void; | 新增 | +| ohos.data.rdb | RdbStore | on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; | 新增 | +| ohos.data.rdb | RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void;
sync(mode: SyncMode, predicates: RdbPredicates): Promise>; | 新增 | +| ohos.data.rdb | RdbStore | obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void;
obtainDistributedTableName(device: string, table: string): Promise; | 新增 | +| ohos.data.rdb | RdbStore | setDistributedTables(tables: Array, callback: AsyncCallback): void;
setDistributedTables(tables: Array): Promise; | 新增 | +| ohos.data.rdb | RdbStore | rollBack():void; | 新增 | +| ohos.data.rdb | RdbStore | commit():void; | 新增 | +| ohos.data.rdb | RdbStore | beginTransaction():void; | 新增 | +| ohos.data.rdb | RdbStore | querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void;
querySql(sql: string, bindArgs?: Array): Promise; | 新增 | +| ohos.data.rdb | SubscribeType | SUBSCRIBE_TYPE_REMOTE = 0 | 新增 | +| ohos.data.rdb | SyncMode | SYNC_MODE_PULL = 1 | 新增 | +| ohos.data.rdb | SyncMode | SYNC_MODE_PUSH = 0 | 新增 | +| ohos.data.distributedDataObject | DistributedObject | off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array }>): void; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | on(type: 'change', callback: Callback<{ sessionId: string, fields: Array }>): void; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | setSessionId(sessionId?: string): boolean; | 新增 | +| ohos.data.distributedDataObject | distributedDataObject | function genSessionId(): string; | 新增 | +| ohos.data.distributedDataObject | distributedDataObject | function createDistributedObject(source: object): DistributedObject; | 新增 | +| ohos.data.distributedData | KVManager | off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; | 新增 | +| ohos.data.distributedData | KVManager | on(event: 'distributedDataServiceDie', deathCallback: Callback): void; | 新增 | +| ohos.data.distributedData | KVManager | getAllKVStoreId(appId: string, callback: AsyncCallback): void;
getAllKVStoreId(appId: string): Promise; | 新增 | +| ohos.data.distributedData | KVManager | deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void;
deleteKVStore(appId: string, storeId: string): Promise; | 新增 | +| ohos.data.distributedData | KVManager | closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback): void;
closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | off(event: 'syncComplete', syncCallback?: Callback>): void; | 新增 | +| ohos.data.distributedData | DeviceKVStore | on(event: 'syncComplete', syncCallback: Callback>): void; | 新增 | +| ohos.data.distributedData | DeviceKVStore | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void; | 新增 | +| ohos.data.distributedData | DeviceKVStore | removeDeviceData(deviceId: string, callback: AsyncCallback): void;
removeDeviceData(deviceId: string): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | getResultSize(query: Query, callback: AsyncCallback): void;
getResultSize(query: Query): Promise;
getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void;
getResultSize(deviceId: string, query: Query): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void;
closeResultSet(resultSet: KvStoreResultSet): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback): void;
getResultSet(deviceId: string, keyPrefix: string): Promise;
getResultSet(query: Query, callback: AsyncCallback): void;
getResultSet(query: Query): Promise;
getResultSet(deviceId: string, query: Query, callback: AsyncCallback): void;
getResultSet(deviceId: string, query: Query): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback): void;
getEntries(deviceId: string, keyPrefix: string): Promise;
getEntries(query: Query, callback: AsyncCallback): void;
getEntries(query: Query): Promise;
getEntries(deviceId: string, query: Query, callback: AsyncCallback): void;
getEntries(deviceId: string, query: Query): Promise; | 新增 | +| ohos.data.distributedData | DeviceKVStore | get(deviceId: string, key: string, callback: AsyncCallback): void;
get(deviceId: string, key: string): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | getSecurityLevel(callback: AsyncCallback): void;
getSecurityLevel(): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback): void;
setSyncParam(defaultAllowedDelayMs: number): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | off(event: 'syncComplete', syncCallback?: Callback>): void; | 新增 | +| ohos.data.distributedData | SingleKVStore | on(event: 'syncComplete', syncCallback: Callback>): void; | 新增 | +| ohos.data.distributedData | SingleKVStore | removeDeviceData(deviceId: string, callback: AsyncCallback): void;
removeDeviceData(deviceId: string): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | getResultSize(query: Query, callback: AsyncCallback): void;
getResultSize(query: Query): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void;
closeResultSet(resultSet: KvStoreResultSet): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | getResultSet(keyPrefix: string, callback: AsyncCallback): void;
getResultSet(keyPrefix: string): Promise;
getResultSet(query: Query, callback: AsyncCallback): void;
getResultSet(query: Query): Promise; | 新增 | +| ohos.data.distributedData | SingleKVStore | getEntries(keyPrefix: string, callback: AsyncCallback): void;
getEntries(keyPrefix: string): Promise;
getEntries(query: Query, callback: AsyncCallback): void;
getEntries(query: Query): Promise; | 新增 | +| ohos.data.distributedData | KVStore | setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void;
setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; | 新增 | +| ohos.data.distributedData | KVStore | enableSync(enabled: boolean, callback: AsyncCallback): void;
enableSync(enabled: boolean): Promise; | 新增 | +| ohos.data.distributedData | KVStore | rollback(callback: AsyncCallback): void;
rollback(): Promise; | 新增 | +| ohos.data.distributedData | KVStore | commit(callback: AsyncCallback): void;
commit(): Promise; | 新增 | +| ohos.data.distributedData | KVStore | startTransaction(callback: AsyncCallback): void;
startTransaction(): Promise; | 新增 | +| ohos.data.distributedData | KVStore | deleteBatch(keys: string[], callback: AsyncCallback): void;
deleteBatch(keys: string[]): Promise; | 新增 | +| ohos.data.distributedData | KVStore | putBatch(entries: Entry[], callback: AsyncCallback): void;
putBatch(entries: Entry[]): Promise; | 新增 | +| ohos.data.distributedData | KVStore | off(event:'dataChange', observer?: Callback): void; | 新增 | +| ohos.data.distributedData | Query | getSqlLike():string; | 新增 | +| ohos.data.distributedData | Query | deviceId(deviceId:string):Query; | 新增 | +| ohos.data.distributedData | Query | setSuggestIndex(index: string): Query; | 新增 | +| ohos.data.distributedData | Query | prefixKey(prefix: string): Query; | 新增 | +| ohos.data.distributedData | Query | endGroup(): Query; | 新增 | +| ohos.data.distributedData | Query | beginGroup(): Query; | 新增 | +| ohos.data.distributedData | Query | isNotNull(field: string): Query; | 新增 | +| ohos.data.distributedData | Query | limit(total: number, offset: number): Query; | 新增 | +| ohos.data.distributedData | Query | orderByDesc(field: string): Query; | 新增 | +| ohos.data.distributedData | Query | orderByAsc(field: string): Query; | 新增 | +| ohos.data.distributedData | Query | or(): Query; | 新增 | +| ohos.data.distributedData | Query | and(): Query; | 新增 | +| ohos.data.distributedData | Query | unlike(field: string, value: string): Query; | 新增 | +| ohos.data.distributedData | Query | like(field: string, value: string): Query; | 新增 | +| ohos.data.distributedData | Query | notInString(field: string, valueList: string[]): Query; | 新增 | +| ohos.data.distributedData | Query | notInNumber(field: string, valueList: number[]): Query; | 新增 | +| ohos.data.distributedData | Query | inString(field: string, valueList: string[]): Query; | 新增 | +| ohos.data.distributedData | Query | inNumber(field: string, valueList: number[]): Query; | 新增 | +| ohos.data.distributedData | Query | isNull(field: string): Query; | 新增 | +| ohos.data.distributedData | Query | lessThanOrEqualTo(field: string, value: number\|string): Query; | 新增 | +| ohos.data.distributedData | Query | greaterThanOrEqualTo(field: string, value: number\|string): Query; | 新增 | +| ohos.data.distributedData | Query | lessThan(field: string, value: number\|string): Query; | 新增 | +| ohos.data.distributedData | Query | greaterThan(field: string, value: number\|string\|boolean): Query; | 新增 | +| ohos.data.distributedData | Query | notEqualTo(field: string, value: number\|string\|boolean): Query; | 新增 | +| ohos.data.distributedData | Query | equalTo(field: string, value: number\|string\|boolean): Query; | 新增 | +| ohos.data.distributedData | Query | reset(): Query; | 新增 | +| ohos.data.distributedData | Query | constructor() | 新增 | +| ohos.data.distributedData | KvStoreResultSet | getEntry(): Entry; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | isAfterLast(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | isBeforeFirst(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | isLast(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | isFirst(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | moveToPosition(position: number): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | move(offset: number): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | moveToPrevious(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | moveToNext(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | moveToLast(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | moveToFirst(): boolean; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | getPosition(): number; | 新增 | +| ohos.data.distributedData | KvStoreResultSet | getCount(): number; | 新增 | +| ohos.data.distributedData | FieldNode | type: number; | 新增 | +| ohos.data.distributedData | FieldNode | nullable: boolean; | 新增 | +| ohos.data.distributedData | FieldNode | default: string; | 新增 | +| ohos.data.distributedData | FieldNode | appendChild(child: FieldNode): boolean; | 新增 | +| ohos.data.distributedData | FieldNode | constructor(name: string) | 新增 | +| ohos.data.distributedData | Schema | skip: number; | 新增 | +| ohos.data.distributedData | Schema | mode: number; | 新增 | +| ohos.data.distributedData | Schema | indexes: Array; | 新增 | +| ohos.data.distributedData | Schema | root: FieldNode; | 新增 | +| ohos.data.distributedData | Schema | constructor() | 新增 | +| ohos.data.distributedData | Options | schema?: Schema; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md index 15fdc3da8b457d64e11364dc221db6e3d3d38082..694e03c4ec8d7f4ad99d7dc6c1549d1afd241292 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md @@ -1,4 +1,4 @@ -# JS API Diff +# 分布式硬件子系统JS API变更 OpenHarmony 3.1 LTS版本相较于OpenHarmony 3.1 Beta版本的API变更如下: diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..3b7cb75a1f4407df5f92c06cc9d397f92ac74b35 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md @@ -1,14 +1,37 @@ -# xxx子系统JS API变更 +# 事件通知子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,事件通知子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| notificationUserInput | NotificationUserInput | inputKey: string; | 新增 | +| notificationTemplate | NotificationTemplate | data: {[key: string]: Object}; | 新增 | +| notificationTemplate | NotificationTemplate | name: string; | 新增 | +| notificationRequest | DistributedOptions | supportOperateDevices?: Array; | 新增 | +| notificationRequest | DistributedOptions | supportDisplayDevices?: Array; | 新增 | +| notificationRequest | DistributedOptions | isDistributed?: boolean; | 新增 | +| notificationRequest | NotificationRequest | readonly notificationFlags?: NotificationFlags; | 新增 | +| notificationRequest | NotificationRequest | distributedOption?: DistributedOptions; | 新增 | +| notificationRequest | NotificationRequest | template?: NotificationTemplate; | 新增 | +| notificationRequest | NotificationRequest | readonly creatorUserId?: number; | 新增 | +| notificationRequest | NotificationRequest | groupName?: string; | 新增 | +| notificationActionButton | NotificationActionButton | userInput?: NotificationUserInput; | 新增 | +| ohos.notification | notification | function isDistributedEnabled(callback: AsyncCallback): void;
function isDistributedEnabled(): Promise; | 新增 | +| ohos.notification | notification | function requestEnableNotification(callback: AsyncCallback): void;
function requestEnableNotification(): Promise; | 新增 | +| ohos.notification | notification | function isSupportTemplate(templateName: string, callback: AsyncCallback): void;
function isSupportTemplate(templateName: string): Promise; | 新增 | +| ohos.notification | notification | function cancelGroup(groupName: string, callback: AsyncCallback): void;
function cancelGroup(groupName: string): Promise; | 新增 | +| ohos.events.emitter | EventPriority | IDLE | 新增 | +| ohos.events.emitter | EventPriority | LOW | 新增 | +| ohos.events.emitter | EventPriority | HIGH | 新增 | +| ohos.events.emitter | EventPriority | IMMEDIATE = 0 | 新增 | +| ohos.events.emitter | InnerEvent | priority?: EventPriority; | 新增 | +| ohos.events.emitter | InnerEvent | eventId: number; | 新增 | +| ohos.events.emitter | EventData | data?: {[key: string]: any}; | 新增 | +| ohos.events.emitter | emitter | function emit(event: InnerEvent, data?: EventData): void; | 新增 | +| ohos.events.emitter | emitter | function off(eventId: number): void; | 新增 | +| ohos.events.emitter | emitter | function once(event: InnerEvent, callback: Callback): void; | 新增 | +| ohos.events.emitter | emitter | function on(event: InnerEvent, callback: Callback): void; | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN" | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED" | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-file-management.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-file-management.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..a5d28bf4980001a228e693e25f2e7c6bd9d93479 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-file-management.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-file-management.md @@ -1,14 +1,58 @@ -# xxx子系统JS API变更 +# 文件管理子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,文件管理子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.statfs | Statfs | function getTotalBytes(path: string, callback: AsyncCallback): void;
function getTotalBytes(path: string): Promise; | 新增 | +| ohos.statfs | Statfs | function getFreeBytes(path: string, callback: AsyncCallback): void;
function getFreeBytes(path: string): Promise; | 新增 | +| ohos.fileio | Watcher | stop(): Promise;
stop(callback: AsyncCallback): void; | 新增 | +| ohos.fileio | ReadOut | buffer: ArrayBuffer; | 新增 | +| ohos.fileio | ReadOut | offset: number; | 新增 | +| ohos.fileio | ReadOut | bytesRead: number; | 新增 | +| ohos.fileio | Stream | read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length?: number; }): Promise;
read(buffer: ArrayBuffer, callback: AsyncCallback): void;
read(buffer: ArrayBuffer, options: { position?: number; offset?: number; length?: number; }, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | Stream | write(buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise;
write(buffer: ArrayBuffer \| string, callback: AsyncCallback): void;
write(buffer: ArrayBuffer \| string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | Stream | flush(): Promise;
flush(callback: AsyncCallback): void; | 新增 | +| ohos.fileio | Stream | close(): Promise;
close(callback: AsyncCallback): void; | 新增 | +| ohos.fileio | Dir | close(): Promise;
close(callback: AsyncCallback): void; | 新增 | +| ohos.fileio | Dir | read(): Promise;
read(callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function createWatcher(filename: string, events: number, callback: AsyncCallback): Watcher; | 新增 | +| ohos.fileio | fileIO | function write(fd: number, buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise;
function write(fd: number, buffer: ArrayBuffer \| string, callback: AsyncCallback): void;
function write(fd: number, buffer: ArrayBuffer \| string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function unlink(path: string): Promise;
function unlink(path: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function truncate(path: string, len?: number): Promise;
function truncate(path: string, callback: AsyncCallback): void;
function truncate(path: string, len: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function symlinkSync(target: string, srcPath: string): void; | 新增 | +| ohos.fileio | fileIO | function symlink(target: string, srcPath: string): Promise;
function symlink(target: string, srcPath: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function stat(path: string): Promise;
function stat(path: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function rmdir(path: string): Promise;
function rmdir(path: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function rename(oldPath: string, newPath: string): Promise;
function rename(oldPath: string, newPath: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }): Promise
function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void;
function read(fd: number, buffer: ArrayBuffer, options: { offset?: number; length?: number; position?: number; }, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function readTextSync(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): string;| 新增 | +| ohos.fileio | fileIO | function readText(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): Promise;
function readText(filePath: string, options: { position?: number; length?: number; encoding?: string; }, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function opendir(path: string): Promise;
function opendir(path: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function open(path: string, flags?: number, mode?: number): Promise;
function open(path: string, callback: AsyncCallback): void;
function open(path: string, flags: number, callback: AsyncCallback): void;
function open(path: string, flags: number, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function mkdtempSync(prefix: string): string; | 新增 | +| ohos.fileio | fileIO | function mkdtemp(prefix: string): Promise;
function mkdtemp(prefix: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function mkdir(path: string, mode?: number): Promise;
function mkdir(path: string, callback: AsyncCallback): void;
function mkdir(path: string, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function lstatSync(path: string): Stat; | 新增 | +| ohos.fileio | fileIO | function lstat(path: string): Promise;
function lstat(path: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function lchownSync(path: string, uid: number, gid: number): void; | 新增 | +| ohos.fileio | fileIO | function lchown(path: string, uid: number, gid: number): Promise;
function lchown(path: string, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function hash(path: string, algorithm: string): Promise;
function hash(path: string, algorithm: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fdopenStream(fd: number, mode: string): Promise;
function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fchmod(fd: number, mode: number): Promise;
function fchmod(fd: number, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fchown(fd: number, uid: number, gid: number): Promise;
function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fdatasyncSync(fd: number): void; | 新增 | +| ohos.fileio | fileIO | function fdatasync(fd: number): Promise;
function fdatasync(fd: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fstat(fd: number): Promise;
function fstat(fd: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function fsync(fd: number): Promise;
function fsync(fd: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function ftruncate(fd: number, len?: number): Promise;
function ftruncate(fd: number, callback: AsyncCallback): void;
function ftruncate(fd: number, len: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function chmod(path: string, mode: number): Promise;
function chmod(path: string, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function chown(path: string, uid: number, gid: number): Promise;
function chown(path: string, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function createStream(path: string, mode: string): Promise;
function createStream(path: string, mode: string, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function copyFile(src: string \| number, dest: string \| number, mode?: number): Promise;
function copyFile(src: string \| number, dest: string \| number, callback: AsyncCallback): void;
function copyFile(src: string \| number, dest: string \| number, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function close(fd: number): Promise;
function close(fd: number, callback: AsyncCallback): void; | 新增 | +| ohos.fileio | fileIO | function access(path: string, mode?: number): Promise;
function access(path: string, callback: AsyncCallback): void;
function access(path: string, mode: number, callback: AsyncCallback): void; | 新增 | +| ohos.document | document | function show(uri: string, type: string): Promise;
function show(uri: string, type: string, callback: AsyncCallback): void; | 新增 | +| ohos.document | document | function choose(types?: string[]): Promise;
function choose(callback: AsyncCallback): void;
function choose(types: string[], callback: AsyncCallback): void; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-geolocation.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-geolocation.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..3f7e47b88f0d24e099f2ef11062ff95f8beae0fb 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-geolocation.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-geolocation.md @@ -1,14 +1,115 @@ -# xxx子系统JS API变更 +# 位置服务子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,位置服务子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.geolocation | LocationCommand | command: string; | 新增 | +| ohos.geolocation | LocationCommand | scenario: LocationRequestScenario; | 新增 | +| ohos.geolocation | LocationPrivacyType | CORE_LOCATION | 新增 | +| ohos.geolocation | LocationPrivacyType | STARTUP | 新增 | +| ohos.geolocation | LocationPrivacyType | OTHERS = 0 | 新增 | +| ohos.geolocation | GeoLocationErrorCode | LOCATION_REQUEST_TIMEOUT_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | LAST_KNOWN_LOCATION_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | LOCATION_SWITCH_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | LOCATOR_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | GEOCODE_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | REVERSE_GEOCODE_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | INPUT_PARAMS_ERROR = 101 | 新增 | +| ohos.geolocation | LocationRequestScenario | NO_POWER | 新增 | +| ohos.geolocation | LocationRequestScenario | DAILY_LIFE_SERVICE | 新增 | +| ohos.geolocation | LocationRequestScenario | CAR_HAILING | 新增 | +| ohos.geolocation | LocationRequestScenario | TRAJECTORY_TRACKING | 新增 | +| ohos.geolocation | LocationRequestScenario | NAVIGATION | 新增 | +| ohos.geolocation | LocationRequestScenario | UNSET = 0x300 | 新增 | +| ohos.geolocation | LocationRequestPriority | FIRST_FIX | 新增 | +| ohos.geolocation | LocationRequestPriority | LOW_POWER | 新增 | +| ohos.geolocation | LocationRequestPriority | ACCURACY | 新增 | +| ohos.geolocation | LocationRequestPriority | UNSET = 0x200 | 新增 | +| ohos.geolocation | Location | additionSize?: number; | 新增 | +| ohos.geolocation | Location | additions?: Array; | 新增 | +| ohos.geolocation | Location | timeSinceBoot: number; | 新增 | +| ohos.geolocation | Location | direction: number; | 新增 | +| ohos.geolocation | Location | timeStamp: number; | 新增 | +| ohos.geolocation | Location | speed: number; | 新增 | +| ohos.geolocation | Location | accuracy: number; | 新增 | +| ohos.geolocation | Location | altitude: number; | 新增 | +| ohos.geolocation | Location | longitude: number; | 新增 | +| ohos.geolocation | Location | latitude: number; | 新增 | +| ohos.geolocation | CurrentLocationRequest | timeoutMs?: number; | 新增 | +| ohos.geolocation | CurrentLocationRequest | maxAccuracy?: number; | 新增 | +| ohos.geolocation | CurrentLocationRequest | scenario?: LocationRequestScenario; | 新增 | +| ohos.geolocation | CurrentLocationRequest | priority?: LocationRequestPriority; | 新增 | +| ohos.geolocation | LocationRequest | maxAccuracy?: number; | 新增 | +| ohos.geolocation | LocationRequest | distanceInterval?: number; | 新增 | +| ohos.geolocation | LocationRequest | timeInterval?: number; | 新增 | +| ohos.geolocation | LocationRequest | scenario?: LocationRequestScenario; | 新增 | +| ohos.geolocation | LocationRequest | priority?: LocationRequestPriority; | 新增 | +| ohos.geolocation | GeoAddress | descriptionsSize?: number; | 新增 | +| ohos.geolocation | GeoAddress | descriptions?: Array; | 新增 | +| ohos.geolocation | GeoAddress | addressUrl?: string; | 新增 | +| ohos.geolocation | GeoAddress | phoneNumber?: string; | 新增 | +| ohos.geolocation | GeoAddress | postalCode?: string; | 新增 | +| ohos.geolocation | GeoAddress | premises?: string; | 新增 | +| ohos.geolocation | GeoAddress | subRoadName?: string; | 新增 | +| ohos.geolocation | GeoAddress | roadName?: string; | 新增 | +| ohos.geolocation | GeoAddress | subLocality?: string; | 新增 | +| ohos.geolocation | GeoAddress | locality?: string; | 新增 | +| ohos.geolocation | GeoAddress | subAdministrativeArea?: string; | 新增 | +| ohos.geolocation | GeoAddress | administrativeArea?: string; | 新增 | +| ohos.geolocation | GeoAddress | countryName?: string; | 新增 | +| ohos.geolocation | GeoAddress | countryCode?: string; | 新增 | +| ohos.geolocation | GeoAddress | placeName?: string; | 新增 | +| ohos.geolocation | GeoAddress | locale?: string; | 新增 | +| ohos.geolocation | GeoAddress | longitude?: number; | 新增 | +| ohos.geolocation | GeoAddress | latitude?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | maxLongitude?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | maxLatitude?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | minLongitude?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | minLatitude?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | maxItems?: number; | 新增 | +| ohos.geolocation | GeoCodeRequest | description: string; | 新增 | +| ohos.geolocation | GeoCodeRequest | locale?: string; | 新增 | +| ohos.geolocation | ReverseGeoCodeRequest | maxItems?: number; | 新增 | +| ohos.geolocation | ReverseGeoCodeRequest | longitude: number; | 新增 | +| ohos.geolocation | ReverseGeoCodeRequest | latitude: number; | 新增 | +| ohos.geolocation | ReverseGeoCodeRequest | locale?: string; | 新增 | +| ohos.geolocation | Geofence | expiration: number; | 新增 | +| ohos.geolocation | Geofence | radius: number; | 新增 | +| ohos.geolocation | Geofence | longitude: number; | 新增 | +| ohos.geolocation | Geofence | latitude: number; | 新增 | +| ohos.geolocation | GeofenceRequest | geofence: Geofence; | 新增 | +| ohos.geolocation | GeofenceRequest | scenario: LocationRequestScenario; | 新增 | +| ohos.geolocation | GeofenceRequest | priority: LocationRequestPriority; | 新增 | +| ohos.geolocation | CachedGnssLocationsRequest | wakeUpCacheQueueFull: boolean; | 新增 | +| ohos.geolocation | CachedGnssLocationsRequest | reportingPeriodSec: number; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | carrierFrequencies: Array; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | azimuths: Array; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | altitudes: Array; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | carrierToNoiseDensitys: Array; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | satelliteIds: Array; | 新增 | +| ohos.geolocation | SatelliteStatusInfo | satellitesNumber: number; | 新增 | +| ohos.geolocation | geolocation | function sendCommand(command: LocationCommand, callback: AsyncCallback) : void;
function sendCommand(command: LocationCommand) : Promise; | 新增 | +| ohos.geolocation | geolocation | function flushCachedGnssLocations(callback: AsyncCallback) : void;
function flushCachedGnssLocations() : Promise; | 新增 | +| ohos.geolocation | geolocation | function getCachedGnssLocationsSize(callback: AsyncCallback) : void;
function getCachedGnssLocationsSize() : Promise; | 新增 | +| ohos.geolocation | geolocation | function isGeoServiceAvailable(callback: AsyncCallback) : void;
function isGeoServiceAvailable() : Promise; | 新增 | +| ohos.geolocation | geolocation | function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback>) : void;
function getAddressesFromLocationName(request: GeoCodeRequest) : Promise>; | 新增 | +| ohos.geolocation | geolocation | function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback>) : void;
function getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise>; | 新增 | +| ohos.geolocation | geolocation | function requestEnableLocation(callback: AsyncCallback) : void;
function requestEnableLocation() : Promise; | 新增 | +| ohos.geolocation | geolocation | function isLocationEnabled(callback: AsyncCallback) : void;
function isLocationEnabled() : Promise; | 新增 | +| ohos.geolocation | geolocation | function getLastLocation(callback: AsyncCallback) : void;
function getLastLocation() : Promise; | 新增 | +| ohos.geolocation | geolocation | function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback) : void;
function getCurrentLocation(callback: AsyncCallback) : void;
function getCurrentLocation(request?: CurrentLocationRequest) : Promise; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'nmeaMessageChange', callback?: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'nmeaMessageChange', callback: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'gnssStatusChange', callback?: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'gnssStatusChange', callback: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'cachedGnssLocationsReporting', callback?: Callback>) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback>) : void; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'locationServiceState', callback?: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'locationServiceState', callback: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function off(type: 'locationChange', callback?: Callback) : void; | 新增 | +| ohos.geolocation | geolocation | function on(type: 'locationChange', request: LocationRequest, callback: Callback) : void; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-global.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-global.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..4b1831bb1e3c609570f1ea7339bcc3f3cf88624a 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-global.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-global.md @@ -1,14 +1,107 @@ -# xxx子系统JS API变更 +# 全球化子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,全球化子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| rawFileDescriptor | RawFileDescriptor | length: number; | 新增 | +| rawFileDescriptor | RawFileDescriptor | offset: number; | 新增 | +| rawFileDescriptor | RawFileDescriptor | fd: number; | 新增 | +| ohos.resourceManager | ResourceManager | release(); | 新增 | +| ohos.resourceManager | ResourceManager | closeRawFileDescriptor(path: string, callback: AsyncCallback): void;
closeRawFileDescriptor(path: string): Promise; | 新增 | +| ohos.resourceManager | ResourceManager | getRawFileDescriptor(path: string, callback: AsyncCallback): void;
getRawFileDescriptor(path: string): Promise; | 新增 | +| ohos.resourceManager | ResourceManager | getRawFile(path: string, callback: AsyncCallback): void;
getRawFile(path: string): Promise; | 新增 | +| ohos.resourceManager | resourceManager | function getResourceManager(callback: AsyncCallback): void;
export function getResourceManager(bundleName: string, callback: AsyncCallback): void;
export function getResourceManager(): Promise;
export function getResourceManager(bundleName: string): Promise; | 新增 | +| ohos.intl | RelativeTimeFormat | resolvedOptions(): RelativeTimeFormatResolvedOptions; | 新增 | +| ohos.intl | RelativeTimeFormat | formatToParts(value: number, unit: string): Array; | 新增 | +| ohos.intl | RelativeTimeFormat | format(value: number, unit: string): string; | 新增 | +| ohos.intl | RelativeTimeFormat | constructor(); | 新增 | +| ohos.intl | RelativeTimeFormatResolvedOptions | numberingSystem: string; | 新增 | +| ohos.intl | RelativeTimeFormatResolvedOptions | numeric: string; | 新增 | +| ohos.intl | RelativeTimeFormatResolvedOptions | style: string; | 新增 | +| ohos.intl | RelativeTimeFormatResolvedOptions | locale: string; | 新增 | +| ohos.intl | RelativeTimeFormatInputOptions | style: string; | 新增 | +| ohos.intl | RelativeTimeFormatInputOptions | numeric: string; | 新增 | +| ohos.intl | RelativeTimeFormatInputOptions | localeMatcher: string; | 新增 | +| ohos.intl | PluralRules | select(n: number): string; | 新增 | +| ohos.intl | PluralRules | constructor(); | 新增 | +| ohos.intl | PluralRulesOptions | maximumSignificantDigits: number; | 新增 | +| ohos.intl | PluralRulesOptions | minimumSignificantDigits: number; | 新增 | +| ohos.intl | PluralRulesOptions | maximumFractionDigits: number; | 新增 | +| ohos.intl | PluralRulesOptions | minimumFractionDigits: number; | 新增 | +| ohos.intl | PluralRulesOptions | minimumIntegerDigits: number; | 新增 | +| ohos.intl | PluralRulesOptions | type: string; | 新增 | +| ohos.intl | PluralRulesOptions | localeMatcher: string; | 新增 | +| ohos.intl | Collator | resolvedOptions(): CollatorOptions; | 新增 | +| ohos.intl | Collator | compare(first: string, second: string): number; | 新增 | +| ohos.intl | Collator | constructor(); | 新增 | +| ohos.intl | CollatorOptions | caseFirst: string; | 新增 | +| ohos.intl | CollatorOptions | numeric: boolean; | 新增 | +| ohos.intl | CollatorOptions | collation: string; | 新增 | +| ohos.intl | CollatorOptions | ignorePunctuation: boolean; | 新增 | +| ohos.intl | CollatorOptions | sensitivity: string; | 新增 | +| ohos.intl | CollatorOptions | usage: string; | 新增 | +| ohos.intl | CollatorOptions | localeMatcher: string; | 新增 | +| ohos.intl | NumberOptions | unitUsage: string | 新增 | +| ohos.intl | LocaleOptions | caseFirst: string; | 新增 | +| ohos.intl | LocaleOptions | numeric: boolean; | 新增 | +| ohos.intl | LocaleOptions | numberingSystem: string; | 新增 | +| ohos.intl | LocaleOptions | hourCycle: string; | 新增 | +| ohos.intl | LocaleOptions | collation: string; | 新增 | +| ohos.intl | LocaleOptions | calendar: string; | 新增 | +| ohos.i18n | TimeZone | getOffset(date?: number): number; | 新增 | +| ohos.i18n | TimeZone | getRawOffset(): number; | 新增 | +| ohos.i18n | TimeZone | getDisplayName(locale?: string, isDST?: boolean): string; | 新增 | +| ohos.i18n | TimeZone | getID(): string; | 新增 | +| ohos.i18n | i18n | function getTimeZone(zoneID?: string): TimeZone; | 新增 | +| ohos.i18n | i18n | function getFirstPreferredLanguage(): string; | 新增 | +| ohos.i18n | i18n | function getPreferredLanguageList(): Array; | 新增 | +| ohos.i18n | i18n | function removePreferredLanguage(index: number): boolean; | 新增 | +| ohos.i18n | i18n | function addPreferredLanguage(language: string, index?: number): boolean; | 新增 | +| ohos.i18n | i18n | function set24HourClock(option: boolean): boolean; | 新增 | +| ohos.i18n | i18n | function is24HourClock(): boolean; | 新增 | +| ohos.i18n | Character | getType(char: string): string; | 新增 | +| ohos.i18n | Character | isUpperCase(char: string): boolean; | 新增 | +| ohos.i18n | Character | isLowerCase(char: string): boolean; | 新增 | +| ohos.i18n | Character | isLetter(char: string): boolean; | 新增 | +| ohos.i18n | Character | isIdeograph(char: string): boolean; | 新增 | +| ohos.i18n | Character | isRTL(char: string): boolean; | 新增 | +| ohos.i18n | Character | isWhitespace(char: string): boolean; | 新增 | +| ohos.i18n | Character | isSpaceChar(char: string): boolean; | 新增 | +| ohos.i18n | Character | isDigit(char: string): boolean; | 新增 | +| ohos.i18n | IndexUtil | getIndex(text: string): string; | 新增 | +| ohos.i18n | IndexUtil | addLocale(locale: string): void; | 新增 | +| ohos.i18n | IndexUtil | getIndexList(): Array; | 新增 | +| ohos.i18n | i18n | function getInstance(locale?:string): IndexUtil; | 新增 | +| ohos.i18n | BreakIterator | isBoundary(offset: number): boolean; | 新增 | +| ohos.i18n | BreakIterator | getLineBreakText(): string; | 新增 | +| ohos.i18n | BreakIterator | following(offset: number): number; | 新增 | +| ohos.i18n | BreakIterator | setLineBreakText(text: string): void; | 新增 | +| ohos.i18n | BreakIterator | previous(): number; | 新增 | +| ohos.i18n | BreakIterator | next(index?: number): number; | 新增 | +| ohos.i18n | BreakIterator | last(): number; | 新增 | +| ohos.i18n | BreakIterator | first(): number; | 新增 | +| ohos.i18n | BreakIterator | current(): number; | 新增 | +| ohos.i18n | i18n | function getLineInstance(locale: string): BreakIterator; | 新增 | +| ohos.i18n | i18n | function isRTL(locale: string): boolean; | 新增 | +| ohos.i18n | Calendar | isWeekend(date?: Date): boolean; | 新增 | +| ohos.i18n | Calendar | getDisplayName(locale: string): string; | 新增 | +| ohos.i18n | Calendar | get(field: string): number; | 新增 | +| ohos.i18n | Calendar | setMinimalDaysInFirstWeek(value: number): void; | 新增 | +| ohos.i18n | Calendar | getMinimalDaysInFirstWeek(): number; | 新增 | +| ohos.i18n | Calendar | setFirstDayOfWeek(value: number): void; | 新增 | +| ohos.i18n | Calendar | getFirstDayOfWeek(): number; | 新增 | +| ohos.i18n | Calendar | getTimeZone(): string; | 新增 | +| ohos.i18n | Calendar | setTimeZone(timezone: string): void; | 新增 | +| ohos.i18n | Calendar | set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void; | 新增 | +| ohos.i18n | Calendar | setTime(date: Date): void;
setTime(time: number): void; | 新增 | +| ohos.i18n | i18n | function getCalendar(locale: string, type?: string): Calendar; | 新增 | +| ohos.i18n | PhoneNumberFormat | format(number: string): string; | 新增 | +| ohos.i18n | PhoneNumberFormat | isValidNumber(number: string): boolean; | 新增 | +| ohos.i18n | PhoneNumberFormat | constructor(country: string, options?: PhoneNumberFormatOptions); | 新增 | +| ohos.i18n | PhoneNumberFormatOptions | type: string; | 新增 | +| ohos.i18n | UnitInfo | measureSystem: string | 新增 | +| ohos.i18n | UnitInfo | unit: string | 新增 | +| ohos.i18n | Util | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-graphic.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-graphic.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..88450608f4827a421b0cf8d5974ed958896565e6 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-graphic.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-graphic.md @@ -1,14 +1,827 @@ -# xxx子系统JS API变更 +# 图形图像子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,图形图像子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| webgl2 | WebGL2RenderingContextOverloads | readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView \| null): void;
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr): void;
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform4iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform3iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform2iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform1iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform4fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform3fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform2fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | uniform1fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr): void;
compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr): void;
compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null): void;
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource): void;
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr): void;
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource): void;
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null): void;
texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource): void;
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr): void;
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource): void;
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource): void;
bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextOverloads | bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum): void;
bufferData(target: GLenum, srcData: BufferSource \| null, usage: GLenum): void;
bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | bindVertexArray(array: WebGLVertexArrayObject \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | isVertexArray(vertexArray: WebGLVertexArrayObject \| null): GLboolean; | 新增 | +| webgl2 | WebGL2RenderingContextBase | deleteVertexArray(vertexArray: WebGLVertexArrayObject \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | createVertexArray(): WebGLVertexArrayObject \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint): string \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): GLuint; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getUniformIndices(program: WebGLProgram, uniformNames: string[]): GLuint[] \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getIndexedParameter(target: GLenum, index: GLuint): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null, offset: GLintptr, size: GLsizeiptr): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | resumeTransformFeedback(): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | pauseTransformFeedback(): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getTransformFeedbackVarying(program: WebGLProgram, index: GLuint): WebGLActiveInfo \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | endTransformFeedback(): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | beginTransformFeedback(primitiveMode: GLenum): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | isTransformFeedback(tf: WebGLTransformFeedback \| null): GLboolean; | 新增 | +| webgl2 | WebGL2RenderingContextBase | deleteTransformFeedback(tf: WebGLTransformFeedback \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | createTransformFeedback(): WebGLTransformFeedback \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getSyncParameter(sync: WebGLSync, pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64): GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | deleteSync(sync: WebGLSync \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | isSync(sync: WebGLSync \| null): GLboolean; | 新增 | +| webgl2 | WebGL2RenderingContextBase | fenceSync(condition: GLenum, flags: GLbitfield): WebGLSync \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getSamplerParameter(sampler: WebGLSampler, pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | bindSampler(unit: GLuint, sampler: WebGLSampler \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | isSampler(sampler: WebGLSampler \| null): GLboolean; | 新增 | +| webgl2 | WebGL2RenderingContextBase | deleteSampler(sampler: WebGLSampler \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | createSampler(): WebGLSampler \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getQueryParameter(query: WebGLQuery, pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getQuery(target: GLenum, pname: GLenum): WebGLQuery \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | endQuery(target: GLenum): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | beginQuery(target: GLenum, query: WebGLQuery): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | isQuery(query: WebGLQuery \| null): GLboolean; | 新增 | +| webgl2 | WebGL2RenderingContextBase | deleteQuery(query: WebGLQuery \| null): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | createQuery(): WebGLQuery \| null; | 新增 | +| webgl2 | WebGL2RenderingContextBase | clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | drawBuffers(buffers: GLenum[]): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribDivisor(index: GLuint, divisor: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribI4uiv(index: GLuint, values: Uint32List): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribI4iv(index: GLuint, values: Int32List): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix3x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix2x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix4x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix2x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix4x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniformMatrix3x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform4uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform3uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform2uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform1uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform4ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform3ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform2ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | uniform1ui(location: WebGLUniformLocation \| null, v0: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getFragDataLocation(program: WebGLProgram, name: string): GLint; | 新增 | +| webgl2 | WebGL2RenderingContextBase | compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr): void;
compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr): void;
compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr): void;
texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource): void;
texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null, srcOffset?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr): void;
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource): void;
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null): void;
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum): any; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readBuffer(src: GLenum): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | invalidateFramebuffer(target: GLenum, attachments: GLenum[]): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture \| null, level: GLint, layer: GLint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr): void; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TIMEOUT_IGNORED: GLint64; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_IMMUTABLE_LEVELS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_ELEMENT_INDEX: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_IMMUTABLE_FORMAT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_ACTIVE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_PAUSED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INT_2_10_10_10_REV: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB10_A2UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly ANY_SAMPLES_PASSED_CONSERVATIVE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly ANY_SAMPLES_PASSED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_DIVISOR: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_FLUSH_COMMANDS_BIT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly WAIT_FAILED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly CONDITION_SATISFIED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TIMEOUT_EXPIRED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly ALREADY_SIGNALED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SIGNALED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNALED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_GPU_COMMANDS_COMPLETE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_FENCE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_FLAGS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_STATUS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SYNC_CONDITION: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly OBJECT_TYPE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_SERVER_WAIT_TIMEOUT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_FRAGMENT_INPUT_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_VERTEX_OUTPUT_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INVALID_INDEX: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_ACTIVE_UNIFORMS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_DATA_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_IS_ROW_MAJOR: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_MATRIX_STRIDE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_ARRAY_STRIDE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_OFFSET: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BLOCK_INDEX: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_TYPE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly ACTIVE_UNIFORM_BLOCKS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BUFFER_OFFSET_ALIGNMENT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_UNIFORM_BLOCK_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_UNIFORM_BUFFER_BINDINGS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_COMBINED_UNIFORM_BLOCKS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_FRAGMENT_UNIFORM_BLOCKS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_VERTEX_UNIFORM_BLOCKS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BUFFER_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BUFFER_START: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNIFORM_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COPY_WRITE_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COPY_READ_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COPY_WRITE_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COPY_READ_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SIGNED_NORMALIZED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA8_SNORM: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB8_SNORM: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG8_SNORM: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R8_SNORM: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly VERTEX_ARRAY_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG32UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG32I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG16UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG16I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG8UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG8I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R32UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R32I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R16UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R16I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R8UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R8I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG32F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG16F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R32F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R16F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG_INTEGER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RG: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly HALF_FLOAT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_SAMPLES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT15: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT14: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT13: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT12: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT11: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT10: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT9: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT7: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT6: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT5: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT4: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT3: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR_ATTACHMENT1: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_COLOR_ATTACHMENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RENDERBUFFER_SAMPLES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly READ_FRAMEBUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_FRAMEBUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly READ_FRAMEBUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_FRAMEBUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_NORMALIZED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DEPTH24_STENCIL8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_24_8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_DEFAULT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_RED_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_32_UNSIGNED_INT_24_8_REV: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DEPTH32F_STENCIL8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DEPTH_COMPONENT32F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_SAMPLER_2D_ARRAY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_SAMPLER_CUBE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_SAMPLER_3D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_SAMPLER_2D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INT_SAMPLER_2D_ARRAY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INT_SAMPLER_CUBE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INT_SAMPLER_3D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INT_SAMPLER_2D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_VEC4: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_VEC3: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_VEC2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_CUBE_SHADOW: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_2D_ARRAY_SHADOW: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_2D_ARRAY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA_INTEGER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB_INTEGER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RED_INTEGER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB8I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA8I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB16I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA16I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB32I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA32I: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB8UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA8UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB16UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA16UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB32UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA32UI: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SEPARATE_ATTRIBS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly INTERLEAVED_ATTRIBS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RASTERIZER_DISCARD: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BUFFER_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BUFFER_START: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_VARYINGS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TRANSFORM_FEEDBACK_BUFFER_MODE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_5_9_9_9_REV: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB9_E5: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_10F_11F_11F_REV: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly R11F_G11F_B10F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_BINDING_2D_ARRAY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_2D_ARRAY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_VARYING_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_PROGRAM_TEXEL_OFFSET: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MIN_PROGRAM_TEXEL_OFFSET: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_ARRAY_TEXTURE_LAYERS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_INTEGER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB16F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA16F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB32F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA32F: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COMPARE_REF_TO_TEXTURE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SRGB8_ALPHA8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SRGB8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SRGB: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT4x3: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT4x2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT3x4: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT3x2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT2x4: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FLOAT_MAT2x3: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PIXEL_UNPACK_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PIXEL_PACK_BUFFER_BINDING: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PIXEL_UNPACK_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PIXEL_PACK_BUFFER: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly FRAGMENT_SHADER_DERIVATIVE_HINT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_2D_SHADOW: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly SAMPLER_3D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_VERTEX_UNIFORM_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_FRAGMENT_UNIFORM_COMPONENTS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER15: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER14: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER13: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER12: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER11: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER10: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER9: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER7: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER6: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER5: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER4: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER3: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER1: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DRAW_BUFFER0: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_DRAW_BUFFERS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DYNAMIC_COPY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DYNAMIC_READ: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly STATIC_COPY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly STATIC_READ: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly STREAM_COPY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly STREAM_READ: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly QUERY_RESULT_AVAILABLE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly QUERY_RESULT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly CURRENT_QUERY: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_COMPARE_FUNC: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_COMPARE_MODE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_TEXTURE_LOD_BIAS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DEPTH_COMPONENT24: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MIN: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_MAX_LEVEL: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_BASE_LEVEL: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_MAX_LOD: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_MIN_LOD: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_ELEMENTS_INDICES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_ELEMENTS_VERTICES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNSIGNED_INT_2_10_10_10_REV: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly MAX_3D_TEXTURE_SIZE: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_WRAP_R: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_3D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNPACK_IMAGE_HEIGHT: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNPACK_SKIP_IMAGES: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly TEXTURE_BINDING_3D: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB10_A2: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGBA8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RGB8: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly RED: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly STENCIL: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly DEPTH: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly COLOR: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PACK_SKIP_PIXELS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PACK_SKIP_ROWS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly PACK_ROW_LENGTH: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNPACK_SKIP_PIXELS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNPACK_SKIP_ROWS: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly UNPACK_ROW_LENGTH: GLenum; | 新增 | +| webgl2 | WebGL2RenderingContextBase | readonly READ_BUFFER: GLenum; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform4iv(location: WebGLUniformLocation \| null, v: Int32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform3iv(location: WebGLUniformLocation \| null, v: Int32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform2iv(location: WebGLUniformLocation \| null, v: Int32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform1iv(location: WebGLUniformLocation \| null, v: Int32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform4fv(location: WebGLUniformLocation \| null, v: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform3fv(location: WebGLUniformLocation \| null, v: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform2fv(location: WebGLUniformLocation \| null, v: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | uniform1fv(location: WebGLUniformLocation \| null, v: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null): void;
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null): void;
texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource): void; | 新增 | +| webgl | WebGLRenderingContextOverloads | bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum): void;
bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib4fv(index: GLuint, values: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib3fv(index: GLuint, values: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib2fv(index: GLuint, values: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib1fv(index: GLuint, values: Float32List): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | vertexAttrib1f(index: GLuint, x: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | validateProgram(program: WebGLProgram): void; | 新增 | +| webgl | WebGLRenderingContextBase | useProgram(program: WebGLProgram \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform1i(location: WebGLUniformLocation \| null, x: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | uniform1f(location: WebGLUniformLocation \| null, x: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | texParameteri(target: GLenum, pname: GLenum, param: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | texParameterf(target: GLenum, pname: GLenum, param: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilMaskSeparate(face: GLenum, mask: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilMask(mask: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | stencilFunc(func: GLenum, ref: GLint, mask: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | shaderSource(shader: WebGLShader, source: string): void; | 新增 | +| webgl | WebGLRenderingContextBase | scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl | WebGLRenderingContextBase | sampleCoverage(value: GLclampf, invert: GLboolean): void; | 新增 | +| webgl | WebGLRenderingContextBase | renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl | WebGLRenderingContextBase | polygonOffset(factor: GLfloat, units: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | pixelStorei(pname: GLenum, param: GLint \| GLboolean): void; | 新增 | +| webgl | WebGLRenderingContextBase | linkProgram(program: WebGLProgram): void; | 新增 | +| webgl | WebGLRenderingContextBase | lineWidth(width: GLfloat): void; | 新增 | +| webgl | WebGLRenderingContextBase | isTexture(texture: WebGLTexture \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isShader(shader: WebGLShader \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isProgram(program: WebGLProgram \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isFramebuffer(framebuffer: WebGLFramebuffer \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isEnabled(cap: GLenum): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | isBuffer(buffer: WebGLBuffer \| null): GLboolean; | 新增 | +| webgl | WebGLRenderingContextBase | hint(target: GLenum, mode: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | getVertexAttribOffset(index: GLuint, pname: GLenum): GLintptr; | 新增 | +| webgl | WebGLRenderingContextBase | getVertexAttrib(index: GLuint, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; | 新增 | +| webgl | WebGLRenderingContextBase | getTexParameter(target: GLenum, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getShaderSource(shader: WebGLShader): string \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getShaderInfoLog(shader: WebGLShader): string \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum): WebGLShaderPrecisionFormat \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getShaderParameter(shader: WebGLShader, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getRenderbufferParameter(target: GLenum, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getProgramInfoLog(program: WebGLProgram): string \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getProgramParameter(program: WebGLProgram, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getError(): GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | getParameter(pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getBufferParameter(target: GLenum, pname: GLenum): any; | 新增 | +| webgl | WebGLRenderingContextBase | getAttribLocation(program: WebGLProgram, name: string): GLint; | 新增 | +| webgl | WebGLRenderingContextBase | getAttachedShaders(program: WebGLProgram): WebGLShader[] \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getActiveUniform(program: WebGLProgram, index: GLuint): WebGLActiveInfo \| null; | 新增 | +| webgl | WebGLRenderingContextBase | getActiveAttrib(program: WebGLProgram, index: GLuint): WebGLActiveInfo \| null; | 新增 | +| webgl | WebGLRenderingContextBase | generateMipmap(target: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | frontFace(mode: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | flush(): void; | 新增 | +| webgl | WebGLRenderingContextBase | finish(): void; | 新增 | +| webgl | WebGLRenderingContextBase | enableVertexAttribArray(index: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | enable(cap: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr): void; | 新增 | +| webgl | WebGLRenderingContextBase | drawArrays(mode: GLenum, first: GLint, count: GLsizei): void; | 新增 | +| webgl | WebGLRenderingContextBase | disableVertexAttribArray(index: GLuint): void; | 新增 | +| webgl | WebGLRenderingContextBase | disable(cap: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | detachShader(program: WebGLProgram, shader: WebGLShader): void; | 新增 | +| webgl | WebGLRenderingContextBase | depthRange(zNear: GLclampf, zFar: GLclampf): void; | 新增 | +| webgl | WebGLRenderingContextBase | depthMask(flag: GLboolean): void; | 新增 | +| webgl | WebGLRenderingContextBase | depthFunc(func: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteTexture(texture: WebGLTexture \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteShader(shader: WebGLShader \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteProgram(program: WebGLProgram \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteFramebuffer(framebuffer: WebGLFramebuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | deleteBuffer(buffer: WebGLBuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | cullFace(mode: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | createTexture(): WebGLTexture \| null; | 新增 | +| webgl | WebGLRenderingContextBase | createShader(type: GLenum): WebGLShader \| null; | 新增 | +| webgl | WebGLRenderingContextBase | createRenderbuffer(): WebGLRenderbuffer \| null; | 新增 | +| webgl | WebGLRenderingContextBase | createProgram(): WebGLProgram \| null; | 新增 | +| webgl | WebGLRenderingContextBase | createFramebuffer(): WebGLFramebuffer \| null; | 新增 | +| webgl | WebGLRenderingContextBase | createBuffer(): WebGLBuffer \| null; | 新增 | +| webgl | WebGLRenderingContextBase | copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; | 新增 | +| webgl | WebGLRenderingContextBase | copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | compileShader(shader: WebGLShader): void; | 新增 | +| webgl | WebGLRenderingContextBase | colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean): void; | 新增 | +| webgl | WebGLRenderingContextBase | clearStencil(s: GLint): void; | 新增 | +| webgl | WebGLRenderingContextBase | clearDepth(depth: GLclampf): void; | 新增 | +| webgl | WebGLRenderingContextBase | clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; | 新增 | +| webgl | WebGLRenderingContextBase | clear(mask: GLbitfield): void; | 新增 | +| webgl | WebGLRenderingContextBase | checkFramebufferStatus(target: GLenum): GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | blendFunc(sfactor: GLenum, dfactor: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | blendEquation(mode: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; | 新增 | +| webgl | WebGLRenderingContextBase | bindTexture(target: GLenum, texture: WebGLTexture \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | bindBuffer(target: GLenum, buffer: WebGLBuffer \| null): void; | 新增 | +| webgl | WebGLRenderingContextBase | bindAttribLocation(program: WebGLProgram, index: GLuint, name: string): void; | 新增 | +| webgl | WebGLRenderingContextBase | attachShader(program: WebGLProgram, shader: WebGLShader): void; | 新增 | +| webgl | WebGLRenderingContextBase | activeTexture(texture: GLenum): void; | 新增 | +| webgl | WebGLRenderingContextBase | getExtension(name: string): any; | 新增 | +| webgl | WebGLRenderingContextBase | getSupportedExtensions(): string[] \| null; | 新增 | +| webgl | WebGLRenderingContextBase | isContextLost(): boolean; | 新增 | +| webgl | WebGLRenderingContextBase | getContextAttributes(): WebGLContextAttributes \| null; | 新增 | +| webgl | WebGLRenderingContextBase | readonly drawingBufferHeight: GLsizei; | 新增 | +| webgl | WebGLRenderingContextBase | readonly drawingBufferWidth: GLsizei; | 新增 | +| webgl | WebGLRenderingContextBase | readonly canvas: HTMLCanvasElement \| OffscreenCanvas; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BROWSER_DEFAULT_WEBGL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CONTEXT_LOST_WEBGL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNPACK_FLIP_Y_WEBGL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INVALID_FRAMEBUFFER_OPERATION: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_RENDERBUFFER_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_BINDING: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_BINDING: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_UNSUPPORTED: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_COMPLETE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NONE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_STENCIL_ATTACHMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_ATTACHMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_ATTACHMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COLOR_ATTACHMENT0: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_STENCIL_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_DEPTH_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_ALPHA_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_BLUE_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_GREEN_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_RED_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_INTERNAL_FORMAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_HEIGHT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER_WIDTH: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_STENCIL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_INDEX8: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_COMPONENT16: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RGB565: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RGB5_A1: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RGBA4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERBUFFER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAMEBUFFER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly HIGH_INT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MEDIUM_INT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LOW_INT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly HIGH_FLOAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MEDIUM_FLOAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LOW_FLOAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COMPILE_STATUS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly IMPLEMENTATION_COLOR_READ_FORMAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly IMPLEMENTATION_COLOR_READ_TYPE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_POINTER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_TYPE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_STRIDE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_ATTRIB_ARRAY_ENABLED: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLER_CUBE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLER_2D: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_MAT4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_MAT3: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_MAT2: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BOOL_VEC4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BOOL_VEC3: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BOOL_VEC2: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BOOL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INT_VEC4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INT_VEC3: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INT_VEC2: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_VEC4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_VEC3: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT_VEC2: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MIRRORED_REPEAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CLAMP_TO_EDGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly REPEAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ACTIVE_TEXTURE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE31: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE30: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE29: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE28: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE27: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE26: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE25: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE24: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE23: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE22: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE21: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE20: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE19: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE18: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE17: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE16: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE15: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE14: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE13: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE12: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE11: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE10: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE9: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE8: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE7: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE6: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE5: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE3: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE2: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE1: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE0: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_CUBE_MAP_TEXTURE_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_POSITIVE_Z: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_POSITIVE_Y: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_NEGATIVE_X: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP_POSITIVE_X: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_BINDING_CUBE_MAP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_CUBE_MAP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_2D: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_WRAP_T: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_WRAP_S: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_MIN_FILTER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_MAG_FILTER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINEAR_MIPMAP_LINEAR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NEAREST_MIPMAP_LINEAR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINEAR_MIPMAP_NEAREST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NEAREST_MIPMAP_NEAREST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINEAR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NEAREST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERSION: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RENDERER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VENDOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DECR_WRAP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INCR_WRAP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INVERT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DECR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INCR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly REPLACE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly KEEP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ALWAYS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly GEQUAL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NOTEQUAL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly GREATER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LEQUAL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly EQUAL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LESS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NEVER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CURRENT_PROGRAM: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SHADING_LANGUAGE_VERSION: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ACTIVE_ATTRIBUTES: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ACTIVE_UNIFORMS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ATTACHED_SHADERS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VALIDATE_STATUS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINK_STATUS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DELETE_STATUS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SHADER_TYPE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_FRAGMENT_UNIFORM_VECTORS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_TEXTURE_IMAGE_UNITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_VARYING_VECTORS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_VERTEX_UNIFORM_VECTORS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_VERTEX_ATTRIBS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VERTEX_SHADER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRAGMENT_SHADER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_SHORT_5_6_5: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_SHORT_5_5_5_1: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_SHORT_4_4_4_4: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LUMINANCE_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LUMINANCE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RGBA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RGB: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_COMPONENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FLOAT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_INT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_SHORT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SHORT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNSIGNED_BYTE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BYTE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly GENERATE_MIPMAP_HINT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NICEST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FASTEST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DONT_CARE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COMPRESSED_TEXTURE_FORMATS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLE_COVERAGE_INVERT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLE_COVERAGE_VALUE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLES: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLE_BUFFERS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TEXTURE_BINDING_2D: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly POLYGON_OFFSET_FACTOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly POLYGON_OFFSET_UNITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ALPHA_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLUE_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly GREEN_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly RED_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SUBPIXEL_BITS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_VIEWPORT_DIMS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly MAX_TEXTURE_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly PACK_ALIGNMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly UNPACK_ALIGNMENT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COLOR_WRITEMASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COLOR_CLEAR_VALUE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SCISSOR_BOX: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly VIEWPORT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_WRITEMASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_VALUE_MASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_REF: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_PASS_DEPTH_PASS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_PASS_DEPTH_FAIL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_FAIL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BACK_FUNC: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_WRITEMASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_VALUE_MASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_REF: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_PASS_DEPTH_PASS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_PASS_DEPTH_FAIL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_FAIL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_FUNC: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_CLEAR_VALUE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_FUNC: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_CLEAR_VALUE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_WRITEMASK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_RANGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRONT_FACE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CULL_FACE_MODE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ALIASED_LINE_WIDTH_RANGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ALIASED_POINT_SIZE_RANGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINE_WIDTH: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CCW: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CW: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly OUT_OF_MEMORY: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INVALID_OPERATION: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INVALID_VALUE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly INVALID_ENUM: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly NO_ERROR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLE_COVERAGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SAMPLE_ALPHA_TO_COVERAGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly POLYGON_OFFSET_FILL: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SCISSOR_TEST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_TEST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_TEST: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DITHER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CULL_FACE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRONT_AND_BACK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BACK: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FRONT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CURRENT_VERTEX_ATTRIB: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BUFFER_USAGE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BUFFER_SIZE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DYNAMIC_DRAW: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STATIC_DRAW: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STREAM_DRAW: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ELEMENT_ARRAY_BUFFER_BINDING: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ARRAY_BUFFER_BINDING: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ELEMENT_ARRAY_BUFFER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ARRAY_BUFFER: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_CONSTANT_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CONSTANT_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_CONSTANT_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly CONSTANT_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_SRC_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_DST_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_SRC_RGB: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_DST_RGB: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FUNC_REVERSE_SUBTRACT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FUNC_SUBTRACT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_EQUATION_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_EQUATION_RGB: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly BLEND_EQUATION: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly FUNC_ADD: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SRC_ALPHA_SATURATE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_DST_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DST_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_DST_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DST_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_SRC_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SRC_ALPHA: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE_MINUS_SRC_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly SRC_COLOR: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ONE: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly ZERO: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TRIANGLE_FAN: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TRIANGLE_STRIP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly TRIANGLES: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINE_STRIP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINE_LOOP: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly LINES: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly POINTS: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly COLOR_BUFFER_BIT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly STENCIL_BUFFER_BIT: GLenum; | 新增 | +| webgl | WebGLRenderingContextBase | readonly DEPTH_BUFFER_BIT: GLenum; | 新增 | +| webgl | WebGLShaderPrecisionFormat | readonly precision: GLint; | 新增 | +| webgl | WebGLShaderPrecisionFormat | readonly rangeMax: GLint; | 新增 | +| webgl | WebGLShaderPrecisionFormat | readonly rangeMin: GLint; | 新增 | +| webgl | WebGLActiveInfo | readonly name: string; | 新增 | +| webgl | WebGLActiveInfo | readonly type: GLenum; | 新增 | +| webgl | WebGLActiveInfo | readonly size: GLint; | 新增 | +| webgl | WebGLContextAttributes | desynchronized?: boolean; | 新增 | +| webgl | WebGLContextAttributes | failIfMajorPerformanceCaveat?: boolean; | 新增 | +| webgl | WebGLContextAttributes | powerPreference?: WebGLPowerPreference; | 新增 | +| webgl | WebGLContextAttributes | preserveDrawingBuffer?: boolean; | 新增 | +| webgl | WebGLContextAttributes | premultipliedAlpha?: boolean; | 新增 | +| webgl | WebGLContextAttributes | antialias?: boolean; | 新增 | +| webgl | WebGLContextAttributes | stencil?: boolean; | 新增 | +| webgl | WebGLContextAttributes | depth?: boolean; | 新增 | +| webgl | WebGLContextAttributes | alpha?: boolean; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-misc.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-misc.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..a12057932b7903ddf3a79990bfdfc0028eaeb5b8 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-misc.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-misc.md @@ -1,14 +1,218 @@ -# xxx子系统JS API变更 +# 杂散软件服务子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,杂散软件服务子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.wallpaper | RgbaColor | alpha: number; | 新增 | +| ohos.wallpaper | RgbaColor | blue: number; | 新增 | +| ohos.wallpaper | RgbaColor | green: number; | 新增 | +| ohos.wallpaper | RgbaColor | red: number; | 新增 | +| ohos.wallpaper | wallpaper | function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; | 新增 | +| ohos.wallpaper | wallpaper | function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; | 新增 | +| ohos.wallpaper | wallpaper | function setWallpaper(source: string \| image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void;
function setWallpaper(source: string \| image.PixelMap, wallpaperType: WallpaperType): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function reset(wallpaperType: WallpaperType, callback: AsyncCallback): void;
function reset(wallpaperType: WallpaperType): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function isOperationAllowed(callback: AsyncCallback): void;
function isOperationAllowed(): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function isChangePermitted(callback: AsyncCallback): void;
function isChangePermitted(): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function getMinWidth(callback: AsyncCallback): void;
function getMinWidth(): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function getMinHeight(callback: AsyncCallback): void;
function getMinHeight(): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function getFile(wallpaperType: WallpaperType, callback: AsyncCallback): void;
function getFile(wallpaperType: WallpaperType): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function getId(wallpaperType: WallpaperType, callback: AsyncCallback): void;
function getId(wallpaperType: WallpaperType): Promise; | 新增 | +| ohos.wallpaper | wallpaper | function getColors(wallpaperType: WallpaperType, callback: AsyncCallback>): void;
function getColors(wallpaperType: WallpaperType): Promise>; | 新增 | +| ohos.wallpaper | WallpaperType | WALLPAPER_LOCKSCREEN | 新增 | +| ohos.wallpaper | WallpaperType | WALLPAPER_SYSTEM | 新增 | +| ohos.systemTime | systemTime | function getTimezone(callback: AsyncCallback): void;
function getTimezone(): Promise; | 新增 | +| ohos.systemTime | systemTime | function getDate(callback: AsyncCallback): void;
function getDate(): Promise; | 新增 | +| ohos.systemTime | systemTime | function getRealTime(isNano?: boolean, callback: AsyncCallback): void;
function getRealTime(isNano?: boolean): Promise; | 新增 | +| ohos.systemTime | systemTime | function getRealActiveTime(isNano?: boolean, callback: AsyncCallback): void;
function getRealActiveTime(isNano?: boolean): Promise; | 新增 | +| ohos.systemTime | systemTime | function getCurrentTime(isNano?: boolean, callback: AsyncCallback): void;
function getCurrentTime(isNano?: boolean): Promise; | 新增 | +| ohos.screenLock | screenLock | function unlockScreen(callback: AsyncCallback): void;
function unlockScreen():Promise; | 新增 | +| ohos.screenLock | screenLock | function isSecureMode(callback: AsyncCallback): void;
function isSecureMode(): Promise; | 新增 | +| ohos.screenLock | screenLock | function isScreenLocked(callback: AsyncCallback): void;
function isScreenLocked(): Promise; | 新增 | +| ohos.request | UploadTask | remove(callback: AsyncCallback): void;
remove(): Promise; | 新增 | +| ohos.request | UploadTask | off(type: 'headerReceive', callback?: (header: object) => void): void; | 新增 | +| ohos.request | UploadTask | on(type: 'headerReceive', callback: (header: object) => void): void; | 新增 | +| ohos.request | UploadTask | off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void; | 新增 | +| ohos.request | UploadTask | on(type: 'progress', callback: (uploadedSize: number, totalSize: number) => void): void; | 新增 | +| ohos.request | UploadConfig | data: Array; | 新增 | +| ohos.request | UploadConfig | files: Array; | 新增 | +| ohos.request | UploadConfig | method: string; | 新增 | +| ohos.request | UploadConfig | header: Object; | 新增 | +| ohos.request | UploadConfig | url: string; | 新增 | +| ohos.request | RequestData | value: string; | 新增 | +| ohos.request | RequestData | name: string; | 新增 | +| ohos.request | File | type: string; | 新增 | +| ohos.request | File | uri: string; | 新增 | +| ohos.request | File | name: string; | 新增 | +| ohos.request | File | filename: string; | 新增 | +| ohos.request | DownloadTask | queryMimeType(callback: AsyncCallback): void;
queryMimeType(): Promise; | 新增 | +| ohos.request | DownloadTask | query(callback: AsyncCallback): void;
query(): Promise; | 新增 | +| ohos.request | DownloadTask | resume(callback: AsyncCallback): void;
resume(): Promise; | 新增 | +| ohos.request | DownloadTask | pause(callback: AsyncCallback): void;
pause(): Promise; | 新增 | +| ohos.request | DownloadTask | remove(callback: AsyncCallback): void;
remove(): Promise; | 新增 | +| ohos.request | DownloadTask | off(type: 'fail', callback?: (err: number) => void): void; | 新增 | +| ohos.request | DownloadTask | on(type: 'fail', callback: (err: number) => void): void; | 新增 | +| ohos.request | DownloadTask | off(type: 'complete' \| 'pause' \| 'remove', callback?: () => void): void; | 新增 | +| ohos.request | DownloadTask | off(type: 'complete' \| 'pause' \| 'remove', callback?: () => void): void; | 新增 | +| ohos.request | DownloadTask | off(type: 'complete' \| 'pause' \| 'remove', callback?: () => void): void; | 新增 | +| ohos.request | DownloadTask | on(type: 'complete' \| 'pause' \| 'remove', callback: () => void): void; | 新增 | +| ohos.request | DownloadTask | on(type: 'complete' \| 'pause' \| 'remove', callback: () => void): void; | 新增 | +| ohos.request | DownloadTask | on(type: 'complete' \| 'pause' \| 'remove', callback: () => void): void; | 新增 | +| ohos.request | DownloadTask | off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void; | 新增 | +| ohos.request | DownloadTask | on(type: 'progress', callback: (receivedSize: number, totalSize: number) => void): void; | 新增 | +| ohos.request | DownloadInfo | downloadTotalBytes: number; | 新增 | +| ohos.request | DownloadInfo | downloadTitle: string; | 新增 | +| ohos.request | DownloadInfo | targetURI: string; | 新增 | +| ohos.request | DownloadInfo | status: number; | 新增 | +| ohos.request | DownloadInfo | pausedReason: number; | 新增 | +| ohos.request | DownloadInfo | filePath: string; | 新增 | +| ohos.request | DownloadInfo | fileName: string; | 新增 | +| ohos.request | DownloadInfo | failedReason: number; | 新增 | +| ohos.request | DownloadInfo | downloadId: number; | 新增 | +| ohos.request | DownloadInfo | downloadedBytes: number; | 新增 | +| ohos.request | DownloadInfo | description: string; | 新增 | +| ohos.request | DownloadConfig | title?: string; | 新增 | +| ohos.request | DownloadConfig | filePath?: string; | 新增 | +| ohos.request | DownloadConfig | networkType?: number; | 新增 | +| ohos.request | DownloadConfig | description?: string; | 新增 | +| ohos.request | DownloadConfig | enableRoaming?: boolean; | 新增 | +| ohos.request | DownloadConfig | enableMetered?: boolean; | 新增 | +| ohos.request | DownloadConfig | header?: Object; | 新增 | +| ohos.request | DownloadConfig | url: string; | 新增 | +| ohos.request | request | function upload(config: UploadConfig, callback: AsyncCallback): void;
function upload(config: UploadConfig): Promise; | 新增 | +| ohos.request | request | function download(config: DownloadConfig, callback: AsyncCallback): void;
function download(config: DownloadConfig): Promise; | 新增 | +| ohos.request | request | const SESSION_SUCCESSFUL: number; | 新增 | +| ohos.request | request | const SESSION_RUNNING: number; | 新增 | +| ohos.request | request | const SESSION_PENDING: number; | 新增 | +| ohos.request | request | const SESSION_PAUSED: number; | 新增 | +| ohos.request | request | const SESSION_FAILED: number; | 新增 | +| ohos.request | request | const PAUSED_WAITING_TO_RETRY: number; | 新增 | +| ohos.request | request | const PAUSED_WAITING_FOR_NETWORK: number; | 新增 | +| ohos.request | request | const PAUSED_UNKNOWN: number; | 新增 | +| ohos.request | request | const PAUSED_QUEUED_FOR_WIFI: number; | 新增 | +| ohos.request | request | const ERROR_UNKNOWN: number; | 新增 | +| ohos.request | request | const ERROR_UNHANDLED_HTTP_CODE: number; | 新增 | +| ohos.request | request | const ERROR_TOO_MANY_REDIRECTS: number; | 新增 | +| ohos.request | request | const ERROR_INSUFFICIENT_SPACE: number; | 新增 | +| ohos.request | request | const ERROR_HTTP_DATA_ERROR: number; | 新增 | +| ohos.request | request | const ERROR_FILE_ERROR: number; | 新增 | +| ohos.request | request | const ERROR_FILE_ALREADY_EXISTS: number; | 新增 | +| ohos.request | request | const ERROR_DEVICE_NOT_FOUND: number; | 新增 | +| ohos.request | request | const ERROR_CANNOT_RESUME: number; | 新增 | +| ohos.request | request | const NETWORK_WIFI: number; | 新增 | +| ohos.request | request | const NETWORK_MOBILE: number; | 新增 | +| ohos.pasteboard | SystemPasteboard | setPasteData(data: PasteData, callback: AsyncCallback): void;
setPasteData(data: PasteData): Promise; | 新增 | +| ohos.pasteboard | SystemPasteboard | hasPasteData(callback: AsyncCallback): void;
hasPasteData(): Promise; | 新增 | +| ohos.pasteboard | SystemPasteboard | getPasteData(callback: AsyncCallback): void;
getPasteData(): Promise; | 新增 | +| ohos.pasteboard | SystemPasteboard | clear(callback: AsyncCallback): void;
clear(): Promise; | 新增 | +| ohos.pasteboard | SystemPasteboard | off(type: 'update', callback?: () => void): void; | 新增 | +| ohos.pasteboard | SystemPasteboard | on(type: 'update', callback: () => void): void; | 新增 | +| ohos.pasteboard | PasteData | replaceRecordAt(index: number, record: PasteDataRecord): boolean; | 新增 | +| ohos.pasteboard | PasteData | removeRecordAt(index: number): boolean; | 新增 | +| ohos.pasteboard | PasteData | hasMimeType(mimeType: string): boolean; | 新增 | +| ohos.pasteboard | PasteData | getTag(): string; | 新增 | +| ohos.pasteboard | PasteData | getRecordCount(): number; | 新增 | +| ohos.pasteboard | PasteData | getRecordAt(index: number): PasteDataRecord; | 新增 | +| ohos.pasteboard | PasteData | getProperty(): PasteDataProperty; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryUri(): string; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryText(): string; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryMimeType(): string; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryWant(): Want; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryHtml(): string; | 新增 | +| ohos.pasteboard | PasteData | getMimeTypes(): Array; | 新增 | +| ohos.pasteboard | PasteData | addUriRecord(uri: string): void; | 新增 | +| ohos.pasteboard | PasteData | addTextRecord(text: string): void; | 新增 | +| ohos.pasteboard | PasteData | addRecord(record: PasteDataRecord): void; | 新增 | +| ohos.pasteboard | PasteData | addWantRecord(want: Want): void; | 新增 | +| ohos.pasteboard | PasteData | addHtmlRecord(htmlText: string): void; | 新增 | +| ohos.pasteboard | PasteDataRecord | convertToText(callback: AsyncCallback): void;
convertToText(): Promise; | 新增 | +| ohos.pasteboard | PasteDataRecord | uri: string; | 新增 | +| ohos.pasteboard | PasteDataRecord | plainText: string; | 新增 | +| ohos.pasteboard | PasteDataRecord | mimeType: string; | 新增 | +| ohos.pasteboard | PasteDataRecord | want: Want; | 新增 | +| ohos.pasteboard | PasteDataRecord | htmlText: string; | 新增 | +| ohos.pasteboard | PasteDataProperty | localOnly: boolean; | 新增 | +| ohos.pasteboard | PasteDataProperty | readonly timestamp: number; | 新增 | +| ohos.pasteboard | PasteDataProperty | tag: string; | 新增 | +| ohos.pasteboard | PasteDataProperty | readonly mimeTypes: Array; | 新增 | +| ohos.pasteboard | PasteDataProperty | additions: { [key: string]: object } | 新增 | +| ohos.pasteboard | pasteboard | function getSystemPasteboard(): SystemPasteboard; | 新增 | +| ohos.pasteboard | pasteboard | function createUriRecord(uri: string): PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | function createPlainTextRecord(text: string): PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | function createWantRecord(want: Want): PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | function createHtmlTextRecord(htmlText: string): PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | function createUriData(uri: string): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | function createPlainTextData(text: string): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | function createWantData(want: Want): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | function createHtmlData(htmlText: string): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | const MIMETYPE_TEXT_URI: string; | 新增 | +| ohos.pasteboard | pasteboard | const MIMETYPE_TEXT_PLAIN: string; | 新增 | +| ohos.pasteboard | pasteboard | const MIMETYPE_TEXT_WANT: string; | 新增 | +| ohos.pasteboard | pasteboard | const MIMETYPE_TEXT_HTML: string; | 新增 | +| ohos.pasteboard | pasteboard | const MAX_RECORD_NUM: number; | 新增 | +| ohos.inputmethodengine | KeyEvent | readonly keyAction: number; | 新增 | +| ohos.inputmethodengine | KeyEvent | readonly keyCode: number; | 新增 | +| ohos.inputmethodengine | EditorAttribute | readonly enterKeyType: number; | 新增 | +| ohos.inputmethodengine | EditorAttribute | readonly inputPattern: number; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | off(type: 'textChange', callback?: (text: string) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | on(type: 'textChange', callback: (text: string) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | off(type: 'keyDown'\|'keyUp', callback?: (event: KeyEvent) => boolean): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | off(type: 'keyDown'\|'keyUp', callback?: (event: KeyEvent) => boolean): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | on(type: 'keyDown'\|'keyUp', callback: (event: KeyEvent) => boolean): void; | 新增 | +| ohos.inputmethodengine | KeyboardDelegate | on(type: 'keyDown'\|'keyUp', callback: (event: KeyEvent) => boolean): void; | 新增 | +| ohos.inputmethodengine | TextInputClient | getEditorAttribute(callback: AsyncCallback): void;
getEditorAttribute(): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | getBackward(length: number, callback: AsyncCallback): void;
getBackward(length: number): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | getForward(length: number, callback: AsyncCallback): void;
getForward(length: number): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | insertText(text: string, callback: AsyncCallback): void;
insertText(text: string): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | deleteBackward(length: number, callback: AsyncCallback): void;
deleteBackward(length: number): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | deleteForward(length: number, callback: AsyncCallback): void;
deleteForward(length: number): Promise; | 新增 | +| ohos.inputmethodengine | TextInputClient | sendKeyFunction(action: number, callback: AsyncCallback): void;
sendKeyFunction(action: number): Promise; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | off(type: 'keyboardShow'\|'keyboardHide', callback?: () => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | off(type: 'keyboardShow'\|'keyboardHide', callback?: () => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | on(type: 'keyboardShow'\|'keyboardHide', callback: () => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | on(type: 'keyboardShow'\|'keyboardHide', callback: () => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; | 新增 | +| ohos.inputmethodengine | KeyboardController | hideKeyboard(callback: AsyncCallback): void;
hideKeyboard(): Promise; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | function createKeyboardDelegate(): KeyboardDelegate; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | function getInputMethodEngine(): InputMethodEngine; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_NO_FULLSCREEN: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_MULTI_LINE: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_AUTO_WORDS: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_AUTO_CAP_SENTENCES: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_AUTO_CAP_CHARACTERS: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_NONE: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const OPTION_ASCII: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const DISPLAY_MODE_FULL: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const DISPLAY_MODE_PART: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const FLAG_SINGLE_LINE: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const FLAG_SELECTING: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_PASSWORD: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_URI: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_EMAIL: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_DATETIME: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_PHONE: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_NUMBER: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_TEXT: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const PATTERN_NULL: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_PREVIOUS: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_DONE: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_NEXT: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_SEND: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_SEARCH: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_GO: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const ENTER_KEY_TYPE_UNSPECIFIED: number; | 新增 | +| ohos.inputmethod | InputMethodProperty | readonly methodId: string; | 新增 | +| ohos.inputmethod | InputMethodProperty | readonly packageName: string; | 新增 | +| ohos.inputmethod | InputMethodController | stopInput(callback: AsyncCallback): void;
stopInput(): Promise; | 新增 | +| ohos.inputmethod | InputMethodSetting | displayOptionalInputMethod(callback: AsyncCallback): void;
displayOptionalInputMethod(): Promise; | 新增 | +| ohos.inputmethod | InputMethodSetting | listInputMethod(callback: AsyncCallback>): void;
listInputMethod(): Promise>; | 新增 | +| ohos.inputmethod | inputMethod | function getInputMethodController(): InputMethodController; | 新增 | +| ohos.inputmethod | inputMethod | function getInputMethodSetting(): InputMethodSetting; | 新增 | +| ohos.inputmethod | inputMethod | const MAX_TYPE_NUM: number | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multi-modal-input.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multi-modal-input.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..ce8227af06338fcd25c05563b45d7740824cee1c 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multi-modal-input.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multi-modal-input.md @@ -1,14 +1,18 @@ -# xxx子系统JS API变更 +# 多模输入子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,多模输入子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.multimodalInput.inputDevice | inputDevice | function getDevice(deviceId: number, callback: AsyncCallback): void;
function getDevice(deviceId: number): Promise; | 新增 | +| ohos.multimodalInput.inputDevice | inputDevice | function getDeviceIds(callback: AsyncCallback>): void;
function getDeviceIds(): Promise>; | 新增 | +| ohos.multimodalInput.inputDevice | InputDeviceData | axisRanges : Array; | 新增 | +| ohos.multimodalInput.inputDevice | InputDeviceData | sources : Array; | 新增 | +| ohos.multimodalInput.inputDevice | InputDeviceData | name: string; | 新增 | +| ohos.multimodalInput.inputDevice | InputDeviceData | id: number; | 新增 | +| ohos.multimodalInput.inputDevice | AxisRange | min: number; | 新增 | +| ohos.multimodalInput.inputDevice | AxisRange | max : number; | 新增 | +| ohos.multimodalInput.inputDevice | AxisRange | axis : AxisType; | 新增 | +| ohos.multimodalInput.inputDevice | AxisRange | source: SourceType; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multimedia.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multimedia.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..2b81aaeffed583812c2de0ac67dd67a25b178772 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multimedia.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-multimedia.md @@ -1,14 +1,423 @@ -# xxx子系统JS API变更 +# 媒体子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,媒体子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.multimedia.mediaLibrary | Size | height: number; | 新增 | +| ohos.multimedia.mediaLibrary | Size | width: number; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | startMediaSelect(option: MediaSelectOption, callback: AsyncCallback>): void;
startMediaSelect(option: MediaSelectOption): Promise>; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | startImagePreview(images: Array, index: number, callback: AsyncCallback): void;
startImagePreview(images: Array, callback: AsyncCallback): void;
startImagePreview(images: Array, index?: number): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback): void;
storeMediaAsset(option: MediaAssetOption): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getAlbums(options: MediaFetchOptions, callback: AsyncCallback>): void;
getAlbums(options: MediaFetchOptions): Promise>; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback): void;
createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback): void; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void;
getFileAssets(options: MediaFetchOptions): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getPublicDirectory(type: DirectoryType, callback: AsyncCallback): void;
getPublicDirectory(type: DirectoryType): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_DOWNLOAD | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_DOCUMENTS | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_AUDIO | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_IMAGE | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_VIDEO | 新增 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_CAMERA = 0 | 新增 | +| ohos.multimedia.mediaLibrary | Album | getFileAssets(callback: AsyncCallback): void;
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void;
getFileAssets(options?: MediaFetchOptions): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | Album | commitModify(callback: AsyncCallback): void;
commitModify(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly coverUri: string; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly relativePath: string; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly count: number; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly dateModified: number; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly albumUri: string; | 新增 | +| ohos.multimedia.mediaLibrary | Album | albumName: string; | 新增 | +| ohos.multimedia.mediaLibrary | Album | readonly albumId: number; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getAllObject(callback: AsyncCallback>): void;
getAllObject(): Promise>; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getPositionObject(index: number, callback: AsyncCallback): void;
getPositionObject(index: number): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getLastObject(callback: AsyncCallback): void;
getLastObject(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getNextObject(callback: AsyncCallback): void;
getNextObject(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getFirstObject(callback: AsyncCallback): void;
getFirstObject(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | close(): void; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | isAfterLast(): boolean; | 新增 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getCount(): number; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | extendArgs?: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | networkId?: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | uri?: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | order?: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | selectionArgs: Array; | 新增 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | selections: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | ALBUM_NAME = "bucket_display_name" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | ALBUM_ID = "bucket_id" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | ORIENTATION = "orientation" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | HEIGHT = "height" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | WIDTH = "width" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | DURATION = "duration" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | AUDIOALBUM = "audio_album" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | ARTIST = "artist" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | TITLE = "title" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_TAKEN = "date_taken" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_MODIFIED = "date_modified" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_ADDED = "date_added" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | SIZE = "size" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | MEDIA_TYPE = "media_type" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | MIME_TYPE = "mime_type" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | PARENT = "parent" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | DISPLAY_NAME = "display_name" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | RELATIVE_PATH = "relative_path" | 新增 | +| ohos.multimedia.mediaLibrary | FileKey | ID = "file_id" | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | isTrash(callback: AsyncCallback): void;
isTrash():Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | trash(isTrash: boolean, callback: AsyncCallback): void;
trash(isTrash: boolean): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | isFavorite(callback: AsyncCallback): void;
isFavorite():Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | favorite(isFavorite: boolean, callback: AsyncCallback): void;
favorite(isFavorite: boolean): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | getThumbnail(callback: AsyncCallback): void;
getThumbnail(size: Size, callback: AsyncCallback): void;
getThumbnail(size?: Size): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | close(fd: number, callback: AsyncCallback): void;
close(fd: number): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | open(mode: string, callback: AsyncCallback): void;
open(mode: string): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | commitModify(callback: AsyncCallback): void;
commitModify(): Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | isDirectory(callback: AsyncCallback): void;
isDirectory():Promise; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumName: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumUri: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumId: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly duration: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | orientation: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly height: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly width: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly audioAlbum: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly artist: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateTaken: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateModified: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateAdded: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly size: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly parent: number; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | relativePath: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | title: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | displayName: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly mediaType: MediaType; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly mimeType: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly uri: string; | 新增 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly id: number; | 新增 | +| ohos.multimedia.mediaLibrary | MediaSelectOption | count: number; | 新增 | +| ohos.multimedia.mediaLibrary | MediaSelectOption | type: 'image' \| 'video' \| 'media'; | 新增 | +| ohos.multimedia.mediaLibrary | MediaAssetOption | relativePath?: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaAssetOption | mimeType: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaAssetOption | src: string; | 新增 | +| ohos.multimedia.mediaLibrary | MediaType | AUDIO | 新增 | +| ohos.multimedia.mediaLibrary | MediaType | VIDEO | 新增 | +| ohos.multimedia.mediaLibrary | MediaType | IMAGE | 新增 | +| ohos.multimedia.mediaLibrary | MediaType | FILE = 0 | 新增 | +| ohos.multimedia.mediaLibrary | mediaLibrary | function getMediaLibrary(): MediaLibrary;
function getMediaLibrary(context: Context): MediaLibrary; | 新增 | +| ohos.multimedia.media | CodecMimeType | AUDIO_FLAC = 'audio/flac' | 新增 | +| ohos.multimedia.media | CodecMimeType | AUDIO_VORBIS = 'audio/vorbis' | 新增 | +| ohos.multimedia.media | CodecMimeType | AUDIO_AAC = 'audio/mp4a-latm' | 新增 | +| ohos.multimedia.media | CodecMimeType | VIDEO_VP8 = 'video/x-vnd.on2.vp8' | 新增 | +| ohos.multimedia.media | CodecMimeType | VIDEO_MPEG4 = 'video/mp4v-es' | 新增 | +| ohos.multimedia.media | CodecMimeType | VIDEO_MPEG2 = 'video/mpeg2' | 新增 | +| ohos.multimedia.media | CodecMimeType | VIDEO_AVC = 'video/avc' | 新增 | +| ohos.multimedia.media | CodecMimeType | VIDEO_H263 = 'video/h263' | 新增 | +| ohos.multimedia.media | SeekMode | SEEK_PREV_SYNC = 1 | 新增 | +| ohos.multimedia.media | SeekMode | SEEK_NEXT_SYNC = 0 | 新增 | +| ohos.multimedia.media | MediaDescription | [key : string]: Object; | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_AUD_SAMPLE_RATE = "sample_rate" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_AUD_CHANNEL_COUNT = "channel_count" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_FRAME_RATE = "frame_rate" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_HEIGHT = "height" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_WIDTH = "width" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_BITRATE = "bitrate" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_DURATION = "duration" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_CODEC_MIME = "codec_mime" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_TRACK_TYPE = "track_type" | 新增 | +| ohos.multimedia.media | MediaDescriptionKey | MD_KEY_TRACK_INDEX = "track_index" | 新增 | +| ohos.multimedia.media | MediaType | MEDIA_TYPE_VID = 1 | 新增 | +| ohos.multimedia.media | MediaType | MEDIA_TYPE_AUD = 0 | 新增 | +| ohos.multimedia.media | ContainerFormatType | CFT_MPEG_4A = "m4a" | 新增 | +| ohos.multimedia.media | ContainerFormatType | CFT_MPEG_4 = "mp4" | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'error', callback: ErrorCallback): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'startRenderFrame', callback: Callback): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'playbackCompleted', callback: Callback): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | setSpeed(speed:number, callback: AsyncCallback): void;
setSpeed(speed:number): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | readonly height: number; | 新增 | +| ohos.multimedia.media | VideoPlayer | readonly width: number; | 新增 | +| ohos.multimedia.media | VideoPlayer | readonly state: VideoPlayState; | 新增 | +| ohos.multimedia.media | VideoPlayer | readonly duration: number; | 新增 | +| ohos.multimedia.media | VideoPlayer | readonly currentTime: number; | 新增 | +| ohos.multimedia.media | VideoPlayer | loop: boolean; | 新增 | +| ohos.multimedia.media | VideoPlayer | url: string; | 新增 | +| ohos.multimedia.media | VideoPlayer | getTrackDescription(callback: AsyncCallback>): void;
getTrackDescription() : Promise>; | 新增 | +| ohos.multimedia.media | VideoPlayer | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | setVolume(vol: number, callback: AsyncCallback): void;
setVolume(vol: number): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | seek(timeMs: number, callback: AsyncCallback): void;
seek(timeMs: number, mode:SeekMode, callback: AsyncCallback): void;
seek(timeMs: number, mode?:SeekMode): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | reset(callback: AsyncCallback): void;
reset(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | stop(callback: AsyncCallback): void;
stop(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | pause(callback: AsyncCallback): void;
pause(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | play(callback: AsyncCallback): void;
play(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | prepare(callback: AsyncCallback): void;
prepare(): Promise; | 新增 | +| ohos.multimedia.media | VideoPlayer | setDisplaySurface(surfaceId: string, callback: AsyncCallback): void;
setDisplaySurface(surfaceId: string): Promise; | 新增 | +| ohos.multimedia.media | PlaybackSpeed | SPEED_FORWARD_2_00_X = 4 | 新增 | +| ohos.multimedia.media | PlaybackSpeed | SPEED_FORWARD_1_75_X = 3 | 新增 | +| ohos.multimedia.media | PlaybackSpeed | SPEED_FORWARD_1_25_X = 2 | 新增 | +| ohos.multimedia.media | PlaybackSpeed | SPEED_FORWARD_1_00_X = 1 | 新增 | +| ohos.multimedia.media | PlaybackSpeed | SPEED_FORWARD_0_75_X = 0 | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'error', callback: ErrorCallback): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | on(type: 'prepare' \| 'start' \| 'pause' \| 'resume' \| 'stop' \| 'release' \| 'reset', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | reset(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | release(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | stop(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | resume(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | pause(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | start(): void; | 新增 | +| ohos.multimedia.media | AudioRecorder | prepare(config: AudioRecorderConfig): void; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | fileFormat?: ContainerFormatType; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | audioEncoderMime?: CodecMimeType; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | location?: Location; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | uri: string; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | format?: AudioOutputFormat; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | numberOfChannels?: number; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | audioSampleRate?: number; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | audioEncodeBitRate?: number; | 新增 | +| ohos.multimedia.media | AudioRecorderConfig | audioEncoder?: AudioEncoder; | 新增 | +| ohos.multimedia.media | Location | longitude: number; | 新增 | +| ohos.multimedia.media | Location | latitude: number; | 新增 | +| ohos.multimedia.media | AudioOutputFormat | AAC_ADTS = 6 | 新增 | +| ohos.multimedia.media | AudioOutputFormat | AMR_WB = 4 | 新增 | +| ohos.multimedia.media | AudioOutputFormat | AMR_NB = 3 | 新增 | +| ohos.multimedia.media | AudioOutputFormat | MPEG_4 = 2 | 新增 | +| ohos.multimedia.media | AudioOutputFormat | DEFAULT = 0 | 新增 | +| ohos.multimedia.media | AudioEncoder | HE_AAC = 4 | 新增 | +| ohos.multimedia.media | AudioEncoder | AAC_LC = 3 | 新增 | +| ohos.multimedia.media | AudioEncoder | AMR_WB = 2 | 新增 | +| ohos.multimedia.media | AudioEncoder | AMR_NB = 1 | 新增 | +| ohos.multimedia.media | AudioEncoder | DEFAULT = 0 | 新增 | +| ohos.multimedia.media | AudioPlayer | on(type: 'play' \| 'pause' \| 'stop' \| 'reset' \| 'dataLoad' \| 'finish' \| 'volumeChange', callback: () => void): void; | 新增 | +| ohos.multimedia.media | AudioPlayer | on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void; | 新增 | +| ohos.multimedia.media | AudioPlayer | getTrackDescription(callback: AsyncCallback>): void;
getTrackDescription() : Promise>; | 新增 | +| ohos.multimedia.media | AudioPlayer | reset(): void; | 新增 | +| ohos.multimedia.media | BufferingInfoType | CACHED_DURATION = 4 | 新增 | +| ohos.multimedia.media | BufferingInfoType | BUFFERING_PERCENT = 3 | 新增 | +| ohos.multimedia.media | BufferingInfoType | BUFFERING_END = 2 | 新增 | +| ohos.multimedia.media | BufferingInfoType | BUFFERING_START = 1 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_UNSUPPORTED = 9 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_INVALID_STATE = 8 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_SERVICE_DIED = 7 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_UNKNOWN = 6 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_TIMEOUT = 5 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_IO = 4 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_INVALID_VAL = 3 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_OPERATION_NOT_PERMIT = 2 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_NO_MEMORY = 1 | 新增 | +| ohos.multimedia.media | MediaErrorCode | MSERR_OK = 0 | 新增 | +| ohos.multimedia.media | media | function createVideoPlayer(callback: AsyncCallback): void;
function createVideoPlayer() : Promise; | 新增 | +| ohos.multimedia.media | media | function createAudioRecorder(): AudioRecorder; | 新增 | +| ohos.multimedia.image | ImagePacker | readonly supportedFormats: Array; | 新增 | +| ohos.multimedia.image | ImagePacker | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.image | ImagePacker | packing(source: ImageSource, option: PackingOption, callback: AsyncCallback): void;
packing(source: ImageSource, option: PackingOption): Promise;
packing(source: PixelMap, option: PackingOption, callback: AsyncCallback): void;
packing(source: PixelMap, option: PackingOption): Promise; | 新增 | +| ohos.multimedia.image | ImageSource | readonly supportedFormats: Array; | 新增 | +| ohos.multimedia.image | ImageSource | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.image | ImageSource | getImageProperty(key:string, options?: GetImagePropertyOptions): Promise;
getImageProperty(key:string, callback: AsyncCallback): void;
getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | ImageSource | createPixelMap(options?: DecodingOptions): Promise;
createPixelMap(callback: AsyncCallback): void;
createPixelMap(options: DecodingOptions, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | ImageSource | getImageInfo(index: number, callback: AsyncCallback): void;
getImageInfo(callback: AsyncCallback): void;
getImageInfo(index?: number): Promise; | 新增 | +| ohos.multimedia.image | PixelMap | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.image | PixelMap | getPixelBytesNumber(): number; | 新增 | +| ohos.multimedia.image | PixelMap | getBytesNumberPerRow(): number; | 新增 | +| ohos.multimedia.image | PixelMap | getImageInfo(): Promise;
getImageInfo(callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | PixelMap | writeBufferToPixels(src: ArrayBuffer): Promise;
writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | PixelMap | writePixels(area: PositionArea): Promise;
writePixels(area: PositionArea, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | PixelMap | readPixels(area: PositionArea): Promise;
readPixels(area: PositionArea, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | PixelMap | readPixelsToBuffer(dst: ArrayBuffer): Promise;
readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback): void; | 新增 | +| ohos.multimedia.image | PixelMap | readonly isEditable: boolean; | 新增 | +| ohos.multimedia.image | image | function createImagePacker(): ImagePacker; | 新增 | +| ohos.multimedia.image | image | function createImageSource(uri: string): ImageSource;
function createImageSource(fd: number): ImageSource; | 新增 | +| ohos.multimedia.image | image | function createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback): void;
function createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise; | 新增 | +| ohos.multimedia.image | InitializationOptions | editable?: boolean; | 新增 | +| ohos.multimedia.image | InitializationOptions | pixelFormat?: PixelMapFormat; | 新增 | +| ohos.multimedia.image | InitializationOptions | size: Size; | 新增 | +| ohos.multimedia.image | DecodingOptions | desiredPixelFormat?: PixelMapFormat; | 新增 | +| ohos.multimedia.image | DecodingOptions | desiredRegion?: Region; | 新增 | +| ohos.multimedia.image | DecodingOptions | desiredSize?: Size; | 新增 | +| ohos.multimedia.image | DecodingOptions | editable?: boolean; | 新增 | +| ohos.multimedia.image | DecodingOptions | rotate?: number; | 新增 | +| ohos.multimedia.image | DecodingOptions | sampleSize?: number; | 新增 | +| ohos.multimedia.image | DecodingOptions | index?: number; | 新增 | +| ohos.multimedia.image | GetImagePropertyOptions | defaultValue?: string; | 新增 | +| ohos.multimedia.image | GetImagePropertyOptions | index?: number; | 新增 | +| ohos.multimedia.image | PackingOption | quality: number; | 新增 | +| ohos.multimedia.image | PackingOption | format: string; | 新增 | +| ohos.multimedia.image | ImageInfo | size: Size; | 新增 | +| ohos.multimedia.image | PositionArea | region: Region; | 新增 | +| ohos.multimedia.image | PositionArea | stride: number; | 新增 | +| ohos.multimedia.image | PositionArea | offset: number; | 新增 | +| ohos.multimedia.image | PositionArea | pixels: ArrayBuffer; | 新增 | +| ohos.multimedia.image | Region | y: number; | 新增 | +| ohos.multimedia.image | Region | x: number; | 新增 | +| ohos.multimedia.image | Region | size: Size; | 新增 | +| ohos.multimedia.image | PropertyKey | GPS_LONGITUDE_REF = "GPSLongitudeRef" | 新增 | +| ohos.multimedia.image | PropertyKey | GPS_LATITUDE_REF = "GPSLatitudeRef" | 新增 | +| ohos.multimedia.image | PropertyKey | GPS_LONGITUDE = "GPSLongitude" | 新增 | +| ohos.multimedia.image | PropertyKey | GPS_LATITUDE = "GPSLatitude" | 新增 | +| ohos.multimedia.image | PropertyKey | IMAGE_WIDTH = "ImageWidth" | 新增 | +| ohos.multimedia.image | PropertyKey | IMAGE_LENGTH = "ImageLength" | 新增 | +| ohos.multimedia.image | PropertyKey | ORIENTATION = "Orientation" | 新增 | +| ohos.multimedia.image | PropertyKey | BITS_PER_SAMPLE = "BitsPerSample" | 新增 | +| ohos.multimedia.image | Size | width: number; | 新增 | +| ohos.multimedia.image | Size | height: number; | 新增 | +| ohos.multimedia.image | PixelMapFormat | RGBA_8888 = 3 | 新增 | +| ohos.multimedia.image | PixelMapFormat | RGB_565 = 2 | 新增 | +| ohos.multimedia.image | PixelMapFormat | UNKNOWN = 0 | 新增 | +| ohos.multimedia.audio | AudioCapturer | on(type: "stateChange", callback: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioCapturer | off(type: "periodReach"): void; | 新增 | +| ohos.multimedia.audio | AudioCapturer | on(type: "periodReach", frame: number, callback: (position: number) => {}): void; | 新增 | +| ohos.multimedia.audio | AudioCapturer | off(type: "markReach"): void; | 新增 | +| ohos.multimedia.audio | AudioCapturer | on(type: "markReach", frame: number, callback: (position: number) => {}): void; | 新增 | +| ohos.multimedia.audio | AudioCapturer | getBufferSize(callback: AsyncCallback): void;
getBufferSize(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | stop(callback: AsyncCallback): void;
stop(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | getAudioTime(callback: AsyncCallback): void;
getAudioTime(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void;
read(size: number, isBlockingRead: boolean): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | start(callback: AsyncCallback): void;
start(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | getStreamInfo(callback: AsyncCallback): void;
getStreamInfo(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | getCapturerInfo(callback: AsyncCallback): void;
getCapturerInfo(): Promise; | 新增 | +| ohos.multimedia.audio | AudioCapturer | readonly state: AudioState; | 新增 | +| ohos.multimedia.audio | AudioCapturerOptions | capturerInfo: AudioCapturerInfo; | 新增 | +| ohos.multimedia.audio | AudioCapturerOptions | streamInfo: AudioStreamInfo; | 新增 | +| ohos.multimedia.audio | AudioCapturerInfo | capturerFlags: number; | 新增 | +| ohos.multimedia.audio | AudioCapturerInfo | source: SourceType; | 新增 | +| ohos.multimedia.audio | SourceType | SOURCE_TYPE_VOICE_COMMUNICATION = 7 | 新增 | +| ohos.multimedia.audio | SourceType | SOURCE_TYPE_MIC = 0 | 新增 | +| ohos.multimedia.audio | SourceType | SOURCE_TYPE_INVALID = -1 | 新增 | +| ohos.multimedia.audio | AudioRenderer | on(type: "stateChange", callback: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioRenderer | off(type: "periodReach"): void; | 新增 | +| ohos.multimedia.audio | AudioRenderer | on(type: "periodReach", frame: number, callback: (position: number) => {}): void; | 新增 | +| ohos.multimedia.audio | AudioRenderer | off(type: "markReach"): void; | 新增 | +| ohos.multimedia.audio | AudioRenderer | on(type: "markReach", frame: number, callback: (position: number) => {}): void; | 新增 | +| ohos.multimedia.audio | AudioRenderer | getRenderRate(callback: AsyncCallback): void;
getRenderRate(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | setRenderRate(rate: AudioRendererRate, callback: AsyncCallback): void;
setRenderRate(rate: AudioRendererRate): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | getBufferSize(callback: AsyncCallback): void;
getBufferSize(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | release(callback: AsyncCallback): void;
release(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | stop(callback: AsyncCallback): void;
stop(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | pause(callback: AsyncCallback): void;
pause(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | drain(callback: AsyncCallback): void;
drain(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | getAudioTime(callback: AsyncCallback): void;
getAudioTime(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | write(buffer: ArrayBuffer, callback: AsyncCallback): void;
write(buffer: ArrayBuffer): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | start(callback: AsyncCallback): void;
start(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | getStreamInfo(callback: AsyncCallback): void;
getStreamInfo(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | getRendererInfo(callback: AsyncCallback): void;
getRendererInfo(): Promise; | 新增 | +| ohos.multimedia.audio | AudioRenderer | readonly state: AudioState; | 新增 | +| ohos.multimedia.audio | DeviceChangeAction | deviceDescriptors: AudioDeviceDescriptors; | 新增 | +| ohos.multimedia.audio | DeviceChangeAction | type: DeviceChangeType; | 新增 | +| ohos.multimedia.audio | AudioInterrupt | pauseWhenDucked: boolean; | 新增 | +| ohos.multimedia.audio | AudioInterrupt | contentType: ContentType; | 新增 | +| ohos.multimedia.audio | AudioInterrupt | streamUsage: StreamUsage; | 新增 | +| ohos.multimedia.audio | InterruptAction | activated?: boolean; | 新增 | +| ohos.multimedia.audio | InterruptAction | hint?: InterruptHint; | 新增 | +| ohos.multimedia.audio | InterruptAction | type?: InterruptType; | 新增 | +| ohos.multimedia.audio | InterruptAction | actionType: InterruptActionType; | 新增 | +| ohos.multimedia.audio | AudioManager | off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioManager | on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioManager | off(type: 'deviceChange', callback?: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioManager | on(type: 'deviceChange', callback: Callback): void; | 新增 | +| ohos.multimedia.audio | AudioManager | getAudioScene(callback: AsyncCallback): void;
getAudioScene(): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback): void;
isDeviceActive(deviceType: ActiveDeviceType): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback): void;
setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | getAudioParameter(key: string, callback: AsyncCallback): void;
getAudioParameter(key: string): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | setAudioParameter(key: string, value: string, callback: AsyncCallback): void;
setAudioParameter(key: string, value: string): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | getRingerMode(callback: AsyncCallback): void;
getRingerMode(): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void;
setRingerMode(mode: AudioRingMode): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | isMicrophoneMute(callback: AsyncCallback): void;
isMicrophoneMute(): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | setMicrophoneMute(mute: boolean, callback: AsyncCallback): void;
setMicrophoneMute(mute: boolean): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void;
isActive(volumeType: AudioVolumeType): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | isMute(volumeType: AudioVolumeType, callback: AsyncCallback): void;
isMute(volumeType: AudioVolumeType): Promise; | 新增 | +| ohos.multimedia.audio | AudioManager | mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void;
mute(volumeType: AudioVolumeType, mute: boolean): Promise; | 新增 | +| ohos.multimedia.audio | AudioScene | AUDIO_SCENE_VOICE_CHAT | 新增 | +| ohos.multimedia.audio | AudioScene | AUDIO_SCENE_DEFAULT = 0 | 新增 | +| ohos.multimedia.audio | DeviceChangeType | DISCONNECT = 1 | 新增 | +| ohos.multimedia.audio | DeviceChangeType | CONNECT = 0 | 新增 | +| ohos.multimedia.audio | InterruptActionType | TYPE_INTERRUPT = 1 | 新增 | +| ohos.multimedia.audio | InterruptActionType | TYPE_ACTIVATED = 0 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_UNDUCK = 5 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_DUCK = 4 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_STOP = 3 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_PAUSE = 2 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_RESUME = 1 | 新增 | +| ohos.multimedia.audio | InterruptHint | INTERRUPT_HINT_NONE = 0 | 新增 | +| ohos.multimedia.audio | InterruptType | INTERRUPT_TYPE_END = 2 | 新增 | +| ohos.multimedia.audio | InterruptType | INTERRUPT_TYPE_BEGIN = 1 | 新增 | +| ohos.multimedia.audio | AudioRendererRate | RENDER_RATE_HALF = 2 | 新增 | +| ohos.multimedia.audio | AudioRendererRate | RENDER_RATE_DOUBLE = 1 | 新增 | +| ohos.multimedia.audio | AudioRendererRate | RENDER_RATE_NORMAL = 0 | 新增 | +| ohos.multimedia.audio | AudioRendererOptions | rendererInfo: AudioRendererInfo; | 新增 | +| ohos.multimedia.audio | AudioRendererOptions | streamInfo: AudioStreamInfo; | 新增 | +| ohos.multimedia.audio | AudioRendererInfo | rendererFlags: number; | 新增 | +| ohos.multimedia.audio | AudioRendererInfo | usage: StreamUsage; | 新增 | +| ohos.multimedia.audio | AudioRendererInfo | content: ContentType; | 新增 | +| ohos.multimedia.audio | AudioStreamInfo | encodingType: AudioEncodingType; | 新增 | +| ohos.multimedia.audio | AudioStreamInfo | sampleFormat: AudioSampleFormat; | 新增 | +| ohos.multimedia.audio | AudioStreamInfo | channels: AudioChannel; | 新增 | +| ohos.multimedia.audio | AudioStreamInfo | samplingRate: AudioSamplingRate; | 新增 | +| ohos.multimedia.audio | StreamUsage | STREAM_USAGE_NOTIFICATION_RINGTONE = 6 | 新增 | +| ohos.multimedia.audio | StreamUsage | STREAM_USAGE_VOICE_COMMUNICATION = 2 | 新增 | +| ohos.multimedia.audio | StreamUsage | STREAM_USAGE_MEDIA = 1 | 新增 | +| ohos.multimedia.audio | StreamUsage | STREAM_USAGE_UNKNOWN = 0 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_RINGTONE = 5 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_SONIFICATION = 4 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_MOVIE = 3 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_MUSIC = 2 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_SPEECH = 1 | 新增 | +| ohos.multimedia.audio | ContentType | CONTENT_TYPE_UNKNOWN = 0 | 新增 | +| ohos.multimedia.audio | AudioEncodingType | ENCODING_TYPE_RAW = 0 | 新增 | +| ohos.multimedia.audio | AudioEncodingType | ENCODING_TYPE_INVALID = -1 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_96000 = 96000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_64000 = 64000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_48000 = 48000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_44100 = 44100 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_32000 = 32000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_24000 = 24000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_22050 = 22050 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_16000 = 16000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_12000 = 12000 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_11025 = 11025 | 新增 | +| ohos.multimedia.audio | AudioSamplingRate | SAMPLE_RATE_8000 = 8000 | 新增 | +| ohos.multimedia.audio | AudioChannel | CHANNEL_2 = 0x1 << 1 | 新增 | +| ohos.multimedia.audio | AudioChannel | CHANNEL_1 = 0x1 << 0 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_S32LE = 3 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_S24LE = 2 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_S16LE = 1 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_U8 = 0 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_INVALID = -1 | 新增 | +| ohos.multimedia.audio | AudioRingMode | RINGER_MODE_NORMAL = 2 | 新增 | +| ohos.multimedia.audio | AudioRingMode | RINGER_MODE_VIBRATE = 1 | 新增 | +| ohos.multimedia.audio | AudioRingMode | RINGER_MODE_SILENT = 0 | 新增 | +| ohos.multimedia.audio | ActiveDeviceType | BLUETOOTH_SCO = 7 | 新增 | +| ohos.multimedia.audio | ActiveDeviceType | SPEAKER = 2 | 新增 | +| ohos.multimedia.audio | DeviceType | USB_HEADSET = 22 | 新增 | +| ohos.multimedia.audio | DeviceType | WIRED_HEADPHONES = 4 | 新增 | +| ohos.multimedia.audio | DeviceType | EARPIECE = 1 | 新增 | +| ohos.multimedia.audio | AudioVolumeType | VOICE_ASSISTANT = 9 | 新增 | +| ohos.multimedia.audio | AudioVolumeType | VOICE_CALL = 0 | 新增 | +| ohos.multimedia.audio | AudioState | STATE_PAUSED | 新增 | +| ohos.multimedia.audio | AudioState | STATE_RELEASED | 新增 | +| ohos.multimedia.audio | AudioState | STATE_STOPPED | 新增 | +| ohos.multimedia.audio | AudioState | STATE_RUNNING | 新增 | +| ohos.multimedia.audio | AudioState | STATE_PREPARED | 新增 | +| ohos.multimedia.audio | AudioState | STATE_NEW | 新增 | +| ohos.multimedia.audio | AudioState | STATE_INVALID = -1 | 新增 | +| ohos.multimedia.audio | audio | function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback): void;
function createAudioRenderer(options: AudioRendererOptions): Promise; | 新增 | +| ohos.multimedia.audio | audio | function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback): void;
function createAudioCapturer(options: AudioCapturerOptions): Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-network.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-network.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..da00bb411de775d3fb9b8a9e9f45380d71e23ff1 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-network.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-network.md @@ -1,14 +1,186 @@ -# xxx子系统JS API变更 +# 网络管理子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,网络管理子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.net.webSocket | WebSocket | off(type: 'error', callback?: ErrorCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | on(type: 'error', callback: ErrorCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | off(type: 'close', callback?: AsyncCallback<{ code: number, reason: string }>): void; | 新增 | +| ohos.net.webSocket | WebSocket | on(type: 'close', callback: AsyncCallback<{ code: number, reason: string }>): void; | 新增 | +| ohos.net.webSocket | WebSocket | off(type: 'message', callback?: AsyncCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | on(type: 'message', callback: AsyncCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | off(type: 'open', callback?: AsyncCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | on(type: 'open', callback: AsyncCallback): void; | 新增 | +| ohos.net.webSocket | WebSocket | close(callback: AsyncCallback): void;
close(options: WebSocketCloseOptions, callback: AsyncCallback): void;
close(options?: WebSocketCloseOptions): Promise; | 新增 | +| ohos.net.webSocket | WebSocket | send(data: string \| ArrayBuffer, callback: AsyncCallback): void;
send(data: string \| ArrayBuffer): Promise; | 新增 | +| ohos.net.webSocket | WebSocket | connect(url: string, callback: AsyncCallback): void;
connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void;
connect(url: string, options?: WebSocketRequestOptions): Promise; | 新增 | +| ohos.net.webSocket | WebSocketCloseOptions | reason?: string; | 新增 | +| ohos.net.webSocket | WebSocketCloseOptions | code?: number; | 新增 | +| ohos.net.webSocket | WebSocketRequestOptions | header?: Object; | 新增 | +| ohos.net.webSocket | webSocket | function createWebSocket(): WebSocket; | 新增 | +| ohos.net.socket | TCPSocket | off(type: 'error', callback?: ErrorCallback): void; | 新增 | +| ohos.net.socket | TCPSocket | on(type: 'error', callback: ErrorCallback): void; | 新增 | +| ohos.net.socket | TCPSocket | off(type: 'connect' \| 'close', callback?: Callback): void; | 新增 | +| ohos.net.socket | TCPSocket | off(type: 'connect' \| 'close', callback?: Callback): void; | 新增 | +| ohos.net.socket | TCPSocket | on(type: 'connect' \| 'close', callback: Callback): void; | 新增 | +| ohos.net.socket | TCPSocket | on(type: 'connect' \| 'close', callback: Callback): void; | 新增 | +| ohos.net.socket | TCPSocket | off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; | 新增 | +| ohos.net.socket | TCPSocket | on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; | 新增 | +| ohos.net.socket | TCPSocket | setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback): void;
setExtraOptions(options: TCPExtraOptions): Promise; | 新增 | +| ohos.net.socket | TCPSocket | getState(callback: AsyncCallback): void;
getState(): Promise; | 新增 | +| ohos.net.socket | TCPSocket | getRemoteAddress(callback: AsyncCallback): void;
getRemoteAddress(): Promise; | 新增 | +| ohos.net.socket | TCPSocket | close(callback: AsyncCallback): void;
close(): Promise; | 新增 | +| ohos.net.socket | TCPSocket | send(options: TCPSendOptions, callback: AsyncCallback): void;
send(options: TCPSendOptions): Promise; | 新增 | +| ohos.net.socket | TCPSocket | connect(options: TCPConnectOptions, callback: AsyncCallback): void;
connect(options: TCPConnectOptions): Promise; | 新增 | +| ohos.net.socket | TCPSocket | bind(address: NetAddress, callback: AsyncCallback): void;
bind(address: NetAddress): Promise; | 新增 | +| ohos.net.socket | TCPExtraOptions | socketLinger: {on: boolean, linger: number}; | 新增 | +| ohos.net.socket | TCPExtraOptions | TCPNoDelay?: boolean; | 新增 | +| ohos.net.socket | TCPExtraOptions | OOBInline?: boolean; | 新增 | +| ohos.net.socket | TCPExtraOptions | keepAlive?: boolean; | 新增 | +| ohos.net.socket | TCPSendOptions | encoding?: string; | 新增 | +| ohos.net.socket | TCPSendOptions | data: string \| ArrayBuffer; | 新增 | +| ohos.net.socket | TCPConnectOptions | timeout?: number; | 新增 | +| ohos.net.socket | TCPConnectOptions | address: NetAddress; | 新增 | +| ohos.net.socket | UDPSocket | off(type: 'error', callback?: ErrorCallback): void; | 新增 | +| ohos.net.socket | UDPSocket | on(type: 'error', callback: ErrorCallback): void; | 新增 | +| ohos.net.socket | UDPSocket | off(type: 'listening' \| 'close', callback?: Callback): void; | 新增 | +| ohos.net.socket | UDPSocket | off(type: 'listening' \| 'close', callback?: Callback): void; | 新增 | +| ohos.net.socket | UDPSocket | on(type: 'listening' \| 'close', callback: Callback): void; | 新增 | +| ohos.net.socket | UDPSocket | on(type: 'listening' \| 'close', callback: Callback): void; | 新增 | +| ohos.net.socket | UDPSocket | off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; | 新增 | +| ohos.net.socket | UDPSocket | on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; | 新增 | +| ohos.net.socket | UDPSocket | setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback): void;
setExtraOptions(options: UDPExtraOptions): Promise; | 新增 | +| ohos.net.socket | UDPSocket | getState(callback: AsyncCallback): void;
getState(): Promise; | 新增 | +| ohos.net.socket | UDPSocket | close(callback: AsyncCallback): void;
close(): Promise; | 新增 | +| ohos.net.socket | UDPSocket | send(options: UDPSendOptions, callback: AsyncCallback): void;
send(options: UDPSendOptions): Promise; | 新增 | +| ohos.net.socket | UDPSocket | bind(address: NetAddress, callback: AsyncCallback): void;
bind(address: NetAddress): Promise; | 新增 | +| ohos.net.socket | SocketRemoteInfo | size: number; | 新增 | +| ohos.net.socket | SocketRemoteInfo | port: number; | 新增 | +| ohos.net.socket | SocketRemoteInfo | family: 'IPv4' \| 'IPv6'; | 新增 | +| ohos.net.socket | SocketRemoteInfo | address: string; | 新增 | +| ohos.net.socket | SocketStateBase | isConnected: boolean; | 新增 | +| ohos.net.socket | SocketStateBase | isClose: boolean; | 新增 | +| ohos.net.socket | SocketStateBase | isBound: boolean; | 新增 | +| ohos.net.socket | UDPExtraOptions | broadcast?: boolean; | 新增 | +| ohos.net.socket | ExtraOptionsBase | socketTimeout?: number; | 新增 | +| ohos.net.socket | ExtraOptionsBase | reuseAddress?: boolean; | 新增 | +| ohos.net.socket | ExtraOptionsBase | sendBufferSize?: number; | 新增 | +| ohos.net.socket | ExtraOptionsBase | receiveBufferSize?: number; | 新增 | +| ohos.net.socket | UDPSendOptions | address: NetAddress; | 新增 | +| ohos.net.socket | UDPSendOptions | data: string \| ArrayBuffer; | 新增 | +| ohos.net.socket | socket | function constructTCPSocketInstance(): TCPSocket; | 新增 | +| ohos.net.socket | socket | function constructUDPSocketInstance(): UDPSocket; | 新增 | +| ohos.net.socket | socket | import NetAddress = connection.NetAddress; | 新增 | +| ohos.net.http | HttpResponse | cookies: string; | 新增 | +| ohos.net.http | HttpResponse | header: Object; | 新增 | +| ohos.net.http | HttpResponse | responseCode: ResponseCode \| number; | 新增 | +| ohos.net.http | HttpResponse | result: string \| Object \| ArrayBuffer; | 新增 | +| ohos.net.http | ResponseCode | VERSION | 新增 | +| ohos.net.http | ResponseCode | GATEWAY_TIMEOUT | 新增 | +| ohos.net.http | ResponseCode | UNAVAILABLE | 新增 | +| ohos.net.http | ResponseCode | BAD_GATEWAY | 新增 | +| ohos.net.http | ResponseCode | NOT_IMPLEMENTED | 新增 | +| ohos.net.http | ResponseCode | INTERNAL_ERROR = 500 | 新增 | +| ohos.net.http | ResponseCode | UNSUPPORTED_TYPE | 新增 | +| ohos.net.http | ResponseCode | REQ_TOO_LONG | 新增 | +| ohos.net.http | ResponseCode | ENTITY_TOO_LARGE | 新增 | +| ohos.net.http | ResponseCode | PRECON_FAILED | 新增 | +| ohos.net.http | ResponseCode | LENGTH_REQUIRED | 新增 | +| ohos.net.http | ResponseCode | GONE | 新增 | +| ohos.net.http | ResponseCode | CONFLICT | 新增 | +| ohos.net.http | ResponseCode | CLIENT_TIMEOUT | 新增 | +| ohos.net.http | ResponseCode | PROXY_AUTH | 新增 | +| ohos.net.http | ResponseCode | NOT_ACCEPTABLE | 新增 | +| ohos.net.http | ResponseCode | BAD_METHOD | 新增 | +| ohos.net.http | ResponseCode | NOT_FOUND | 新增 | +| ohos.net.http | ResponseCode | FORBIDDEN | 新增 | +| ohos.net.http | ResponseCode | PAYMENT_REQUIRED | 新增 | +| ohos.net.http | ResponseCode | UNAUTHORIZED | 新增 | +| ohos.net.http | ResponseCode | BAD_REQUEST = 400 | 新增 | +| ohos.net.http | ResponseCode | USE_PROXY | 新增 | +| ohos.net.http | ResponseCode | NOT_MODIFIED | 新增 | +| ohos.net.http | ResponseCode | SEE_OTHER | 新增 | +| ohos.net.http | ResponseCode | MOVED_TEMP | 新增 | +| ohos.net.http | ResponseCode | MOVED_PERM | 新增 | +| ohos.net.http | ResponseCode | MULT_CHOICE = 300 | 新增 | +| ohos.net.http | ResponseCode | PARTIAL | 新增 | +| ohos.net.http | ResponseCode | RESET | 新增 | +| ohos.net.http | ResponseCode | NO_CONTENT | 新增 | +| ohos.net.http | ResponseCode | NOT_AUTHORITATIVE | 新增 | +| ohos.net.http | ResponseCode | ACCEPTED | 新增 | +| ohos.net.http | ResponseCode | CREATED | 新增 | +| ohos.net.http | ResponseCode | OK = 200 | 新增 | +| ohos.net.http | RequestMethod | CONNECT = "CONNECT" | 新增 | +| ohos.net.http | RequestMethod | TRACE = "TRACE" | 新增 | +| ohos.net.http | RequestMethod | DELETE = "DELETE" | 新增 | +| ohos.net.http | RequestMethod | PUT = "PUT" | 新增 | +| ohos.net.http | RequestMethod | POST = "POST" | 新增 | +| ohos.net.http | RequestMethod | HEAD = "HEAD" | 新增 | +| ohos.net.http | RequestMethod | GET = "GET" | 新增 | +| ohos.net.http | RequestMethod | OPTIONS = "OPTIONS" | 新增 | +| ohos.net.http | HttpRequest | once(type: "headersReceive", callback: Callback): void; | 新增 | +| ohos.net.http | HttpRequest | off(type: "headersReceive", callback?: Callback): void; | 新增 | +| ohos.net.http | HttpRequest | on(type: "headersReceive", callback: Callback): void; | 新增 | +| ohos.net.http | HttpRequest | off(type: "headerReceive", callback?: AsyncCallback): void; | 新增 | +| ohos.net.http | HttpRequest | on(type: "headerReceive", callback: AsyncCallback): void; | 新增 | +| ohos.net.http | HttpRequest | destroy(): void; | 新增 | +| ohos.net.http | HttpRequest | request(url: string, callback: AsyncCallback): void;
request(url: string, options: HttpRequestOptions, callback: AsyncCallback): void;
request(url: string, options?: HttpRequestOptions): Promise; | 新增 | +| ohos.net.http | HttpRequestOptions | connectTimeout?: number; | 新增 | +| ohos.net.http | HttpRequestOptions | readTimeout?: number; | 新增 | +| ohos.net.http | HttpRequestOptions | header?: Object; | 新增 | +| ohos.net.http | HttpRequestOptions | extraData?: string \| Object \| ArrayBuffer; | 新增 | +| ohos.net.http | HttpRequestOptions | method?: RequestMethod; | 新增 | +| ohos.net.http | http | function createHttp(): HttpRequest; | 新增 | +| ohos.net.connection | NetAddress | port?: number; | 新增 | +| ohos.net.connection | NetAddress | family?: number; | 新增 | +| ohos.net.connection | NetAddress | address: string; | 新增 | +| ohos.net.connection | LinkAddress | prefixLength: number; | 新增 | +| ohos.net.connection | LinkAddress | address: NetAddress; | 新增 | +| ohos.net.connection | RouteInfo | isDefaultRoute: boolean; | 新增 | +| ohos.net.connection | RouteInfo | hasGateway: boolean; | 新增 | +| ohos.net.connection | RouteInfo | gateway: NetAddress; | 新增 | +| ohos.net.connection | RouteInfo | destination: LinkAddress; | 新增 | +| ohos.net.connection | RouteInfo | interface: string; | 新增 | +| ohos.net.connection | ConnectionProperties | mtu: number; | 新增 | +| ohos.net.connection | ConnectionProperties | routes: Array; | 新增 | +| ohos.net.connection | ConnectionProperties | dnses: Array; | 新增 | +| ohos.net.connection | ConnectionProperties | linkAddresses: Array; | 新增 | +| ohos.net.connection | ConnectionProperties | domains: string; | 新增 | +| ohos.net.connection | ConnectionProperties | interfaceName: string; | 新增 | +| ohos.net.connection | NetBearType | BEARER_ETHERNET = 3 | 新增 | +| ohos.net.connection | NetBearType | BEARER_WIFI = 1 | 新增 | +| ohos.net.connection | NetBearType | BEARER_CELLULAR = 0 | 新增 | +| ohos.net.connection | NetCap | NET_CAPABILITY_VALIDATED = 16 | 新增 | +| ohos.net.connection | NetCap | NET_CAPABILITY_NOT_VPN = 15 | 新增 | +| ohos.net.connection | NetCap | NET_CAPABILITY_INTERNET = 12 | 新增 | +| ohos.net.connection | NetCap | NET_CAPABILITY_NOT_METERED = 11 | 新增 | +| ohos.net.connection | NetCap | NET_CAPABILITY_MMS = 0 | 新增 | +| ohos.net.connection | NetCapabilities | bearerTypes: Array; | 新增 | +| ohos.net.connection | NetCapabilities | networkCap?: Array; | 新增 | +| ohos.net.connection | NetCapabilities | linkDownBandwidthKbps?: number; | 新增 | +| ohos.net.connection | NetCapabilities | linkUpBandwidthKbps?: number; | 新增 | +| ohos.net.connection | NetHandle | getAddressByName(host: string, callback: AsyncCallback): void;
getAddressByName(host: string): Promise; | 新增 | +| ohos.net.connection | NetHandle | getAddressesByName(host: string, callback: AsyncCallback>): void;
getAddressesByName(host: string): Promise>; | 新增 | +| ohos.net.connection | NetHandle | netId: number; | 新增 | +| ohos.net.connection | NetSpecifier | bearerPrivateIdentifier?: string; | 新增 | +| ohos.net.connection | NetSpecifier | netCapabilities: NetCapabilities; | 新增 | +| ohos.net.connection | NetConnection | unregister(callback: AsyncCallback): void; | 新增 | +| ohos.net.connection | NetConnection | register(callback: AsyncCallback): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netUnavailable', callback: Callback): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netLost', callback: Callback): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void; | 新增 | +| ohos.net.connection | NetConnection | on(type: 'netAvailable', callback: Callback): void; | 新增 | +| ohos.net.connection | connection | function getAddressesByName(host: string, callback: AsyncCallback>): void;
function getAddressesByName(host: string): Promise>; | 新增 | +| ohos.net.connection | connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback): void;
function reportNetDisconnected(netHandle: NetHandle): Promise; | 新增 | +| ohos.net.connection | connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void;
function reportNetConnected(netHandle: NetHandle): Promise; | 新增 | +| ohos.net.connection | connection | function hasDefaultNet(callback: AsyncCallback): void;
function hasDefaultNet(): Promise; | 新增 | +| ohos.net.connection | connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void;
function getNetCapabilities(netHandle: NetHandle): Promise; | 新增 | +| ohos.net.connection | connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback): void;
function getConnectionProperties(netHandle: NetHandle): Promise; | 新增 | +| ohos.net.connection | connection | function getAllNets(callback: AsyncCallback>): void;
function getAllNets(): Promise>; | 新增 | +| ohos.net.connection | connection | function getDefaultNet(callback: AsyncCallback): void;
function getDefaultNet(): Promise; | 新增 | +| ohos.net.connection | connection | function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-recovery.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-recovery.md deleted file mode 100644 index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-recovery.md +++ /dev/null @@ -1,14 +0,0 @@ -# xxx子系统JS API变更 - -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: - -## 接口变更 - -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..d79973a700db099cd4fcdc90d954b7d338911a30 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler.md @@ -1,14 +1,91 @@ -# xxx子系统JS API变更 +# 资源调度子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,资源调度子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.reminderAgent | LocalDateTime | second?: number; | 新增 | +| ohos.reminderAgent | LocalDateTime | minute: number; | 新增 | +| ohos.reminderAgent | LocalDateTime | hour: number; | 新增 | +| ohos.reminderAgent | LocalDateTime | day: number; | 新增 | +| ohos.reminderAgent | LocalDateTime | month: number; | 新增 | +| ohos.reminderAgent | LocalDateTime | year: number; | 新增 | +| ohos.reminderAgent | ReminderRequestTimer | triggerTimeInSeconds: number; | 新增 | +| ohos.reminderAgent | ReminderRequestAlarm | daysOfWeek?: Array; | 新增 | +| ohos.reminderAgent | ReminderRequestAlarm | minute: number; | 新增 | +| ohos.reminderAgent | ReminderRequestAlarm | hour: number; | 新增 | +| ohos.reminderAgent | ReminderRequestCalendar | repeatDays?: Array; | 新增 | +| ohos.reminderAgent | ReminderRequestCalendar | repeatMonths?: Array; | 新增 | +| ohos.reminderAgent | ReminderRequestCalendar | dateTime: LocalDateTime; | 新增 | +| ohos.reminderAgent | ReminderRequest | slotType?: notification.SlotType; | 新增 | +| ohos.reminderAgent | ReminderRequest | notificationId?: number; | 新增 | +| ohos.reminderAgent | ReminderRequest | snoozeContent?: string; | 新增 | +| ohos.reminderAgent | ReminderRequest | expiredContent?: string; | 新增 | +| ohos.reminderAgent | ReminderRequest | content?: string; | 新增 | +| ohos.reminderAgent | ReminderRequest | title?: string; | 新增 | +| ohos.reminderAgent | ReminderRequest | timeInterval?: number; | 新增 | +| ohos.reminderAgent | ReminderRequest | snoozeTimes?: number; | 新增 | +| ohos.reminderAgent | ReminderRequest | ringDuration?: number; | 新增 | +| ohos.reminderAgent | ReminderRequest | maxScreenWantAgent?: MaxScreenWantAgent; | 新增 | +| ohos.reminderAgent | ReminderRequest | wantAgent?: WantAgent; | 新增 | +| ohos.reminderAgent | ReminderRequest | actionButton?: [ActionButton?, ActionButton?]; | 新增 | +| ohos.reminderAgent | ReminderRequest | reminderType: ReminderType; | 新增 | +| ohos.reminderAgent | MaxScreenWantAgent | abilityName: string; | 新增 | +| ohos.reminderAgent | MaxScreenWantAgent | pkgName: string; | 新增 | +| ohos.reminderAgent | WantAgent | abilityName: string; | 新增 | +| ohos.reminderAgent | WantAgent | pkgName: string; | 新增 | +| ohos.reminderAgent | ActionButton | type: ActionButtonType; | 新增 | +| ohos.reminderAgent | ActionButton | title: string; | 新增 | +| ohos.reminderAgent | ReminderType | REMINDER_TYPE_ALARM = 2 | 新增 | +| ohos.reminderAgent | ReminderType | REMINDER_TYPE_CALENDAR = 1 | 新增 | +| ohos.reminderAgent | ReminderType | REMINDER_TYPE_TIMER = 0 | 新增 | +| ohos.reminderAgent | ActionButtonType | ACTION_BUTTON_TYPE_SNOOZE = 1 | 新增 | +| ohos.reminderAgent | ActionButtonType | ACTION_BUTTON_TYPE_CLOSE = 0 | 新增 | +| ohos.reminderAgent | reminderAgent | function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void;
function removeNotificationSlot(slotType: notification.SlotType): Promise; | 新增 | +| ohos.reminderAgent | reminderAgent | function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void;
function addNotificationSlot(slot: NotificationSlot): Promise; | 新增 | +| ohos.reminderAgent | reminderAgent | function cancelAllReminders(callback: AsyncCallback): void;
function cancelAllReminders(): Promise; | 新增 | +| ohos.reminderAgent | reminderAgent | function getValidReminders(callback: AsyncCallback>): void;
function getValidReminders(): Promise>; | 新增 | +| ohos.reminderAgent | reminderAgent | function cancelReminder(reminderId: number, callback: AsyncCallback): void;
function cancelReminder(reminderId: number): Promise; | 新增 | +| ohos.reminderAgent | reminderAgent | function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void;
function publishReminder(reminderReq: ReminderRequest): Promise; | 新增 | +| ohos.bundleState | bundleState | function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void;
function queryCurrentBundleActiveStates(begin: number, end: number): Promise>; | 新增 | +| ohos.bundleState | IntervalType | BY_ANNUALLY = 4 | 新增 | +| ohos.bundleState | IntervalType | BY_MONTHLY = 3 | 新增 | +| ohos.bundleState | IntervalType | BY_WEEKLY = 2 | 新增 | +| ohos.bundleState | IntervalType | BY_DAILY = 1 | 新增 | +| ohos.bundleState | IntervalType | BY_OPTIMIZED = 0 | 新增 | +| ohos.bundleState | BundleActiveInfoResponse | [key: string]: BundleStateInfo; | 新增 | +| ohos.bundleState | bundleState | function queryAppUsagePriorityGroup(callback: AsyncCallback): void;
function queryAppUsagePriorityGroup(): Promise; | 新增 | +| ohos.bundleState | bundleState | function isIdleState(bundleName: string, callback: AsyncCallback): void;
function isIdleState(bundleName: string): Promise; | 新增 | +| ohos.bundleState | BundleActiveState | stateType?: number; | 新增 | +| ohos.bundleState | BundleActiveState | stateOccurredTime?: number; | 新增 | +| ohos.bundleState | BundleActiveState | nameOfClass?: string; | 新增 | +| ohos.bundleState | BundleActiveState | indexOfLink?: string; | 新增 | +| ohos.bundleState | BundleActiveState | bundleName?: string; | 新增 | +| ohos.bundleState | BundleActiveState | appUsagePriorityGroup?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | merge(toMerge: BundleStateInfo): void; | 新增 | +| ohos.bundleState | BundleStateInfo | infosEndTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | infosBeginTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | fgAbilityPrevAccessTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | fgAbilityAccessTotalTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | bundleName?: string; | 新增 | +| ohos.bundleState | BundleStateInfo | abilitySeenTotalTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | abilityPrevSeenTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | abilityPrevAccessTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | abilityInFgTotalTime?: number; | 新增 | +| ohos.bundleState | BundleStateInfo | id: number; | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | TASK_KEEPING = 9 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | MULTI_DEVICE_CONNECTION = 6 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | BLUETOOTH_INTERACTION = 5 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | LOCATION = 4 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | AUDIO_RECORDING = 3 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | AUDIO_PLAYBACK = 2 | 新增 | +| ohos.backgroundTaskManager | BackgroundMode | DATA_TRANSFER = 1 | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | function stopBackgroundRunning(context: Context, callback: AsyncCallback): void;
function stopBackgroundRunning(context: Context): Promise; | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void;
function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise; | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | function requestSuspendDelay(reason: string, callback: Callback): DelaySuspendInfo; | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | function getRemainingDelayTime(requestId: number, callback: AsyncCallback): void;
function getRemainingDelayTime(requestId: number): Promise; | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | function cancelSuspendDelay(requestId: number): void; | 新增 | +| ohos.backgroundTaskManager | DelaySuspendInfo | actualDelayTime: number; | 新增 | +| ohos.backgroundTaskManager | DelaySuspendInfo | requestId: number; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-security.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-security.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..6131699b92d239f0b92c5fe9d7b5a2a21486f503 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-security.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-security.md @@ -1,14 +1,247 @@ -# xxx子系统JS API变更 +# 安全子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,安全子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.security.huks | HuksTag | HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES \| 20003 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES \| 20002 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_SYMMETRIC_KEY_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES \| 20001 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_OS_PATCHLEVEL = HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_OS_VERSION = HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IS_KEY_HANDLE = HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AE_TAG = HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PAYLOAD_LEN = HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_VERSION = HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_CRYPTO_CTX = HuksTagType.HUKS_TAG_TYPE_ULONG \| 10005 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_USES_TIME = HuksTagType.HUKS_TAG_TYPE_UINT \| 10004 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ACCESS_TIME = HuksTagType.HUKS_TAG_TYPE_UINT \| 10003 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PACKAGE_NAME = HuksTagType.HUKS_TAG_TYPE_BYTES \| 10002 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PROCESS_NAME = HuksTagType.HUKS_TAG_TYPE_BYTES \| 10001 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_DOMAIN = HuksTagType.HUKS_TAG_TYPE_UINT \| 1011 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_SECURE_KEY_UUID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 1010 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_SECURE_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL \| 1009 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IS_ASYNCHRONIZED = HuksTagType.HUKS_TAG_TYPE_UINT \| 1008 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_FLAG = HuksTagType.HUKS_TAG_TYPE_UINT \| 1007 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_ROLE = HuksTagType.HUKS_TAG_TYPE_UINT \| 1006 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_AUTH_ID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 1005 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_WRAP_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT \| 1004 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IS_ALLOWED_WRAP = HuksTagType.HUKS_TAG_TYPE_BOOL \| 1003 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_STORAGE_FLAG = HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IS_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_VERSION_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_UDID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_SOCID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 512 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES \| 511 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_MODEL = HuksTagType.HUKS_TAG_TYPE_BYTES \| 510 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_MANUFACTURER = HuksTagType.HUKS_TAG_TYPE_BYTES \| 509 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_MEID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 508 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_IMEI = HuksTagType.HUKS_TAG_TYPE_BYTES \| 507 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_SERIAL = HuksTagType.HUKS_TAG_TYPE_BYTES \| 506 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_PRODUCT = HuksTagType.HUKS_TAG_TYPE_BYTES \| 505 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_DEVICE = HuksTagType.HUKS_TAG_TYPE_BYTES \| 504 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_ID_BRAND = HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_APPLICATION_ID = HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ATTESTATION_CHALLENGE = HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AUTH_TOKEN = HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AUTH_TIMEOUT = HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_USER_AUTH_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_NO_AUTH_REQUIRED = HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_USER_ID = HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ALL_USERS = HuksTagType.HUKS_TAG_TYPE_BOOL \| 301 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_CREATION_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG \| 204 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_USAGE_EXPIRE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ORIGINATION_EXPIRE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ACTIVE_DATETIME = HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_DERIVE_KEY_SIZE = HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES \| 23 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AGREE_PUBLIC_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES \| 22 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BYTES \| 21 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = HuksTagType.HUKS_TAG_TYPE_BOOL \| 20 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_AGREE_ALG = HuksTagType.HUKS_TAG_TYPE_UINT \| 19 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_DERIVE_ALG = HuksTagType.HUKS_TAG_TYPE_UINT \| 18 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_DERIVE_FACTOR = HuksTagType.HUKS_TAG_TYPE_BYTES \| 17 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_DERIVE_MAIN_KEY = HuksTagType.HUKS_TAG_TYPE_BYTES \| 16 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_GENERATE_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT \| 15 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ITERATION = HuksTagType.HUKS_TAG_TYPE_UINT \| 14 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PWD = HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_SALT = HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_INFO = HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IV = HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_NONCE = HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ASSOCIATED_DATA = HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_BLOCK_MODE = HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PADDING = HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_DIGEST = HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_SIZE = HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_PURPOSE = HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_ALGORITHM = HuksTagType.HUKS_TAG_TYPE_UINT \| 1 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_INVALID = HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_BYTES = 5 << 28 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_BOOL = 4 << 28 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_ULONG = 3 << 28 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_UINT = 2 << 28 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_INT = 1 << 28 | 新增 | +| ohos.security.huks | HuksTagType | HUKS_TAG_TYPE_INVALID = 0 << 28 | 新增 | +| ohos.security.huks | HuksSendType | HUKS_SEND_TYPE_SYNC = 1 | 新增 | +| ohos.security.huks | HuksSendType | HUKS_SEND_TYPE_ASYNC = 0 | 新增 | +| ohos.security.huks | HuksKeyStorageType | HUKS_STORAGE_PERSISTENT = 1 | 新增 | +| ohos.security.huks | HuksKeyStorageType | HUKS_STORAGE_TEMP = 0 | 新增 | +| ohos.security.huks | HuksKeyFlag | HUKS_KEY_FLAG_DERIVE_KEY = 4 | 新增 | +| ohos.security.huks | HuksKeyFlag | HUKS_KEY_FLAG_AGREE_KEY = 3 | 新增 | +| ohos.security.huks | HuksKeyFlag | HUKS_KEY_FLAG_GENERATE_KEY = 2 | 新增 | +| ohos.security.huks | HuksKeyFlag | HUKS_KEY_FLAG_IMPORT_KEY = 1 | 新增 | +| ohos.security.huks | HuksKeyGenerateType | HUKS_KEY_GENERATE_TYPE_AGREE = 2 | 新增 | +| ohos.security.huks | HuksKeyGenerateType | HUKS_KEY_GENERATE_TYPE_DERIVE = 1 | 新增 | +| ohos.security.huks | HuksKeyGenerateType | HUKS_KEY_GENERATE_TYPE_DEFAULT = 0 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_DH = 103 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_ED25519 = 102 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_X25519 = 101 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_ECDH = 100 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_PBKDF2 = 52 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_HKDF = 51 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_HMAC = 50 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_AES = 20 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_DSA = 3 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_ECC = 2 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_RSA = 1 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_DH_KEY_SIZE_4096 = 4096 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_DH_KEY_SIZE_3072 = 3072 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_DH_KEY_SIZE_2048 = 2048 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_CURVE25519_KEY_SIZE_256 = 256 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_AES_KEY_SIZE_512 = 512 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_AES_KEY_SIZE_256 = 256 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_AES_KEY_SIZE_192 = 192 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_AES_KEY_SIZE_128 = 128 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_ECC_KEY_SIZE_521 = 521 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_ECC_KEY_SIZE_384 = 384 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_ECC_KEY_SIZE_256 = 256 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_ECC_KEY_SIZE_224 = 224 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_4096 = 4096 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_3072 = 3072 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_2048 = 2048 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_1024 = 1024 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_768 = 768 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_RSA_KEY_SIZE_512 = 512 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_GCM = 32 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_CCM = 31 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_OFB = 4 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_CTR = 3 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_CBC = 2 | 新增 | +| ohos.security.huks | HuksCipherMode | HUKS_MODE_ECB = 1 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_PKCS7 = 5 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_PKCS5 = 4 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_PKCS1_V1_5 = 3 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_PSS = 2 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_OAEP = 1 | 新增 | +| ohos.security.huks | HuksKeyPadding | HUKS_PADDING_NONE = 0 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SHA512 = 14 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SHA384 = 13 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SHA256 = 12 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SHA224 = 11 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SHA1 = 10 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_MD5 = 1 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_NONE = 0 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_AGREE = 256 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_MAC = 128 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_UNWRAP = 64 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_WRAP = 32 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_DERIVE = 16 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_VERIFY = 8 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_SIGN = 4 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_DECRYPT = 2 | 新增 | +| ohos.security.huks | HuksKeyPurpose | HUKS_KEY_PURPOSE_ENCRYPT = 1 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_UNKNOWN_ERROR = -1000 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INTERNAL_ERROR = -999 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_OPERATION = -125 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_ITERATION = -124 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_SALT = -123 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_AE_TAG = -122 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_NONCE = -121 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_AAD = -120 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_IV = -119 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_SIGNATURE_SIZE = -118 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_DIGEST = -117 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_MODE = -116 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_PURPOSE = -115 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_PADDING = -114 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_KEY_SIZE = -113 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_ALGORITHM = -112 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_ITERATION_FAIL = -111 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_SALT_FAIL = -110 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_AE_TAG_FAIL = -109 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_IV_FAIL = -108 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_AAD_FAIL = -107 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_NONCE_FAIL = -106 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_MODE_FAIL = -105 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_DIGEST_FAIL = -104 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_PURPOSE_FAIL = -103 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_PADDING_FAIL = -102 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CHECK_GET_ALG_FAIL = -100 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_VERIFICATION_FAILED = -38 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL = -37 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST = -36 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_EFUSE_READ_FAIL = -35 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_IPC_DLOPEN_FAIL = -34 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_IPC_INIT_FAIL = -33 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_COMMUNICATION_TIMEOUT = -32 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CRYPTO_ENGINE_ERROR = -31 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_PARAM_NOT_EXIST = -30 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_REQUEST_OVERFLOWS = -29 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_IPC_MSG_FAIL = -28 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_KEY_FILE = -27 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_MAKE_DIR_FAIL = -26 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_CLOSE_FILE_FAIL = -25 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_OPEN_FILE_FAIL = -24 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_REMOVE_FILE_FAIL = -23 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_WRITE_FILE_FAIL = -22 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_MALLOC_FAIL = -21 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_HASH_NOT_EQUAL = -20 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_KEY_INFO = -19 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_PRIVATE_KEY = -18 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_PUBLIC_KEY = -17 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_READ_FILE_FAIL = -16 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_FILE_SIZE_FAIL = -15 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_NULL_POINTER = -14 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_NOT_EXIST = -13 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_ALREADY_EXISTS = -12 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_HARDWARE_FAILURE = -11 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_STORAGE_FAILURE = -10 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_COMMUNICATION_FAILURE = -9 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INSUFFICIENT_MEMORY = -8 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_BUFFER_TOO_SMALL = -7 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INSUFFICIENT_DATA = -6 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_NO_PERMISSION = -5 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_NOT_SUPPORTED = -4 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_ARGUMENT = -3 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_BAD_STATE = -2 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_FAILURE = -1 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_SUCCESS = 0 | 新增 | +| ohos.security.huks | HuksResult | certChains?: Array; | 新增 | +| ohos.security.huks | HuksResult | properties?: Array; | 新增 | +| ohos.security.huks | HuksResult | outData?: Uint8Array; | 新增 | +| ohos.security.huks | HuksResult | errorCode: number; | 新增 | +| ohos.security.huks | HuksOptions | inData?: Uint8Array; | 新增 | +| ohos.security.huks | HuksOptions | properties?: Array; | 新增 | +| ohos.security.huks | HuksHandle | token?: Uint8Array; | 新增 | +| ohos.security.huks | HuksHandle | handle: number; | 新增 | +| ohos.security.huks | HuksHandle | errorCode: number; | 新增 | +| ohos.security.huks | HuksParam | value: boolean \| number \| bigint \| Uint8Array; | 新增 | +| ohos.security.huks | HuksParam | tag: HuksTag; | 新增 | +| ohos.security.huks | huks | function getSdkVersion(options: HuksOptions) : string; | 新增 | +| ohos.security.huks | huks | function abort(handle: number, options: HuksOptions, callback: AsyncCallback) : void;
function abort(handle: number, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function finish(handle: number, options: HuksOptions, callback: AsyncCallback) : void;
function finish(handle: number, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback) : void;
function update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function init(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function init(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function getKeyProperties(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function exportKey(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function importKey(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function deleteKey(keyAlias: string, options: HuksOptions) : Promise; | 新增 | +| ohos.security.huks | huks | function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void;
function generateKey(keyAlias: string, options: HuksOptions) : Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-sensor.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-sensor.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..5f954b20ef74c120f6575b251002029533a34609 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-sensor.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-sensor.md @@ -1,14 +1,112 @@ -# xxx子系统JS API变更 +# 泛Sensor子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,泛Sensor子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.vibrator | VibratorStopMode | VIBRATOR_STOP_MODE_PRESET = "preset" | 新增 | +| ohos.vibrator | VibratorStopMode | VIBRATOR_STOP_MODE_TIME = "time" | 新增 | +| ohos.vibrator | EffectId | EFFECT_CLOCK_TIMER = "haptic.clock.timer" | 新增 | +| ohos.vibrator | vibrator | function stop(stopMode: VibratorStopMode): Promise;
function stop(stopMode: VibratorStopMode, callback?: AsyncCallback): void; | 新增 | +| ohos.vibrator | vibrator | function vibrate(duration: number, callback?: AsyncCallback): void;
function vibrate(duration: number): Promise;
function vibrate(effectId: EffectId): Promise;
function vibrate(effectId: EffectId, callback?: AsyncCallback): void; | 新增 | +| ohos.sensor | WearDetectionResponse | value: number; | 新增 | +| ohos.sensor | HeartRateResponse | heartRate: number; | 新增 | +| ohos.sensor | BarometerResponse | pressure: number; | 新增 | +| ohos.sensor | AmbientTemperatureResponse | temperature: number; | 新增 | +| ohos.sensor | PedometerDetectionResponse | scalar: number; | 新增 | +| ohos.sensor | HumidityResponse | humidity: number; | 新增 | +| ohos.sensor | PedometerResponse | steps: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | biasZ: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | biasY: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | biasX: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | z: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | y: number; | 新增 | +| ohos.sensor | MagneticFieldUncalibratedResponse | x: number; | 新增 | +| ohos.sensor | MagneticFieldResponse | z: number; | 新增 | +| ohos.sensor | MagneticFieldResponse | y: number; | 新增 | +| ohos.sensor | MagneticFieldResponse | x: number; | 新增 | +| ohos.sensor | HallResponse | status: number; | 新增 | +| ohos.sensor | LightResponse | intensity: number; | 新增 | +| ohos.sensor | ProximityResponse | distance: number; | 新增 | +| ohos.sensor | SignificantMotionResponse | scalar: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | biasZ: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | biasY: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | biasX: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | z: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | y: number; | 新增 | +| ohos.sensor | GyroscopeUncalibratedResponse | x: number; | 新增 | +| ohos.sensor | GyroscopeResponse | z: number; | 新增 | +| ohos.sensor | GyroscopeResponse | y: number; | 新增 | +| ohos.sensor | GyroscopeResponse | x: number; | 新增 | +| ohos.sensor | RotationVectorResponse | w: number; | 新增 | +| ohos.sensor | RotationVectorResponse | z: number; | 新增 | +| ohos.sensor | RotationVectorResponse | y: number; | 新增 | +| ohos.sensor | RotationVectorResponse | x: number; | 新增 | +| ohos.sensor | OrientationResponse | gamma: number; | 新增 | +| ohos.sensor | OrientationResponse | beta: number; | 新增 | +| ohos.sensor | OrientationResponse | alpha: number; | 新增 | +| ohos.sensor | GravityResponse | z: number; | 新增 | +| ohos.sensor | GravityResponse | y: number; | 新增 | +| ohos.sensor | GravityResponse | x: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | biasZ: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | biasY: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | biasX: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | z: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | y: number; | 新增 | +| ohos.sensor | AccelerometerUncalibratedResponse | x: number; | 新增 | +| ohos.sensor | LinearAccelerometerResponse | z: number; | 新增 | +| ohos.sensor | LinearAccelerometerResponse | y: number; | 新增 | +| ohos.sensor | LinearAccelerometerResponse | x: number; | 新增 | +| ohos.sensor | AccelerometerResponse | z: number; | 新增 | +| ohos.sensor | AccelerometerResponse | y: number; | 新增 | +| ohos.sensor | AccelerometerResponse | x: number; | 新增 | +| ohos.sensor | Response | timestamp: number; | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED = 281 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_WEAR_DETECTION = 280 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_HEART_RATE = 278 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_PEDOMETER = 266 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_PEDOMETER_DETECTION = 265 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_SIGNIFICANT_MOTION = 264 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED = 263 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED = 261 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_AMBIENT_TEMPERATURE = 260 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_ROTATION_VECTOR = 259 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_LINEAR_ACCELERATION = 258 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_GRAVITY = 257 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_ORIENTATION = 256 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_HUMIDITY = 13 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_PROXIMITY = 12 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_HALL = 10 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_BAROMETER = 8 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_MAGNETIC_FIELD = 6 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_AMBIENT_LIGHT = 5 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_GYROSCOPE = 2 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_ACCELEROMETER = 1 | 新增 | +| ohos.sensor | Options | interval?: number; | 新增 | +| ohos.sensor | RotationMatrixResponse | inclination: Array | 新增 | +| ohos.sensor | RotationMatrixResponse | rotation: Array; | 新增 | +| ohos.sensor | sensor | function getDirection(rotationMatrix: Array, callback: AsyncCallback>): void;
function getDirection(rotationMatrix: Array): Promise>; | 新增 | +| ohos.sensor | sensor | function createQuaternion(rotationVector: Array, callback: AsyncCallback>): void;
function createQuaternion(rotationVector: Array): Promise>; | 新增 | +| ohos.sensor | sensor | function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions, callback: AsyncCallback>): void;
function transformCoordinateSystem(inRotationVector: Array, coordinates: CoordinatesOptions): Promise>; | 新增 | +| ohos.sensor | CoordinatesOptions | y: number; | 新增 | +| ohos.sensor | CoordinatesOptions | x: number; | 新增 | +| ohos.sensor | sensor | function createRotationMatrix(rotationVector: Array, callback: AsyncCallback>): void;
function createRotationMatrix(rotationVector: Array): Promise>;
function createRotationMatrix(gravity: Array, geomagnetic: Array, callback: AsyncCallback): void;
function createRotationMatrix(gravity: Array, geomagnetic: Array,): Promise; | 新增 | +| ohos.sensor | sensor | function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array, callback: AsyncCallback>): void;
function getAngleModify(currentRotationMatrix: Array, preRotationMatrix: Array): Promise>;| 新增 | +| ohos.sensor | sensor | function getGeomagneticDip(inclinationMatrix: Array, callback: AsyncCallback): void;
function getGeomagneticDip(inclinationMatrix: Array): Promise; | 新增 | +| ohos.sensor | sensor | function getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback): void;
function getAltitude(seaPressure: number, currentPressure: number): Promise; | 新增 | +| ohos.sensor | sensor | function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback): void;
function getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise; | 新增 | +| ohos.sensor | GeomagneticResponse | totalIntensity: number; | 新增 | +| ohos.sensor | GeomagneticResponse | levelIntensity: number; | 新增 | +| ohos.sensor | GeomagneticResponse | deflectionAngle: number; | 新增 | +| ohos.sensor | GeomagneticResponse | geomagneticDip: number; | 新增 | +| ohos.sensor | GeomagneticResponse | z: number; | 新增 | +| ohos.sensor | GeomagneticResponse | y: number; | 新增 | +| ohos.sensor | GeomagneticResponse | x: number; | 新增 | +| ohos.sensor | LocationOptions | altitude: number; | 新增 | +| ohos.sensor | LocationOptions | longitude: number; | 新增 | +| ohos.sensor | LocationOptions | latitude: number; | 新增 | +| ohos.sensor | sensor | function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback): void;
function off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback): void;| 新增 | +| ohos.sensor | sensor | function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback): void;
function once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback): void; | 新增 | +| ohos.sensor | sensor | function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback, options?: Options): void;
function on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback, options?: Options): void; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-settings.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-settings.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..a14266c90a2e4beb5b8108cf450b5f8cdb882d1e 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-settings.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-settings.md @@ -1,14 +1,88 @@ -# xxx子系统JS API变更 +# 应用子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,应用子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.settings | settings | function setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean; | 新增 | +| ohos.settings | settings | function getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string; | 新增 | +| ohos.settings | settings | function getUriSync(name: string): string; | 新增 | +| ohos.settings | settings | function canShowFloating(callback: AsyncCallback): void;
function canShowFloating(): Promise; | 新增 | +| ohos.settings | settings | function enableAirplaneMode(enable: boolean, callback: AsyncCallback): void;
function enableAirplaneMode(enable: boolean): Promise; | 新增 | +| ohos.settings | settings | function getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback): void;
function getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise; | 新增 | +| ohos.settings | settings | function getURI(name: string, callback: AsyncCallback): void;
function getURI(name: string): Promise; | 新增 | +| ohos.settings | wireless | const WIFI_WATCHDOG_STATUS: string | 新增 | +| ohos.settings | wireless | const WIFI_STATUS: string | 新增 | +| ohos.settings | wireless | const WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT: string | 新增 | +| ohos.settings | wireless | const WIFI_DHCP_MAX_RETRY_COUNT: string | 新增 | +| ohos.settings | wireless | const OWNER_LOCKDOWN_WIFI_CFG: string | 新增 | +| ohos.settings | wireless | const WIFI_RADIO: string | 新增 | +| ohos.settings | wireless | const NFC_RADIO: string | 新增 | +| ohos.settings | wireless | const CELL_RADIO: string | 新增 | +| ohos.settings | wireless | const BLUETOOTH_RADIO: string | 新增 | +| ohos.settings | wireless | const BLUETOOTH_STATUS: string | 新增 | +| ohos.settings | wireless | const AIRPLANE_MODE_RADIOS: string | 新增 | +| ohos.settings | wireless | const BLUETOOTH_DISCOVER_TIMEOUT: string | 新增 | +| ohos.settings | wireless | const BLUETOOTH_DISCOVER_ABILITY_STATUS: string | 新增 | +| ohos.settings | TTS | const ENABLED_TTS_PLUGINS: string | 新增 | +| ohos.settings | TTS | const DEFAULT_TTS_SYNTH: string | 新增 | +| ohos.settings | TTS | const DEFAULT_TTS_RATE: string | 新增 | +| ohos.settings | TTS | const DEFAULT_TTS_PITCH: string | 新增 | +| ohos.settings | sound | const HAPTIC_FEEDBACK_STATUS: string | 新增 | +| ohos.settings | sound | const VIBRATE_STATUS: string | 新增 | +| ohos.settings | sound | const SOUND_EFFECTS_STATUS: string | 新增 | +| ohos.settings | sound | const DEFAULT_RINGTONE: string | 新增 | +| ohos.settings | sound | const DEFAULT_NOTIFICATION_SOUND: string | 新增 | +| ohos.settings | sound | const AFFECTED_MUTE_STREAMS: string | 新增 | +| ohos.settings | sound | const AFFECTED_MODE_RINGER_STREAMS: string | 新增 | +| ohos.settings | sound | const DTMF_TONE_WHILE_DIALING: string | 新增 | +| ohos.settings | sound | const DTMF_TONE_TYPE_WHILE_DIALING: string | 新增 | +| ohos.settings | sound | const DEFAULT_ALARM_ALERT: string | 新增 | +| ohos.settings | sound | const VIBRATE_WHILE_RINGING: string | 新增 | +| ohos.settings | phone | const RTT_CALLING_STATUS: string | 新增 | +| ohos.settings | network | const NETWORK_PREFERENCE_USAGE: string | 新增 | +| ohos.settings | network | const HTTP_PROXY_CFG: string | 新增 | +| ohos.settings | network | const DATA_ROAMING_STATUS: string | 新增 | +| ohos.settings | input | const SHOW_PASSWORD_TEXT_INPUT: string | 新增 | +| ohos.settings | input | const AUTO_REPLACE_TEXT_INPUT: string | 新增 | +| ohos.settings | input | const AUTO_PUNCTUATE_TEXT_INPUT: string | 新增 | +| ohos.settings | input | const AUTO_CAPS_TEXT_INPUT: string | 新增 | +| ohos.settings | input | const SELECTOR_VISIBILITY_FOR_INPUT_METHOD: string | 新增 | +| ohos.settings | input | const ACTIVATED_INPUT_METHODS: string | 新增 | +| ohos.settings | input | const ACTIVATED_INPUT_METHOD_SUB_MODE: string | 新增 | +| ohos.settings | input | const DEFAULT_INPUT_METHOD: string | 新增 | +| ohos.settings | general | const TOUCH_EXPLORATION_STATUS: string | 新增 | +| ohos.settings | general | const SKIP_USE_HINTS: string | 新增 | +| ohos.settings | general | const GEOLOCATION_ORIGINS_ALLOWED: string | 新增 | +| ohos.settings | general | const ACTIVATED_ACCESSIBILITY_SERVICES: string | 新增 | +| ohos.settings | general | const ACCESSIBILITY_STATUS: string | 新增 | +| ohos.settings | general | const DEBUG_APP_PACKAGE: string | 新增 | +| ohos.settings | general | const DEBUGGER_WAITING: string | 新增 | +| ohos.settings | general | const USB_STORAGE_STATUS: string | 新增 | +| ohos.settings | general | const DEVICE_NAME: string | 新增 | +| ohos.settings | general | const DEVELOPMENT_SETTINGS_STATUS: string | 新增 | +| ohos.settings | general | const CONTACT_METADATA_SYNC_STATUS: string | 新增 | +| ohos.settings | general | const BOOT_COUNTING: string | 新增 | +| ohos.settings | general | const HDC_STATUS: string | 新增 | +| ohos.settings | general | const DEVICE_PROVISION_STATUS: string | 新增 | +| ohos.settings | general | const AIRPLANE_MODE_STATUS: string | 新增 | +| ohos.settings | general | const ACCELEROMETER_ROTATION_STATUS: string | 新增 | +| ohos.settings | general | const END_BUTTON_ACTION: string | 新增 | +| ohos.settings | general | const SETUP_WIZARD_FINISHED: string | 新增 | +| ohos.settings | display | const DISPLAY_INVERSION_STATUS: string | 新增 | +| ohos.settings | display | const WINDOW_ANIMATION_SCALE: string | 新增 | +| ohos.settings | display | const TRANSITION_ANIMATION_SCALE: string | 新增 | +| ohos.settings | display | const ANIMATOR_DURATION_SCALE: string | 新增 | +| ohos.settings | display | const DEFAULT_SCREEN_ROTATION: string | 新增 | +| ohos.settings | display | const SCREEN_OFF_TIMEOUT: string | 新增 | +| ohos.settings | display | const MANUAL_SCREEN_BRIGHTNESS_MODE: number | 新增 | +| ohos.settings | display | const AUTO_SCREEN_BRIGHTNESS_MODE: number | 新增 | +| ohos.settings | display | const AUTO_SCREEN_BRIGHTNESS: string | 新增 | +| ohos.settings | display | const SCREEN_BRIGHTNESS_STATUS: string | 新增 | +| ohos.settings | display | const FONT_SCALE: string | 新增 | +| ohos.settings | date | const AUTO_GAIN_TIME_ZONE: string | 新增 | +| ohos.settings | date | const AUTO_GAIN_TIME: string | 新增 | +| ohos.settings | date | const TIME_FORMAT: string | 新增 | +| ohos.settings | date | const DATE_FORMAT: string | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-soft-bus.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-soft-bus.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..1400f329e320b00311e490cbfbfbc0379a5c0d2e 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-soft-bus.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-soft-bus.md @@ -1,14 +1,43 @@ -# xxx子系统JS API变更 +# 分布式软总线子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,分布式软总线子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.rpc | Ashmem | readFromAshmem(size: number, offset: number): number[]; | 新增 | +| ohos.rpc | Ashmem | writeToAshmem(buf: number[], size: number, offset: number): boolean; | 新增 | +| ohos.rpc | Ashmem | setProtection(protectionType: number): boolean; | 新增 | +| ohos.rpc | Ashmem | mapReadOnlyAshmem(): boolean; | 新增 | +| ohos.rpc | Ashmem | mapReadAndWriteAshmem(): boolean; | 新增 | +| ohos.rpc | Ashmem | mapAshmem(mapType: number): boolean; | 新增 | +| ohos.rpc | Ashmem | getAshmemSize(): number; | 新增 | +| ohos.rpc | Ashmem | unmapAshmem(): void; | 新增 | +| ohos.rpc | Ashmem | closeAshmem(): void; | 新增 | +| ohos.rpc | Ashmem | static createAshmemFromExisting(ashmem: Ashmem): Ashmem; | 新增 | +| ohos.rpc | Ashmem | static createAshmem(name: string, size: number): Ashmem; | 新增 | +| ohos.rpc | Ashmem | PROT_WRITE = 2; | 新增 | +| ohos.rpc | Ashmem | PROT_READ = 1; | 新增 | +| ohos.rpc | Ashmem | PROT_NONE = 0; | 新增 | +| ohos.rpc | Ashmem | PROT_EXEC = 4; | 新增 | +| ohos.rpc | IPCSkeleton | static getCallingTokenId(): number; | 新增 | +| ohos.rpc | SendRequestResult | reply: MessageParcel; | 新增 | +| ohos.rpc | SendRequestResult | data: MessageParcel; | 新增 | +| ohos.rpc | SendRequestResult | code: number; | 新增 | +| ohos.rpc | SendRequestResult | errCode: number; | 新增 | +| ohos.rpc | MessageParcel | readRawData(size: number): number[]; | 新增 | +| ohos.rpc | MessageParcel | writeRawData(rawData: number[], size: number): boolean; | 新增 | +| ohos.rpc | MessageParcel | getRawDataCapacity(): number; | 新增 | +| ohos.rpc | MessageParcel | readAshmem(): Ashmem; | 新增 | +| ohos.rpc | MessageParcel | writeAshmem(ashmem: Ashmem): boolean; | 新增 | +| ohos.rpc | MessageParcel | readFileDescriptor(): number; | 新增 | +| ohos.rpc | MessageParcel | writeFileDescriptor(fd: number): boolean; | 新增 | +| ohos.rpc | MessageParcel | containFileDescriptors(): boolean; | 新增 | +| ohos.rpc | MessageParcel | static dupFileDescriptor(fd: number) :number; | 新增 | +| ohos.rpc | MessageParcel | static closeFileDescriptor(fd: number): void; | 新增 | +| ohos.rpc | MessageParcel | readRemoteObjectArray(objects: IRemoteObject[]): void;
readRemoteObjectArray(): IRemoteObject[]; | 新增 | +| ohos.rpc | MessageParcel | readSequenceableArray(sequenceableArray: Sequenceable[]): void; | 新增 | +| ohos.rpc | MessageParcel | writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean; | 新增 | +| ohos.rpc | MessageParcel | readException(): void; | 新增 | +| ohos.rpc | MessageParcel | writeNoException(): void; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-telephony.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-telephony.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..7e206375dc20eaef97801219064ac480e2aeb5db 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-telephony.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-telephony.md @@ -1,14 +1,230 @@ -# xxx子系统JS API变更 +# 电话服务子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,电话服务子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.telephony.sms | sms | function hasSmsCapability(): boolean; | 新增 | +| ohos.telephony.sim | CardType | SINGLE_MODE_ISIM_CARD = 60 | 新增 | +| ohos.telephony.sim | CardType | DUAL_MODE_UG_CARD = 50 | 新增 | +| ohos.telephony.sim | CardType | DUAL_MODE_TELECOM_LTE_CARD = 43 | 新增 | +| ohos.telephony.sim | CardType | CU_DUAL_MODE_CARD = 42 | 新增 | +| ohos.telephony.sim | CardType | CT_NATIONAL_ROAMING_CARD = 41 | 新增 | +| ohos.telephony.sim | CardType | DUAL_MODE_CG_CARD = 40 | 新增 | +| ohos.telephony.sim | CardType | SINGLE_MODE_RUIM_CARD = 30 | 新增 | +| ohos.telephony.sim | CardType | SINGLE_MODE_USIM_CARD = 20 | 新增 | +| ohos.telephony.sim | CardType | SINGLE_MODE_SIM_CARD = 10 | 新增 | +| ohos.telephony.sim | CardType | UNKNOWN_CARD = -1 | 新增 | +| ohos.telephony.sim | sim | function hasSimCard(slotId: number, callback: AsyncCallback): void;
function hasSimCard(slotId: number): Promise; | 新增 | +| ohos.telephony.sim | sim | function getMaxSimCount(): number; | 新增 | +| ohos.telephony.sim | sim | function getCardType(slotId: number, callback: AsyncCallback): void;
function getCardType(slotId: number): Promise; | 新增 | +| ohos.telephony.sim | sim | function hasOperatorPrivileges(slotId: number, callback: AsyncCallback): void;
function hasOperatorPrivileges(slotId: number): Promise; | 新增 | +| ohos.telephony.sim | sim | function isSimActive(slotId: number, callback: AsyncCallback): void;
function isSimActive(slotId: number): Promise; | 新增 | +| ohos.telephony.radio | NetworkState | cfgTech: RadioTechnology; | 新增 | +| ohos.telephony.radio | radio | function getOperatorName(slotId: number, callback: AsyncCallback): void;
function getOperatorName(slotId: number): Promise; | 新增 | +| ohos.telephony.radio | radio | function isNrSupported(): boolean;
function isNrSupported(slotId: number): boolean; | 新增 | +| ohos.telephony.radio | radio | function getPrimarySlotId(callback: AsyncCallback): void;
function getPrimarySlotId(): Promise; | 新增 | +| ohos.telephony.observer | LockReason | SIM_SIM_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_SIM_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_PC_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_PC_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_PP_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_PP_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_PU_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_PU_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_PN_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_PN_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_PUK | 新增 | +| ohos.telephony.observer | LockReason | SIM_PIN | 新增 | +| ohos.telephony.observer | LockReason | SIM_NONE | 新增 | +| ohos.telephony.observer | SimStateData | reason: LockReason; | 新增 | +| ohos.telephony.observer | SimStateData | state: SimState; | 新增 | +| ohos.telephony.observer | SimStateData | type: CardType; | 新增 | +| ohos.telephony.observer | observer | function off(type: 'simStateChange', callback?: Callback): void; | 新增 | +| ohos.telephony.observer | observer | function on(type: 'simStateChange', callback: Callback): void;
function on(type: 'simStateChange', options: { slotId: number }, callback: Callback): void; | 新增 | +| ohos.telephony.observer | observer | function off(type: 'cellularDataFlowChange', callback?: Callback): void; | 新增 | +| ohos.telephony.observer | observer | function on(type: 'cellularDataFlowChange', callback: Callback): void;
function on(type: 'cellularDataFlowChange', options: { slotId: number },callback: Callback): void;| 新增 | +| ohos.telephony.observer | observer | function off(type: 'cellularDataConnectionStateChange',callback?: Callback<{ state: DataConnectState, network: RatType }>): void;| 新增 | +| ohos.telephony.observer | observer | function on(type: 'cellularDataConnectionStateChange', callback: Callback<{ state: DataConnectState, network: RatType }>): void;
function on(type: 'cellularDataConnectionStateChange', options: { slotId: number }, callback: Callback<{ state: DataConnectState, network: RatType }>): void; | 新增 | +| ohos.telephony.data | DataConnectState | DATA_STATE_SUSPENDED = 3 | 新增 | +| ohos.telephony.data | DataConnectState | DATA_STATE_CONNECTED = 2 | 新增 | +| ohos.telephony.data | DataConnectState | DATA_STATE_CONNECTING = 1 | 新增 | +| ohos.telephony.data | DataConnectState | DATA_STATE_DISCONNECTED = 0 | 新增 | +| ohos.telephony.data | DataConnectState | DATA_STATE_UNKNOWN = -1 | 新增 | +| ohos.telephony.data | DataFlowType | DATA_FLOW_TYPE_DORMANT = 4 | 新增 | +| ohos.telephony.data | DataFlowType | DATA_FLOW_TYPE_UP_DOWN = 3 | 新增 | +| ohos.telephony.data | DataFlowType | DATA_FLOW_TYPE_UP = 2 | 新增 | +| ohos.telephony.data | DataFlowType | DATA_FLOW_TYPE_DOWN = 1 | 新增 | +| ohos.telephony.data | DataFlowType | DATA_FLOW_TYPE_NONE = 0 | 新增 | +| ohos.telephony.data | data | function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback): void;
function isCellularDataRoamingEnabled(slotId: number): Promise; | 新增 | +| ohos.telephony.data | data | function isCellularDataEnabled(callback: AsyncCallback): void;
function isCellularDataEnabled(): Promise; | 新增 | +| ohos.telephony.data | data | function getCellularDataState(callback: AsyncCallback): void;
function getCellularDataState(): Promise; | 新增 | +| ohos.telephony.data | data | function getCellularDataFlowType(callback: AsyncCallback): void;
function getCellularDataFlowType(): Promise; | 新增 | +| ohos.telephony.data | data | function getDefaultCellularDataSlotId(callback: AsyncCallback): void;
function getDefaultCellularDataSlotId(): Promise; | 新增 | +| ohos.telephony.call | call | function hasVoiceCapability(): boolean; | 新增 | +| ohos.telephony.call | call | function makeCall(phoneNumber: string, callback: AsyncCallback): void;
function makeCall(phoneNumber: string): Promise; | 新增 | +| ohos.contact | Website | website: string | 新增 | +| ohos.contact | SipAddress | labelId: number | 新增 | +| ohos.contact | SipAddress | sipAddress: string | 新增 | +| ohos.contact | SipAddress | labelName: string | 新增 | +| ohos.contact | SipAddress | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | SipAddress | static readonly SIP_OTHER: 3 | 新增 | +| ohos.contact | SipAddress | static readonly SIP_WORK: 2 | 新增 | +| ohos.contact | SipAddress | static readonly SIP_HOME: 1 | 新增 | +| ohos.contact | SipAddress | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | Relation | labelId: number | 新增 | +| ohos.contact | Relation | relationName: string | 新增 | +| ohos.contact | Relation | labelName: string | 新增 | +| ohos.contact | Relation | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | Relation | static readonly RELATION_SPOUSE: 14 | 新增 | +| ohos.contact | Relation | static readonly RELATION_SISTER: 13 | 新增 | +| ohos.contact | Relation | static readonly RELATION_RELATIVE: 12 | 新增 | +| ohos.contact | Relation | static readonly RELATION_REFERRED_BY: 11 | 新增 | +| ohos.contact | Relation | static readonly RELATION_PARTNER: 10 | 新增 | +| ohos.contact | Relation | static readonly RELATION_PARENT: 9 | 新增 | +| ohos.contact | Relation | static readonly RELATION_MOTHER: 8 | 新增 | +| ohos.contact | Relation | static readonly RELATION_MANAGER: 7 | 新增 | +| ohos.contact | Relation | static readonly RELATION_FRIEND: 6 | 新增 | +| ohos.contact | Relation | static readonly RELATION_FATHER: 5 | 新增 | +| ohos.contact | Relation | static readonly RELATION_DOMESTIC_PARTNER: 4 | 新增 | +| ohos.contact | Relation | static readonly RELATION_CHILD: 3 | 新增 | +| ohos.contact | Relation | static readonly RELATION_BROTHER: 2 | 新增 | +| ohos.contact | Relation | static readonly RELATION_ASSISTANT: 1 | 新增 | +| ohos.contact | Relation | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | PostalAddress | labelId: number | 新增 | +| ohos.contact | PostalAddress | street: string | 新增 | +| ohos.contact | PostalAddress | region: string | 新增 | +| ohos.contact | PostalAddress | postcode: string | 新增 | +| ohos.contact | PostalAddress | postalAddress: string | 新增 | +| ohos.contact | PostalAddress | pobox: string | 新增 | +| ohos.contact | PostalAddress | neighborhood: string | 新增 | +| ohos.contact | PostalAddress | labelName: string | 新增 | +| ohos.contact | PostalAddress | country: string | 新增 | +| ohos.contact | PostalAddress | city: string | 新增 | +| ohos.contact | PostalAddress | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | PostalAddress | static readonly ADDR_OTHER: 3 | 新增 | +| ohos.contact | PostalAddress | static readonly ADDR_WORK: 2 | 新增 | +| ohos.contact | PostalAddress | static readonly ADDR_HOME: 1 | 新增 | +| ohos.contact | PostalAddress | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | Portrait | uri: string | 新增 | +| ohos.contact | PhoneNumber | labelId: number | 新增 | +| ohos.contact | PhoneNumber | phoneNumber: string | 新增 | +| ohos.contact | PhoneNumber | labelName: string | 新增 | +| ohos.contact | PhoneNumber | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_MMS: 20 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_ASSISTANT: 19 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_WORK_PAGER: 18 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_WORK_MOBILE: 17 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_TTY_TDD: 16 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_TELEX: 15 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_RADIO: 14 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_OTHER_FAX: 13 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_MAIN: 12 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_ISDN: 11 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_COMPANY_MAIN: 10 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_CAR: 9 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_CALLBACK: 8 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_OTHER: 7 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_PAGER: 6 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_FAX_HOME: 5 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_FAX_WORK: 4 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_WORK: 3 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_MOBILE: 2 | 新增 | +| ohos.contact | PhoneNumber | static readonly NUM_HOME: 1 | 新增 | +| ohos.contact | PhoneNumber | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | Organization | title: string | 新增 | +| ohos.contact | Organization | name: string | 新增 | +| ohos.contact | Note | noteContent: string | 新增 | +| ohos.contact | NickName | nickName: string | 新增 | +| ohos.contact | Name | nameSuffix: string | 新增 | +| ohos.contact | Name | namePrefix: string | 新增 | +| ohos.contact | Name | middleNamePhonetic: string | 新增 | +| ohos.contact | Name | middleName: string | 新增 | +| ohos.contact | Name | givenNamePhonetic: string | 新增 | +| ohos.contact | Name | givenName: string | 新增 | +| ohos.contact | Name | fullName: string | 新增 | +| ohos.contact | Name | familyNamePhonetic: string | 新增 | +| ohos.contact | Name | familyName: string | 新增 | +| ohos.contact | ImAddress | labelId: number | 新增 | +| ohos.contact | ImAddress | labelName: string | 新增 | +| ohos.contact | ImAddress | imAddress: string | 新增 | +| ohos.contact | ImAddress | static readonly INVALID_LABEL_ID: -2 | 新增 | +| ohos.contact | ImAddress | static readonly IM_JABBER: 7 | 新增 | +| ohos.contact | ImAddress | static readonly IM_ICQ: 6 | 新增 | +| ohos.contact | ImAddress | static readonly IM_QQ: 4 | 新增 | +| ohos.contact | ImAddress | static readonly IM_SKYPE: 3 | 新增 | +| ohos.contact | ImAddress | static readonly IM_YAHOO: 2 | 新增 | +| ohos.contact | ImAddress | static readonly IM_MSN: 1 | 新增 | +| ohos.contact | ImAddress | static readonly IM_AIM: 0 | 新增 | +| ohos.contact | ImAddress | static readonly CUSTOM_LABEL: -1 | 新增 | +| ohos.contact | Holder | holderId: number | 新增 | +| ohos.contact | Holder | readonly displayName: string | 新增 | +| ohos.contact | Holder | readonly bundleName: string | 新增 | +| ohos.contact | Group | title: string | 新增 | +| ohos.contact | Group | groupId: number | 新增 | +| ohos.contact | Event | labelId: number | 新增 | +| ohos.contact | Event | labelName: string | 新增 | +| ohos.contact | Event | eventDate: string | 新增 | +| ohos.contact | Event | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | Event | static readonly EVENT_BIRTHDAY: 3 | 新增 | +| ohos.contact | Event | static readonly EVENT_OTHER: 2 | 新增 | +| ohos.contact | Event | static readonly EVENT_ANNIVERSARY: 1 | 新增 | +| ohos.contact | Event | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | Email | labelId: number | 新增 | +| ohos.contact | Email | displayName: string | 新增 | +| ohos.contact | Email | labelName: string | 新增 | +| ohos.contact | Email | email: string | 新增 | +| ohos.contact | Email | static readonly INVALID_LABEL_ID: -1 | 新增 | +| ohos.contact | Email | static readonly EMAIL_OTHER: 3 | 新增 | +| ohos.contact | Email | static readonly EMAIL_WORK: 2 | 新增 | +| ohos.contact | Email | static readonly EMAIL_HOME: 1 | 新增 | +| ohos.contact | Email | static readonly CUSTOM_LABEL: 0 | 新增 | +| ohos.contact | Attribute | ATTR_WEBSITE | 新增 | +| ohos.contact | Attribute | ATTR_SIP_ADDRESS | 新增 | +| ohos.contact | Attribute | ATTR_RELATION | 新增 | +| ohos.contact | Attribute | ATTR_POSTAL_ADDRESS | 新增 | +| ohos.contact | Attribute | ATTR_PORTRAIT | 新增 | +| ohos.contact | Attribute | ATTR_PHONE | 新增 | +| ohos.contact | Attribute | ATTR_ORGANIZATION | 新增 | +| ohos.contact | Attribute | ATTR_NOTE | 新增 | +| ohos.contact | Attribute | ATTR_NICKNAME | 新增 | +| ohos.contact | Attribute | ATTR_NAME | 新增 | +| ohos.contact | Attribute | ATTR_IM | 新增 | +| ohos.contact | Attribute | ATTR_GROUP_MEMBERSHIP | 新增 | +| ohos.contact | Attribute | ATTR_EMAIL | 新增 | +| ohos.contact | Attribute | ATTR_CONTACT_EVENT | 新增 | +| ohos.contact | ContactAttributes | attributes: Attribute[] | 新增 | +| ohos.contact | Contact | organization: Organization | 新增 | +| ohos.contact | Contact | note: Note | 新增 | +| ohos.contact | Contact | nickName: NickName | 新增 | +| ohos.contact | Contact | name: Name | 新增 | +| ohos.contact | Contact | websites: Website[] | 新增 | +| ohos.contact | Contact | sipAddresses: SipAddress[] | 新增 | +| ohos.contact | Contact | relations: Relation[] | 新增 | +| ohos.contact | Contact | postalAddresses: PostalAddress[] | 新增 | +| ohos.contact | Contact | portrait: Portrait | 新增 | +| ohos.contact | Contact | phoneNumbers: PhoneNumber[] | 新增 | +| ohos.contact | Contact | imAddresses: ImAddress[] | 新增 | +| ohos.contact | Contact | groups: Group[] | 新增 | +| ohos.contact | Contact | events: Event[] | 新增 | +| ohos.contact | Contact | emails: Email[] | 新增 | +| ohos.contact | Contact | contactAttributes: ContactAttributes | 新增 | +| ohos.contact | Contact | readonly key: string | 新增 | +| ohos.contact | Contact | readonly id: number | 新增 | +| ohos.contact | Contact | static readonly INVALID_CONTACT_ID: -1 | 新增 | +| ohos.contact | contact | function isMyCard(id: number, callback: AsyncCallback): void;
function isMyCard(id: number): Promise; | 新增 | +| ohos.contact | contact | function isLocalContact(id: number, callback: AsyncCallback): void;
function isLocalContact(id: number): Promise; | 新增 | +| ohos.contact | contact | function updateContact(contact: Contact, callback: AsyncCallback): void;
function updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallback): void;
function updateContact(contact: Contact, attrs?: ContactAttributes): Promise; | 新增 | +| ohos.contact | contact | function queryMyCard(callback: AsyncCallback): void;
function queryMyCard(attrs: ContactAttributes, callback: AsyncCallback): void;
function queryMyCard(attrs?: ContactAttributes): Promise; | 新增 | +| ohos.contact | contact | function queryKey(id: number, callback: AsyncCallback): void;
function queryKey(id: number, holder: Holder, callback: AsyncCallback): void;
function queryKey(id: number, holder?: Holder): Promise; | 新增 | +| ohos.contact | contact | function queryHolders(callback: AsyncCallback>): void;
function queryHolders(): Promise>; | 新增 | +| ohos.contact | contact | function queryGroups(callback: AsyncCallback>): void;
function queryGroups(holder: Holder, callback: AsyncCallback>): void;
function queryGroups(holder?: Holder): Promise>; | 新增 | +| ohos.contact | contact | function queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback>): void;
function queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncCallback>): void;
function queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContactsByPhoneNumber(phoneNumber: string, holder?: Holder, attrs?: ContactAttributes): Promise>; | 新增 | +| ohos.contact | contact | function queryContactsByEmail(email: string, callback: AsyncCallback>): void;
function queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback>): void;
function queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContactsByEmail(email: string, holder?: Holder, attrs?: ContactAttributes): Promise>; | 新增 | +| ohos.contact | contact | function queryContacts(callback: AsyncCallback>): void;
function queryContacts(holder: Holder, callback: AsyncCallback>): void;
function queryContacts(attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback>): void;
function queryContacts(holder?: Holder, attrs?: ContactAttributes): Promise>; | 新增 | +| ohos.contact | contact | function queryContact(key: string, callback: AsyncCallback): void;
function queryContact(key: string, holder: Holder, callback: AsyncCallback): void;
function queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback): void;
function queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback): void;
function queryContact(key: string, holder?: Holder, attrs?: ContactAttributes): Promise; | 新增 | +| ohos.contact | contact | function deleteContact(key: string, callback: AsyncCallback): void;
function deleteContact(key: string): Promise; | 新增 | +| ohos.contact | contact | function selectContact(callback: AsyncCallback>): void;
function selectContact(): Promise>; | 新增 | +| ohos.contact | contact | function addContact(contact: Contact, callback: AsyncCallback): void;
function addContact(contact: Contact): Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-unitest.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-unitest.md new file mode 100644 index 0000000000000000000000000000000000000000..8f52e684d282cb6551b69566a3d09af57f2c3286 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-unitest.md @@ -0,0 +1,49 @@ +# 测试框架子系统JS API变更 + +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,测试框架子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.uitest | UiDriver | screenCap(savePath:string):Promise; | 新增 | +| ohos.uitest | UiDriver | swipe(startx:number,starty:number,endx:number,endy:number):Promise; | 新增 | +| ohos.uitest | UiDriver | longClick(x:number,y:number):Promise; | 新增 | +| ohos.uitest | UiDriver | doubleClick(x:number,y:number):Promise; | 新增 | +| ohos.uitest | UiDriver | click(x:number,y:number):Promise; | 新增 | +| ohos.uitest | UiDriver | triggerKey(keyCode:number):Promise; | 新增 | +| ohos.uitest | UiDriver | pressBack():Promise; | 新增 | +| ohos.uitest | UiDriver | assertComponentExist(by:By):Promise; | 新增 | +| ohos.uitest | UiDriver | findComponents(by:By):Promise>; | 新增 | +| ohos.uitest | UiDriver | findComponent(by:By):Promise; | 新增 | +| ohos.uitest | UiDriver | delayMs(duration:number):Promise; | 新增 | +| ohos.uitest | UiDriver | static create():UiDriver; | 新增 | +| ohos.uitest | UiComponent | scrollSearch(by:By):Promise; | 新增 | +| ohos.uitest | UiComponent | inputText(text: string):Promise; | 新增 | +| ohos.uitest | UiComponent | isSelected():Promise; | 新增 | +| ohos.uitest | UiComponent | isFocused():Promise; | 新增 | +| ohos.uitest | UiComponent | isEnabled():Promise; | 新增 | +| ohos.uitest | UiComponent | isScrollable():Promise; | 新增 | +| ohos.uitest | UiComponent | isClickable():Promise; | 新增 | +| ohos.uitest | UiComponent | getType():Promise; | 新增 | +| ohos.uitest | UiComponent | getText():Promise; | 新增 | +| ohos.uitest | UiComponent | getKey():Promise; | 新增 | +| ohos.uitest | UiComponent | getId():Promise; | 新增 | +| ohos.uitest | UiComponent | longClick():Promise; | 新增 | +| ohos.uitest | UiComponent | doubleClick():Promise; | 新增 | +| ohos.uitest | UiComponent | click():Promise; | 新增 | +| ohos.uitest | By | isAfter(by:By):By; | 新增 | +| ohos.uitest | By | isBefore(by:By):By; | 新增 | +| ohos.uitest | By | selected(b?:bool):By; | 新增 | +| ohos.uitest | By | focused(b?:bool):By; | 新增 | +| ohos.uitest | By | enabled(b?:bool):By; | 新增 | +| ohos.uitest | By | scrollable(b?:bool):By; | 新增 | +| ohos.uitest | By | clickable(b?:bool):By; | 新增 | +| ohos.uitest | By | type(tp:string):By; | 新增 | +| ohos.uitest | By | id(id:number):By; | 新增 | +| ohos.uitest | By | key(key:string):By; | 新增 | +| ohos.uitest | By | text(txt:string,pattern?:MatchPattern):By; | 新增 | +| ohos.uitest | MatchPattern | ENDS_WITH = 3 | 新增 | +| ohos.uitest | MatchPattern | STARTS_WITH = 2 | 新增 | +| ohos.uitest | MatchPattern | CONTAINS = 1 | 新增 | +| ohos.uitest | MatchPattern | EQUALS = 0 | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-update.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-update.md deleted file mode 100644 index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-update.md +++ /dev/null @@ -1,14 +0,0 @@ -# xxx子系统JS API变更 - -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: - -## 接口变更 - -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-usb.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-usb.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..b10c55c50ac76ca3a3cd815c20562c945988ed12 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-usb.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-usb.md @@ -1,14 +1,73 @@ -# xxx子系统JS API变更 +# USB服务子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,USB服务子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.usb | USBRequestDirection | USB_REQUEST_DIR_FROM_DEVICE = 0x80 | 新增 | +| ohos.usb | USBRequestDirection | USB_REQUEST_DIR_TO_DEVICE = 0 | 新增 | +| ohos.usb | USBControlRequestType | USB_REQUEST_TYPE_VENDOR | 新增 | +| ohos.usb | USBControlRequestType | USB_REQUEST_TYPE_CLASS | 新增 | +| ohos.usb | USBControlRequestType | USB_REQUEST_TYPE_STANDARD = 0 | 新增 | +| ohos.usb | USBRequestTargetType | USB_REQUEST_TARGET_OTHER | 新增 | +| ohos.usb | USBRequestTargetType | USB_REQUEST_TARGET_ENDPOINT | 新增 | +| ohos.usb | USBRequestTargetType | USB_REQUEST_TARGET_INTERFACE | 新增 | +| ohos.usb | USBRequestTargetType | USB_REQUEST_TARGET_DEVICE = 0 | 新增 | +| ohos.usb | USBControlParams | data: Uint8Array; | 新增 | +| ohos.usb | USBControlParams | index: number; | 新增 | +| ohos.usb | USBControlParams | value: number; | 新增 | +| ohos.usb | USBControlParams | reqType: USBControlRequestType; | 新增 | +| ohos.usb | USBControlParams | target: USBRequestTargetType; | 新增 | +| ohos.usb | USBControlParams | request: number; | 新增 | +| ohos.usb | USBDevicePipe | devAddress: number; | 新增 | +| ohos.usb | USBDevicePipe | busNum: number; | 新增 | +| ohos.usb | USBDevice | configs: Array; | 新增 | +| ohos.usb | USBDevice | protocol: number; | 新增 | +| ohos.usb | USBDevice | subClass: number; | 新增 | +| ohos.usb | USBDevice | clazz: number; | 新增 | +| ohos.usb | USBDevice | productId: number; | 新增 | +| ohos.usb | USBDevice | vendorId: number; | 新增 | +| ohos.usb | USBDevice | version: string; | 新增 | +| ohos.usb | USBDevice | productName: string; | 新增 | +| ohos.usb | USBDevice | manufacturerName: string; | 新增 | +| ohos.usb | USBDevice | name: string; | 新增 | +| ohos.usb | USBDevice | serial: string; | 新增 | +| ohos.usb | USBDevice | devAddress: number; | 新增 | +| ohos.usb | USBDevice | busNum: number; | 新增 | +| ohos.usb | USBConfig | interfaces: Array; | 新增 | +| ohos.usb | USBConfig | isSelfPowered: boolean; | 新增 | +| ohos.usb | USBConfig | isRemoteWakeup: boolean; | 新增 | +| ohos.usb | USBConfig | name: string; | 新增 | +| ohos.usb | USBConfig | maxPower: number; | 新增 | +| ohos.usb | USBConfig | attributes: number; | 新增 | +| ohos.usb | USBConfig | id: number; | 新增 | +| ohos.usb | USBInterface | endpoints: Array; | 新增 | +| ohos.usb | USBInterface | name: string; | 新增 | +| ohos.usb | USBInterface | alternateSetting: number; | 新增 | +| ohos.usb | USBInterface | subClass: number; | 新增 | +| ohos.usb | USBInterface | clazz: number; | 新增 | +| ohos.usb | USBInterface | protocol: number; | 新增 | +| ohos.usb | USBInterface | id: number; | 新增 | +| ohos.usb | USBEndpoint | interfaceId: number; | 新增 | +| ohos.usb | USBEndpoint | type: number; | 新增 | +| ohos.usb | USBEndpoint | number: number; | 新增 | +| ohos.usb | USBEndpoint | direction: USBRequestDirection; | 新增 | +| ohos.usb | USBEndpoint | maxPacketSize: number; | 新增 | +| ohos.usb | USBEndpoint | interval: number; | 新增 | +| ohos.usb | USBEndpoint | attributes: number; | 新增 | +| ohos.usb | USBEndpoint | address: number; | 新增 | +| ohos.usb | usb | function closePipe(pipe: USBDevicePipe): number; | 新增 | +| ohos.usb | usb | function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array,timeout?: number): Promise; | 新增 | +| ohos.usb | usb | function controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise; | 新增 | +| ohos.usb | usb | function getFileDescriptor(pipe: USBDevicePipe): number; | 新增 | +| ohos.usb | usb | function getRawDescriptor(pipe: USBDevicePipe): Uint8Array; | 新增 | +| ohos.usb | usb | function setInterface(pipe: USBDevicePipe, iface: USBInterface): number; | 新增 | +| ohos.usb | usb | function setConfiguration(pipe: USBDevicePipe, config: USBConfig): number; | 新增 | +| ohos.usb | usb | function releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number; | 新增 | +| ohos.usb | usb | function claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number; | 新增 | +| ohos.usb | usb | function requestRight(deviceName: string): Promise; | 新增 | +| ohos.usb | usb | function hasRight(deviceName: string): boolean; | 新增 | +| ohos.usb | usb | function connectDevice(device: USBDevice): Readonly; | 新增 | +| ohos.usb | usb | function getDevices(): Array>; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..0d349c07d0ae6f4008c80643eff0cc9f5ad7445c 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md @@ -1,14 +1,65 @@ -# xxx子系统JS API变更 +# 用户身份认证子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,用户身份认证子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.userIAM.userAuth | AuthTrustLevel | ATL4 = 40000 | 新增 | +| ohos.userIAM.userAuth | AuthTrustLevel | ATL3 = 30000 | 新增 | +| ohos.userIAM.userAuth | AuthTrustLevel | ATL2 = 20000 | 新增 | +| ohos.userIAM.userAuth | AuthTrustLevel | ATL1 = 10000 | 新增 | +| ohos.userIAM.userAuth | UserAuthType | FINGERPRINT = 4 | 新增 | +| ohos.userIAM.userAuth | UserAuthType | FACE = 2 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_TOO_SLOW = 5 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_TOO_FAST = 4 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_PARTIAL = 3 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_INSUFFICIENT = 2 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_DIRTY = 1 | 新增 | +| ohos.userIAM.userAuth | FingerprintTips | FINGERPRINT_AUTH_TIP_GOOD = 0 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_NOT_DETECTED = 11 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_POOR_GAZE = 10 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_MUCH_MOTION = 9 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_LEFT = 8 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_RIGHT = 7 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_LOW = 6 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_HIGH = 5 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_FAR = 4 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_CLOSE = 3 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_DARK = 2 | 新增 | +| ohos.userIAM.userAuth | FaceTips | FACE_AUTH_TIP_TOO_BRIGHT = 1 | 新增 | +| ohos.userIAM.userAuth | ResultCode | NOT_ENROLLED = 10 | 新增 | +| ohos.userIAM.userAuth | ResultCode | LOCKED = 9 | 新增 | +| ohos.userIAM.userAuth | ResultCode | INVALID_PARAMETERS = 8 | 新增 | +| ohos.userIAM.userAuth | ResultCode | BUSY = 7 | 新增 | +| ohos.userIAM.userAuth | ResultCode | TRUST_LEVEL_NOT_SUPPORT = 6 | 新增 | +| ohos.userIAM.userAuth | ResultCode | TYPE_NOT_SUPPORT = 5 | 新增 | +| ohos.userIAM.userAuth | ResultCode | TIMEOUT = 4 | 新增 | +| ohos.userIAM.userAuth | ResultCode | CANCELED = 3 | 新增 | +| ohos.userIAM.userAuth | ResultCode | GENERAL_ERROR = 2 | 新增 | +| ohos.userIAM.userAuth | ResultCode | FAIL = 1 | 新增 | +| ohos.userIAM.userAuth | ResultCode | SUCCESS = 0 | 新增 | +| ohos.userIAM.userAuth | AuthResult | freezingTime ?: number; | 新增 | +| ohos.userIAM.userAuth | AuthResult | remainTimes ?: number; | 新增 | +| ohos.userIAM.userAuth | AuthResult | token ?: Uint8Array; | 新增 | +| ohos.userIAM.userAuth | IUserAuthCallback | onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void; | 新增 | +| ohos.userIAM.userAuth | IUserAuthCallback | onResult: (result : number, extraInfo : AuthResult) => void; | 新增 | +| ohos.userIAM.userAuth | UserAuth | cancelAuth(contextID : Uint8Array) : number; | 新增 | +| ohos.userIAM.userAuth | UserAuth | auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; | 新增 | +| ohos.userIAM.userAuth | UserAuth | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number; | 新增 | +| ohos.userIAM.userAuth | UserAuth | getVersion() : number; | 新增 | +| ohos.userIAM.userAuth | UserAuth | constructor(); | 新增 | +| ohos.userIAM.userAuth | userAuth | function getAuthenticator(): Authenticator; | 新增 | +| ohos.userIAM.userAuth | Authenticator | execute(type: AuthType, level: SecureLevel, callback: AsyncCallback): void;
execute(type: AuthType, level: SecureLevel): Promise; | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | GENERAL_ERROR = 100 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | NOT_ENROLLED = 8 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | LOCKED = 7 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | INVALID_PARAMETERS = 6 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | BUSY = 5 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | CAMERA_FAIL = 4 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | TIMEOUT = 3 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | CANCELED = 2 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | COMPARE_FAILURE = 1 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | SUCCESS = 0 | 新增 | +| ohos.userIAM.userAuth | AuthenticationResult | NO_SUPPORT = -1 | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-v3.1-release.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-v3.1-release.md index 4c655b742d78cf5c842eb8c132e3352e2fc8fbef..f5444d08d13a28dcea5758ccb9f3c7ba6cc69138 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-v3.1-release.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-v3.1-release.md @@ -2,7 +2,6 @@ OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本的JS API变更,参见各子系统的详细记录: - [元能力](js-apidiff-ability.md) -- [程序访问控制](js-apidiff-access-control.md) - [无障碍](js-apidiff-accessibility.md) - [帐号](js-apidiff-account.md) - [ArkUI开发框架](js-apidiff-ace.md) @@ -10,7 +9,6 @@ OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本的JS API变更 - [包管理](js-apidiff-bundle.md) - [基础通信](js-apidiff-communicate.md) - [语言编译器运行时](js-apidiff-complier-and-runtime.md) -- [定制](js-apidiff-config-policy.md) - [DFX](js-apidiff-dfx.md) - [分布式数据管理](js-apidiff-distributed-data.md) - [分布式硬件](js-apidiff-distributed-hardware.md) @@ -23,14 +21,12 @@ OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本的JS API变更 - [多模输入](js-apidiff-multi-modal-input.md) - [OS媒体软件](js-apidiff-multimedia.md) - [网络管理](js-apidiff-network.md) -- [启动恢复](js-apidiff-recovery.md) - [资源调度](js-apidiff-resource-scheduler.md) - [安全基础能力](js-apidiff-security.md) - [泛Sensor服务](js-apidiff-sensor.md) - [应用](js-apidiff-settings.md) - [软总线](js-apidiff-soft-bus.md) - [电话服务](js-apidiff-telephony.md) -- [升级服务](js-apidiff-update.md) - [USB服务](js-apidiff-usb.md) - [用户IAM](js-apidiff-user-authentication.md) - [窗口管理](js-apidiff-window.md) diff --git a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-window.md b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-window.md index dce4c7f9e083fd237d29ff4bc4ff0ca53ba0c2f4..b1d4d42814a123566333b237e345648d50f06ce8 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-window.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/js-apidiff-window.md @@ -1,14 +1,97 @@ -# xxx子系统JS API变更 +# 窗口管理子系统JS API变更 -OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,XXX子系统的API变更如下: +OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,窗口管理子系统的API变更如下: ## 接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.window | Window | setTouchable(isTouchable: boolean): Promise;
setTouchable(isTouchable: boolean, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setPrivacyMode(isPrivacyMode: boolean): Promise;
setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setOutsideTouchable(touchable: boolean): Promise;
setOutsideTouchable(touchable: boolean, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setKeepScreenOn(isKeepScreenOn: boolean): Promise;
setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setFocusable(isFocusable: boolean): Promise;
setFocusable(isFocusable: boolean, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setDimBehind(dimBehindValue: number, callback: AsyncCallback): void;
setDimBehind(dimBehindValue: number): Promise; | 新增 | +| ohos.window | Window | setBrightness(brightness: number): Promise;
setBrightness(brightness: number, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setBackgroundColor(color: string): Promise;
setBackgroundColor(color: string, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | getColorSpace(): Promise;
getColorSpace(callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | setColorSpace(colorSpace:ColorSpace): Promise;
setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | isSupportWideGamut(): Promise;
isSupportWideGamut(callback: AsyncCallback): void; | 新增 | +| ohos.window | Window | off(type: 'keyboardHeightChange', callback?: Callback): void; | 新增 | +| ohos.window | Window | on(type: 'keyboardHeightChange', callback: Callback): void; | 新增 | +| ohos.window | Window | off(type: 'systemAvoidAreaChange', callback?: Callback): void; | 新增 | +| ohos.window | Window | on(type: 'systemAvoidAreaChange', callback: Callback): void; | 新增 | +| ohos.window | Window | off(type: 'windowSizeChange', callback?: Callback): void; | 新增 | +| ohos.window | Window | on(type: 'windowSizeChange', callback: Callback): void; | 新增 | +| ohos.window | Window | isShowing(callback: AsyncCallback): void;
isShowing(): Promise; | 新增 | +| ohos.window | Window | loadContent(path: string, callback: AsyncCallback): void;
loadContent(path: string): Promise; | 新增 | +| ohos.window | Window | setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback): void;
setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise; | 新增 | +| ohos.window | Window | setSystemBarEnable(names: Array<'status'\|'navigation'>, callback: AsyncCallback): void;
setSystemBarEnable(names: Array<'status'\|'navigation'>): Promise; | 新增 | +| ohos.window | Window | setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback): void;
setLayoutFullScreen(isLayoutFullScreen: boolean): Promise; | 新增 | +| ohos.window | Window | setFullScreen(isFullScreen: boolean, callback: AsyncCallback): void;
setFullScreen(isFullScreen: boolean): Promise; | 新增 | +| ohos.window | Window | getAvoidArea(type: AvoidAreaType, callback: AsyncCallback): void;
getAvoidArea(type: AvoidAreaType): Promise; | 新增 | +| ohos.window | Window | getProperties(callback: AsyncCallback): void;
getProperties(): Promise; | 新增 | +| ohos.window | Window | destroy(callback: AsyncCallback): void;
destroy(): Promise; | 新增 | +| ohos.window | Window | show(callback: AsyncCallback): void;
show(): Promise; | 新增 | +| ohos.window | window | function find(id: string, callback: AsyncCallback): void;
function find(id: string): Promise; | 新增 | +| ohos.window | window | function create(id: string, type: WindowType, callback: AsyncCallback): void;
function create(id: string, type: WindowType): Promise;
function create(ctx: Context, id: string, type: WindowType): Promise;
function create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback): void; | 新增 | +| ohos.window | ColorSpace | WIDE_GAMUT | 新增 | +| ohos.window | ColorSpace | DEFAULT | 新增 | +| ohos.window | WindowProperties | isTransparent: boolean | 新增 | +| ohos.window | WindowProperties | isRoundCorner: boolean | 新增 | +| ohos.window | WindowProperties | isPrivacyMode: boolean | 新增 | +| ohos.window | WindowProperties | isKeepScreenOn: boolean | 新增 | +| ohos.window | WindowProperties | dimBehindValue: number | 新增 | +| ohos.window | WindowProperties | brightness: number | 新增 | +| ohos.window | WindowProperties | touchable: boolean | 新增 | +| ohos.window | WindowProperties | focusable: boolean | 新增 | +| ohos.window | WindowProperties | isLayoutFullScreen: boolean | 新增 | +| ohos.window | WindowProperties | isFullScreen: boolean | 新增 | +| ohos.window | WindowProperties | type: WindowType; | 新增 | +| ohos.window | WindowProperties | windowRect: Rect; | 新增 | +| ohos.window | Size | height: number; | 新增 | +| ohos.window | Size | width: number; | 新增 | +| ohos.window | AvoidArea | bottomRect: Rect; | 新增 | +| ohos.window | AvoidArea | rightRect: Rect; | 新增 | +| ohos.window | AvoidArea | topRect: Rect; | 新增 | +| ohos.window | AvoidArea | leftRect: Rect; | 新增 | +| ohos.window | Rect | height: number; | 新增 | +| ohos.window | Rect | width: number; | 新增 | +| ohos.window | Rect | top: number; | 新增 | +| ohos.window | Rect | left: number; | 新增 | +| ohos.window | SystemBarProperties | navigationBarContentColor?: string; | 新增 | +| ohos.window | SystemBarProperties | isNavigationBarLightIcon?: boolean; | 新增 | +| ohos.window | SystemBarProperties | navigationBarColor?: string; | 新增 | +| ohos.window | SystemBarProperties | statusBarContentColor?: string; | 新增 | +| ohos.window | SystemBarProperties | isStatusBarLightIcon?: boolean; | 新增 | +| ohos.window | SystemBarProperties | statusBarColor?: string; | 新增 | +| ohos.window | AvoidAreaType | TYPE_CUTOUT | 新增 | +| ohos.window | AvoidAreaType | TYPE_SYSTEM | 新增 | +| ohos.display | Display | yDPI: number; | 新增 | +| ohos.display | Display | xDPI: number; | 新增 | +| ohos.display | Display | scaledDensity: number; | 新增 | +| ohos.display | Display | densityPixels: number; | 新增 | +| ohos.display | Display | densityDPI: number; | 新增 | +| ohos.display | Display | height: number; | 新增 | +| ohos.display | Display | width: number; | 新增 | +| ohos.display | Display | rotation: number; | 新增 | +| ohos.display | Display | refreshRate: number; | 新增 | +| ohos.display | Display | state: DisplayState; | 新增 | +| ohos.display | Display | alive: boolean; | 新增 | +| ohos.display | Display | name: string; | 新增 | +| ohos.display | Display | id: number; | 新增 | +| ohos.display | DisplayState | STATE_ON_SUSPEND | 新增 | +| ohos.display | DisplayState | STATE_VR | 新增 | +| ohos.display | DisplayState | STATE_DOZE_SUSPEND | 新增 | +| ohos.display | DisplayState | STATE_DOZE | 新增 | +| ohos.display | DisplayState | STATE_ON | 新增 | +| ohos.display | DisplayState | STATE_OFF | 新增 | +| ohos.display | DisplayState | STATE_UNKNOWN = 0 | 新增 | +| ohos.display | display | function off(type: 'add' \| 'remove' \| 'change', callback?: Callback): void; | 新增 | +| ohos.display | display | function off(type: 'add' \| 'remove' \| 'change', callback?: Callback): void; | 新增 | +| ohos.display | display | function off(type: 'add' \| 'remove' \| 'change', callback?: Callback): void; | 新增 | +| ohos.display | display | function on(type: 'add' \| 'remove' \| 'change', callback: Callback): void; | 新增 | +| ohos.display | display | function on(type: 'add' \| 'remove' \| 'change', callback: Callback): void; | 新增 | +| ohos.display | display | function on(type: 'add' \| 'remove' \| 'change', callback: Callback): void; | 新增 | +| ohos.display | display | function getAllDisplay(callback: AsyncCallback>): void;
function getAllDisplay(): Promise>; | 新增 | +| ohos.display | display | function getDefaultDisplay(callback: AsyncCallback): void;
function getDefaultDisplay(): Promise; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md b/zh-cn/release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md index a9dcb0efdc5d35935032b5fef431320686d37fab..e4e1668afab1c58e7c9eb85d5ac4513aa579b109 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md @@ -4,13 +4,206 @@ OpenHarmony 3.1 Release相较于OpenHarmony 3.0 LTS版本的API变更如下: ## 标准系统接口变更 -| 模块名称 | 接口名称 | 变更类型 | 变更说明 | -| -------- | -------- | -------- | -------- | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | -| | | | | \ No newline at end of file + | 模块名称 | 接口名称 | 变更类型 | 变更说明 | + | -------- | ------------------------------------------------------------ | -------- | ----------------------------------------------- | + | 图形-drawing | OH_Drawing_FontCollection* OH_Drawing_CreateFontCollection(void) | 新增 | 创建OH_Drawing_FontCollection | + | 图形-drawing | void OH_Drawing_DestroyFontCollection(OH_Drawing_FontCollection*) | 新增 | 释放被OH_Drawing_FontCollection对象占据的内存 | + | 图形-drawing | OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle(void) | 新增 | 创建OH_Drawing_TypographyStyle | + | 图形-drawing | void OH_Drawing_DestroyTypographyStyle(OH_Drawing_TypographyStyle*) | 新增 | 释放被OH_Drawing_TypographyStyle对象占据的内存 | + | 图形-drawing | void OH_Drawing_SetTypographyTextDirection(OH_Drawing_TypographyStyle*, int /* OH_Drawing_TextDirection */) | 新增 | 设置文本方向 | + | 图形-drawing | void OH_Drawing_SetTypographyTextAlign(OH_Drawing_TypographyStyle*, int /* OH_Drawing_TextAlign */) | 新增 | 设置文本对齐方式 | + | 图形-drawing | void OH_Drawing_SetTypographyTextMaxLines(OH_Drawing_TypographyStyle*, int /* maxLines */) | 新增 | 设置文本最大行数 | + | 图形-drawing | OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle(void) | 新增 | 创建OH_Drawing_TextStyle | + | 图形-drawing | void OH_Drawing_DestroyTextStyle(OH_Drawing_TextStyle*) | 新增 | 释放被OH_Drawing_TextStyle对象占据的内存 | + | 图形-drawing | void OH_Drawing_SetTextStyleColor(OH_Drawing_TextStyle*, uint32_t /* color */) | 新增 | 设置文本颜色 | + | 图形-drawing | void OH_Drawing_SetTextStyleFontSize(OH_Drawing_TextStyle*, double /* fontSize */); | 新增 | 设置字号 | + | 图形-drawing | void OH_Drawing_SetTextStyleFontWeight(OH_Drawing_TextStyle*, int /* OH_Drawing_FontWeight */) | 新增 | 设置字重 | + | 图形-drawing | void OH_Drawing_SetTextStyleBaseLine(OH_Drawing_TextStyle*, int /* OH_Drawing_TextBaseline */) | 新增 | 设置字体基线位置 | + | 图形-drawing | void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */) | 新增 | 设置装饰 | + | 图形-drawing | void OH_Drawing_SetTextStyleDecorationColor(OH_Drawing_TextStyle*, uint32_t /* color */) | 新增 | 设置装饰颜色 | + | 图形-drawing | void OH_Drawing_SetTextStyleFontHeight(OH_Drawing_TextStyle*, double /* fontHeight */) | 新增 | 设置字体高度 | + | 图形-drawing | void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle*,int /* fontFamiliesNumber \*/, const char* fontFamilies[]); | 新增 | 设置字体类型 | + | 图形-drawing | void OH_Drawing_SetTextStyleFontStyle(OH_Drawing_TextStyle*, int /* OH_Drawing_FontStyle */) | 新增 | 设置字体风格 | + | 图形-drawing | void OH_Drawing_SetTextStyleLocale(OH_Drawing_TextStyle*, const char*) | 新增 | 设置语言区域 | + | 图形-drawing | OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler(OH_Drawing_TypographyStyle*, OH_Drawing_FontCollection*) | 新增 | 创建指向OH_Drawing_TypographyCreate对象的指针 | + | 图形-drawing | void OH_Drawing_DestroyTypographyHandler(OH_Drawing_TypographyCreate*) | 新增 | 释放被OH_Drawing_TypographyCreate对象占据的内存 | + | 图形-drawing | void OH_Drawing_TypographyHandlerPushTextStyle(OH_Drawing_TypographyCreate*, OH_Drawing_TextStyle*) | 新增 | 排版风格入栈 | + | 图形-drawing | void OH_Drawing_TypographyHandlerAddText(OH_Drawing_TypographyCreate*, const char*) | 新增 | 设置文本内容 | + | 图形-drawing | void OH_Drawing_TypographyHandlerPopTextStyle(OH_Drawing_TypographyCreate*) | 新增 | 排版风格出栈 | + | 图形-drawing | OH_Drawing_Typography* OH_Drawing_CreateTypography(OH_Drawing_TypographyCreate*) | 新增 | 创建OH_Drawing_Typography | + | 图形-drawing | void OH_Drawing_DestroyTypography(OH_Drawing_Typography*) | 新增 | 释放OH_Drawing_Typography对象占据的内存 | + | 图形-drawing | void OH_Drawing_TypographyLayout(OH_Drawing_Typography*, double /* maxWidth */) | 新增 | 排版布局 | + | 图形-drawing | void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, double /* potisionX */, double /\* potisionY */) | 新增 | 显示文本 | + | 图形-drawing |OH_Drawing_Bitmap* OH_Drawing_BitmapCreate(void)|新增|函数用于创建一个位图对象| + | 图形-drawing |void OH_Drawing_BitmapDestroy(OH_Drawing_Bitmap*)|新增|函数用于销毁位图对象并回收该对象占有内存| + | 图形-drawing |void OH_Drawing_BitmapBuild(OH_Drawing_Bitmap*, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat*)|新增|函数用于初始化位图对象的宽度和高度,并且为该位图设置像素格式| + | 图形-drawing |uint32_t OH_Drawing_BitmapGetWidth(OH_Drawing_Bitmap*)|新增|该函数用于获取指定位图的宽度| + | 图形-drawing |uint32_t OH_Drawing_BitmapGetHeight(OH_Drawing_Bitmap*)|新增|函数用于获取指定位图的高度| + | 图形-drawing |void* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*)|新增|函数用于获取指定位图的像素地址,可以通过像素地址获取到位图的像素数据| + | 图形-drawing |OH_Drawing_Brush* OH_Drawing_BrushCreate(void)|新增|函数用于创建一个画刷对象| + | 图形-drawing |void OH_Drawing_BrushDestroy(OH_Drawing_Brush*)|新增|函数用于销毁画刷对象并回收该对象占有的内存| + | 图形-drawing |bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush*)|新增|函数用于获取画刷是否设置抗锯齿属性,如果为真则说明画刷会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理| + | 图形-drawing |void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush*, bool)|新增|函数用于设置画刷的抗锯齿属性,设置为真则画刷在绘制图形时会对图形的边缘像素进行半透明的模糊处理| + | 图形-drawing |uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush*)|新增|函数用于获取画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示| + | 图形-drawing |void OH_Drawing_BrushSetColor(OH_Drawing_Brush*, uint32_t color)|新增|函数用于设置画刷的颜色属性,颜色属性描述了画刷填充图形时使用的颜色,用一个32位(ARGB)的变量表示| + | 图形-drawing |OH_Drawing_Canvas* OH_Drawing_CanvasCreate(void)|新增|函数用于创建一个画布对象| + | 图形-drawing |void OH_Drawing_CanvasDestroy(OH_Drawing_Canvas*)|新增|函数用于销毁画布对象并回收该对象占有的内存| + | 图形-drawing |void OH_Drawing_CanvasBind(OH_Drawing_Canvas*, OH_Drawing_Bitmap*)|新增|函数用于将一个位图对象绑定到画布中,使得画布绘制的内容输出到位图中(即CPU渲染)| + | 图形-drawing |void OH_Drawing_CanvasAttachPen(OH_Drawing_Canvas*, const OH_Drawing_Pen*)|新增|函数用于设置画笔给画布,画布将会使用设置画笔的样式和颜色去绘制图形形状的轮廓| + | 图形-drawing |void OH_Drawing_CanvasDetachPen(OH_Drawing_Canvas*)|新增|函数用于去除掉画布中的画笔,使用后画布将不去绘制图形形状的轮廓| + | 图形-drawing |void OH_Drawing_CanvasAttachBrush(OH_Drawing_Canvas*, const OH_Drawing_Brush*)|新增|函数用于设置画刷给画布,画布将会使用设置的画刷样式和颜色去填充绘制的图形形状| + | 图形-drawing |void OH_Drawing_CanvasDetachBrush(OH_Drawing_Canvas*)|新增|函数用于去除掉画布中的画刷,使用后画布将不去填充图形形状| + | 图形-drawing |void OH_Drawing_CanvasSave(OH_Drawing_Canvas*)|新增|函数用于保存当前画布的状态(画布矩阵)到一个栈顶| + | 图形-drawing |void OH_Drawing_CanvasRestore(OH_Drawing_Canvas*)|新增|函数用于恢复保存在栈顶的画布状态(画布矩阵)| + | 图形-drawing |void OH_Drawing_CanvasDrawLine(OH_Drawing_Canvas*, float x1, float y1, float x2, float y2)|新增|函数用于画一条直线段| + | 图形-drawing |void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*)|新增|函数用于画一个自定义路径| + | 图形-drawing |void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color)|新增|函数用于使用指定颜色去清空画布| + | 图形-drawing |uint32_t OH_Drawing_ColorSetArgb(uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue)|新增|函数用于将4个变量(分别描述透明度、红色、绿色和蓝色)转化为一个描述颜色的32位(ARGB)变量| + | 图形-drawing |OH_Drawing_Path* OH_Drawing_PathCreate(void)|新增|函数用于创建一个路径对象| + | 图形-drawing |void OH_Drawing_PathDestroy(OH_Drawing_Path*)|新增|函数用于销毁路径对象并回收该对象占有的内存| + | 图形-drawing |void OH_Drawing_PathMoveTo(OH_Drawing_Path*, float x, float y)|新增|函数用于设置自定义路径的起始点位置| + | 图形-drawing |void OH_Drawing_PathLineTo(OH_Drawing_Path*, float x, float y)|新增|函数用于添加一条从路径的最后点位置到目标点位置的线段| + | 图形-drawing |void OH_Drawing_PathArcTo(OH_Drawing_Path*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg)|新增|函数用于给路径添加一段弧线,绘制弧线的方式为角度弧,该方式首先会指定一个矩形边框,矩形边框会包裹椭圆,然后会指定一个起始角度和扫描度数,从起始角度扫描截取的椭圆周长一部分即为绘制的弧线。另外会默认添加一条从路径的最后点位置到弧线起始点位置的线段| + | 图形-drawing |void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY)|新增|函数用于添加一条从路径最后点位置到目标点位置的二阶贝塞尔圆滑曲线| + | 图形-drawing |void OH_Drawing_PathCubicTo(OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY)|新增|函数用于添加一条从路径最后点位置到目标点位置的三阶贝塞尔圆滑曲线| + | 图形-drawing |void OH_Drawing_PathClose(OH_Drawing_Path*)|新增|函数用于闭合路径,会添加一条从路径起点位置到最后点位置的线段| + | 图形-drawing |void OH_Drawing_PathReset(OH_Drawing_Path*)|新增|函数用于重置自定义路径数据| + | 图形-drawing |OH_Drawing_Pen* OH_Drawing_PenCreate(void)|新增|函数用于创建一个画笔对象| + | 图形-drawing |void OH_Drawing_PenDestroy(OH_Drawing_Pen*)|新增|函数用于销毁画笔对象并回收该对象占有的内存| + | 图形-drawing |bool OH_Drawing_PenIsAntiAlias(const OH_Drawing_Pen*)|新增|函数用于获取画笔是否设置抗锯齿属性,如果为真则说明画笔会启用抗锯齿功能,在绘制图形时会对图形的边缘像素进行半透明的模糊处理| + | 图形-drawing |void OH_Drawing_PenSetAntiAlias(OH_Drawing_Pen*, bool)|新增|函数用于设置画笔的抗锯齿属性,设置为真则画笔在绘制图形时会对图形的边缘像素进行半透明的模糊处理| + | 图形-drawing |uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen*)|新增|函数用于获取画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示| + | 图形-drawing |void OH_Drawing_PenSetColor(OH_Drawing_Pen*, uint32_t color)|新增|函数用于设置画笔的颜色属性,颜色属性描述了画笔绘制图形轮廓时使用的颜色,用一个32位(ARGB)的变量表示| + | 图形-drawing |float OH_Drawing_PenGetWidth(const OH_Drawing_Pen*)|新增|函数用于获取画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度| + | 图形-drawing |void OH_Drawing_PenSetWidth(OH_Drawing_Pen*, float width)|新增|函数用于设置画笔的厚度属性,厚度属性描述了画笔绘制图形轮廓的宽度| + | 图形-drawing |float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen*)|新增|函数用于获取折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角| + | 图形-drawing |void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen*, float miter)|新增|函数用于设置折线尖角的限制值,当画笔绘制一条折线,转角类型设置为尖角时,那么此时该属性用于限制出现尖角的长度范围,如果超出则平角显示,不超出依然为尖角| + | 图形-drawing |OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen*)|新增|函数用于获取画笔笔帽的样式| + | 图形-drawing |void OH_Drawing_PenSetCap(OH_Drawing_Pen*, OH_Drawing_PenLineCapStyle)|新增|函数用于设置画笔笔帽样式| + | 图形-drawing |OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen*)|新增|函数用于获取画笔绘制折线转角的样式| + | 图形-drawing |void OH_Drawing_PenSetJoin(OH_Drawing_Pen*, OH_Drawing_PenLineJoinStyle)|新增|函数用于设置画笔绘制转角的样式| + | 图形-NativeWindow | struct NativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface) | 新增 | 新增创建NativeWindow实例接口 | + | 图形-NativeWindow | void OH_NativeWindow_DestroyNativeWindow(struct NativeWindow* window) | 新增 | 新增NativeWindow对象的引用计数减1接口 | + | 图形-NativeWindow | struct NativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer) | 新增 | 新增创建NativeWindowBuffer实例接口 | + | 图形-NativeWindow | void OH_NativeWindow_DestroyNativeWindowBuffer(struct NativeWindowBuffer* buffer) | 新增 | 新增NativeWindowBuffer对象的引用计数减1接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowRequestBuffer(struct NativeWindow *window, struct NativeWindowBuffer **buffer, int *fenceFd) | 新增 | 新增通过NativeWindow对象申请一块NativeWindowBuffer接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowFlushBuffer(struct NativeWindow *window, struct NativeWindowBuffer *buffer, int fenceFd, Region region) | 新增 | 新增通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowAbortBuffer(struct NativeWindow *window, struct NativeWindowBuffer *buffer) | 新增 | 新增通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowHandleOpt(struct NativeWindow *window, int code, ...) | 新增 | 新增设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等接口 | + | 图形-NativeWindow | BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(struct NativeWindowBuffer *buffer) | 新增 | 新增通过NativeWindowBuffer获取该buffer的BufferHandle指针接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeObjectReference(void *obj) | 新增 | 新增增加一个NativeObject的引用计数接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_NativeObjectUnreference(void *obj) | 新增 | 新增减少一个NativeObject的引用计数接口 | + | 图形-NativeWindow | int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj) | 新增 | 新增获取NativeObject的MagicId接口 | + | DFX-hilog | LOG_DOMAIN | 新增 | 十六进制整数宏,标识日志所对应的业务领域。 | + | DFX-hilog | LOG_TAG | 新增 | 字符串宏,标识调用所在的类或者业务。 | + | DFX-hilog | LOG_APP | 新增 | 日志类型枚举,标识应用日志类型。 | + | DFX-hilog | LOG_DEBUG | 新增 | 日志级别枚举,标识DEBUG日志级别。 | + | DFX-hilog | LOG_INFO | 新增 | 日志级别枚举,标识INFO日志级别。 | + | DFX-hilog | LOG_WARN | 新增 | 日志级别枚举,标识WARN日志级别。 | + | DFX-hilog | LOG_ERROR | 新增 | 日志级别枚举,标识ERROR日志级别。 | + | DFX-hilog | LOG_FATAL | 新增 | 日志级别枚举,标识FATAL日志级别。 | + | DFX-hilog | bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | 新增 | 普通接口,用于检查指定业务领域、TAG、级别的日志是否可以打印。 | + | DFX-hilog | int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | 新增 | 普通接口,用于写日志。 | + | DFX-hilog | OH_LOG_DEBUG(type, ...) | 新增 | 宏封装接口,用于写DEBUG级别日志。 | + | DFX-hilog | OH_LOG_INFO(type, ...) | 新增 | 宏封装接口,用于写INFO级别日志。 | + | DFX-hilog | OH_LOG_WARN(type, ...) | 新增 | 宏封装接口,用于写WARN级别日志。 | + | DFX-hilog | OH_LOG_ERROR(type, ...) | 新增 | 宏封装接口,用于写ERROR级别日志。 | + | DFX-hilog | OH_LOG_FATAL(type, ...) | 新增 | 宏封装接口,用于写FATAL级别日志。 | + | zlib | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, z_size_t len)); | 新增 | 使用buf更新adler32 | + | zlib | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | 新增 | 合并两个adler32 | + | zlib | ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level));
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); | 新增 | 将源缓冲区压缩到目标缓冲区 | + | zlib | ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); | 新增 | 返回压缩大小的上限。在compress2/compress调用之前使用,以分配目标缓冲区 | + | zlib | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, z_size_t len)); | 新增 | 使用buf更新crc32 | + | zlib | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); | 新增 | 合并两个crc32 | + | zlib | ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | 新增 | 压缩函数 | + | zlib | ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); | 新增 | 返回压缩大小的上限。在deflateInit/deflateInit2调用之后使用,以分配目标缓冲区 | + | zlib | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); | 新增 | 将目标流设置为源流的完整副本 | + | zlib | ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | 新增 | 压缩完成以后,释放空间 | + | zlib | ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, Bytef *dictionary, uInt *dictLength)); | 新增 | 返回由deflate维护的滑动字典 | + | zlib | ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size));
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); | 新增 | 压缩初始化的基础函数 | + | zlib | ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); | 新增 | 动态更新压缩级别和压缩策略 | + | zlib | ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, unsigned *pending, int *bits)); | 新增 | 返回已生成但尚未在可用输出中提供的输出的字节数和位数 | + | zlib | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); | 新增 | 在压缩输出流中插入bit | + | zlib | ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | 新增 | 等价于 deflateEnd 后跟 deflateInit,但是不释放和重新分配内部压缩状态 | + | zlib | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); | 新增 | 从给定的字节序列初始化压缩字典,而不产生任何压缩输出 | + | zlib | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); | 新增 | 当delateInit2()请求gzip流时,delateSetHeader()提供gzip头信息 | + | zlib | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); | 新增 | 微调压缩的内部压缩参数 | + | zlib | ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | 新增 | 设置此库函数使用的内部缓冲区大小。默认缓冲区大小为8192字节 | + | zlib | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | 新增 | 清除文件的错误和文件结束标志 | + | zlib | ZEXTERN int ZEXPORT gzclose OF((gzFile file));
ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | 新增 | 刷新所有挂起的输出,关闭压缩文件并解除压缩状态 | + | zlib | ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | 新增 | 如果在读取时直接复制文件,则返回true (1);如果文件是正在解压缩的gzip流,则返回false (0)。 | + | zlib | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | 新增 | 将gzFile与文件描述符fd关联。文件描述符从open、dup、create、管道或fileno等调用中获得(如果文件以前已使用fopen打开)。mode参数与gzopen中的一样 | + | zlib | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | 新增 | 如果在读取时设置了文件结束指示器,则返回true (1),否则返回false (0) | + | zlib | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | 新增 | 返回给定压缩文件上发生的最后一个错误的错误消息 | + | zlib | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | 新增 | 将所有挂起的输出刷新到压缩文件中 | + | zlib | ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, gzFile file)); | 新增 | 从文件读取最多n个大小的item到Buf | + | zlib | ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, z_size_t nitems, gzFile file)); | 新增 | 将n个大小为Buf的item写入文件,复制stdio的fwrite()的接口,使用size_t请求和返回类型 | + | zlib | ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); | 新增 | 从压缩文件中读取一个字节 | + | zlib | ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | 新增 | 从压缩文件中读取字节,直到读取len-1字符,或读取换行符并将其传输到Buf,或遇到文件结束条件 | + | zlib | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | 新增 | 返回正在读取或写入的文件中的当前偏移量 | + | zlib | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 新增 | 打开gzip (.gz)文件以进行读取或写入 | + | zlib | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | 新增 | 在格式字符串的控制下转换、格式化和写入参数到压缩文件中 | + | zlib | ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | 新增 | 将转换为无符号字符的c写入压缩文件。gzputc返回写入的值,如果出现错误,则返回-1。 | + | zlib | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | 新增 | 从压缩文件中读取给定数量的未压缩字节 | + | zlib | ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | 新增 | 重定向给定的文件 | + | zlib | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); | 新增 | 设置给定压缩文件上下一个gzread或gzwrite的起始位置 | + | zlib | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | 新增 | 动态更新压缩级别或策略 | + | zlib | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | 新增 | 返回给定压缩文件上下一个gzread或gzwrite的起始位置 | + | zlib | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | 新增 | 将一个字符写入流,作为下一次读取时的第一个字符读取 | + | zlib | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); | 新增 | 将给定数量的未压缩字节写入压缩文件 | + | zlib | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | 新增 | 解压缩尽可能多的数据,并在输入缓冲区变空或输出缓冲区变满时停止 | + | zlib | ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc));
ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)); | 新增 | 使用回调接口实现解压 | + | zlib | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source)); | 新增 | 将目标流设置为源流的完整副本 | + | zlib | ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | 新增 | 此流的所有动态分配的数据结构都将被释放 | + | zlib | ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, Bytef *dictionary, uInt *dictLength)); | 新增 | 返回由inflate维护的滑动字典 | + | zlib | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); | 新增 | 将gzip头信息存储在提供的gz_header结构中。 | + | zlib | ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size));
/ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); | 新增 | 解压初始化函数 | + | zlib | ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); | 新增 | 返回两个值,一个在返回值的低16位,另一个在剩余的高位,通过将返回值向下移动16位获得。 | + | zlib | ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); | 新增 | 在inflate输入流中插入位 | + | zlib | ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, int windowBits)); | 新增 | 此函数等效于inflateEnd后跟inflateInit,但不会释放和重新分配内部解压缩状态。流将保留可能已由inflateInit2设置的属性。 | + | zlib | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); | 新增 | 从给定的未压缩字节序列初始化解压缩字典 | + | zlib | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | 新增 | 跳过无效的压缩数据,直到找到可能的完全刷新点,或直到跳过所有可用输入。没有输出。 | + | zlib | ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong *sourceLen)); | 新增 | 将源缓冲区解压到目标缓冲区,sourceLen是源缓冲区的字节长度。 | + | zlib | ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | 新增 | 返回指示编译时选项的标志。 | + | zlib | ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | 新增 | 返回zlib版本 | + | 全球化-resmgr | NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr) | 新增 | 新增初始化native资源管理接口 | + | 全球化-resmgr | void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr) | 新增 | 新增释放native资源管理接口 | + | 全球化-resmgr | RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName) | 新增 | 新增打开指定rawfile目录接口 | + | 全球化-resmgr | RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName) | 新增 | 新增打开指定rawfile文件接口 | + | 全球化-resmgr | const char *OH_ResourceManager_GetRawFileName(RawDir *rawDir, int index) | 新增 | 新增获取rawfile名字接口 | + | 全球化-resmgr | int OH_ResourceManager_GetRawFileCount(RawDir *rawDir) | 新增 | 新增获取指定rawfile目录下的rawfile文件数量接口 | + | 全球化-resmgr | void OH_ResourceManager_CloseRawDir(RawDir *rawDir) | 新增 | 新增释放rawfile目录相关资源接口 | + | 全球化-resmgr | int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length) | 新增 | 新增读取指定rawfile文件接口 | + | 全球化-resmgr | int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence) | 新增 | 新增根据指定偏移量查询rawfile中的数据接口 | + | 全球化-resmgr | long OH_ResourceManager_GetRawFileSize(RawFile *rawFile) | 新增 | 新增获取rawfile文件size大小接口 | + | 全球化-resmgr | void OH_ResourceManager_CloseRawFile(RawFile *rawFile) | 新增 | 新增释放rawfile文件相关资源接口 | + | 全球化-resmgr | long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile) | 新增 | 新增获取当前rawfile的偏移量接口 | + | 全球化-resmgr | bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor) | 新增 | 新增获取rawfile的fd接口 | + | 全球化-resmgr | bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor) | 新增 | 新增释放rawfile的fd接口 | + | 媒体-multimedia | OH_GetImageInfo | 新增 | 通过pixel的数据地址来获取信息 | + | 媒体-multimedia | OH_AccessPixels | 新增 | 锁定给定的pixel的数据地址 | + | 媒体-multimedia | OH_UnAccessPixels | 新增 | 解锁给定的pixel的数据地址 | + | 媒体-audio_standard | SL_API SLresult SLAPIENTRY slCreateEngine(
SLObjectItf *pEngine,
SLuint32 numOptions,
const SLEngineOption *pEngineOptions,
SLuint32 numInterfaces,
const SLInterfaceID *pInterfaceIds,
const SLboolean * pInterfaceRequired
); | 新增 | 创建并返回Engine对象 | + | 媒体-audio_standard | SLObjectItf_
SLresult (*Realize) (
SLObjectItf self,
SLboolean async
); | 新增 | 初始化Object对象 | + | 媒体-audio_standard | SLObjectItf_
SLresult (*Resume) (
SLObjectItf self,
SLboolean async
); | 新增 | 恢复Object对象 | + | 媒体-audio_standard | SLObjectItf_
SLresult (*GetState) (
SLObjectItf self,
SLuint32 * pState
); | 新增 | 获取对象的状态 | + | 媒体-audio_standard | SLObjectItf_
SLresult (*GetInterface) (
SLObjectItf self,
const SLInterfaceID iid,
void * pInterface
); | 新增 | 根据接口iid获取对象的接口 | + | 媒体-audio_standard | SLObjectItf_
SLresult (*RegisterCallback) (
SLObjectItf self,
slObjectCallback callback,
void * pContext
); | 新增 | 注册callback | + | 媒体-audio_standard | SLObjectItf_
void (*Destroy) (
SLObjectItf self
); | 新增 | 销毁对象 | + | 媒体-audio_standard | SLresult (*CreateAudioPlayer) (
SLEngineItf self,
SLObjectItf * pPlayer,
SLDataSource *pAudioSrc,
SLDataSink *pAudioSnk,
SLuint32 numInterfaces,
const SLInterfaceID * pInterfaceIds,
const SLboolean * pInterfaceRequired
); | 新增 | 创建AudioPlayer对象 | + | 媒体-audio_standard | SLresult (*CreateOutputMix) (
SLEngineItf self,
SLObjectItf * pMix,
SLuint32 numInterfaces,
const SLInterfaceID * pInterfaceIds,
const SLboolean * pInterfaceRequired
); | 新增 | 创建OutputMix对象 | + | 媒体-audio_standard | SLPlayItf_
SLresult (*SetPlayState) (
SLPlayItf self,
SLuint32 state
); | 新增 | 设置Player的状态 | + | 媒体-audio_standard | SLPlayItf_
SLresult (*GetPlayState) (
SLPlayItf self,
SLuint32 *pState
); | 新增 | 获取Player的状态 | + | 媒体-audio_standard | SLBufferQueueItf_
SLresult (*Enqueue) (
SLBufferQueueItf self,
const void *pBuffer,
SLuint32 size
); | 新增 | 向BufferQueue中填入数据 | + | 媒体-audio_standard | SLBufferQueueItf_
SLresult (*Clear) (
SLBufferQueueItf self
); | 新增 | 清除BufferQueue的数据 | + | 媒体-audio_standard | SLBufferQueueItf_
SLresult (*GetState) (
SLBufferQueueItf self,
SLBufferQueueState *pState
); | 新增 | 获取BufferQueue的状态 | + | 媒体-audio_standard | SLVolumeItf_
SLresult (*SetVolumeLevel) (
SLVolumeItf self,
SLmillibel level
); | 新增 | 设置音量分贝值 | + | 媒体-audio_standard | SLVolumeItf_
SLresult (*GetVolumeLevel) (
SLVolumeItf self,
SLmillibel *pLevel
); | 新增 | 获取音量分贝值 | + | 媒体-audio_standard | SLVolumeItf_
SLresult (*GetMaxVolumeLevel) (
SLVolumeItf self,
SLmillibel *pMaxLevel
); | 新增 | 设置支持的最大分贝值 | + | LIBUV | [LIBUV标准](https://gitee.com/openharmony/docs/tree/2844f08105b08115f6f5694e9f7552e2f1fe3c12/zh-cn/application-dev/reference/native-lib/third_party_libuv) | 新增 | 新增LIBUV接口 | + | Node-API | [Node-API](https://gitee.com/openharmony/docs/blob/2844f08105b08115f6f5694e9f7552e2f1fe3c12/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md) | 新增 | NAPI组件对Node-API的接口进行了重新实现,新增支持Node-API标准库中的部分接口 | + | EGL | [EGL标准](https://github.com/KhronosGroup/EGL-Registry/tree/main/api/EGL/) | 新增 | 新增EGL接口 | + | GLES3 | [GLES3标准](https://github.com/KhronosGroup/OpenGL-Registry/tree/main/api/GLES3/) | 新增 | 新增OpenGLES3.0接口 | + | 标准C++库 | [libc++标准](https://libcxx.llvm.org/) | 新增 | 新增标准C++库接口 | + | 标准C库 | [libc、libm、libdl](https://zh.cppreference.com/w/c/header)组合实现C11标准C库 | 新增 | 新增标准C库接口 | + diff --git a/zh-cn/website.md b/zh-cn/website.md index 385f5d06bd2d926acedc14a3c3838a982f3c8506..501739923a8dd3092c8d683a29136ffadbd27937 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -1,10 +1,11 @@ # 了解OpenHarmony - [了解OpenHarmony开源项目](OpenHarmony-Overview_zh.md) -- [术语](device-dev/glossary/glossary.md) +- [术语](glossary.md) - 版本说明 - OpenHarmony 3.x Releases - + + - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) @@ -32,5 +33,4 @@ - [贡献文档](contribute/贡献文档.md) - [写作规范](contribute/写作规范.md) - [社区沟通与交流](contribute/社区沟通与交流.md) - - [FAQ](contribute/FAQ.md) - \ No newline at end of file + - [FAQ](contribute/FAQ.md) \ No newline at end of file