diff --git a/CODEOWNERS b/CODEOWNERS index 9cb100bed35dd224b8357d35a3ff270fc08409ef..200832f4e488b910697dbb875624c74e173c1bc5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -16,6 +16,6 @@ zh-cn/device-dev/kernel/ @Austin23 zh-cn/device-dev/website.md @Austin23 README.md @Austin23 -zh-cn/device-dev/porting duangavin123_admin -zh-cn/device-dev/guide duangavin123_admin -zh-cn/device-dev/subsystems li-yan339 \ No newline at end of file +zh-cn/device-dev/porting/ @duangavin123_admin +zh-cn/device-dev/guide/ @duangavin123_admin +zh-cn/device-dev/subsystems/ @li-yan339 \ No newline at end of file diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index 6193ac5b4df39a8a2dbe759b0590b3eeb726ec1a..8ef60fba9b498e0e1578d8f12641840d88933677 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -10,33 +10,39 @@ - [Preparations](start-overview.md) - [Getting Started with eTS in the Traditional Coding Approach](quick-start/start-with-ets.md) - [Getting Started with eTS in the Low-Code Approach](quick-start/start-with-ets-low-code.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) + - [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md) + - [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md) - Development Fundamentals - - [Application Development Package Structure (FA Model)](package-structure.md) - - [Application Development Package Structure (Stage Model)](module-structure.md) - - [Resource File Categories](basic-resource-file-categories.md) - - [SysCap](syscap.md) + - [Application Development Package Structure (FA Model)](quick-start/package-structure.md) + - [Application Development Package Structure (Stage Model)](quick-start/module-structure.md) + - [Resource File Categories](quick-start/basic-resource-file-categories.md) + - [SysCap](quick-start/syscap.md) - Development - [Ability Development](ability/Readme-EN.md) - [UI Development](ui/Readme-EN.md) - Basic Feature Development + - [Common Event and Notification](notification/Readme-EN.md) - [Window Manager](windowmanager/Readme-EN.md) - [WebGL](webgl/Readme-EN.md) - [Media](media/Readme-EN.md) - [Security](security/Readme-EN.md) - [Connectivity](connectivity/Readme-EN.md) - [Data Management](database/Readme-EN.md) + - [Telephony](telephony/Readme-EN.md) - [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/Readme-EN.md) - [Background Task Management](background-task-management/Readme-EN.md) + - [Work Scheduler](work-scheduler/Readme-EN.md) - [Device Management](device/Readme-EN.md) - [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [DFX](dfx/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md) + - + - [Using Native APIs in Application Projects](napi/napi-guidelines.md) - Tools - [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) + - [Codelabs](https://gitee.com/openharmony/codelabs) - API References - [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md) - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) diff --git a/en/application-dev/ability/Readme-EN.md b/en/application-dev/ability/Readme-EN.md index 9c9a1628970d656a281f80e2fcc1698c86fb5f3d..bd494f0618f105521e83cf3b81deb8de44f9fe69 100644 --- a/en/application-dev/ability/Readme-EN.md +++ b/en/application-dev/ability/Readme-EN.md @@ -1,20 +1,21 @@ # 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) - - Stage Model - - [Stage Model Overview](stage-brief.md) - - [Ability Development](stage-ability.md) - - [Service Extension Ability Development](stage-serviceextension.md) - - [Ability Continuation Development](stage-ability-continuation.md) - - [Ability Call Development](stage-call.md) - - [Stage Widget Development](stage-formextension.md) - - Other - - [WantAgent Development](wantagent.md) - - [Ability Assistant Usage](ability-assistant-guidelines.md) - - [Test Framework Usage](ability-delegator.md) +- [Ability Framework Overview](ability-brief.md) +- [Context Usage](context-userguide.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) +- Stage Model + - [Stage Model Overview](stage-brief.md) + - [Ability Development](stage-ability.md) + - [Service Extension Ability Development](stage-serviceextension.md) + - [Ability Continuation Development](stage-ability-continuation.md) + - [Ability Call Development](stage-call.md) + - [Stage Widget Development](stage-formextension.md) +- Other + - [WantAgent Development](wantagent.md) + - [Ability Assistant Usage](ability-assistant-guidelines.md) + - [Test Framework Usage](ability-delegator.md) diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md new file mode 100644 index 0000000000000000000000000000000000000000..c7447fde5764729f2592321460e03fc07218465c --- /dev/null +++ b/en/application-dev/ability/context-userguide.md @@ -0,0 +1,238 @@ +# Context Usage + +## Context Overview +**context** provides the capability of obtaining contextual information of an application. + +## Context Structure + +The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. + +**application/BaseContext** is a common context base class, which does not belong to either model. It has only one attribute, **stageMode**, which specifies whether the context is used for the stage model. + +The FA model has only one type of context: **app/Context**. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the context instance. + +The stage model has six types of contexts: **application/Context**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, **application/FormExtensionContext**, and **application/ServiceExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model). + + +![contextIntroduction](figures/contextIntroduction.png) + +## Context in the FA Model + +Only the methods in **app/Context** can be used for the context in the FA model. + +The FA model has only one context definition. All capabilities in the context are provided through methods. The context uses these methods to extend the capabilities of the FA. + +The context is defined in the d.ts file below: + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/app/context.d.ts + +Use the context as follows: + +```javascript +// 1. Import featureAbility. +import featureAbility from '@ohos.ability.featureAbility' + +export default { + onCreate() { + console.log('Application onCreate') + + // 2. Obtain the context. + let context = featureAbility.getContext(); + + // 3. Call the methods. + context.setShowOnLockScreen(false, (data) => { + console.log("data: " + JSON.stringify(data)); + }); + }, + onActive() { + console.log('Application onActive') + }, + onDestroy() { + console.log('Application onDestroy') + }, +} +``` + +## Context in the Stage Model + +The stage model has six contexts. The following describes these contexts in detail. + +### application/Context + +**Overview** + +**application/Context** is the base class context that provides basic application information such as **resourceManager**, **applicationInfo**, and **cacheDir**. It also provides basic application methods such as **createBundleContext** and **switchArea**. The application-level context is of the **application/Context** type. + +**How to Obtain** + +Obtain the context by calling **context.getApplicationContext()** in **AbilityStage**, **Ability**, and **Extension**. + +**Example** + +```javascript +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log('MainAbility onCreate is called' + want + launchParam); + // Obtain the application context. + let appContext = this.context.getApplicationContext(); + // Obtain the path. + console.log('filesDir is ' + appContext.filesDir); + } + + onDestroy() { + console.log('MainAbility onDestroy is called'); + } +} +``` + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts + +### application/AbilityStageContext + +**Overview** + +**application/AbilityStageContext** is the context for the HAP file. In addition to those provided by the base class **application/Context**, this context contains **HapModuleInfo** and **Configuration**. + +**How to Obtain** + +Obtain the context from the **context** attribute in **AbilityStage**. + +**Example** + +```javascript +export default class MyAbilityStage extends AbilityStage { + onCreate() { + // The context attribute is of the AbilityStageContext type. + console.log('HapModuleInfo is ' + context.currentHapModuleInfo); + } +} +``` + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityStageContext.d.ts + +### application/AbilityContext + +**Overview** + +In the stage model, each ability has a context attribute. + +**Ability** provides methods to manage the ability lifecycle, and **AbilityContext** provides methods to operate abilities (such as **startAbility** and **connectAbility**). + +**How to Obtain** + +Obtain the context from the **context** attribute in **Ability**. + +**Example** + +```javascript +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log('MainAbility onCreate is called' + want + launchParam); + var want = { + "bundleName": "com.example.MyApplication", + "abilityName": "ServiceExtAbility", + } + // 1. The context here is of the AbilityContext type. + let contxt = this.context; + // 2. Start the ability. + contxt.startAbility(want).then((data) => { + console.info("startAbility success:" + JSON.stringify(data)); + }).catch((error) => { + console.error("startAbility failed:" + JSON.stringify(error)); + }); + } + + onDestroy() { + console.log("MainAbility on Destroy is called"); + } +} +``` + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityContext.d.ts + +### application/ExtensionContext + +**Overview** + +Unlike the FA model, the stage model separates **Service** from **Ability** and defines a group of **Extension** classes to provide the same capabilities. **Extension** is a base class and does not provide specific service functions. The service party extends the corresponding **Extension** class as required. For example, a Service ability is extended to **ServiceExtensionAbility**, and a form (service widget) is extended to **FormExtensionAbility**. + +**ExtensionContext** provides the context for the extension. **ExtensionContext** has the **HapModuleInfo** and **Configuration** attributes. + +**How to Obtain** + +This type of context is not used independently. + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ExtensionContext.d.ts + +### application/ServiceExtensionContext + +**Overview** + +Similar to **ServiceAbility** of the FA model, **ServiceExtensionAbility** contains only the processing related to lifecycle callbacks. + +The methods for operating the Service Extension ability (such as **startAbility** and **connectAbility**) are provided in **ServiceExtensionContext**. + +**How to Obtain** + +Obtain the context from the **context** attribute in **ServiceExtensionAbility**. + +**Example** +```javascript +export default class ServiceExtAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info("ServiceAbility onCreate**"); + // The context here is of the ServiceExtensionContext type. + let contxt = this.context; + } + + onRequest(want, startId) { + console.info("ServiceAbility onRequest**"); + } + + onConnect(want) { + console.info("ServiceAbility onConnect**"); + return new StubTest("test"); + } + + onDisconnect(want) { + console.info("ServiceAbility onDisconnect**"); + } + + onDestroy() { + console.info("ServiceAbility onDestroy**"); + } +} + +``` + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ServiceExtensionContext.d.ts + +### application/FormExtensionContext + +For details, see [FormExtensionContext](/en/application-dev/reference/apis/js-apis-formextensioncontext.md) + +**d.ts statement** + +https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/FormExtensionContext.d.ts + +## FAQs + +Can I obtain the context through globalThis? + +**Answer** + +You can use **globalThis** to obtain the context in the FA model, but not in the stage model. To obtain the context in the stage model, use the **context** attribute in the corresponding component. + +**Reason** + +In the FA model, each ability instance has a JS VM instance. Therefore, a global ability instance can be obtained from the **global** object of the JS engine. In the stage model, where all the processes of an application share a JS VM instance, there is no global ability instance, and using **globalThis** may cause an error or crash. diff --git a/en/application-dev/ability/figures/contextIntroduction.png b/en/application-dev/ability/figures/contextIntroduction.png new file mode 100644 index 0000000000000000000000000000000000000000..f7da3ba36ec5abf333229e1421964a15fa7d392b Binary files /dev/null and b/en/application-dev/ability/figures/contextIntroduction.png differ diff --git a/en/application-dev/internationalization/public_sys-resources/icon-caution.gif b/en/application-dev/internationalization/public_sys-resources/icon-caution.gif deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-caution.gif and /dev/null 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 deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-danger.gif and /dev/null 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 deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-note.gif and /dev/null 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 deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-notice.gif and /dev/null 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 deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-tip.gif and /dev/null 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 deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/en/application-dev/internationalization/public_sys-resources/icon-warning.gif and /dev/null differ diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index dea72108451e84d1b6c3b23a9b40df11ed4b31a2..085506f3c514624f8fd8a2a8526b149a8e0927a8 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -22,32 +22,43 @@ For details about the APIs, see [AudioPlayer in the Media API](../reference/apis The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources. -For details about the **src** media source input types supported by **AudioPlayer**, see the [src attribute](../reference/apis/js-apis-media.md#audioplayer_attributes). +For details about the **src** types supported by **AudioPlayer**, see the [src attribute](../reference/apis/js-apis-media.md#audioplayer_attributes). ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' -function SetCallBack(audioPlayer) { +// Print the stream track information. +function printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('audio key is ' + item); + console.info('audio value is ' + property); + } +} + +// Set the player callbacks. +function setCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - // The playback page is ready. You can click the Play button to start the playback. + audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. }); audioPlayer.on('play', () => { // Set the 'play' event callback. console.info('audio play success'); - // The Play button is changed to the pausable state. + audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. }); audioPlayer.on('pause', () => { // Set the 'pause' event callback. console.info('audio pause success'); - // The Play button is changed to the playable state. + audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. }); audioPlayer.on('stop', () => { // Set the 'stop' event callback. console.info('audio stop success'); - // The playback stops, the playback progress bar returns to 0, and the Play button is changed to the playable state. + audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. }); audioPlayer.on('reset', () => { // Set the 'reset' event callback. console.info('audio reset success'); - // You can reconfigure the src attribute to play another audio file. + audioPlayer.release(); // Release the AudioPlayer resources. + audioPlayer = undefined; }); audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. if (typeof(seekDoneTime) == 'undefined') { @@ -55,72 +66,49 @@ function SetCallBack(audioPlayer) { return; } console.info('audio seek success, and seek time is ' + seekDoneTime); - // The playback progress bar is updated to the seek position. + audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. }); audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback. console.info('audio volumeChange success'); - // Display the updated volume. + audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. + if (typeof (arrlist) != 'undefined') { + for (let i = 0; i < arrlist.length; i++) { + printfDescription(arrlist[i]); + } + } else { + console.log(`audio getTrackDescription fail, error:${error.message}`); + } + audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. + }); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. + audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. console.info('audio play finish'); }); - audioPlayer.on('error', (error) => { // Set the 'error' event callback. + audioPlayer.on('error', (error) => { // Set the 'error' event callback. 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}`); }); } -function printfDescription(obj) { - for (let item in obj) { - let property = obj[item]; - console.info('audio key is ' + item); - console.info('audio value is ' + property); - } +async function audioPlayerDemo() { + // 1. Create an audioPlayer instance. + let audioPlayer = media.createAudioPlayer(); + setCallBack(audioPlayer); // Set the event callbacks. + // 2. Set the URI of the audio file selected by the user. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); + }); + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. } - -// 1. Create an audioPlayer instance. -let audioPlayer = media.createAudioPlayer(); -SetCallBack(audioPlayer); // Set the event callbacks. -// 2. Set the URI of the audio file selected by the user. -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. -// 3. Play the audio file. -audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is triggered. -// 4. Seek to the playback position. -audioPlayer.seek(30000); // Trigger the 'timeUpdate' event callback, and seek to 30000 ms for playback. -// 5. Set the volume. -audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. -// 6. Pause the playback. -audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. -// 7. Obtain the track information. -audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. - if (typeof (arrlist) != 'undefined') { - for (let i = 0; i < arrlist.length; i++) { - printfDescription(arrlist[i]); - } - } else { - console.log(`audio getTrackDescription fail, error:${error.message}`); - } -}); -// 8. Stop the playback. -audioPlayer.stop(); // Trigger the 'stop' event callback. -// 9. Reset the player. -audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. -// 10. Release the resource. -audioPlayer.release(); // Release the AudioPlayer instance. -audioPlayer = undefined; ``` ### Normal Playback Scenario @@ -128,38 +116,40 @@ audioPlayer = undefined; ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -function SetCallBack(audioPlayer) { +export class AudioDemo { + // Set the player callbacks. + setCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. - console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + console.info('audio set source success'); + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); audioPlayer.on('play', () => { // Set the 'play' event callback. - console.info('audio play success'); + console.info('audio play success'); }); audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. - console.info('audio play finish'); - audioPlayer.release(); // Release the AudioPlayer instance. - audioPlayer = undefined; + console.info('audio play finish'); + audioPlayer.release(); // Release the AudioPlayer resources. + audioPlayer = undefined; + }); + } + + async audioPlayerDemo() { + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + } } - -let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. -SetCallBack(audioPlayer); // Set the event callbacks. -/* Set the FD (local playback) of the audio file selected by the user. */ -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. ``` ### Switching to the Next Song @@ -167,54 +157,62 @@ audioPlayer.src = fdPath; // Set the src attribute and ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -function SetCallBack(audioPlayer) { +export class AudioDemo { +// Set the player callbacks. + private isNextMusic = false; + setCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. - console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + console.info('audio set source success'); + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); audioPlayer.on('play', () => { // Set the 'play' event callback. - console.info('audio play success'); + console.info('audio play success'); + audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. - console.info('audio play finish'); + audioPlayer.on('reset', () => { // Set the 'reset' event callback. + console.info('audio play success'); + if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. + this.nextMusic(audioPlayer); // Changing songs is implemented. + } else { audioPlayer.release(); // Release the AudioPlayer instance. - audioPlayer = undefined; + audioPlayer = undefined; + } + }); + } + + async nextMusic(audioPlayer) { + this.isNextMusic = true; + let nextFdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. + let nextpath = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/02.mp3'; + await fileIO.open(nextpath).then((fdNumber) => { + nextFdPath = nextFdPath + '' + fdNumber; + console.info('open fd sucess fd is' + nextFdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); + }); + audioPlayer.src = nextFdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + } + + async audioPlayerDemo() { + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + } } - -let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. -SetCallBack(audioPlayer); // Set the event callbacks. -/* Set the FD (local playback) of the audio file selected by the user. */ -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. -/* Send the instruction to switch to the next song after a period of time. */ -audioPlayer.reset(); - -/* Set the FD (local playback) of the audio file selected by the user. */ -let fdNextPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/accounts/account_0/appdata" command. -let nextPath = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp3'; -await fileIO.open(nextPath).then(fdNumber) => { - fdNextPath = fdNextPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdNextPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); -audioPlayer.src = fdNextPath; ``` ### Looping a Song @@ -222,40 +220,36 @@ audioPlayer.src = fdNextPath; ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -function SetCallBack(audioPlayer) { +export class AudioDemo { + // Set the player callbacks. + setCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. - console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + console.info('audio set source success'); + audioPlayer.loop = true; // Set the loop playback attribute. + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. - console.info('audio play success'); + audioPlayer.on('play', () => { // Sets the 'play' event callback to start loop playback. + console.info('audio play success'); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. - console.info('audio play finish'); - audioPlayer.release(); // Release the AudioPlayer instance. - audioPlayer = undefined; + } + + async audioPlayerDemo() { + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); + audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + } } - -let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. -SetCallBack(audioPlayer); // Set the event callbacks. - -/* Set the FD (local playback) of the audio file selected by the user. */ -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. -audioPlayer.loop = true; // Set the loop playback attribute. ``` ## Samples @@ -263,7 +257,6 @@ audioPlayer.loop = true; // Set the loop playback att The following samples are provided to help you better understand how to develop audio playback: - [`JsDistributedMusicPlayer`: Distributed Music Player (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) - -- [`JsAudioPlayer`: Audio Playback and Management (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) - +- [`JsAudioPlayer`: Audio Playback and Management (JS, API 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) +- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md index 56f72dc5a475a6ba697e204117488c17a8c6846d..cd8d8ee0d976d6a2ee56cdb0e7ad93d2d46ac05d 100644 --- a/en/application-dev/media/audio-recorder.md +++ b/en/application-dev/media/audio-recorder.md @@ -25,46 +25,49 @@ The full audio recording process includes creating an instance, setting recordin ```js import media from '@ohos.multimedia.media' import mediaLibrary from '@ohos.multimedia.mediaLibrary' - -let testFdNumber; - -function SetCallBack(audioRecorder) { - audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. - console.log('prepare success'); - // The recording page is ready. You can click the Record button to start recording. +export class AudioRecorderDemo { + private testFdNumber; // Used to save the FD address. + + // Set the callbacks related to audio recording. + setCallBack(audioRecorder) { + audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. + console.log('prepare success'); + audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. }); - audioRecorder.on('start', () => { // Set the 'start' event callback. - console.log('audio recorder start success'); - // The Record button is changed to the pausable state. + audioRecorder.on('start', () => { // Set the 'start' event callback. + console.log('audio recorder start success'); + audioRecorder.pause(); // Call the pause API to pause recording and trigger the 'pause' event callback. }); - audioRecorder.on('pause', () => { // Set the 'pause' event callback. - console.log('audio recorder pause success'); - // The Record button is changed to the recordable state. + audioRecorder.on('pause', () => { // Set the 'pause' event callback. + console.log('audio recorder pause success'); + audioRecorder.resume(); // Call the resume API to resume recording and trigger the 'resume' event callback. }); - audioRecorder.on('resume', () => { // Set the 'resume' event callback. - console.log('audio recorder resume success'); - // The Record button is changed to the pausable state. + audioRecorder.on('resume', () => { // Set the 'resume' event callback. + console.log('audio recorder resume success'); + audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. }); - audioRecorder.on('stop', () => { // Set the 'stop' event callback. - console.log('audio recorder stop success'); + audioRecorder.on('stop', () => { // Set the 'stop' event callback. + console.log('audio recorder stop success'); + audioRecorder.reset(); // Call the reset API to reset the recorder and trigger the 'reset' event callback. }); - audioRecorder.on('release', () => { // Set the 'release' event callback. - console.log('audio recorder release success'); + audioRecorder.on('reset', () => { // Set the 'reset' event callback. + console.log('audio recorder reset success'); + audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. }); - audioRecorder.on('reset', () => { // Set the 'reset' event callback. - console.log('audio recorder reset success'); - // You need to reset the recording parameters for another recording. + audioRecorder.on('release', () => { // Set the 'release' event callback. + console.log('audio recorder release success'); + audioRecorder = undefined; }); - audioRecorder.on('error', (error) => { // Set the 'error' event callback. - 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}`); + audioRecorder.on('error', (error) => { // Set the 'error' event callback. + 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}`); }); -} + } -// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Movies/01.mp3. -// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. -async function getFd(pathName) { + // pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Video/01.mp3. + // To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. + async getFd(pathName) { let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); let fileKeyObj = mediaLibrary.FileKey; @@ -72,49 +75,37 @@ async function getFd(pathName) { 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; + 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'); + this.testFdNumber = "fd://" + fdNumber.toString(); } + } + + async audioRecorderDemo() { + // 1. Create an AudioRecorder instance. + let audioRecorder = media.createAudioRecorder(); + // 2. Set the callbacks. + this.setCallBack(audioRecorder); + await this.getFd('01.mp3'); // Call the getFd method to obtain the FD address of the file to be recorded. + // 3. Set the recording parameters. + let audioRecorderConfig = { + audioEncodeBitRate : 22050, + audioSampleRate : 22050, + numberOfChannels : 2, + uri : this.testFdNumber, // testFdNumber is generated by getFd. + location : { latitude : 30, longitude : 130}, + audioEncoderMime : media.CodecMimeType.AUDIO_AAC, + fileFormat : media.ContainerFormatType.CFT_MPEG_4A, + } + audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. + } } - -await getFd('01.mp3'); - -// 1. Create an AudioRecorder instance. -let audioRecorder = media.createAudioRecorder(); -// 2. Set the callbacks. -SetCallBack(audioRecorder); -// 3. Set the recording parameters. -let audioRecorderConfig = { - audioEncoder : media.AudioEncoder.AAC_LC , - audioEncodeBitRate : 22050, - audioSampleRate : 22050, - numberOfChannels : 2, - format : media.AudioOutputFormat.AAC_ADTS, - uri : testFdNumber, // testFdNumber is generated by getFd. - location : { latitude : 30, longitude : 130}, -} -audioRecorder.prepare(audioRecorderConfig); -// 4. Start recording. -audioRecorder.start(); // The start API can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. -// 5. Pause recording. -audioRecorder.pause(); // The pause API can be called to trigger the 'pause' event callback only after the 'start' event callback is complete. -// 6. Resume recording. -audioRecorder.resume(); // The resume API can be called to trigger the 'resume' event callback only after the 'pause' event callback is complete. -// 7. Stop recording. -audioRecorder.stop(); // The stop API can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. -// 8. Reset recording. -audioRecorder.reset(); // The prepare API can be called for another recording only after the 'reset' event callback is complete. -// 9. Release resources. -audioRecorder.release(); // The AudioRecorder resource is destroyed. -audioRecorder = undefined; ``` ### Normal Recording Scenario @@ -124,29 +115,37 @@ Unlike the full-process scenario, the normal recording scenario does not include ```js import media from '@ohos.multimedia.media' import mediaLibrary from '@ohos.multimedia.mediaLibrary' - -let testFdNumber; - -function SetCallBack(audioRecorder) { - audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. - console.log('prepare success'); - // The recording page is ready. You can click the Record button to start recording. +export class AudioRecorderDemo { + private testFdNumber; // Used to save the FD address. + + // Set the callbacks related to audio recording. + setCallBack(audioRecorder) { + audioRecorder.on('prepare', () => { // Set the 'prepare' event callback. + console.log('prepare success'); + audioRecorder.start(); // Call the start API to start recording and trigger the 'start' event callback. }); - audioRecorder.on('start', () => { // Set the 'start' event callback. - console.log('audio recorder start success'); - // The Record button is changed to the pausable state. - }); - audioRecorder.on('stop', () => { // Set the 'stop' event callback. - console.log('audio recorder stop success'); - }); - audioRecorder.on('release', () => { // Set the 'release' event callback. - console.log('audio recorder release success'); - }); -} + audioRecorder.on('start', () => { // Set the 'start' event callback. + console.log('audio recorder start success'); + audioRecorder.stop(); // Call the stop API to stop recording and trigger the 'stop' event callback. + }); + audioRecorder.on('stop', () => { // Set the 'stop' event callback. + console.log('audio recorder stop success'); + audioRecorder.release(); // Call the release API to release resources and trigger the 'release' event callback. + }); + audioRecorder.on('release', () => { // Set the 'release' event callback. + console.log('audio recorder release success'); + audioRecorder = undefined; + }); + audioRecorder.on('error', (error) => { // Set the 'error' event callback. + 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}`); + }); + } -// pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Movies/01.mp3. -// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. -async function getFd(pathName) { + // pathName indicates the passed recording file name, for example, 01.mp3. The generated file address is /storage/media/100/local/files/Video/01.mp3. + // To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. + async getFd(pathName) { let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); let fileKeyObj = mediaLibrary.FileKey; @@ -154,41 +153,43 @@ async function getFd(pathName) { 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; + 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'); + this.testFdNumber = "fd://" + fdNumber.toString(); } + } + + async audioRecorderDemo() { + // 1. Create an AudioRecorder instance. + let audioRecorder = media.createAudioRecorder(); + // 2. Set the callbacks. + this.setCallBack(audioRecorder); + await this.getFd('01.mp3'); // Call the getFd method to obtain the FD address of the file to be recorded. + // 3. Set the recording parameters. + let audioRecorderConfig = { + audioEncodeBitRate : 22050, + audioSampleRate : 22050, + numberOfChannels : 2, + uri : this.testFdNumber, // testFdNumber is generated by getFd. + location : { latitude : 30, longitude : 130}, + audioEncoderMime : media.CodecMimeType.AUDIO_AAC, + fileFormat : media.ContainerFormatType.CFT_MPEG_4A, + } + audioRecorder.prepare(audioRecorderConfig); // Call the prepare method to trigger the 'prepare' event callback. + } } - -await getFd('01.mp3'); - -// 1. Create an AudioRecorder instance. -let audioRecorder = media.createAudioRecorder(); -// 2. Set the callbacks. -SetCallBack(audioRecorder); -// 3. Set the recording parameters. -let audioRecorderConfig = { - audioEncoder : media.AudioEncoder.AAC_LC , - audioEncodeBitRate : 22050, - audioSampleRate : 22050, - numberOfChannels : 2, - format : media.AudioOutputFormat.AAC_ADTS, - uri : testFdNumber, // testFdNumber is generated by getFd. - location : { latitude : 30, longitude : 130}, -} -audioRecorder.prepare(audioRecorderConfig) -// 4. Start recording. -audioRecorder.start(); // The start API can be called to trigger the 'start' event callback only after the 'prepare' event callback is complete. -// 5. Stop recording. -audioRecorder.stop(); // The stop API can be called to trigger the 'stop' event callback only after the 'start' or 'resume' event callback is complete. -// 6. Release resources. -audioRecorder.release(); // The AudioRecorder resource is destroyed. -audioRecorder = undefined; ``` + +## Samples + +The following samples are provided to help you better understand how to develop audio recording: + +- [`Recorder`: Recorder (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) +- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index 7520e2cfdc687e8596afa9558e3935812650ece5..49f0f084420b7302806ea46833636815ab12ade0 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -2,7 +2,7 @@ ## When to Use -You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes the following video playback development scenarios: full-process, normal playback, video switching, and loop playback. +You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback. **Figure 1** Video playback state transition @@ -22,11 +22,11 @@ Note: Video playback requires hardware capabilities such as display, audio, and ## Compatibility -You are advised to use the mainstream playback formats and resolutions, rather than custom or abnormal streams to avoid playback failure, frame freezing, and artifacts. The system is not affected by incompatibility issues. If such an error occurs, you can exit stream playback mode. +Use the mainstream playback formats and resolutions, rather than custom ones to avoid playback failures, frame freezing, and artifacts. The system is not affected by incompatibility issues. If such an issue occurs, you can exit stream playback mode. The table below lists the mainstream playback formats and resolutions. -| Video Container Specification| Specification Description | Resolution | +| Video Container Format| Description | Resolution | | :----------: | :-----------------------------------------------: | :--------------------------------: | | mp4 | Video format: H.264/MPEG-2/MPEG-4/H.263; audio format: AAC/MP3| Mainstream resolutions, such as 1080p, 720p, 480p, and 270p| | mkv | Video format: H.264/MPEG-2/MPEG-4/H.263; audio format: AAC/MP3| Mainstream resolutions, such as 1080p, 720p, 480p, and 270p| @@ -41,143 +41,137 @@ For details about the APIs, see [VideoPlayer in the Media API](../reference/apis The full video playback process includes creating an instance, setting the URL, setting the surface ID, preparing for video playback, playing video, pausing playback, obtaining track information, seeking to a playback position, setting the volume, setting the playback speed, stopping playback, resetting the playback configuration, and releasing resources. -For details about the **url** media source input types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes). +For details about the **url** types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes). -For details about how to create an XComponent, see [XComponent Creation](#xcomponent-creation). +For details about how to create an XComponent, see [XComponent](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md). -*Note: **SetSurface** must be called after the URL is set but before **Prepare** is called. +*Note: **setSurface** must be called after the URL is set but before **prepare** is called. ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. -let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface. - -// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded. -LoadXcomponent() { - surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); - console.info('LoadXcomponent surfaceID is' + surfaceID); -} - -// Report an error in the case of a function invocation failure. -function failureCallback(error) { +export class VideoPlayerDemo { + // Report an error in the case of a function invocation failure. + 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}`); -} + } -// Report an error in the case of a function invocation exception. -function catchCallback(error) { + // Report an error in the case of a function invocation exception. + 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}`); -} + } -// Used to print the video track information. -function printfDescription(obj) { + // Used to print the video track information. + printfDescription(obj) { for (let item in obj) { - let property = obj[item]; - console.info('key is ' + item); - console.info('value is ' + property); + let property = obj[item]; + console.info('key is ' + item); + console.info('value is ' + property); } -} - -// Call createVideoPlayer to create a VideoPlayer instance. -await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + } + + async videoPlayerDemo() { + let videoPlayer = undefined; + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); + }); + // Call createVideoPlayer to create a VideoPlayer instance. + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { console.info('createVideoPlayer success!'); videoPlayer = video; - } else { + } else { console.info('createVideoPlayer fail!'); - } -}, failureCallback).catch(catchCallback); - -// Set the FD (local playback) of the video file selected by the user. -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -videoPlayer.url = fdPath; - -// Set the surface ID to display the video image. -await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('setDisplaySurface success'); -}, failureCallback).catch(catchCallback); - -// Call the prepare interface to prepare for playback. -await videoPlayer.prepare().then(() => { - console.info('prepare success'); -}, failureCallback).catch(catchCallback); - -// Call the play interface to start playback. -await videoPlayer.play().then(() => { - console.info('play success'); -}, failureCallback).catch(catchCallback); - -// Pause playback. -await videoPlayer.pause().then(() => { - console.info('pause success'); -}, failureCallback).catch(catchCallback); - -// Use a promise to obtain the video track information. -let arrayDescription; -await videoPlayer.getTrackDescription().then((arrlist) => { - if (typeof (arrlist) != 'undefined') { + } + }, this.failureCallback).catch(this.catchCallback); + // Set the playback source URL for the player. + videoPlayer.url = fdPath; + + // Set the surface ID to display the video image. + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + console.info('setDisplaySurface success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the prepare API to prepare for playback. + await videoPlayer.prepare().then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the play API to start playback. + await videoPlayer.play().then(() => { + console.info('play success'); + }, this.failureCallback).catch(this.catchCallback); + + // Pause playback. + await videoPlayer.pause().then(() => { + console.info('pause success'); + }, this.failureCallback).catch(this.catchCallback); + + // Use a promise to obtain the video track information. + let arrayDescription; + await videoPlayer.getTrackDescription().then((arrlist) => { + if (typeof (arrlist) != 'undefined') { arrayDescription = arrlist; - } else { + } else { console.log('video getTrackDescription fail'); + } + }, this.failureCallback).catch(this.catchCallback); + + for (let i = 0; i < arrayDescription.length; i++) { + this.printfDescription(arrayDescription[i]); } -}, failureCallback).catch(catchCallback); -for (let i = 0; i < arrayDescription.length; i++) { - printfDescription(arrayDescription[i]); + // Seek to the 50s position. For details about the input parameters, see the interface document. + let seekTime = 50000; + await videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + console.info('seek success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the volume. For details about the input parameters, see the interface document. + let volume = 0.5; + await videoPlayer.setVolume(volume).then(() => { + console.info('setVolume success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the playback speed. For details about the input parameters, see the interface document. + let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; + await videoPlayer.setSpeed(speed).then(() => { + console.info('setSpeed success'); + }, this.failureCallback).catch(this.catchCallback); + + // Stop playback. + await videoPlayer.stop().then(() => { + console.info('stop success'); + }, this.failureCallback).catch(this.catchCallback); + + // Reset the playback configuration. + await videoPlayer.reset().then(() => { + console.info('reset success'); + }, this.failureCallback).catch(this.catchCallback); + + // Release playback resources. + await videoPlayer.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the related instances to undefined. + videoPlayer = undefined; + surfaceID = undefined; + } } - -// Seek to the 50s position. For details about the input parameters, see the interface document. -let seekTime = 50000; -await videoPlayer.seek(seekTime, media.SeekMode._NEXT_SYNC).then((seekDoneTime) => { - console.info('seek success'); -}, failureCallback).catch(catchCallback); - -// Set the volume. For details about the input parameters, see the interface document. -let volume = 0.5; -await videoPlayer.setVolume(volume).then(() => { - console.info('setVolume success'); -}, failureCallback).catch(catchCallback); - -// Set the playback speed. For details about the input parameters, see the interface document. -let speed = media.PlaybackRateMode.SPEED_FORWARD_2_00_X; -await videoPlayer.setSpeed(speed).then(() => { - console.info('setSpeed success'); -}, failureCallback).catch(catchCallback); - -// Stop playback. -await videoPlayer.stop().then(() => { - console.info('stop success'); -}, failureCallback).catch(catchCallback); - -// Reset the playback configuration. -await videoPlayer.reset().then(() => { - console.info('reset success'); -}, failureCallback).catch(catchCallback); - -// Release playback resources. -await videoPlayer.release().then(() => { - console.info('release success'); -}, failureCallback).catch(catchCallback); - -// Set the related instances to undefined. -videoPlayer = undefined; -surfaceID = undefined; ``` ### Normal Playback Scenario @@ -185,86 +179,86 @@ surfaceID = undefined; ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. -let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface. - -// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded. -LoadXcomponent() { - surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); - console.info('LoadXcomponent surfaceID is' + surfaceID); -} - -// Report an error in the case of a function invocation failure. -function failureCallback(error) { +export class VideoPlayerDemo { + // Report an error in the case of a function invocation failure. + 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}`); -} + } -// Report an error in the case of a function invocation exception. -function catchCallback(error) { + // Report an error in the case of a function invocation exception. + 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}`); -} + } -// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete. -function SetCallBack(videoPlayer) { - videoPlayer.on('playbackCompleted', () => { - console.info('video play finish'); - - await videoPlayer.release().then(() => { - console.info('release success'); - }, failureCallback).catch(catchCallback); - - videoPlayer = undefined; - surfaceID = undefined; + // Used to print the video track information. + printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('key is ' + item); + console.info('value is ' + property); + } + } + + async videoPlayerDemo() { + let videoPlayer = undefined; + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); -} - -// Call createVideoPlayer to create a VideoPlayer instance. -await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + // Call createVideoPlayer to create a VideoPlayer instance. + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { console.info('createVideoPlayer success!'); videoPlayer = video; - } else { + } else { console.info('createVideoPlayer fail!'); - } -}, failureCallback).catch(catchCallback); - -// Set the event callbacks. -SetCallBack(videoPlayer); - -// Set the FD (local playback) of the video file selected by the user. -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -videoPlayer.url = fdPath; - -// Set the surface ID to display the video image. -await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('setDisplaySurface success'); -}, failureCallback).catch(catchCallback); - -// Call the prepare interface to prepare for playback. -await videoPlayer.prepare().then(() => { - console.info('prepare success'); -}, failureCallback).catch(catchCallback); - -// Call the play interface to start playback. -await videoPlayer.play().then(() => { - console.info('play success'); -}, failureCallback).catch(catchCallback); + } + }, this.failureCallback).catch(this.catchCallback); + // Set the playback source for the player. + videoPlayer.url = fdPath; + + // Set the surface ID to display the video image. + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + console.info('setDisplaySurface success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the prepare API to prepare for playback. + await videoPlayer.prepare().then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the play API to start playback. + await videoPlayer.play().then(() => { + console.info('play success'); + }, this.failureCallback).catch(this.catchCallback); + + // Stop playback. + await videoPlayer.stop().then(() => { + console.info('stop success'); + }, this.failureCallback).catch(this.catchCallback); + + // Release playback resources. + await videoPlayer.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the related instances to undefined. + videoPlayer = undefined; + surfaceID = undefined; + } +} ``` ### Switching to the Next Video Clip @@ -272,122 +266,110 @@ await videoPlayer.play().then(() => { ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. -let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface. - -// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded. -LoadXcomponent() { - surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); - console.info('LoadXcomponent surfaceID is' + surfaceID); -} - -// Report an error in the case of a function invocation failure. -function failureCallback(error) { +export class VideoPlayerDemo { + // Report an error in the case of a function invocation failure. + 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}`); -} + } -// Report an error in the case of a function invocation exception. -function catchCallback(error) { + // Report an error in the case of a function invocation exception. + 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}`); -} + } -// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete. -function SetCallBack(videoPlayer) { - videoPlayer.on('playbackCompleted', () => { - console.info('video play finish'); - - await videoPlayer.release().then(() => { - console.info('release success'); - }, failureCallback).catch(catchCallback); - - videoPlayer = undefined; - surfaceID = undefined; + // Used to print the video track information. + printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('key is ' + item); + console.info('value is ' + property); + } + } + + async videoPlayerDemo() { + let videoPlayer = undefined; + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; + let nextPath = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/MP4_AAC.mp4'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); -} - -// Call createVideoPlayer to create a VideoPlayer instance. -await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + // Call createVideoPlayer to create a VideoPlayer instance. + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { console.info('createVideoPlayer success!'); videoPlayer = video; - } else { + } else { console.info('createVideoPlayer fail!'); - } -}, failureCallback).catch(catchCallback); - -// Set the event callbacks. -SetCallBack(videoPlayer); - -// Set the FD (local playback) of the video file selected by the user. -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -videoPlayer.url = fdPath; - -// Set the surface ID to display the video image. -await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('setDisplaySurface success'); -}, failureCallback).catch(catchCallback); - -// Call the prepare interface to prepare for playback. -await videoPlayer.prepare().then(() => { - console.info('prepare success'); -}, failureCallback).catch(catchCallback); - -// Call the play interface to start playback. -await videoPlayer.play().then(() => { - console.info('play success'); -}, failureCallback).catch(catchCallback); - -// Send the instruction to switch to the next video clip after a period of time. -// Reset the playback configuration. -await videoPlayer.reset().then(() => { - console.info('reset success'); -}, failureCallback).catch(catchCallback); - -// Set the FD (local playback) of the video file selected by the user. -let fdNextPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/accounts/account_0/appdata" command. -let nextPath = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp4'; -await fileIO.open(nextPath).then(fdNumber) => { - fdNextPath = fdNextPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdNextPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -videoPlayer.url = fdNextPath; - -// Set the surface ID to display the video image. -await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('setDisplaySurface success'); -}, failureCallback).catch(catchCallback); - -// Call the prepare interface to prepare for playback. -await videoPlayer.prepare().then(() => { - console.info('prepare success'); -}, failureCallback).catch(catchCallback); - -// Call the play interface to start playback. -await videoPlayer.play().then(() => { - console.info('play success'); -}, failureCallback).catch(catchCallback); + } + }, this.failureCallback).catch(this.catchCallback); + // Set the playback source for the player. + videoPlayer.url = fdPath; + + // Set the surface ID to display the video image. + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + console.info('setDisplaySurface success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the prepare API to prepare for playback. + await videoPlayer.prepare().then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the play API to start playback. + await videoPlayer.play().then(() => { + console.info('play success'); + }, this.failureCallback).catch(this.catchCallback); + + // Reset the playback configuration. + await videoPlayer.reset().then(() => { + console.info('reset success'); + }, this.failureCallback).catch(this.catchCallback); + + // Obtain the next video FD address. + fdPath = 'fd://' + await fileIO.open(nextPath).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); + }); + // Set the second video playback source. + videoPlayer.url = fdPath; + + // Call the prepare interface to prepare for playback. + await videoPlayer.prepare().then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the play API to start playback. + await videoPlayer.play().then(() => { + console.info('play success'); + }, this.failureCallback).catch(this.catchCallback); + + // Release playback resources. + await videoPlayer.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the related instances to undefined. + videoPlayer = undefined; + surfaceID = undefined; + } +} ``` ### Looping a Video Clip @@ -395,100 +377,88 @@ await videoPlayer.play().then(() => { ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' - -let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. -let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface. - -// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded. -LoadXcomponent() { - surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); - console.info('LoadXcomponent surfaceID is' + surfaceID); -} - -// Report an error in the case of a function invocation failure. -function failureCallback(error) { +export class VideoPlayerDemo { + // Report an error in the case of a function invocation failure. + 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}`); -} + } -// Report an error in the case of a function invocation exception. -function catchCallback(error) { + // Report an error in the case of a function invocation exception. + 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}`); -} + } -// Set the 'playbackCompleted' event callback, which is triggered when the playback is complete. -function SetCallBack(videoPlayer) { - videoPlayer.on('playbackCompleted', () => { - console.info('video play finish'); - - await videoPlayer.release().then(() => { - console.info('release success'); - }, failureCallback).catch(catchCallback); - - videoPlayer = undefined; - surfaceID = undefined; + // Used to print the video track information. + printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('key is ' + item); + console.info('value is ' + property); + } + } + + sleep(time) { + for(let t = Date.now(); Date.now() - t <= time;); + } + + async videoPlayerDemo() { + let videoPlayer = undefined; + let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent interface. For details about the document link, see the method of creating the XComponent. + let fdPath = 'fd://' + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command. + let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4'; + await fileIO.open(path).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); + }, (err) => { + console.info('open fd failed err is' + err); + }).catch((err) => { + console.info('open fd failed err is' + err); }); -} - -// Call createVideoPlayer to create a VideoPlayer instance. -await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + // Call createVideoPlayer to create a VideoPlayer instance. + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { console.info('createVideoPlayer success!'); videoPlayer = video; - } else { + } else { console.info('createVideoPlayer fail!'); - } -}, failureCallback).catch(catchCallback); - -// Set the event callbacks. -SetCallBack(videoPlayer); - -// Set the FD (local playback) of the video file selected by the user. -let fdPath = 'fd://' -// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command. -let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; -await fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; - console.info('open fd sucess fd is' + fdPath); -}, (err) => { - console.info('open fd failed err is' + err); -}),catch((err) => { - console.info('open fd failed err is' + err); -}); - -videoPlayer.url = fdPath; - -// Set the surface ID to display the video image. -await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('setDisplaySurface success'); -}, failureCallback).catch(catchCallback); - -// Call the prepare interface to prepare for playback. -await videoPlayer.prepare().then(() => { - console.info('prepare success'); -}, failureCallback).catch(catchCallback); - -// Set the loop playback attribute. -videoPlayer.loop = true; - -// Call the play interface to start playback. -await videoPlayer.play().then(() => { - console.info('play success'); -}, failureCallback).catch(catchCallback); -``` - -### XComponent Creation - -The XComponent is used to obtain the surface ID during video playback. You need to create an xxx.hml file and add the following code to the xxx.hml file, where xxx is the same as that in the xxx.js file: - -```js - // Set the window width, height, and other attributes. - + } + }, this.failureCallback).catch(this.catchCallback); + // Set the playback source for the player. + videoPlayer.url = fdPath; + + // Set the surface ID to display the video image. + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + console.info('setDisplaySurface success'); + }, this.failureCallback).catch(this.catchCallback); + + // Call the prepare API to prepare for playback. + await videoPlayer.prepare().then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + // Set the loop playback attribute. + videoPlayer.loop = true; + // Call the play API to start playback. + await videoPlayer.play().then(() => { + console.info('play success'); + }, this.failureCallback).catch(this.catchCallback); + // After the progress bar reaches the end, the playback continues for 3 seconds and then starts from the beginning, since loop playback is configured. + await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + console.info('seek duration success'); + }, this.failureCallback).catch(this.catchCallback); + this.sleep(3000); + // Release playback resources. + await videoPlayer.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the related instances to undefined. + videoPlayer = undefined; + surfaceID = undefined; + } +} ``` diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md index dc036c1240e48732e063e45841d93a4c1f766f9f..f77052fa5ea8e21d48f9a6f11c4636c88483d9c0 100644 --- a/en/application-dev/media/video-recorder.md +++ b/en/application-dev/media/video-recorder.md @@ -16,21 +16,20 @@ During video recording, audio and video signals are captured, encoded, and saved ## How to Develop -For details about the APIs used for video recording, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md). +For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md). ### Full-Process Scenario -The full video recording process includes creating an instance, setting recording parameters, recording video, pausing, resuming, and stopping recording, and releasing resources. +The full video recording process includes creating an instance, setting recording parameters, starting, pausing, resuming, and stopping recording, and releasing resources. ```js import media from '@ohos.multimedia.media' import mediaLibrary from '@ohos.multimedia.mediaLibrary' - -let testFdNumber; - -// pathName indicates the passed recording file name, for example, 01.mp4. The generated file address is /storage/media/100/local/files/Movies/01.mp4. -// To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. -async function getFd(pathName) { +export class VideoRecorderDemo { + private testFdNumber; // Used to save the FD address. + // pathName indicates the passed recording file name, for example, 01.mp4. The generated file address is /storage/media/100/local/files/Video/01.mp4. + // To use the media library, declare the following permissions: ohos.permission.MEDIA_LOCATION, ohos.permission.WRITE_MEDIA, and ohos.permission.READ_MEDIA. + async getFd(pathName) { let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); let fileKeyObj = mediaLibrary.FileKey; @@ -38,110 +37,115 @@ async function getFd(pathName) { 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; + 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'); + this.testFdNumber = "fd://" + fdNumber.toString(); + } + } + + // Error callback triggered in the case of an error + 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); + } + + // Error callback triggered in the case of an exception + 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); + } + + async videoRecorderDemo() { + let videoRecorder = null; // videoRecorder is an empty object and assigned with a value after createVideoRecorder is successfully called. + let surfaceID = null; // Used to save the surface ID returned by getInputSurface. + // Obtain the FD address of the video to be recorded. + await this.getFd('01.mp4'); + // Recording-related parameter settings + 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 } -} - -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 is generated by getFd. - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, -} - -// Error callback triggered in the case of an error -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); -} - -// Error callback triggered in the case of an exception -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 is an empty object and assigned with a value after createVideoRecorder is successfully called. -let surfaceID = null; // Used to save the surface ID returned by getInputSurface. - -// Create a VideoRecorder object. -await media.createVideoRecorder().then((recorder) => { - console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + let videoConfig = { + audioSourceType : 1, + videoSourceType : 0, + profile : videoProfile, + url : this.testFdNumber, // testFdNumber is generated by getFd. + orientationHint : 0, + location : { latitude : 30, longitude : 130 }, + } + // Create a VideoRecorder object. + await media.createVideoRecorder().then((recorder) => { + console.info('case createVideoRecorder called'); + if (typeof (recorder) != 'undefined') { videoRecorder = recorder; console.info('createVideoRecorder success'); - } else { + } else { console.info('createVideoRecorder failed'); - } -}, failureCallback).catch(catchCallback); - -// Obtain the surface ID, save it, and pass it to camera-related interfaces. -await videoRecorder.getInputSurface().then((surface) => { - console.info('getInputSurface success'); - surfaceID = surface; -}, failureCallback).catch(catchCallback); - -// Video recording depends on camera-related interfaces. The following operations can be performed only after the video output start interface is invoked. - -// Start video recording. -await videoRecorder.start().then(() => { - console.info('start success'); -}, failureCallback).catch(catchCallback); - -// Pause video playback before the video output stop interface is invoked. -await videoRecorder.pause().then(() => { - console.info('pause success'); -}, failureCallback).catch(catchCallback); - -// Resume video playback after the video output start interface is invoked. -await videoRecorder.resume().then(() => { - console.info('resume success'); -}, failureCallback).catch(catchCallback); - -// Stop video recording after the video output stop interface is invoked. -await videoRecorder.stop().then(() => { - console.info('stop success'); -}, failureCallback).catch(catchCallback); - -// Reset the recording configuration. -await videoRecorder.reset().then(() => { - console.info('reset success'); -}, failureCallback).catch(catchCallback); - -// Release the video recording resources and camera object resources. -await videoRecorder.release().then(() => { - console.info('release success'); -}, failureCallback).catch(catchCallback); - -// Set the related object to null. -videoRecorder = null; -surfaceID = null; + } + }, this.failureCallback).catch(this.catchCallback); + + // Call the prepare API to prepare for video recording. + await videoRecorder.prepare(videoConfig).then(() => { + console.info('prepare success'); + }, this.failureCallback).catch(this.catchCallback); + + // Obtain the surface ID, save it, and pass it to camera-related APIs. + await videoRecorder.getInputSurface().then((surface) => { + console.info('getInputSurface success'); + surfaceID = surface; + }, this.failureCallback).catch(this.catchCallback); + + // Video recording depends on camera-related APIs. The following operations can be performed only after the video output start API is invoked. For details about how to call the camera APIs, see the samples. + // Start video recording. + await videoRecorder.start().then(() => { + console.info('start success'); + }, this.failureCallback).catch(this.catchCallback); + + // Pause video recording before the video output stop API of the camera is invoked. + await videoRecorder.pause().then(() => { + console.info('pause success'); + }, this.failureCallback).catch(this.catchCallback); + + // Resume video recording after the video output start API of the camera is invoked. + await videoRecorder.resume().then(() => { + console.info('resume success'); + }, this.failureCallback).catch(this.catchCallback); + + // Stop video recording after the video output stop API of the camera is invoked. + await videoRecorder.stop().then(() => { + console.info('stop success'); + }, this.failureCallback).catch(this.catchCallback); + + // Reset the recording configuration. + await videoRecorder.reset().then(() => { + console.info('reset success'); + }, this.failureCallback).catch(this.catchCallback); + + // Release the video recording resources and camera object resources. + await videoRecorder.release().then(() => { + console.info('release success'); + }, this.failureCallback).catch(this.catchCallback); + + // Set the related object to null. + videoRecorder = undefined; + surfaceID = undefined; + } +} ``` diff --git a/en/application-dev/napi/napi-guidelines.md b/en/application-dev/napi/napi-guidelines.md index 0a1b7b89b46bc1c07311f110c6b5c654191d3a71..f2b6fe0e20564626d7a37d03832fae69f7f7866a 100644 --- a/en/application-dev/napi/napi-guidelines.md +++ b/en/application-dev/napi/napi-guidelines.md @@ -1,37 +1,37 @@ # Using Native APIs in Application Projects -OpenHarmony applications need to use JavaScript (JS) when calling native APIs. The napi interfaces provided by the **arkui_napi** repository are used to implement the interaction with JS. Currently, the **arkui_napi** repository supports some third-party **Node.js** interfaces. The names of the napi interfaces are the same as those in the third-party **Node.js**. For details about the interfaces supported, see `libnapi.ndk.json` in this repository. +OpenHarmony applications use JavaScript (JS) when calling native APIs. The native APIs (NAPIs) provided by the **arkui_napi** repository are used to implement the interaction with JS. Currently, the **arkui_napi** repository supports some third-party **Node.js** interfaces. The names of the NAPIs are the same as those in the third-party **Node.js**. For details about the interfaces supported, see `libnapi.ndk.json` in this repository. ## How to Develop -The IDE has a default project that uses native APIs. You can choose `File` > `New` > `Create Project` to create a `Native C++` project. The cpp directory is generated in the main directory. You can use the napi interfaces provided by the **arkui_napi** repository for development. +The IDE has a default project that uses NAPIs. You can choose `File` > `New` > `Create Project` to create a `Native C++` project. The **cpp** directory is generated in the **main** directory. You can use the NAPIs provided by the **arkui_napi** repository for development. -You can `import` the native .so that contains the JS processing logic. For example, `import hello from 'libhello.so'` to use the **libhello.so** capability. Then, the JS object created using the NAPI interface can be passed to the `hello` object of the application to call the native capability. +You can `import` the native .so that contains the JS processing logic. For example, `import hello from 'libhello.so'` to use the **libhello.so** capability. Then, the JS object created using the NAPI can be passed to the `hello` object of the application to call the native capability. ## Development Guidelines ### Registration * Add **static** to the **nm_register_func** function to prevent symbol conflicts with other .so files. -* The name of the module registration entry, that is, the function modified by **\_\_attribute\_\_((constructor))**, must be unique. +* The name of the module registration entry, that is, the function decorated by **\_\_attribute\_\_((constructor))**, must be unique. ### .so Naming Rules Each module has a .so file. For example, if the module name is `hello`, name the .so file **libhello.so**. The `nm_modname` field in `napi_module` must be `hello`, which is the same as the module name. The sample code for importing the .so file is `import hello from 'libhello.so'`. ### JS Objects and Threads -The Ark engine prevents napi interfaces from being called to operate JS objects in non-JS threads. Otherwise, the application will crash. +The Ark engine prevents NAPIs from being called to operate JS objects in non-JS threads. Otherwise, the application will crash. -* The napi interfaces can be used only in JS threads. -* **env** is bound to a thread and cannot be used across threads. The JS object created by a native API can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread. +* The NAPIs can be used only in JS threads. +* **env** is bound to a thread and cannot be used across threads. The JS object created by a NAPI can be used only in the thread, in which the object is created, that is, the JS object is bound to the **env** of the thread. ### napi_create_async_work **napi_create_async_work** has two callbacks: -* **execute**: processes service logic asynchronously. This callback is not executed by a JS thread, therefore, it cannot call any NAPI interface. The return value of **execute** is processed by the **complete** callback. +* **execute**: processes service logic asynchronously. This callback is not executed by a JS thread; therefore, it cannot call any NAPI. The return value of **execute** is processed by the **complete** callback. -* **complete**: calls the napi interface to encapsulate the return value of **execute** into a JS object and return it for processing. This callback is executed by a JS thread. +* **complete**: calls the NAPI to encapsulate the return value of **execute** into a JS object and return it for processing. This callback is executed by a JS thread. ```c++ napi_status napi_create_async_work(napi_env env, @@ -45,7 +45,7 @@ napi_status napi_create_async_work(napi_env env, -## Example 1 Encapsulating Synchronous and Asynchronous APIs for the Storage Module +## Example 1: Encapsulating Synchronous and Asynchronous APIs for the Storage Module ### Overview @@ -131,7 +131,7 @@ static napi_value JSStorageGetSync(napi_env env, napi_callback_info info) char value[128] = {0}; size_t valueLen = 0; - // parse parameters + // Parse parameters. for (size_t i = 0; i < argc; i++) { napi_valuetype valueType; napi_typeof(env, argv[i], &valueType); @@ -212,7 +212,7 @@ static napi_value JSStorageGet(napi_env env, napi_callback_info info) napi_create_async_work( env, nullptr, resource, - // Callback 1: This callback contains the service logic to be asynchronously executed and is asynchronously executed by the napi interface. Do not operate JS objects using the napi interface because the execution is asynchronous. + // Callback 1: This callback contains the service logic to be asynchronously executed and is asynchronously executed by the NAPI. Do not operate JS objects using theNAPI because the execution is asynchronous. [](napi_env env, void* data) { StorageAsyncContext* asyncContext = (StorageAsyncContext*)data; auto itr = gKeyValueStorage.find(asyncContext->key); @@ -239,10 +239,10 @@ static napi_value JSStorageGet(napi_env env, napi_callback_info info) if (asyncContext->deferred) { // If a promise is used, check the result of callback 1. if (!asyncContext->status) { - // Triggered when callback 1 is successful (status is 1), that is, invoke the callback passed in then in the promise. + // Triggered when callback 1 is successful (status is 1), that is, to invoke the callback passed in then in the promise. napi_resolve_deferred(env, asyncContext->deferred, result[1]); } else { - // Triggered when callback 1 fails (status is 0), that is, invoke the callback passed in catch in the promise. + // Triggered when callback 1 fails (status is 0), that is, to invoke the callback passed in catch in the promise. napi_reject_deferred(env, asyncContext->deferred, result[0]); } } else { @@ -287,11 +287,11 @@ export default { -## Example 2 Binding Native and JS Objects for the NetServer Module +## Example 2: Binding Native and JS Objects for the NetServer Module ### Overview -This example shows how to implement the `on/off/once` method and bind C++ and JS objects using the **wrap** API. The NetServer module implements a network service. +This example shows how to implement the `on/off/once` method and bind C++ and JS objects using the **wrap** API. The NetServer module implements the network service. ### API Declaration @@ -486,11 +486,11 @@ export default { -## Example 3 Calling Back a JS API in a Non-JS Thread +## Example 3: Calling Back a JS API in a Non-JS Thread ### Overview -This example describes how to invoke a JS callback in a non-JS thread. For example, a sensor listener is registered for a JS application. The sensor data is reported by an SA. When the SA invokes the client through Inter-Process Communication (IPC), the execution thread is an IPC thread, which is different from the JS thread of the application. In this case, the JS callback must be thrown to the JS thread to execute. Otherwise, the application will crash. +This example describes how to invoke a JS callback in a non-JS thread. For example, a sensor listener is registered for a JS application. The sensor data is reported by an SA. When the SA invokes the client through Inter-Process Communication (IPC), the execution thread is an IPC thread, which is different from the JS thread of the SA. In this case, the JS callback must be thrown to the JS thread to execute. Otherwise, the application will crash. ### Implementation @@ -513,7 +513,7 @@ static napi_value CallbackExport(napi_env env, napi_value exports) return exports; } -// Define the callback +// Define the callback. static napi_module callbackModule = { .nm_version = 1, .nm_flags = 0, @@ -524,7 +524,7 @@ static napi_module callbackModule = { .reserved = { 0 }, }; -// Register the callback +// Register the callback. extern "C" __attribute__((constructor)) void CallbackTestRegister() { napi_module_register(&callbackModule); @@ -574,7 +574,7 @@ void callbackTest(CallbackContext* context) return; } - // Call napi interfaces. + // Call the NAPIs. napi_value callback = nullptr; napi_get_reference_value(context->env, context->callbackRef, &callback); napi_value retArg; diff --git a/en/application-dev/quick-start/basic-resource-file-categories.md b/en/application-dev/quick-start/basic-resource-file-categories.md index db223b338d505727b8194c50ebc2e228daed89ec..41d37718c3bb8b20feda1e4c8e5e8c32c256f3e4 100644 --- a/en/application-dev/quick-start/basic-resource-file-categories.md +++ b/en/application-dev/quick-start/basic-resource-file-categories.md @@ -5,7 +5,7 @@ All the application resource files, such as strings, images, and audio files, are stored in the **resources** directory, allowing you to easily access, use, and maintain them. The **resources** directory consists of two types of sub-directories: the **base** sub-directory and qualifiers sub-directories, and the **rawfile** sub-directory. For details, see Categories of the **resources** directory. - Example of the **resources** directory: +Example of the **resources** directory: ``` resources @@ -22,13 +22,13 @@ resources |---rawfile // Default directory ``` - **Table 1** Categories of the **resources** directory +**Table 1** Categories of the **resources** directory -| Category | base and Qualifiers Sub-directories | rawfile Sub-directory | +| Category | base and Qualifiers Sub-directories | rawfile Sub-directory | | -------- | -------- | -------- | -| Structure | Sub-directories are structured in two levels. The directory name must comply with specified naming conventions so that its target resource file in the correct directory can be matched based on the device status.
  The **base** sub-directory and qualifiers sub-directories are the first level of sub-directories under **resources**.
- The **base** sub-directory is generated by default. 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. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).
Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** sub-directory will not be matched based on the device status. | -| Compilation | Resource files in the sub-directories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | -| Reference | Resource files in the sub-directories are referenced based on the resource type and resource name. | Resource files in the sub-directories are referenced based on the specified file path and file name. | +| Structure | Sub-directories are structured in two levels. The directory name must comply with specified naming conventions so that its target resource file in the correct directory can be matched based on the device status.
The **base** sub-directory and qualifiers sub-directories are the first level of sub-directories under **resources**.
- The **base** sub-directory is generated by default. 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. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).
Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** sub-directory will not be matched based on the device status. | +| Compilation | Resource files in the sub-directories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | +| Reference | Resource files in the sub-directories are referenced based on the resource type and resource name. | Resource files in the sub-directories are referenced based on the specified file path and file name. | ## Qualifiers Sub-directories @@ -39,21 +39,22 @@ The name of a qualifiers sub-directory consists of one or more qualifiers that r - Qualifiers are ordered in the following sequence: _MCC_MNC-language_script_country/region-screen orientation-device type-color mode-screen density_. You can select one or multiple qualifiers to name your sub-directory based on your application scenarios and device characteristics. -- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (_); the MNC and MCC qualifiers are also separated using underscores (_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. +- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. - Value range of qualifiers: The value of each qualifier must meet the requirements. Otherwise, the resource files in the sub-directory cannot be matched. - **Table 2** Requirements for qualifier values + + **Table 2** Requirements for qualifier values - | Qualifier Type | Description and Value Range | + | Qualifier Type | Description and Value Range | | -------- | -------- | - | MCC&MNC | Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (_) in between or be used independently. For example, **mcc460** represents China, and **mcc460_mnc00** represents China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions). | - | Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages). | - | Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, **Hans** indicates simplified Chinese and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts). | - | Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, **CN** indicates China and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions). | - | Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation | - | Device type | Indicates the device type. The value can be:
- **phone**: smartphones
- **tablet**: tablets
- **car**: head units
- **tv**: smart TVs
- **wearable**: wearables | - | Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode | - | Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640]. | + | MCC&MNC | Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (_) in between or be used independently. For example, **mcc460** represents China, and **mcc460_mnc00** represents China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions). | + | Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages). | + | Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, **Hans** indicates simplified Chinese and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts). | + | Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, **CN** indicates China and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions). | + | Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation | + | Device type | Indicates the device type. The value can be:
- **phone**: smartphones
- **tablet**: tablets
- **car**: head units
- **tv**: smart TVs
- **wearable**: wearables | + | Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode | + | Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640]. | **Rules for Matching Qualifiers Sub-directories and Device Resources** @@ -66,14 +67,13 @@ The name of a qualifiers sub-directory consists of one or more qualifiers that r You can create resource group sub-directories (including element, media, animation, layout, graphic, and profile) in the **base** and qualifiers sub-directories to store resource files of specific types. For details, see Resource group sub-directories. +**Table 3** Resource group sub-directories - **Table 3** Resource group sub-directories - -| Resource Group Sub-directory | Description | Resource File | +| Resource Group Sub-directory | Description | Resource File | | -------- | -------- | -------- | -| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integer
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data | It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | -| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | -| animation | Indicates animation resources, in XML format. | The file name can be customized, for example, **zoom_in.xml**. | -| layout | Indicates layout resources, in XML format. | The file name can be customized, for example, **home_layout.xml**. | -| graphic | Indicates graphic resources, in XML format. | The file name can be customized, for example, **notifications_dark.xml**. | -| profile | Indicates other types of files, which are stored in their raw formats. | The file name can be customized. | +| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integer
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data | It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | +| animation | Indicates animation resources, in XML format. | The file name can be customized, for example, **zoom_in.xml**. | +| layout | Indicates layout resources, in XML format. | The file name can be customized, for example, **home_layout.xml**. | +| graphic | Indicates graphic resources, in XML format. | The file name can be customized, for example, **notifications_dark.xml**. | +| profile | Indicates other types of files, which are stored in their raw formats. | The file name can be customized. | diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/module-structure.md index 32f6801185a2514e54fab437529702a1e7317c4c..ef19d2b394b87375811dd483ab162d81a7068b4a 100644 --- a/en/application-dev/quick-start/module-structure.md +++ b/en/application-dev/quick-start/module-structure.md @@ -4,40 +4,40 @@ When developing an application in the FA model, you need to declare the package structure of the application in the **config.json** file. Similarly, when developing an application in the stage model, you need to declare the package structure of the application in the **module.json** file. -## Internal Structure of the config.json File +## Internal Structure of the module.json File -The **module.json** file consists of two parts: **app** and **module**. See Table 1 for details. +The **module.json** file consists of two tags: **app** and **module**. See Table 1 for details. Table 1 Internal structure of the module.json file -| Attribute| Description | Data Type| Default| +| Tag| Description | Data Type| Initial Value Allowed| | -------- | ------------------------------------------------------------ | -------- | ---------- | -| app | Global configuration of an application. Different HAP files of the same application must use the same **app** configuration. For details, see [Internal Structure of the app Tag](#internal-structure-of-the-app-tag).| Object | No | -| module | Configuration of a HAP file. The ***module*** configuration is valid only for the current HAP file. For details, see [Internal Structure of the module Tag](#internal-structure-of-the-module-tag).| Object | No | +| app | Global configuration of an application. Different HAP files of an application must use the same **app** configuration. For details, see [Internal Structure of the app Tag](#internal-structure-of-the-app-tag).| Object | No | +| module | Configuration of a HAP file. The **module** configuration is valid only for the current HAP file. For details, see [Internal Structure of the module Tag](#internal-structure-of-the-module-tag).| Object | No | -Example of the module.json file: +Example of the **module.json** file: ```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 -         } -    }, + "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", @@ -48,15 +48,8 @@ Example of the module.json file: "deviceTypes": [ "tablet", "tv", - "wearable", - "liteWearable", - "ar", - "vr", - "car", - "earphones", - "speaker", - "smartVision", - "linkIoT", + "wearable", + "car", "router", ], "deliveryWithInstall": true, @@ -168,76 +161,69 @@ Example of the module.json file: ### Internal Structure of the app Tag -This tag is an attribute of the entire application. It affects the left and right hap and components in the application and will not be replaced by hap or components. For an internal structure of the label, refer to Table 2. +This tag is an application-level attribute that affects all the HAP files and components in the application. For the internal structure of the tag, see Table 2. Table 2 Internal structure of the app tag -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- | -| bundleName | Bundle name of the application. It uniquely identifies the application. This attribute cannot be left empty. The value must meet the following rules:
1) Consists of letters, digits, underscores (_), and periods (.).
(2) Starts with a letter.
(3) Contains 7 to 127 bytes.
You are advised to use the reverse domain name format, for example, com.example.xxx. The first level is the domain name suffix com, the second level is the vendor/individual name, and the third level is the application name. Multiple levels are supported.
The application compiled with the system source code must be named in the format of com.ohos.xxx, where ohos indicates the OpenHarmony system application.| String | No | -| debug | Indicates whether an application can be debugged. | Boolean | No (initial value: **false**) | -| icon | Icon of the application. The value is the index to the resource file. | String | No | +| bundleName | Bundle name that uniquely identifies the application. This attribute cannot be left empty. The value must comply with the following rules:
(1) Consists of letters, digits, underscores (_), and periods (.).
(2) Starts with a letter.
(3) Contains 7 to 127 bytes.
You are advised to use the reverse domain name notion, for example, *com.example.xxx*. The first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.
The application compiled with the system source code must be named in the format of **com.ohos.*xxx***, where **ohos** signifies OpenHarmony.| String | No | +| debug | Whether the application can be debugged. | Boolean | Yes (initial value: **false**) | +| icon | Icon of the application. The value is the index to the resource file. | String | No | | label | Name of the application. The value is a resource index to descriptions in multiple languages.| String | No | | description | Description of the application. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty) | -| vendor | Application vendor. The value is a string of a maximum of 255 bytes.| String | Yes (initial value: left empty) | -| versionCode | Version number of the application. The value is a 32-bit non-negative integer. The value is used only to determine whether a version is later than another version. A larger value indicates a later version. You can set the value to any positive integer. However, you must ensure that the new version of the application uses a value greater than any earlier version. The value must be less than 2 to the power of 31.| Number | | -| versionName | Text description of the version number, which is displayed to users.
The value consists of only digits and dots. The A.B.C.D four-segment format is recommended. The meaning of the four-segment format is as follows:
Segment 1: major version number. The value ranges from 0 to 99. This segment indicates the version that is modified greatly, for example, the version that implements a new major function or has a major change.
Segment 2: minor version number. The value ranges from 0 to 99. This segment indicates outstanding features, such as new function addition and major issue rectification.
Segment 3: feature version number. The value ranges from 0 to 99. This segment indicates the planned new version features.
Segment 4: revision version number or patch. The value ranges from 0 to 999. This segment indicates a maintenance version for fixing bugs.| String | No | +| vendor | Application vendor. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | +| versionCode | Version number of the application. The value is a 32-bit non-negative integer and less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number | No | +| versionName | Text description of the version number, which is displayed to users.
The value consists of only digits and dots. The four-segment format *A.B.C.D* is recommended, wherein:
Segment 1: major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.
Segment 2: minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.
Segment 3: feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.
Segment 4: maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.| String | No | | minCompatibleVersionCode | Minimum API version required for running the application. | Number | Yes (initial value: value of **versionCode**)| | minAPIVersion | Target API version required for running the application. | Number | No | | targetAPIVersion | Target API version required for running the application. | Integer | No | -| apiReleaseType | Type of the target API version required for running the application. The value is a string. The value can be **CanaryN**, **BetaN**, or **Release**, where **N** represents a positive integer.
Canary: indicates a restricted release.
Beta: indicates a publicly released beta version.
Release: indicates a publicly released official version.| String | Yes (initial value: **Release**) | +| apiReleaseType | Type of the target API version required for running the application. The value can be **CanaryN**, **BetaN**, or **Release**, where **N** represents a positive integer.
**Canary**: indicates a restricted release.
**Beta**: indicates a publicly released beta version.
**Release**: indicates a publicly released official version.| String | Yes (initial value: **"Release"**) | | distributedNotificationEnabled | Whether the distributed notification feature is enabled for the application. | Boolean | Yes (initial value: **true**) | -| entityType | Category of the application, which can be: game, media, communication, news, travel, utility, shopping, education, kids, business, and photography.| String | Yes (initial value: unspecified) | +| entityType | Category of the application, which can be **game**, **media**, **communication**, **news**, **travel**, **utility**, **shopping**, **education**, **kids**, **business**, and **photography**.| String | Yes (initial value: unspecified) | ### Internal Structure of the module Tag -This tag specifies the HAP configuration, which only applies to the current HAP file. +This tag stores the HAP configuration, which only applies to the current HAP file. Table 3 Internal structure of the module tag -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------- | -| name | Name of the current module. After the module is packed into the HAP, this attribute indicates the name of the HAP. The value is a string containing a maximum of 31 bytes and must be unique in the entire application.| String | No | -| type | Type of the current HAP file. There are three types: entry, feature, and har.| String | No | -| srcEntrance | Path of the entry JS code corresponding to the HAP. The value is a string containing a maximum of 127 bytes.| String | Yes | +| name | Name of the current module. After the module is packed into a HAP file, this attribute indicates the name of the HAP file. The value is a string with a maximum of 31 bytes and must be unique in the entire application.| String | No | +| type | Type of the current HAP file. There are three types: **entry**, **feature**, and **har**.| String | No | +| srcEntrance | Path of the entry JS code corresponding to the HAP file. The value is a string with a maximum of 127 bytes.| String | Yes | | description | Description of the HAP file. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty) | -| process | Process of the HAP file. The value is a string with a maximum of 31 bytes. If a process is configured in the **hap** tag, all abilities of the application run in this process.| String | Yes (initial value: name of the HAP) | -| mainElement | Entrance ability name or extension name of the HAP. Only the ability or extension whose value is **mainElement** can be displayed in the Service Center. This attribute cannot be left empty for an OpenHarmony atomic service.| String | Yes for an OpenHarmony application | -| deviceTypes | Types of the devices on which the HAP can run. The value is a string array. Table 4 lists the device types predefined by the system.
Different from **syscap**, which is based on the device capability (such as Bluetooth and Wi-Fi), **deviceTypes** is based on the device type.| String array| No (can be left empty) | -| deliveryWithInstall | Whether this HAP will be installed when the user installs the application. The value **true** indicates that the HAP file will be automatically installed when the user installs the application. Value "false" indicates the opposite.| Boolean | No | -| installationFree | Whether the HAP file supports the installation-free feature. No default value is allowed for the HAP file.
**true**: The HAP file supports the installation-free feature and meets installation-free constraints.
**false**: The HAP file does not support the installation-free feature.

When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap** must be **true**.
When **entry.hap** is set to **false**, **feature.hap** related to **entry.hap** can be set to **true** or **false** based on service requirements.| Boolean | No | -| virtualMachine | Type of the target VM where the current HAP is running. It is used for cloud distribution, such as the application market and distribution center.
The value is a string. If the target VM type is Ark, the value is **ark**. Otherwise, the value is **default**. This attribute is automatically inserted when the IDE builds the HAP. When the decompression tool parses the HAP file, if the HAP file does not contain this attribute, the value is set to **default**.| String | Yes (initial value: **default**) | -| uiSyntax | **syntax**: defines the syntax type of the JS component.
**hml**: indicates that the JS component is developed using HML, CSS, or JS.
**ets**: indicates that the JS component is developed using the eTS declarative syntax.| String | Yes (initial value: **hml**) | -| pages | Profile resource used to list information about each page in the JS component. For details about how to use pages, see the pages example.| Object | No in the ability scenario| -| metadata | Custom metadata of the HAP. The configuration is valid only for the current module, ability, or extensionAbility. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | -| abilities | Metadata capability configuration. The configuration under this tag is valid only for the current ability. For details about the capabilities, see [Internal Structure of the abilities Attribute](#internal-structure-of-the-abilities-attribute).| Object | Yes (initial value: left empty) | -| extensionAbilities | Configuration information of extensionAbilities. The configuration under this tag is valid only for the current extensionAbility. For details about extensionAbilities, see [Internal structure of the extensionAbility attribute](#internal-structure-of-the-extensionAbility-attribute).| Object | Yes (initial value: left empty) | -| requestPermissions | A set of permissions that the application needs to apply for from the system when the application is running. For details about requestPermissions, see [Internal structure of the requestPermissions attribute](#internal-structure-of-the-requestPermissions-attribute).| Object | Yes (initial value: left empty) | +| process | Process of the HAP file. The value is a string with a maximum of 31 bytes. If a process is configured under **hap**, all abilities of the application run in this process.| String | Yes (initial value: name of the HAP file) | +| mainElement | Entrance ability name or extension name of the HAP file. Only the ability or extension whose value is **mainElement** can be displayed in the Service Center. This attribute cannot be left at the initial value for an OpenHarmony atomic service.| String | Yes for an OpenHarmony application | +| deviceTypes | Types of the devices on which the HAP file can run. Table 4 lists the device types predefined by the system.
Different from **syscap**, which is based on the device capability (such as Bluetooth and Wi-Fi), **deviceTypes** is based on the device type.| String array| No (can be left empty) | +| deliveryWithInstall | Whether the current HAP file will be installed when the user installs the application. The value **true** means that the HAP file will be automatically installed when the user installs the application, and **false** means the opposite.| Boolean | No | +| installationFree | Whether the HAP file supports the installation-free feature.
**true**: The HAP file supports the installation-free feature and meets installation-free constraints.
**false**: The HAP file does not support the installation-free feature.

When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap** must be **true**.
When **entry.hap** is set to **false**, **feature.hap** fields related to **entry.hap** can be set to **true** or **false** based on service requirements. | Boolean | No | +| virtualMachine | Type of the target virtual machine (VM) where the current HAP file is running. It is used for cloud distribution, such as the application market and distribution center.
If the target VM type is Ark, the value is **ark**. Otherwise, the value is **default**. This attribute is automatically inserted when the IDE builds the HAP file. When the decompression tool parses the HAP file, if the HAP file does not contain this attribute, the value is set to **default**. | String | Yes (initial value: **default**) | +| uiSyntax | Syntax type of the JS component.
**hml**: indicates that the JS component is developed using HML, CSS, or JS.
**ets**: indicates that the JS component is developed using the eTS declarative syntax.| String | Yes (initial value: **hml**) | +| pages | Profile resource used to list information about each page in the JS component. For details about how to use **pages**, see the **pages** example.| Object | No in the ability scenario| +| metadata | Custom metadata of the HAP file. The configuration is valid only for the current module, ability, or extensionAbility. For details about **metadata**, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | +| abilities | Metadata capability configuration, which is valid only for the current ability. For details about **abilities**, see [Internal Structure of the abilities Attribute](#internal-structure-of-the-abilities-attribute).| Object | Yes (initial value: left empty) | +| extensionAbilities | Configuration of extensionAbilities, which is valid only for the current extensionAbility. For details about **extensionAbilities**, see [Internal structure of the extensionAbility attribute](#internal-structure-of-the-extensionability-attribute).| Object | Yes (initial value: left empty) | +| requestPermissions | A set of permissions that the application needs to apply for from the system when the application is running. For details about **requestPermissions**, see [Internal structure of the requestPermissions attribute](#internal-structure-of-the-requestpermissions-attribute).| Object | Yes (initial value: left empty) | Table 4 System-defined deviceTypes values -| Value | Device Type | -| ------------ | -------------------------------------------------------- | -| tablet | Tablet, speaker with a screen | -| tv | | -| wearable | Smart watch, kids watch, especially a watch that packs a wide array of resources | -| liteWearable | Basic functions watch, sports watch | -| ar | | -| vr | | -| car | | -| earphones | | -| speaker | Speaker without a screen, speaker with a screen | -| smartVision | Devices with cameras | -| linkIoT | Wi-Fi module, Bluetooth module | -| router | Router | - -Example of deviceTypes: +| Device Type | Value | Description | +| ------------ | ------------ | -------------------------------------------------------- | +| tablet | tablet | Tablet, speaker with a screen | +| smart TV | tv | | +| smart watch | wearable | Smart watch, kids' watch, especially a watch that provides call features| +| head unit | car | | +| router | router | Router | + +Example of the **deviceTypes** attribute structure: ```json { "module": { - "name": "myHapName", -        "type": "har", + "name": "myHapName", + "type": "har", "deviceTypes" : [ "wearable" ] @@ -245,31 +231,31 @@ Example of deviceTypes: } ``` -Example of pages: +Example of the **pages** attribute structure:: ```json { - "module": { -       "name": "myHapName", -        "type": "har", + "module": { + "name": "myHapName", + "type": "har", "deviceTypes" : [ "wearable" ], -        "pages": "$profile:pages_config" -    } + "pages": "$profile:pages_config" + } } ``` -pages_config configuration file +Example of the **pages_config** configuration file: ```json { -    "src": [ -        "pages/index/index", -        "pages/second/second", -        "pages/third/third", -        "pages/four/four" -    ] + "src": [ + "pages/index/index", + "pages/second/second", + "pages/third/third", + "pages/four/four" + ] } ``` @@ -277,34 +263,34 @@ pages_config configuration file #### Internal Structure of the metadata Attribute -Configuration information about the module, ability, and extensionAbility. The value is of the array type. The configuration is valid only for the current module, ability, or extensionAbility. +The **metadata** attribute provides the configuration about the module, ability, and extensionAbility. The value is of the array type. The configuration is valid only for the current module, ability, or extensionAbility. Table 5 Internal structure of the metadata attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------------- | -| name | Key of a data element. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty) | -| value | This tag indicates the value of a data item. The tag value is a character string containing a maximum of 255 bytes. | String | Yes (initial value: left empty) | +| name | Name of a data item. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| +| value | Value of a data item. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty) | | resource | Custom data format. The value is an index to the resource that identifies the data.| String | Yes (initial value: left empty) | -Example of metadata: +Example of the **metadata** attribute structure: ```json -{  -    "module": { -        "metadata": [ -            { -                "name": "string", -                "value": "string", -                "resource": "$profile:config_file" -            }, -            { -                "name": "string", -                "value": "string", -                "resource": "$profile:config_file" -            } -        ] -    } +{ + "module": { + "metadata": [ + { + "name": "string", + "value": "string", + "resource": "$profile:config_file" + }, + { + "name": "string", + "value": "string", + "resource": "$profile:config_file" + } + ] + } } ``` @@ -314,52 +300,54 @@ The **abilities** attribute describes the ability configuration information. The Table 6 Internal structure of the abilities attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | -| name | Logical name of the ability, which must be unique in the entire application. The value is a string containing a maximum of 127 bytes.| String | No | -| srcEntrance | JS code path corresponding to the ability. The tag value is a string containing a maximum of 127 bytes.| String | No | -| launchType | Ability startup mode. The value can be **standard**, **singleton**, or **specified**. The default value is **standard**. The value **standard** indicates common multi-instance, the value **specified** indicates that multiple instances are configured for the ability based on the service, and the value **singleton** indicates a singleton.| String | Yes (initial value: **standard**) | +| name | Logical name of the ability, which must be unique in the entire application. The value is a string with a maximum of 127 bytes.| String | No | +| srcEntrance | JS code path corresponding to the ability. The value is a string with a maximum of 127 bytes.| String | No | +| launchType | Ability startup mode. The value can be **standard**, **singleton**, or **specified**. The default value is **singleton**. The value **standard** indicates common multi-instance, the value **singleton** indicates a singleton, and the value **specified** indicates one or more specified instances, depending on the internal service of the ability.| String | Yes (initial value: **singleton**) | | description | Ability description. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty) | | icon | Icon of the ability. The value is the index to the resource file. This attribute can be left empty, and the default value is an empty array.
If **ability** is set to **MainElement**, this attribute is mandatory.| String | Yes (initial value: left empty)
If **ability** is set to **MainElement**, this attribute is mandatory.| -| permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a character string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute. This attribute can be left empty, and the default value is an empty array.| String array| Yes (initial value: left empty) | -| metadata | Metadata about the ability. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | -| visible | Indicates whether the Ability can be invoked by other applications. The value is a boolean value. Value "true" means that the Ability can be invoked by other applications, and "false" means the opposite.| Boolean | Yes (initial value: **false**) | -| continuable | Indicates whether the ability can be migrated. The value is a Boolean value. The value true indicates that the ability can be migrated, and the value false indicates that the ability cannot be migrated.| Boolean | Yes (initial value: **false**) | -| skills | Feature set of wants that can be received by the ability. The tag is in array format.
Configuration rule: In an entry package, you can configure the ability of multiple **skill** attributes (**action.system.home** and **entity.system.home** are configured) that have the entry capability. The label and icon in the first **skill** attribute that is configured are used as the label and icon of the OpenHarmony service or application.
The skills tag with the entry capability cannot be configured for the feature package of the OpenHarmony service.
The **skill** attribute with the entry capability can be configured for the feature package of the OpenHarmony application.
For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | -| backgroundModes | Continuous task modes of the ability.
Continuous tasks are classified into the following types:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices
**audioPlayback**: audio playback service
**audioRecording**: audio recording service
**location**: location and navigation services
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables)
**multiDeviceConnection**: multi-device interconnection service
**wifiInteraction**: Wi-Fi scanning, connection, and transmission services (multi-screen cloning)
**voip**: voice/video call and VoIP services
**taskKeeping**: computing service.
| String | Yes (initial value: left empty) | +| permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute. | String array| Yes (initial value: left empty) | +| metadata | Metadata about the ability. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | +| visible | Indicates whether the ability can be invoked by other applications. The value **true** means that the ability can be invoked by other applications, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | +| continuable | Whether the ability can be migrated. The value **true** means that the ability can be migrated, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | +| skills | Feature set of wants that can be received by the ability.
Configuration rule: In an entry package, you can configure multiple abilities with the **skills** attribute (where **action.system.home** and **entity.system.home** are configured) that has the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the entire service/application.
The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,
but not for an OpenHarmony service.
For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | +| backgroundModes | Continuous task modes of the ability.
Continuous tasks are classified into the following types:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices
**audioPlayback**: audio playback service
**audioRecording**: audio recording service
**location**: location and navigation services
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables)
**multiDeviceConnection**: multi-device interconnection service
**wifiInteraction**: Wi-Fi scanning, connection, and transmission services (multi-screen cloning)
**voip**: voice/video call and VoIP services
**taskKeeping**: computing service
| String | Yes (initial value: left empty) | +| startWindowIcon | Index to the icon file of the ability startup page. Example value: **$media:icon**. | String | No | +| startWindowBackground | Index to the background color resource file of the ability startup page. Example value: **$color:red**. | String | No | -Example of the abilities attribute structure: +Example of the **abilities** attribute structure: ```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" -        ], -    }], + "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" + ], + }], } ``` @@ -367,9 +355,9 @@ Example of the abilities attribute structure: This attribute identifies a want feature that can be received by the ability or extension. -Table 7 Internal structure of skills +Table 7 Internal structure of the skills attribute -| Attribute| Description | Data Type | Default | +| Attribute| Description | Data Type | Initial Value Allowed | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | A set of want action values that can be received. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| | entities | Categories of abilities that can receive the want. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| @@ -377,7 +365,7 @@ Table 7 Internal structure of skills Table 8 Internal structure of the uris attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------- | -------- | -------------------- | | scheme | Scheme in the URI.| String | No | | host | Host in the URI. | String | Yes (initial value: left empty)| @@ -385,58 +373,58 @@ Table 8 Internal structure of the uris attribute | path | Path in the URI. | String | Yes (initial value: left empty)| | type | Type of the URI. | String | Yes (initial value: left empty)| -Example of the skills attribute structure: +Example of the **skills** attribute structure: ```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/*" -                        }, -                    ] -                } -            ], -        } -    ], + "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/*" + }, + ] + } + ], + } + ], } ``` @@ -446,50 +434,50 @@ The **extensionAbility** attribute describes the configuration information of ** Table 9 Internal structure of the extensionAbility attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ----------- | ------------------------------------------------------------ | ---------- | ----------------------------- | -| name | Logical name of the current extensionAbility. The value is a string containing a maximum of 127 bytes. The name must be unique in the entire application.| String | No | -| srcEntrance | JS code path corresponding to extensionAbility. The value is a character string containing a maximum of 127 bytes.| String | No | +| name | Logical name of the current extensionAbility. The value is a string with a maximum of 127 bytes. The name must be unique in the entire application.| String | No | +| srcEntrance | JS code path corresponding to extensionAbility. The value is a string with a maximum of 127 bytes.| String | No | | description | Description of the extensionAbility. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty) | | icon | Icon of the extensionAbility. The value is the index to the resource file. If **extensionAbility** is set to **MainElement**, this attribute is mandatory.| String | Yes (initial value: left empty) | | label | Name of the extensionAbility displayed to users. The value is a resource index to names in multiple languages.
If **extensionAbility** is set to **MainElement**, this attribute is mandatory and the value must be unique in the application.| String | No | -| type | Type of the extension capability. The value can be form, workScheduler, inputMethod, service, accessibility, dataShare, fileShare, staticSubscriber or wallpaper.| String | No | -| permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a character string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty) | +| type | Type of the extension capability. The value can be form, workScheduler, inputMethod, service, accessibility, dataShare, fileShare, staticSubscriber, wallpaper, or backup. | String | No | +| permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty) | | uri | Data URI provided by the ability. The value is an array containing a maximum of 255 characters and is in the format of a reverse domain name. This attribute is mandatory when **type** is set to **extensionAbility** of the dataShare type.| String | Yes (initial value: left empty) | -| skills | Feature set of wants that can be received by the ability.
Configuration rule: In an entry package, you can configure the ability of multiple **skill** attributes (**action.system.home** and **entity.system.home** are configured) that have the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the OpenHarmony service or application.
The **skills** attribute with the entry capability cannot be configured for the feature package of the OpenHarmony service.
The **skills** attribute with the entry capability can be configured for the feature package of the OpenHarmony application.
For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | +| skills | Feature set of wants that can be received by the ability.
Configuration rule: In an entry package, you can configure multiple abilities with the **skills** attribute (where **action.system.home** and **entity.system.home** are configured) that has the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the entire service/application.
The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,
but not for an OpenHarmony service.
For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | | metadata | Metadata of extensionAbility. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Object | Yes (initial value: left empty) | | visible | Whether extensionAbility can be invoked by other applications. The value is of the Boolean type. The value **true** means that it can be invoked by other applications, and the value **false** means the opposite.| | Yes (initial value: **false**)| -Example of extensionAbility: +Example of the **extensionAbility** attribute structure: ```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",  -                } -            ], -        } -    ] + "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", + } + ], + } + ] } ``` @@ -498,49 +486,48 @@ Example of extensionAbility: This attribute identifies a set of permissions that the application needs to apply for from the system when the application is running. -Table 10 requestPermissions fields +Table 10 requestPermissions attributes -| Attribute | Description | Type | **Value Range** | **Default Value** | **Restrictions** | +| Attribute | Description | **Type** | **Value Range** | **Default Value** | **Restrictions** | | --------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | -| name | Permission name, which is mandatory. | String | Custom | None | Parsing will fail if this field is not set. | -| reason | Optional. This field is mandatory when the requested permission is **user_grant**. Reason for requesting the permission.| String | The displayed text cannot exceed 256 bytes. | Empty | This attribute is mandatory for the **user_grant** permission. If it is left empty, application release will be rejected. Multi-language adaptation is required. | -| usedScene | Optional. This field is mandatory when the requested permission is **user_grant**. Describes the application scenario and timing for using the permission. This attribute consists of the **ability** and **when** sub-attributes. Multiple abilities can be configured.| **ability**: string array; **when**: string| **ability**: ability name; **when**: **inuse** or **always**| **ability**: left empty; **when**: **inuse**| The **ability** sub-attribute is mandatory for the **user_grant** permission, and the **when** field is optional. | +| name | Permission name. This attribute is mandatory. | String | Custom | None | Parsing will fail if this field is not set. | +| reason | Reason for requesting the permission. This attribute is mandatory when the requested permission is **user_grant**. | String | The maximum length is 256 bytes. | Empty | If the requested permission is **user_grant**, this attribute is required for the application to be released to AppGallery. Multi-language adaptation is required. | +| usedScene | Application scenario and timing for using the permission, which is mandatory when the requested permission is **user_grant**. This attribute consists of the **ability** and **when** sub-attributes. Multiple abilities can be configured. | **ability**: string array; **when**: string | **ability**: ability name; **when**: **inuse** or **always** | **ability**: left empty; **when**: **inuse** | If the requested permission is **user_grant**, the **ability** sub-attribute is mandatory and **when** is optional. | -Example of requestPermissions: +Example of the **requestPermissions** attribute structure: ```json { -    "usedScene": { -        "abilities": [ -            "AudioAbility", -            "VedioAbility", -        ], -        "when": "inuse" -    } + "usedScene": { + "abilities": [ + "AudioAbility", + "VedioAbility", + ], + "when": "inuse" + } } ``` #### Internal Structure of the form Attribute -The **forms** attribute indicates the service widget configuration. The service widget is a brief application view that can be embedded on the home screen and periodically updated. The **form** attribute can be contained in the following scenarios: +The **forms** attribute indicates the service widget configuration. The service widget is an application brief view that can be displayed on the home screen and periodically updated. You can include the **forms** attribute in any of the following modes: 1. Set **type** to **form** in **extensions**. - -2. Specify the **form** information in metadata, - where **name** indicates the name of the service widget,**ohos.extability.form** indicates the identifier of the service widget, - and **resource** indicates the resource location of the service widget. +2. Specify the **form** information in **metadata**, where: + - **name** indicates the name of the service widget, for example, **ohos.extability.form**. + - **resource** indicates where the resources of the service widget are stored. Table 11 Internal structure of the forms attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ----------------- | ------------------------------------------------------------ | ---------- | ----------------------------- | | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | src | UI code of a JS service widget. It is recommended that you use the adaptive layout to display a service widget of different specifications. If the layout of a service widget of different specifications differs greatly, you are advised to use different service widgets.| String | Yes (initial value: left empty) | | window | Adaptive capability of a JS service widget. For details about the window structure, see Table 12. | Object | Yes (initial value: left empty) | -| isDefault | Whether the widget is a default one. Each ability has only one default widget. **true**: The widget is the default one. **false**: The widget is not the default one.| Boolean | No | -| colorMode | Theme style of a service widget. The options are as follows: **auto**; **dark**: The widget adopts the dark color mode; **light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**) | -| supportDimensions | Appearance specifications supported by the widget. The options are as follows: 1 * 2: indicates a grid with one row and two columns. 2 * 2: indicates a grid with two rows and two columns. 2 * 4: indicates a grid with two rows and four columns. 4 * 4: indicates a grid with four rows and four columns.| String array| No | +| isDefault | Whether the service widget is the default one. Each ability has only one default service widget. **true**: The service widget is the default one. **false**: The service widget is not the default one.| Boolean | No | +| colorMode | Theme style of the service widget. The value can be **auto**, **dark**, or **light**.| String | Yes (initial value: **auto**) | +| supportDimensions | Dimensions supported by the service widget. The value can be **1 * 2**, **2 * 2**, **2 * 4**, or **4 * 4**, where the number before the asterisk (*) indicates the number of rows, and the number after the asterisk (*) indicates the number of columns.| String array| No | | defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No | | updateDuration | Update frequency of a widget. The unit is 30 minutes. The value is a multiple of 30. The highest frequency of refreshing a widget is once every 30 minutes. You can also use scheduled refresh to refresh a widget at a fixed time or once every 30 minutes. If both of them are configured, the scheduled refresh takes precedence.| Number | Yes (initial value: left empty) | | metadata | Custom information about a widget. For details about the internal structure of metadata, see Table 5. | Object | Yes (initial value: left empty) | @@ -549,46 +536,46 @@ Table 11 Internal structure of the forms attribute Table 12 Internal structure of window -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | --------------- | ------------------------------------------------------------ | -------- | -------------------- | | designWidth | Baseline width of the page design, in pixels. The element size is scaled by the actual device width. The value is an integer.| Number | Yes (initial value: left empty)| | autoDesignWidth | Whether to automatically calculate the baseline width of the page design. If this parameter is set to **true**, the **designWidth** attribute is invalid. The baseline width is calculated based on the device width and screen density.| Boolean | Yes (initial value: left empty)| -Example of the form attribute structure: +Example of the **forms** attribute structure: -Define the **form_config.json** file in **resources/base/profile** of the development view. (The file name can be defined by developers.) +Define the **form_config.json** file (this file name is customizable) in **resources/base/profile** of the development view. ```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" -             } -           ]  -        } -    ] + "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" + } + ] + } + ] } ``` @@ -596,14 +583,14 @@ Define metadata information in the **extension** component of the **module.json* ```json { - "extensionAbilities": [ + "extensionAbilities": [ { - "name": "MyForm", - "type": "form",  - "metadata": [ + "name": "MyForm", + "type": "form", + "metadata": [ { - "name": "ohos.extability.form", - "resource": "$profile:form_config", + "name": "ohos.extability.form", + "resource": "$profile:form_config", } ], } @@ -613,80 +600,83 @@ Define metadata information in the **extension** component of the **module.json* #### Internal Structure of the shortcuts Attribute -This attribute identifies the shortcut information of an application. The value is an array. A maximum of four shortcuts can be configured. It contains four sub-attributes: **shortcutId**, **label**, **icon**, and **intents**. +This attribute identifies the shortcut information of an application. The value is an array. A maximum of four shortcuts can be configured. It contains four sub-attributes: **shortcutId**, **label**, **icon**, and **wants**. + +Specify the **shortcut** information in **metadata**, where: -The shortcut information is identified in metadata, where: -(1) **name**: name of a shortcut.**ohos.ability.shortcut** is used as the identifier of the shortcut. -(2) **resource**: resource location of the shortcut. +- **name** indicates the name of the shortcut, for example, **ohos.ability.shortcut**. + +- **resource** indicates where the resources of the shortcut are stored. Table 13 Internal structure of the shortcuts attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ---------- | ------------------------------------------------------------ | -------- | -------------------------- | | shortcutId | Shortcut ID. The value is a string with a maximum of 63 bytes. | String | No | | label | Label of the shortcut, that is, the text description displayed by the shortcut. The value can be a string or a resource index to the description. The value is a string with a maximum of 63 bytes.| String | Yes (initial value: left empty) | | icon | Icon of the shortcut. The value is the index to the resource file. | String | Yes (initial value: left empty)| -| wants | Wants to which the shortcut points. The attribute consists of the **bundleName** and **abilityName** sub-attributes.
**bundleName**: target bundle name of the shortcut, which is a string.
**abilityName**: target component name of the shortcut, which is a string.| Object | Yes (initial value: left empty) | +| wants | Wants to which the shortcut points. The attribute consists of the **bundleName** and **abilityName** sub-attributes.
**bundleName**: target bundle name of the shortcut; string type.
**abilityName**: target component name of the shortcut; string type.| Object | Yes (initial value: left empty) | -Define the **shortcut_config.json** file in **resources/base/profile** of the development view. (The file name can be defined by developers.) +Define the **shortcut_config.json** file (this file name is customizable) in **resources/base/profile** of the development view. ```json { -        "shortcuts": [ -            { -                "shortcutId": "id_test1", -                "label": "$string:shortcut", -                "icon": "$media:aa_icon", -                "wants": [ -                    { -                       "bundleName": "com.ohos.hello" -                       "abilityName": "MainAbility" -                    } -                ] -            } -        ] + "shortcuts": [ + { + "shortcutId": "id_test1", + "label": "$string:shortcut", + "icon": "$media:aa_icon", + "wants": [ + { + "bundleName": "com.ohos.hello" + "abilityName": "MainAbility" + } + ] + } + ] } ``` -Define the metadata information under **module** in the **config.json** file as follows: +Define the **metadata** information under **module** in the **config.json** file as follows: ```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",  -                    } -                ], -            } -        ] -    } + "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", + } + ], + } + ] + } } ``` #### Internal Structure of the commonEvents Attribute The **commonEvents** attribute identifies the registered static common event information. The value is an array. -The **commonEvent** information is defined in the metadata, where: -1. **name**: name of a common event.**ohos.extability.staticSubscriber** is used as the common event ID. +Specify the **commonEvent** information in the **metadata**, where: -2. **resource**: resource location of the **commonEvent** information. +- **name** indicates the name of the common event, for example, **ohos.extability.staticSubscriber**. + +- **resource** indicates where the resources of the common event are stored. Table 14 Internal structure of the commonEvents attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ---------- | ------------------------------------------------------------ | ---------- | -------------------------- | | name | Ability name corresponding to the current static common event. The class must be marked in the ability.| String | No | | permission | Permission required for implementing the static common event. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.| String | Yes (initial value: left empty) | @@ -697,38 +687,38 @@ Define the **common_event_config.json** file in **resources/base/profile** in th ```json { -    "commonEvents": [ -            { -                "name": "abilityName", -                "permission": "string", -                "types": [ -                    "string", -                    "string" -                ], -                "events": [ -                    "string", -                    "string" -                ] -            } -    ] + "commonEvents": [ + { + "name": "abilityName", + "permission": "string", + "types": [ + "string", + "string" + ], + "events": [ + "string", + "string" + ] + } + ] } ``` -Define metadata information in the **extension** component of the **module.json** file as follows: +Define the **metadata** information under **extension** in the **module.json** file as follows: ```json -"extensionAbilities": [ -    { -        "name": "mySubscriber", -        "srcEntrance": "./extension/my_subscriber.js", -        "type": "staticSubscriber", -        "metadata": [ -            { -                "name": "ohos.extability.staticSubscriber", -                "resource": "$profile:common_event_config",  -            } -        ], -    } +"extensionAbilities": [ + { + "name": "mySubscriber", + "srcEntrance": "./extension/my_subscriber.js", + "type": "staticSubscriber", + "metadata": [ + { + "name": "ohos.extability.staticSubscriber", + "resource": "$profile:common_event_config", + } + ], + } ] ``` @@ -740,50 +730,50 @@ This attribute defines the rules for distributing HAP files based on different d Table 15 Internal structure of the distroFilter attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------- | ------------------------------------------------------------ | -------- | -------------------------- | | apiVersion | Supported API versions. For details, see Table 16. | Object array| Yes (initial value: left empty)| | screenShape | Supported screen shapes. | Object array| Yes (initial value: left empty)| | screenWindow | Supported window resolutions when the application is running. This attribute applies only to the lite wearables.| Object array| Yes (initial value: left empty)| -| screenDensity | It indicates the dot per inch (DPI) of the screen. This attribute is optional. If this attribute is set, the value must be valid. The value is a string array. The range is as follows:
**sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
**mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
**ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
**xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
**xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
**xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| Object array| Yes (initial value: left empty)| -| countryCode | Code of the country or region to which an application is distributed. For details, see ISO-3166-1. Enumerated definitions of multiple countries and regions are supported. This attribute is optional. If this attribute is set, the value must be valid. The substring of the value indicates the supported countries or regions and consists of two uppercase letters.| Object array| Yes (initial value: left empty)| +| screenDensity | Dots per inch (DPI) of the screen. This attribute is optional. The value options are as follows:
**sdpi**: small-scale dots per inch. This value is applicable for devices with a DPI range of (0, 120].
**mdpi**: medium-scale dots per inch. This value is applicable for devices with a DPI range of (120, 160].
**ldpi**: large-scale dots per inch. This value is applicable for devices with a DPI in the (160, 240] range.
**xldpi**: extra-large-scale dots per inch. This value is applicable for devices with a DPI in the (240, 320] range.
**xxldpi**: extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI in the (320, 480] range.
**xxxldpi**: extra-extra-extra-large-scale dots per inch. This value is applicable for devices with a DPI in the (480, 640] range.| Object array| Yes (initial value: left empty)| +| countryCode | Code of the country or region to which an application is to be distributed. For details, see ISO-3166-1. Enumerated definitions of multiple countries and regions are supported. This attribute is optional. The substring of the value consists of two uppercase letters and indicates the supported countries or regions.| Object array| Yes (initial value: left empty)| Table 16 Internal structure of the apiVersion attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| -| value | An integer of the existing API version, for example, 4, 5, or 6. Example: If an application uses two software versions developed using API 5 and API 6 for the same device model, two installation packages of the entry type can be released.| Array | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| value | An integer of the existing API version, for example, 4, 5, or 6. If an application uses two software versions developed using API 5 and API 6 for the same device model, two installation packages of the entry type can be released. | Array | Yes (initial value: left empty)| Table 17 Internal structure of the screenShape attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| -| value | The value can be **circle** or **rect**. Example: Different HAPs can be provided for a smart watch with a circular face and that with a rectangular face.| Array | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| value | The value can be **circle** or **rect**. Example: Different HAPs can be provided for a smart watch with a circular face and a smart watch with a rectangular face.| Array | Yes (initial value: left empty)| Table 18 Internal structure of the screenWindow attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| -| value | Width and height of the screen. The value of a single string is in the format of Width x Height in pixels, for example, **454*454**.| Array | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| value | Width and height of the screen. The value is in the "width * height" format, in pixels, for example, **454*454**.| Array | Yes (initial value: left empty)| Table 19 Internal structure of the screenDensity attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| -| value | It indicates the dot per inch (DPI) of the screen. | Array | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| value | Dots per inch (DPI) of the screen. | Array | Yes (initial value: left empty)| Table 20 Internal structure of the countryCode attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | Code of the country or region to which an application is to be distributed. | Array | Yes (initial value: left empty)| -Example of the distroFilter attribute structure: +Example of the **distroFilter** attribute structure: Define the **distroFilter_config.json** file in **resources/base/profile** of the development view. (The file name can be defined by developers.) @@ -806,21 +796,21 @@ Define the **distroFilter_config.json** file in **resources/base/profile** of th ] ``` -Define metadata information in the **extensionAbilities** component of the **module.json** file as follows: +Define the **metadata** information under **extensionAbilities** in the **module.json** file as follows: ```json -"extensionAbilities": [ -    { -        "name": "mySubscriber", -        "srcEntrance": "./extension/my_subscriber.js", -        "type": "staticSubscriber",  -        "metadata": [ -            { -                "name": "ohos.extability.staticSubscriber", -                "resource": "$profile:distroFilter_config",  -            } -        ], -    } +"extensionAbilities": [ + { + "name": "mySubscriber", + "srcEntrance": "./extension/my_subscriber.js", + "type": "staticSubscriber", + "metadata": [ + { + "name": "ohos.extability.staticSubscriber", + "resource": "$profile:distroFilter_config", + } + ], + } ] ``` diff --git a/en/application-dev/quick-start/package-structure.md b/en/application-dev/quick-start/package-structure.md index 1b3d88f8b378aa84ce9d571c97320b5b6c861494..07a151684093b7d0b85745b7211b53a7283bac2b 100644 --- a/en/application-dev/quick-start/package-structure.md +++ b/en/application-dev/quick-start/package-structure.md @@ -6,17 +6,17 @@ In an application development project, you need to declare the package structure ## Internal Structure of the config.json File -The **config.json** file consists of three mandatory tags, namely, **app**, **deviceConfig**, and ***module***. See Table 1 for details. +The **config.json** file consists of three mandatory tags, namely, **app**, **deviceConfig**, and **module**. See Table 1 for details. Table 1 Internal structure of the config.json file -| Tag | Description | Data Type| Default| +| Tag | Description | Data Type| Initial Value Allowed| | ------------ | ------------------------------------------------------------ | -------- | ---------- | -| app | Global configuration of an application. Different HAP files of the same application must use the same **app** configuration. For details, see [Internal Structure of the app Tag](#Internal-structure-of-the-app-tag).| Object | No | -| deviceConfig | Application configuration applied to a specific type of device. For details, see [Internal Structure of the deviceconfig Tag](#Internal-structure-of-the-deviceconfig-tag).| Object | No | -| module | Configuration of a HAP file. The ***module*** configuration is valid only for the current HAP file. For details, see [Internal Structure of the module Tag](#Internal-structure-of-the-module-tag).| Object | No | +| app | Global configuration of an application. Different HAP files of the same application must use the same **app** configuration. For details, see [Internal Structure of the app Tag](#internal-structure-of-the-app-tag).| Object | No | +| deviceConfig | Application configuration applied to a specific type of device. For details, see [Internal Structure of the deviceconfig Tag](#internal-structure-of-the-deviceconfig-tag).| Object | No | +| module | Configuration of a HAP file. The **module** configuration is valid only for the current HAP file. For details, see [Internal Structure of the module Tag](#internal-structure-of-the-module-tag).| Object | No | -Example of config.json: +Example of the **config.json** file: ```json { @@ -86,16 +86,16 @@ The **app** tag contains the global configuration information of the application Table 2 Internal structure of the app tag -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | -| bundleName | Bundle name of the application. It uniquely identifies the application. The bundle name can contain only letters, digits, underscores (_), and periods (.). It must start with a letter. The value is a string with 7 to 127 bytes of a reverse domain name, for example, **com.example.myapplication**. It is recommended that the first level be the domain name suffix "com" and the second level be the vendor/individual name. More levels are also accepted.| String | No | +| bundleName | Bundle name of the application. It uniquely identifies the application. The bundle name can contain only letters, digits, underscores (_), and periods (.). It must start with a letter. The value is a string with 7 to 127 bytes of a reverse domain name, for example, **com.example.myapplication**. It is recommended that the first level be the domain suffix "com" and the second level be the vendor/individual name. More levels are also accepted.| String | No | | vendor | Description of the application vendor. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| | version | Version information of the application. For details, see Table 3. | Object | No | | apiVersion | OpenHarmony API version on which the application depends. For details, see Table 4. | Object | Yes (initial value: left empty)| Table 3 Internal structure of version -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------------------ | ------------------------------------------------------------ | -------- | -------------------------- | | name | Application version number visible to users. The value can be customized and cannot exceed 127 bytes. The customization rules are as follows:
API 5 and earlier versions: A three-segment version number is recommended, for example, A.B.C (also compatible with A.B). In the version number, A, B, and C are integers ranging from 0 to 999. Other formats are not supported.
A indicates the major version number.
B indicates the minor version number.
C indicates the patch version number.
API 6 and later versions: A four-segment version number is recommended, for example, A.B.C.D. In the version number, A, B, and C are integers ranging from 0 to 99, and D is an integer ranging from 0 to 999.
A indicates the major version number.
B indicates the minor version number.
C indicates the feature version number.
D indicates the patch version number.| Number | No | | code | Application version number used only for application management by OpenHarmony. This version number is not visible to users of the application. The value rules are as follows:
API 5 and earlier versions: It is a non-negative integer less than 32 bits in binary mode, converted from the value of version.name as follows: The conversion rules are as follows:
Value of **code** = A * 1,000,000 + B * 1,000 + C. For example, if the value of **version.name** is 2.2.1, the value of **code** is 2002001.
API 6 and later versions: The value of **code** is not associated with the value of **version.name** and can be customized. The value is a non-negative integer ranging from 2 to 31. Note that the value must be updated each time the application version is updated. The value for a later version must be greater than that for an earlier version.| Number | No | @@ -103,7 +103,7 @@ Table 3 Internal structure of version Table 4 Internal structure of apiVersion -| Attribute | Description | Data Type| Default| +| Attribute | Description | Data Type| Initial Value Allowed| | ----------- | ----------------------------------------------------------- | -------- | ---------- | | compatible | Minimum API version required for running the application. The value ranges from 0 to 2147483647. | Integer | Yes | | target | Target API version required for running the application. The value ranges from 0 to 2147483647.| Integer | Yes | @@ -129,56 +129,55 @@ Example of the app tag structure: ### Internal Structure of the deviceConfig Tag -The **deviceConfig** tag contains the application configuration information on the device, including attributes such as **default**, **tv**, **car**, **wearable**, and **liteWearable**. The **default** configuration applies to all types of devices. You need to declare the peculiar configuration of a specific device type in the associated sub-tag of this type. For details about the internal structure, see Table 5. +The **deviceConfig** tag contains the application configuration information on the device, including attributes such as **default**, **tv**, **car**, and **wearable**. The **default** configuration applies to all types of devices. You need to declare the peculiar configuration of a specific device type in the associated sub-tag of this type. For details about the internal structure, see Table 5. Table 5 Internal structure of the deviceConfig tag -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------ | ----------------------------------------------- | -------- | ------------------ | | default | Application configuration applied to all types of devices. See Table 6. | Object | No | | tablet | Application configuration specific to tablets. See Table 6. | Object | Yes (initial value: left empty)| | tv | Application configuration specific to smart TVs. See Table 6. | Object | Yes (initial value: left empty)| | car | Application configuration specific to head units. See Table 6. | Object | Yes (initial value: left empty)| | wearable | Application configuration specific to wearables. See Table 6. | Object | Yes (initial value: left empty)| -| liteWearable | Application configuration specific to lite wearables. See Table 6.| Object | Yes (initial value: left empty)| For details about the internal structures of device attributes, see Table 6. Table 6 Internal structure of device attributes -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------------ | ------------------------------------------------------------ | -------- | ----------------------- | -| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types. The value can contain a maximum of 31 characters. | String | Yes | -| supportBackup | Whether the application supports backup and restoration. If this attribute is set to **false**, backup or restoration will not be performed for the application.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | Boolean | Yes (initial value: **false**)| -| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed. If this attribute is set to **false**, the **libs** libraries are stored without being compressed and will be directly loaded during the installation of the HAP file.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | Boolean | Yes (initial value: **true**) | -| directLaunch | Whether the application can be started when the device is locked. If you want to start the application without unlocking the device, set this attribute to **true**. Devices running OpenHarmony do not support this attribute.| Boolean | Yes (initial value: **false**)| +| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types. The value can contain a maximum of 31 characters.| String | Yes | +| supportBackup | Whether the application supports backup and restoration. The value **false** means that the application does not support backup or restoration.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **false**)| +| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed. The value **false** means that the **libs** libraries are stored without being compressed and will be directly loaded during the installation of the HAP file.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **true**) | +| directLaunch | Whether the application can be started when the device is locked. The value **true** means that the application can be started when the device is locked. Devices running OpenHarmony do not support this attribute.| Boolean | Yes (initial value: **false**)| | ark | Maple configuration. See Table 7. | Object | Yes (initial value: left empty) | | network | Network security configuration. You can customize the network security settings of the application in the security statement of the configuration file without modifying the application code. See Table 9.| Object | Yes (initial value: left empty) | -Table 7 Internal structure of the **ark** attribute +Table 7 Internal structure of the ark attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ---------- | -------------------------------- | -------- | ------------------------------ | | reqVersion | Maple version required for the application. For details, see Table 8.| Object | No | | flag | Type of the Maple application. | String | No (available options: **m**, **mo**, **z**).| Table 8 Internal structure of the reqVersion attribute -| Attribute | Description | Data Type| Default| +| Attribute | Description | Data Type| Initial Value Allowed| | ---------- | --------------------------------------------------------- | -------- | ---------- | | compatible | Minimum Maple version required for the application. The value is a 32-bit unsigned integer.| Integer | No | | target | Type of the Maple application. The value is a 32-bit unsigned integer. | Integer | No | Table 9 Internal structure of the network attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ---------------- | ------------------------------------------------------------ | -------- | ----------------------- | | cleartextTraffic | Whether to allow the application to use plaintext traffic, for example, plaintext HTTP traffic.
**true**: The application is allowed to use plaintext traffic.
**false**: The application is not allowed to use plaintext traffic.| Boolean | Yes (initial value: **false**)| | securityConfig | Network security configuration of the application. For details, see Table 10. | Object | Yes (initial value: left empty) | Table 10 Internal structure of the securityConfig attribute -| Attribute | Sub-attribute | Description | Data Type| Default | +| Attribute | Sub-attribute | Description | Data Type| Initial Value Allowed | | -------------- | ------------------ | ------------------------------------------------------------ | -------- | ---------------- | | domainSettings | - | Security settings of the custom network domain. This attribute allows nested domains. To be more specific, the **domainSettings** object of a large domain can be nested with the **domainSettings** objects of small network domains.| Object| Yes (initial value: left empty)| | | cleartextPermitted | Whether plaintext traffic can be transmitted in the custom network domain. If both **cleartextTraffic** and **security** are declared, whether plaintext traffic can be transmitted in the custom network domain is determined by the **cleartextPermitted** attribute.
**true**: Plaintext traffic can be transmitted.
**false**: Plaintext traffic cannot be transmitted.| Boolean| No | @@ -215,28 +214,28 @@ The **module** tag contains the configuration information of the HAP file. For d Table 11 Internal structure of the module tag -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | | mainAbility | Ability displayed on the Service Center icon. When the resident process is started, the **mainAbility** is started.| String | No if any ability using the Page template exists | -| package | Structure name of the HAP file. The value must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | No | -| name | Class name of the HAP file. The value is in the reverse domain name notation. The prefix must be the same as the package name specified by the **package** label at the same level. The value can also start with a period (.). The value is a string with a maximum of 255 bytes.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | No | -| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: left empty) | +| package | Structure name of the HAP file, which must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | No | +| name | Class name of the HAP file. The value is in the reverse domain name notation. The prefix must be the same as the package name specified by the **package** label at the same level. The value can also start with a period (.). The value is a string with a maximum of 255 bytes.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | No | +| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: left empty) | | supportedModes | Mode supported by the application. Currently, only the **drive** mode is defined. This attribute applies only to head units.| String array| Yes (initial value: left empty) | -| deviceType | Type of device on which the abilities can run. The device types predefined in the system include **tablet**, **tv**, **car**, **wearable**, and **liteWearable**. | String array| No | -| distro | Distribution description of the current HAP file. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. For details, see Table 12. | Object | No | +| deviceType | Type of device on which the abilities can run. The device types predefined in the system include **tablet**, **tv**, **car**, and **wearable**.| String array| No | +| distro | Distribution description of the current HAP file. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types. For details, see Table 12.| Object | No | | metaData | Metadata of the HAP file. For details, see Table 13. | Object | Yes (initial value: left empty) | | abilities | All abilities in the current module. The value is an array of objects, each of which represents a shortcut object. For details, see Table 17.| Object array | Yes (initial value: left empty) | | js | A set of JS modules developed using the ArkUI framework. Each element in the set represents the information about a JS module. For details, see Table 22.| Object array | Yes (initial value: left empty) | | shortcuts | Shortcut information of the application. The value is an array of objects, each of which represents a shortcut object. For details, see Table 25.| Object array | Yes (initial value: left empty) | | reqPermissions | Permissions that the application applies for from the system before its running. For details, see Table 21. | Object array | Yes (initial value: left empty) | -| colorMode | Color mode of the application.
**dark**: Resources applicable for the dark mode are selected.
**light**: Resources applicable for the light mode are selected.
**auto**: Resources are selected based on the color mode of the system.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: **auto**) | -| distroFilter | Application distribution rules.
This attribute defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when AppGallery distributes applications. Applications can be distributed by API version, screen shape, or screen resolution. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these three factors. For details, see Table 29. | Object | Yes (initial value: left empty) Configure this attribute when an application has multiple entry modules.| +| colorMode | Color mode of the application.
**dark**: Resources applicable for the dark mode are selected.
**light**: Resources applicable for the light mode are selected.
**auto**: Resources are selected based on the color mode of the system.
This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types. | String | Yes (initial value: **auto**) | +| distroFilter | Application distribution rules.
AppGallery uses these rules to distribute HAP files to the matching devices. Distribution rules cover three factors: API version, screen shape, and screen resolution. AppGallery distributes a HAP file to the device whose on the mapping between **deviceType** and these three factors. For details, see Table 29. | Object | Yes (initial value: left empty)
Set this attribute when an application has multiple entry modules. | | reqCapabilities | Device capabilities required for running the application. | String array| Yes (initial value: left empty) | | commonEvents | Static broadcast. For details, see Table 35. | Object array | Yes (initial value: left empty) | | allowClassMap | Metadata of the HAP file. The value can be **true** or **false**. If the value is **true**, the HAP file uses the Java object proxy mechanism provided by the OpenHarmony framework. | Boolean | No (initial value: **false**) | -| entryTheme | Keyword of an OpenHarmony internal topic. Set it to the resource index of the name.| String | Yes (initial value: left empty) | +| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String | Yes (initial value: left empty) | -Example of the module tag structure: +Example of the **module** tag structure: ```json "module": { @@ -272,13 +271,13 @@ Example of the module tag structure: Table 12 Internal structure of the distro attribute -| Attribute | Description | Data Type| Default| +| Attribute | Description | Data Type| Initial Value Allowed| | ---------------- | ------------------------------------------------------------ | -------- | ---------- | | moduleName | Name of the current HAP file. The maximum length is 31 characters. | String | No | | moduleType | Type of the current HAP file. The value can be **entry** or **feature**. For the HAR type, set this attribute to **har**.| String | No | | installationFree | Whether the HAP file supports the installation-free feature.
**true**: The HAP file supports the installation-free feature and meets installation-free constraints.
**false**: The HAP file does not support the installation-free feature.
Pay attention to the following:
When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap **must be **true**.
When **entry.hap** is set to **false**, **feature.hap** related to **entry.hap** can be set to **true** or **false** based on service requirements.| Boolean | No | -Example of the distro attribute structure: +Example of the **distro** attribute structure: ```json "distro": { @@ -290,7 +289,7 @@ Example of the distro attribute structure: Table 13 Internal structure of the metaData attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------- | ------------------------------------------------------------ | -------- | -------------------- | | parameters | Metadata of the parameters to be passed for calling the ability. The metadata of each parameter consists of the **description**, **name**, and **type** sub-attributes. For details, see Table 14.| Object array| Yes (initial value: left empty) | | results | Metadata of the ability return value. The metadata of each return value consists of the **description**, **name**, and **type** sub-attributes. For details, see Table 15.| Object array| Yes (initial value: left empty)| @@ -298,7 +297,7 @@ Table 13 Internal structure of the metaData attribute Table 14 Internal structure of the parameters attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ----------- | ------------------------------------------------------------ | -------- | ------------------ | | description | Description of the parameter. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty)| | name | Name of the parameter. The value can contain a maximum of 255 characters. | String | Yes (initial value: left empty)| @@ -306,7 +305,7 @@ Table 14 Internal structure of the parameters attribute Table 15 Internal structure of the results attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ----------- | ------------------------------------------------------------ | -------- | -------------------- | | description | Description of the return value. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty)| | name | Name of the return value. The value can contain a maximum of 255 characters. | String | Yes (initial value: left empty)| @@ -314,13 +313,13 @@ Table 15 Internal structure of the results attribute Table 16 Internal structure of the customizeData attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ---------------------------------------------------------- | -------- | -------------------- | | name | Key of a data element. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| | value | Value of a data element. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| | extra | Custom format of the data element. The value is an index to the resource that identifies the data.| String | Yes (initial value: left empty)| -Example of the metaData attribute structure: +Example of the **metaData** attribute structure: ```json "metaData": { @@ -344,45 +343,47 @@ Example of the metaData attribute structure: Table 17 Internal structure of the abilities attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | | process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. Devices running OpenHarmony do not support this attribute.| String | Yes (initial value: left empty) | -| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types.
Note: When you use DevEco Studio to create a project, the configuration of the first ability is generated by default, including the **MainAbility.java** file and the class name **MainAbility** defaulted in the **name** string for the **abilities** attribute in **config.json**. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters. | String | No | +| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.
Note: When you use DevEco Studio to create a project, the configuration of the first ability is generated by default, including the **MainAbility.java** file and the class name **MainAbility** defaulted in the **name** string for the **abilities** attribute in **config.json**. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters.| String | No | | description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) | | icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String | Yes (initial value: left empty) | | label | Ability name visible to users. The value can be a name string or a resource index to names in multiple languages. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) | | uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 characters. | String | Yes (No for abilities using the Data template) | -| launchType | Startup type of the ability. The value can be **standard**, **singleMission**, or **singleton**.
**standard**: Multiple **Ability** instances can be created during startup.
Most abilities can use this type.
**singleMission**: Only a single **Ability** instance can be created in each task stack during startup.
**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton startup type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: **standard**) | +| launchType | Startup type of the ability. The value can be **standard** or **singleton**.
**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.
**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton startup type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: **"singleton"**) | | visible | Whether the ability can be called by other applications.
**true**: The ability can be called by other applications.
**false**: The ability cannot be called by other applications.| Boolean | Yes (initial value: **false**) | | permissions | Permissions required for abilities of another application to call the current ability, generally in the format of a reverse domain name. The value can be either the permissions predefined in the OS or your custom permissions.| String array| Yes (initial value: left empty) | | skills | Types of the **want** that can be accepted by the ability. | Object array | Yes (initial value: left empty) | | deviceCapability | Device capabilities required to run the ability.| String array| Yes (initial value: left empty) | | metaData | Metadata. For details, see Table 13. | Object | Yes (initial value: left empty) | | type | Type of the ability. Available values are as follows:
**page**: FA developed using the Page template to provide the capability of interacting with users.
**service**: PA developed using the Service template to provide the capability of running tasks in the background.
**data**: PA developed using the Data template to provide unified data access for external systems.
**CA**: ability that can be started by other applications as a window.| String | No | -| orientation | Display orientation of the ability. This attribute applies only to the ability using the Page template. Available values are as follows:
unspecified: indicates that the system automatically determines the display orientation of the ability.
**landscape**: indicates the landscape orientation.
**portrait**: indicates the portrait orientation.
**followRecent**: indicates that the orientation follows the most recent application in the stack.| String | Yes (initial value: **unspecified**) | +| orientation | Display orientation of the ability. This attribute applies only to the ability using the Page template. Available values are as follows:
unspecified: indicates that the system automatically determines the display orientation of the ability.
**landscape**: indicates the landscape orientation.
**portrait**: indicates the portrait orientation.
**followRecent**: indicates that the orientation follows the most recent application in the stack.| String | Yes (initial value: **"unspecified"**) | | backgroundModes | Background service type of the ability. You can assign multiple background service types to a specific ability. This attribute applies only to the ability using the Service template. Available values are as follows:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices
**audioPlayback**: audio playback service
**audioRecording**: audio recording service
**pictureInPicture**: picture in picture (PiP) and small-window video playback services
**voip**: voice/video call and VoIP services
**location**: location and navigation services
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services
**wifiInteraction**: WLAN scanning, connection, and transmission services
**screenFetch**: screen recording and screenshot services
**multiDeviceConnection**: multi-device interconnection service| String array| Yes (initial value: left empty) | | grantPermission | Whether permissions can be granted for any data in the ability. | Boolean | Yes (initial value: left empty) | -| readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: left empty) | -| writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: left empty) | +| readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: left empty) | +| writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: left empty) | | configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. Available values are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user has selected a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty) | -| mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: bundle name of the application) | -| targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | String | Yes (initial value: left empty, indicating that the current ability is not an alias)| -| multiUserShared | Whether the ability supports data sharing among multiple users. This attribute applies only to the ability using the Data template. If this attribute is set to **true**, only one copy of data is stored for multiple users. Note that this attribute will invalidate the **visible** attribute. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | Boolean | Yes (initial value: **false**) | -| supportPipMode | Whether the ability allows the user to enter the Picture in Picture (PiP) mode. The PiP mode enables the user to watch a video in a small window that hovers on top of a full screen window (main window). This attribute applies only to the ability using the Page template. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. | Boolean | Yes (initial value: **false**) | +| mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: bundle name of the application) | +| targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String | Yes (initial value: left empty, indicating that the current ability is not an alias)| +| multiUserShared | Whether the ability supports data sharing among multiple users. This attribute applies only to the ability using the Data template. If this attribute is set to **true**, only one copy of data is stored for multiple users. Note that this attribute will invalidate the **visible** attribute. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **false**) | +| supportPipMode | Whether the ability allows the user to enter the Picture in Picture (PiP) mode. The PiP mode enables the user to watch a video in a small window that hovers on top of a full screen window (main window). This attribute applies only to the ability using the Page template. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **false**) | | formsEnabled | Whether the ability can provide forms. This attribute applies only to the ability using the Page template.
**true**: This ability can provide forms.
**false**: This ability cannot provide forms.| Boolean | Yes (initial value: **false**) | | forms | Details about the forms used by the ability. This attribute is valid only when **formsEnabled** is set to **true**. For details, see Table 27.| Object array | Yes (initial value: left empty) | | srcLanguage | Programming language used to develop the ability. | String | The value can be **java**, **js**, or **ets**. | | srcPath | Path of the JS code and components corresponding to the ability. | String | Yes (initial value: left empty) | | uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider. Devices running OpenHarmony do not support this attribute. For details, see Table 18.| Object | Yes (initial value: left empty) | +| startWindowIcon | Index to the icon file of the ability startup page. Example value: **$media:icon**. | String | Yes (initial value: left empty) | +| startWindowBackground | Index to the background color resource file of the ability startup page. Example value: **$color:red**. | String | Yes (initial value: left empty) | Table 18 Internal structure of the uriPermission attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ----------------------- | -------- | ------------------------- | | path | Path identified by **uriPermission**.| String | No | -| mode | Mode matching the **uriPeimission**.| String | Yes (initial value: *default***)| +| mode | Mode matching the **uriPermission**.| String | Yes (initial value: *default***)| -Example of the abilities attribute structure: +Example of the **abilities** attribute structure: ```json "abilities": [ @@ -412,7 +413,9 @@ Example of the abilities attribute structure: "fontSize", "orientation" ], - "type": "page" + "type": "page", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:red" }, { "name": ".PlayService", @@ -449,7 +452,7 @@ Example of the abilities attribute structure: Table 19 Internal structure of the skills attribute -| Attribute| Description | Data Type | Default | +| Attribute| Description | Data Type | Initial Value Allowed | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | Actions of the **want** that can be accepted by the ability. Generally, the value is an **action** value predefined in the system.| String array| Yes (initial value: left empty)| | entities | Entities of the **want** that can be accepted by the ability, such as video and Home application.| String array| Yes (initial value: left empty)| @@ -457,7 +460,7 @@ Table 19 Internal structure of the skills attribute Table 20 Internal structure of the uris attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------- | -------------------------- | -------- | -------------------- | | scheme | Scheme in the URI. | String | No | | host | Host in the URI. | String | Yes (initial value: left empty)| @@ -467,7 +470,7 @@ Table 20 Internal structure of the uris attribute | pathRegx | **pathRegx** value in the URI. | String | Yes (initial value: left empty)| | type | Type of the URI. | String | Yes (initial value: left empty)| -Example of the skills attribute structure: +Example of the **skills** attribute structure: ```json "skills": [ @@ -496,34 +499,34 @@ Table 21 reqPermissions | Attribute | Description | **Type**| **Value Range** | **Default Value** | **Restrictions** | | --------- | ------------------------------------------------------------ | -------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | | name | Permission name, which is mandatory. | String | Custom | None | Parsing will fail if this field is not set. | -| reason | Reason for applying for the permission, which is mandatory only when applying for the **user_grant** permission.| String | The displayed text cannot exceed 256 bytes. | Empty | This field is mandatory for the **user_grant** permission. If it is left empty, application release will be rejected. Multi-language adaptation is required.| -| usedScene | Description of the application scenario and timing for using the permission, which is mandatory only when applying for the **user_grant** permission. This attribute consists of the **ability** and **when** sub-attributes. Multiple abilities can be configured.| Object | **ability**: ability name; **when**: **inuse** or **always**| **ability**: left empty; **when**: **inuse**| The **ability** sub-attribute is mandatory for the **user_grant** permission, and the **when** field is optional. | +| reason | Reason for applying for the permission, which is mandatory only when applying for the **user_grant** permission.| String | The displayed text cannot exceed 256 bytes. | Empty | If the requested permission is **user_grant**, this attribute is required for the application to be released to AppGallery. Multi-language adaptation is required.| +| usedScene | Application scenario and timing for using the permission, which is mandatory when the requested permission is **user_grant**. This attribute consists of the **ability** and **when** sub-attributes. Multiple abilities can be configured.| Object | **ability**: ability name; **when**: **inuse** or **always**| **ability**: left empty; **when**: **inuse**| If the requested permission is **user_grant**, the **ability** sub-attribute is mandatory and **when** is optional. | Table 22 Internal structure of the js attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | | name | Name of a JavaScript component. The default value is **default**. | String | No | | pages | Route information about all pages in the JavaScript component, including the page path and page name. The value is an array, in which each element represents a page. The first element in the array represents the home page of the JavaScript FA.| Array | No | -| window | Window-related configurations. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device type types. For details, see Table 23. | Object | Yes | +| window | Window-related configurations. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types. For details, see Table 23.| Object | Yes | | type | Type of the JavaScript component. Available values are as follows:
**normal**: indicates that the JavaScript component is an application instance.
**form**: indicates that the JavaScript component is a widget instance.| String | Yes (initial value: **normal**)| | mode | Development mode of the JavaScript component. For details, see Table 24. | Object | Yes (initial value: left empty) | Table 23 Internal structure of the window attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | --------------- | ------------------------------------------------------------ | -------- | ----------------------- | | designWidth | Baseline width for page design, in pixels. The size of an element is scaled by the actual device width.| Number | Yes (initial value: 720px) | | autoDesignWidth | Whether to automatically calculate the baseline width for page design. If it is set to **true**, the **designWidth** attribute becomes invalid. The baseline width is calculated based on the device width and screen density.| Boolean| Yes (initial value: **false**)| -Table 24 Internal structure of the **mode** attribute +Table 24 Internal structure of the mode attribute -| Attribute| Description | Data Type | Default | +| Attribute| Description | Data Type | Initial Value Allowed | | -------- | -------------------- | ----------------------------------- | --------------------------- | | type | Type of the JavaScript component.| String. The value can be **pageAbility** or **form**.| Yes (initial value: **pageAbility**)| | syntax | Syntax type of the JavaScript component.| String. The value can be **hml** or **ets**. | Yes (initial value: **hml**) | -Example of the js attribute structure: +Example of the **js** attribute structure: ```json "js": [ @@ -544,7 +547,7 @@ Example of the js attribute structure: Table 25 Internal structure of the shortcuts attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | | shortcutId | Shortcut ID. The value is a string with a maximum of 63 bytes. | String | No | | label | Label of the shortcut, that is, the text description displayed by the shortcut. The value can be a string or a resource index to the description. The value is a string with a maximum of 63 bytes.| String | Yes (initial value: left empty)| @@ -553,12 +556,12 @@ Table 25 Internal structure of the shortcuts attribute Table 26 Internal structure of the intents attribute -| Attribute | Description | Data Type| Default | +| Attribute | Description | Data Type| Initial Value Allowed | | ------------ | --------------------------------------- | -------- | -------------------- | | targetClass | Class name for the target ability of the shortcut. | String | Yes (initial value: left empty)| | targetBundle | Application bundle name for the target ability of the shortcut.| String | Yes (initial value: left empty)| -Example of the shortcuts attribute structure: +Example of the **shortcuts** attribute structure: ```json "shortcuts": [ @@ -577,7 +580,7 @@ Example of the shortcuts attribute structure: Table 27 Internal structure of the forms attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | @@ -591,7 +594,7 @@ Table 27 Internal structure of the forms attribute | updateEnabled | Whether the widget can be updated periodically. Available values are as follows:
**true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended.
**false**: The widget cannot be updated periodically.| Boolean | No | | scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute. | String | Yes (initial value: **0:0**) | | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.| Number | Yes (initial value: **0**) | -| formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) | +| formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) | | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) | | jsComponentName | Component name of the widget. The value is a string with a maximum of 127 bytes. This attribute is required only by JavaScript-programmed widgets.| String | No | | metaData | Metadata of the widget. This attribute contains the array of the **customizeData** attribute. For details, see Table 13. | Object | Yes (initial value: left empty) | @@ -599,13 +602,13 @@ Table 27 Internal structure of the forms attribute Table 28 Internal structure of the customizeData attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | --------------------------------------------------- | -------- | -------------------- | | name | Name in the custom name-value pair. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| | value | Value in the custom name-value pair. The value is a string with a maximum of 255 bytes. | String | Yes (initial value: left empty)| | extra | Format of the current custom data. The value is the resource value of **extra**.| String | Yes (initial value: left empty)| -Example of the forms attribute structure: +Example of the **forms** attribute structure: ```json "forms": [ @@ -660,7 +663,7 @@ Example of the forms attribute structure: Table 29 Internal structure of the distroFilter attribute -| Attribute | Description | Data Type| Default| +| Attribute | Description | Data Type| Initial Value Allowed| | ------------- | ------------------------------------------------------------ | -------- | ---------- | | apiVersion | Supported API versions. For details, see Table 30. | Object | No | | screenShape | Supported screen shapes. For details, see Table 31. | Object array| No | @@ -670,40 +673,40 @@ Table 29 Internal structure of the distroFilter attribute Table 30 Internal structure of the apiVersion attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | An integer of the existing API version, for example, 4, 5, or 6. Example: If an application uses two software versions developed using API 5 and API 6 for the same device model, two installation packages of the entry type can be released.| Array | Yes (initial value: left empty)| Table 31 Internal structure of the screenShape attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | The value can be **circle** or **rect**. Example: Different HAPs can be provided for a smart watch with a circular face and that with a rectangular face.| Array | Yes (initial value: left empty)| Table 32 Internal structure of the screenWindow attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | Width and height of the screen. The value of a single string is in the format of Width x Height in pixels, for example, **454*454**.| Array | Yes (initial value: left empty)| Table 33 Internal structure of the screenDensity attribute -| Attribute| Description | Data Type| Default | +| Attribute| Description | Data Type| Initial Value Allowed | | -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | Available values are as follows:
**sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
**mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
**ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
**xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
**xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
**xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| Array | Yes (initial value: left empty)| Table 34 Internal structure of the countryCode attribute -| Attribute| Description | Data Type | Default | +| Attribute| Description | Data Type | Initial Value Allowed | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | -| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**.**include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| +| policy | Blocklist and trustlist rule of the sub-attribute value. Set this attribute to **exclude** or **include**. **include** indicates that the sub-attribute value is in the trustlist. If the value matches any of the **value** enums, it matches this attribute.| String | Yes (initial value: left empty)| | value | Country code of the area to which the application is to be distributed. The value is a string array, of which each substring indicates a country or region. The substring consists of two uppercase letters.| String array| Yes (initial value: left empty)| -Example of the distroFilter attribute structure: +Example of the **distroFilter** attribute structure: ```json "distroFilter": { @@ -732,15 +735,15 @@ Example of the distroFilter attribute structure: Table 35 Internal structure of the commonEvents attribute -| Attribute | Description | Data Type | Default | +| Attribute | Description | Data Type | Initial Value Allowed | | ---------- | ------------------------------------------------------------ | ---------- | ------------------ | | name | Name of a static broadcast. | String | No | -| permission | Permission that needs to be applied for to implement the static common event. | String array| Yes (initial value: left empty)| +| permission | Permission needed to implement the static common event. | String array| Yes (initial value: left empty)| | data | Additional data array to be carried by the current static common event. | String array| Yes (initial value: left empty)| | type | Type array of the current static common event. | String array| Yes (initial value: left empty)| | events | A set of events for the wants that can be received. The value can be system predefined or custom.| String array| No | -Example of the commonEvents attribute structure: +Example of the **commonEvents** attribute structure: ```json "commonEvents": [ diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md index 070a76f249a753fae52e970e36c257862e4d7ce4..7dcfb3583408d68454489f1eef38f1b1e19defea 100644 --- a/en/application-dev/quick-start/start-overview.md +++ b/en/application-dev/quick-start/start-overview.md @@ -18,10 +18,10 @@ OpenHarmony provides a UI development framework, known as ArkUI. ArkUI provides 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** | +| **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 | +| 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. diff --git a/en/application-dev/quick-start/start-with-ets-low-code.md b/en/application-dev/quick-start/start-with-ets-low-code.md index 7e0fd658f59ec68342dfa8b4fffdd82152a980ae..a2e41c66e918ccc33623ab6b746d1129fdedd7d3 100644 --- a/en/application-dev/quick-start/start-with-ets-low-code.md +++ b/en/application-dev/quick-start/start-with-ets-low-code.md @@ -1,10 +1,9 @@ # Getting Started with eTS in the Low-Code Approach -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> This feature is supported in DevEco Studio V3.0 Beta3 and later versions. -> +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
This feature is supported in DevEco Studio V3.0 Beta3 and later versions. +> > The component lineup that supports low-code development in eTS is now at its preliminary stage and will be expanding in coming 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. @@ -21,7 +20,7 @@ You can develop applications or services in the low-code approach using either o ## Creating a Project That Supports Low-Code Development -1. Open DevEco Studio, choose **File** > **New** > **Create Project**, select **Empty Ability**, and click **Next**. +1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**. ![en-us_image_0000001233528152](figures/en-us_image_0000001233528152.png) @@ -50,26 +49,32 @@ After the project synchronization is complete, the default first page contains t Add **Column**, **Text**, and **Button** components to the first page. A column is a container component whose child components are vertically arranged. For details, see [Column](../reference/arkui-ts/ts-container-column.md). 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. + + 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_0000001233208980](figures/en-us_image_0000001233208980.gif) +![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) 2. Add a **Column** component and set its styles and attributes. + Drag the **Column** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001233048996](figures/en-us_image_0000001233048996.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001233368860](figures/en-us_image_0000001233368860.png)**Feature** and set **AlignItems** to **center** so that the child components of the **Column** component are centered along the horizontal axis. Below is an illustration of the operations. ![en-us_image_0000001277488977](figures/en-us_image_0000001277488977.gif) 3. Add a **Text** component. + Drag the **Text** component from the **UI Control** area to the canvas and then to the center area of the **Column** component. In the **Attributes & Styles** area, click ![en-us_image_0000001277608813](figures/en-us_image_0000001277608813.png)**Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hello World**), set **FontSize** to **30fp**, and set **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_0000001235731706](figures/en-us_image_0000001235731706.gif) 4. Add a **Button** component. + Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations. - ![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) +![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) + +5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. -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 in the Previewer. + Below is how the first page looks in the Previewer. ![en-us_image_0000001235892798](figures/en-us_image_0000001235892798.png) @@ -77,9 +82,10 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ## 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** > **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder. + + In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder. - ![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) +![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) 2. [Delete the existing template components from the canvas.](#delete_origin_content) @@ -108,6 +114,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ![en-us_image_0000001280255513](figures/en-us_image_0000001280255513.gif) 5. Add a **Button** component. + Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes & Styles** area on the right, click ![en-us_image_0000001233528160](figures/en-us_image_0000001233528160.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277728597](figures/en-us_image_0000001277728597.png)**Feature** and set **Value** to **Back** and **FontSize** to **25fp**. Below is an illustration of the operations. ![en-us_image_0000001280383937](figures/en-us_image_0000001280383937.gif) @@ -118,7 +125,9 @@ Add **Column**, **Text**, and **Button** components to the first page. A column 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 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 .ets and .visual files. + + 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 .ets and .visual files. + - In the **index.ets** file: ``` @@ -143,12 +152,13 @@ You can implement page redirection through the page router, which finds the targ } } ``` - - - In the index.visual file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001233209020](figures/en-us_image_0000001233209020.png)**Events** and set **OnClick** to **this.onclick**. - ![en-us_image_0000001235745716](figures/en-us_image_0000001235745716.png) + - In the **index.visual** file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001233209020](figures/en-us_image_0000001233209020.png)**Events** and set **OnClick** to **this.onclick**. + ![en-us_image_0000001235745716](figures/en-us_image_0000001235745716.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 .ets and .visual files. - In the **second.ets** file: @@ -174,7 +184,7 @@ You can implement page redirection through the page router, which finds the targ } } ``` - - In the second.visual file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001233368900](figures/en-us_image_0000001233368900.png)**Events** and set **OnClick** to **this.back**. + - In the **second.visual** file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click ![en-us_image_0000001233368900](figures/en-us_image_0000001233368900.png)**Events** and set **OnClick** to **this.back**. ![en-us_image_0000001280385809](figures/en-us_image_0000001280385809.png) diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md index 9ec3597755e23ba5172f24d1a72b1c9274a13cdc..53c1133bfb918ed07e1c6d81f90a2f46a85ca500 100644 --- a/en/application-dev/quick-start/start-with-ets.md +++ b/en/application-dev/quick-start/start-with-ets.md @@ -1,14 +1,13 @@ # Getting Started with eTS in the Traditional Coding Approach -> ![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. -> +> ![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**. +1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**. ![en-us_image_0000001223556342](figures/en-us_image_0000001223556342.png) @@ -21,14 +20,14 @@ ## eTS Project Files -- **entry** : OpenHarmony project module, which can be built into an ability package (HAP). +- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#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**. + - **build-profile.json5** : current 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. @@ -37,9 +36,10 @@ ## 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 @@ -61,9 +61,10 @@ ``` 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 @@ -97,7 +98,9 @@ } ``` -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. +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) @@ -105,14 +108,16 @@ ## 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: + + 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, you can see the structure of the **pages** folder. - ![en-us_image_0000001223397122](figures/en-us_image_0000001223397122.png) +![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 @@ -151,9 +156,10 @@ 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 '@ohos.router'; @@ -194,9 +200,10 @@ You can implement page redirection through the page router, which finds the targ ``` 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 '@ohos.router'; 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 index 760db88367888ce365b76d09a9441b05b1e16f3f..a20c01c2f459fc07b799ca847683f99350dd4829 100644 --- a/en/application-dev/quick-start/start-with-js-low-code.md +++ b/en/application-dev/quick-start/start-with-js-low-code.md @@ -1,8 +1,7 @@ # 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. -> +> ![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. @@ -19,10 +18,10 @@ You can develop applications or services in the low-code approach using either o ## 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. +> ![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**. +1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** > **New** > **Create Project**. Then, 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. @@ -39,8 +38,8 @@ After the project synchronization is complete, a low-code directory structure is ![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**. + > ![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. @@ -51,26 +50,33 @@ After the project synchronization is complete, the default first page contains t 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. + + +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) +![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) +![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. +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) @@ -78,20 +84,23 @@ Add **Div**, **Text**, and **Button** components to the first page. ## 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: + + 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, you can see the structure of the **pages** folder. - ![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) +![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) @@ -102,7 +111,9 @@ Add **Div**, **Text**, and **Button** components to the first page. 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 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: ```js @@ -118,10 +129,11 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ``` - 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) - + + ![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. @@ -137,7 +149,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin } } ``` - - 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**. + - 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) diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md index 1935fd67953ad414d7267275dabdabffd185ece3..60131768f2dd3727a4d1467ca92896abb0239752 100644 --- a/en/application-dev/quick-start/start-with-js.md +++ b/en/application-dev/quick-start/start-with-js.md @@ -1,12 +1,12 @@ # 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. +> ![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**. +1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**. ![en-us_image_0000001223558814](figures/en-us_image_0000001223558814.png) @@ -19,26 +19,27 @@ ## 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. +- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#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**: current 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: - + ```
@@ -48,9 +49,10 @@ ``` 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: - + ```
@@ -63,9 +65,10 @@ ``` 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; @@ -96,22 +99,26 @@ } ``` -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. - +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: + + 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, you can see the structure of the **second** folder. - ![en-us_image_0000001223877210](figures/en-us_image_0000001223877210.png) +![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: - + ```
@@ -124,7 +131,7 @@ ``` 3. Set the page style in the **second.css** file. The sample code in the **second.css** file is shown below: - + ``` .container { display: flex; @@ -161,9 +168,10 @@ 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 '@ohos.router'; @@ -177,9 +185,10 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ``` 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 '@ohos.router'; diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index d3e2597d19eff7001b17d41a0be2f9fab43a2947..9db4123736ac6f7a03605c931713076e13f7d2c6 100644 --- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -1,7 +1,7 @@ # 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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import @@ -36,7 +36,7 @@ Triggered when the Work Scheduler task starts. ## WorkSchedulerExtensionAbility.onWorkStop -onWorkStop(work: workScheduler.WorkInfo) +onWorkStop(work: workScheduler.WorkInfo): void Triggered when the Work Scheduler task stops. diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index 5197114dc3068f84c457530b58ca8a7a5520d1c2..8c2e4f41606e44f93d872427c2c81b1ecf70cb4f 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -13,17 +13,6 @@ import bluetooth from '@ohos.bluetooth'; ``` -## Required Permissions - -ohos.permission.USE_BLUETOOTH - -ohos.permission.MANAGE_BLUETOOTH - -ohos.permission.DISCOVER_BLUETOOTH - -ohos.permission.LOCATION - - ## bluetooth.enableBluetooth8+ enableBluetooth(): boolean @@ -202,7 +191,7 @@ let result = bluetooth.pairDevice("XX:XX:XX:XX:XX:XX"); getProfileConnState(profileId: ProfileId): ProfileConnectionState -Obtains the connection status of a profile. +Obtains the connection state of a profile. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -237,6 +226,8 @@ Cancels a paired remote device. **System capability**: SystemCapability.Communication.Bluetooth.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name | Type | Mandatory | Description | @@ -979,13 +970,13 @@ Obtains a profile object. | Name | Type | Mandatory | Description | | --------- | --------- | ---- | ------------------------------------- | -| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.| +| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| A2dpSourceProfile or HandsFreeAudioGatewayProfile| Profile object obtained. Only **A2dpSourceProfile** and **HandsFreeAudioGatewayProfile** are supported.| +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [A2dpSourceProfile](#A2dpSourceProfile) or [HandsFreeAudioGatewayProfile](#HandsFreeAudioGatewayProfile) | Profile object obtained. Only **A2dpSourceProfile** and **HandsFreeAudioGatewayProfile** are supported.| **Example** @@ -993,6 +984,32 @@ Obtains a profile object. let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); ``` +## bluetooth.getProfile9+ + +getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile + +Obtains the profile object instance based on **ProfileId**. API version 9 is added with **HidHostProfile**. + +**System capability**: SystemCapability.Communication.Bluetooth.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------- | ---- | ------------------------------------- | +| profileId | [ProfileId](#ProfileId) | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [A2dpSourceProfile](#A2dpSourceProfile), [HandsFreeAudioGatewayProfile](#HandsFreeAudioGatewayProfile), or [HidHostProfile](#HidHostProfile) | Profile object obtained. **A2dpSourceProfile**, **HandsFreeAudioGatewayProfile**, and **HidHostProfile** are supported.| + +**Example** + +```js +let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +``` + ## bluetooth.BLE @@ -1215,17 +1232,22 @@ No value is returned. **Return value** -| | | +| Type | Description | | ------------------- | ------------- | -| Type | Description | -| Array<string> | List of addresses of the connected devices. | +| Array<string> | Addresses of the connected devices.| +**Example** + +```js +let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE) +let retArray = a2dpSrc.getConnectionDevices(); +``` ### getDeviceState8+ getDeviceState(device: string): ProfileConnectionState -Obtains the connection status of the profile. +Obtains the connection state of the profile. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -1235,16 +1257,20 @@ Obtains the connection status of the profile. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the target device.| -| +| device | string | Yes | Address of the remote device.| **Return value** -| | | +| Type | Description | | ------------------------------------------------- | ----------------------- | -| Type | Description | -| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained. | +| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.| +**Example** + +```js +let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE) +let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX'); +``` ## A2dpSourceProfile @@ -1266,14 +1292,12 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the remote device to connect.| -| **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1298,14 +1322,12 @@ Disconnects an A2DP connection. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the remote device to disconnect.| -| **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1315,11 +1337,11 @@ let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX'); ``` -### A2dpSourceProfile.on('connectionStateChange')8+ +### on('connectionStateChange')8+ on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void -Subscribes to the A2DP connection status change events. +Subscribes to the A2DP connection state change events. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -1340,15 +1362,16 @@ No value is returned. function onReceiveEvent(data) { console.info('a2dp state = '+ JSON.stringify(data)); } -A2dpSourceProfile.on('connectionStateChange', onReceiveEvent); +let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +a2dpSrc.on('connectionStateChange', onReceiveEvent); ``` -### A2dpSourceProfile.off('connectionStateChange')8+ +### off('connectionStateChange')8+ off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void -Unsubscribes from the A2DP connection status change events. +Unsubscribes from the A2DP connection state change events. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -1357,7 +1380,7 @@ Unsubscribes from the A2DP connection status change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the A2DP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the A2DP connection state change event. | **Return value** @@ -1369,7 +1392,9 @@ No value is returned. function onReceiveEvent(data) { console.info('a2dp state = '+ JSON.stringify(data)); } -A2dpSourceProfile.off('connectionStateChange', onReceiveEvent); +let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +a2dpSrc.on('connectionStateChange', onReceiveEvent); +a2dpSrc.off('connectionStateChange', onReceiveEvent); ``` @@ -1377,7 +1402,7 @@ A2dpSourceProfile.off('connectionStateChange', onReceiveEvent); getPlayingState(device: string): PlayingState -Obtains the playing status of a device. +Obtains the playing state of a device. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -1385,14 +1410,13 @@ Obtains the playing status of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the target device.| +| device | string | Yes | Address of the remote device.| **Return value** -| | | +| Type | Description | | ----------------------------- | ---------- | -| Type | Description | -| [PlayingState](#PlayingState) | Playing status obtained. | +| [PlayingState](#PlayingState) | Playing state of the remote device obtained.| **Example** @@ -1421,15 +1445,13 @@ Sets up a Hands-free Profile (HFP) connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the target device.| -| +| device | string | Yes | Address of the remote device.| **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1453,8 +1475,7 @@ Disconnects the HFP connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the target device.| -| +| device | string | Yes | Address of the remote device.| **Return value** @@ -1470,11 +1491,11 @@ let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX'); ``` -### HandsFreeAudioGatewayProfile.on('connectionStateChange')8+ +### on('connectionStateChange')8+ on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void -Subscribes to the HFP connection status change events. +Subscribes to the HFP connection state change events. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -1495,15 +1516,16 @@ No value is returned. function onReceiveEvent(data) { console.info('hfp state = '+ JSON.stringify(data)); } -HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent); +let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +hfpAg.on('connectionStateChange', onReceiveEvent); ``` -### HandsFreeAudioGatewayProfile.off('connectionStateChange')8+ +### off('connectionStateChange')8+ off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void -Unsubscribes from the HFP connection status change events. +Unsubscribes from the HFP connection state change events. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -1512,7 +1534,7 @@ Unsubscribes from the HFP connection status change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the HFP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the HFP connection state change event. | **Return value** @@ -1524,7 +1546,139 @@ No value is returned. function onReceiveEvent(data) { console.info('hfp state = '+ JSON.stringify(data)); } -HandsFreeAudioGatewayProfile.off('connectionStateChange', onReceiveEvent); +let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +hfpAg.on('connectionStateChange', onReceiveEvent); +hfpAg.off('connectionStateChange', onReceiveEvent); +``` + + +## HidHostProfile + +Before using a method of **HidHostProfile**, you need to create an instance of this class by using the **getProfile()** method. + + +### connect9+ + +connect(device: string): boolean + +Connects to the HidHost service of a device. + +**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH + +**System capability**: SystemCapability.Communication.Bluetooth.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ------- | +| device | string | Yes | Address of the remote device.| + +**Return value** + +| Type | Description | +| --------------------- | --------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```js +let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST); +let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); +``` + + +### disconnect9+ + +disconnect(device: string): boolean + +Disconnects from the HidHost service of a device. + +**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH + +**System capability**: SystemCapability.Communication.Bluetooth.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ------- | +| device | string | Yes | Address of the remote device.| + +**Return value** + +| Type | Description | +| --------------------- | --------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```js +let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST); +let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX'); +``` + + +### on('connectionStateChange')9+ + +on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void + +Subscribes to the HidHost connection state change events. + +**System capability**: SystemCapability.Communication.Bluetooth.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event.| +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HidHost connection state change event. | + +**Return value** + +No value is returned. + +**Example** + +```js +function onReceiveEvent(data) { + console.info('hidHost state = '+ JSON.stringify(data)); +} +let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +hidHost.on('connectionStateChange', onReceiveEvent); +``` + + +### off('connectionStateChange')9+ + +off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void + +Unsubscribes from the HidHost connection state change events. + +**System capability**: SystemCapability.Communication.Bluetooth.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- | +| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event.| +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the HidHost connection state change event. | + +**Return value** + +No value is returned. + +**Example** + +```js +function onReceiveEvent(data) { + console.info('hidHost state = '+ JSON.stringify(data)); +} +let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +hidHost.on('connectionStateChange', onReceiveEvent); +hidHost.off('connectionStateChange', onReceiveEvent); ``` @@ -1904,7 +2058,7 @@ Subscribes to the characteristic write request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | -------------------------------------- | | type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event.| -| callback | Callback<[CharacteristicWriteReq](#descriptorwritereq)> | Yes | Callback invoked to return a characteristic write request from the GATT client. | +| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | Yes | Callback invoked to return a characteristic write request from the GATT client. | **Return value** @@ -2272,7 +2426,7 @@ let ret = device.close(); getServices(callback: AsyncCallback<Array<GattService>>): void -Obtains all services of the remote BLE device. This method uses an asynchronous callback to return the result. +Obtains all services of the remote BLE device. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2314,7 +2468,7 @@ device.getServices(getServices); getServices(): Promise<Array<GattService>> -Obtains all services of the remote BLE device. This method uses a promise to return the result. +Obtains all services of the remote BLE device. This API uses a promise to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2347,7 +2501,7 @@ for (let i = 0; i < services.length; i++) { readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void -Reads the characteristic value of the specific service of the remote BLE device. This method uses an asynchronous callback to return the result. +Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2401,7 +2555,7 @@ device.readCharacteristicValue(characteristic, readCcc); readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic> -Reads the characteristic value of the specific service of the remote BLE device. This method uses a promise to return the result. +Reads the characteristic value of the specific service of the remote BLE device. This API uses a promise to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2448,7 +2602,7 @@ device.readCharacteristicValue(characteristic); readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void -Reads the descriptor contained in the specific characteristic of the remote BLE device. This method uses an asynchronous callback to return the result. +Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2492,7 +2646,7 @@ device.readDescriptorValue(descriptor, readDesc); readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor> -Reads the descriptor contained in the specific characteristic of the remote BLE device. This method uses a promise to return the result. +Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses a promise to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2620,7 +2774,7 @@ if (retWriteDesc) { setBLEMtuSize(mtu: number): boolean -Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This method can be used only after a connection is set up by calling [connect](#connect). +Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect). **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2806,7 +2960,7 @@ device.off('BLEConnectionStateChange'); getDeviceName(callback: AsyncCallback<string>): void -Obtains the name of the remote BLE device. This method uses an asynchronous callback to return the result. +Obtains the name of the remote BLE device. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2838,7 +2992,7 @@ let deviceName = gattClient.getDeviceName((err, data)=> { getDeviceName(): Promise<string> -Obtains the name of the remote BLE device. This method uses a promise to return the result. +Obtains the name of the remote BLE device. This API uses a promise to return the result. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2866,7 +3020,7 @@ let deviceName = gattClient.getDeviceName().then((data) => { getRssiValue(callback: AsyncCallback<number>): void -Obtains the received signal strength indication (RSSI) of the remote BLE device. This method uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect). +Obtains the received signal strength indication (RSSI) of the remote BLE device. This API uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect). **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -2899,7 +3053,7 @@ let rssi = gattClient.getRssiValue((err, data)=> { getRssiValue(): Promise<number> -Obtains the RSSI of the remote BLE device. This method uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect). +Obtains the RSSI of the remote BLE device. This API uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect). **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -3436,7 +3590,7 @@ Enumerates the A2DP playing states. ## ProfileId8+ -Enumerates the Bluetooth profile IDs. +Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST**. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -3444,3 +3598,4 @@ Enumerates the Bluetooth profile IDs. | -------------------------------- | ------ | --------------- | | PROFILE_A2DP_SOURCE | 0x0001 | A2DP profile.| | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | HFP profile. | +| PROFILE_HID_HOST9+ | 0x0006 | Human Interface Device (HID) profile. | diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 2f4b695a6c88c635d4a92cd1b58c617e47d2b5c2..14fba2457383feceeefe0b302b1710e856bc187e 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -6,8 +6,8 @@ ## Modules to Import -``` -import dataAbility from '@ohos.data.dataAbility' +```js +import dataAbility from '@ohos.data.dataAbility'; ``` @@ -21,19 +21,19 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Table name in the RDB store.| - | dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object.| + | dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. | -- Return value +**Return value** | Type| Description| | -------- | -------- | | rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.| -- Example: - ``` +**Example** + ```js let dataAbilityPredicates = new dataAbility.DataAbilityPredicates() dataAbilityPredicates.equalTo("NAME", "Rose").between("AGE", 16, 30) let predicates = dataAbility.createRdbPredicates("EMPLOYEE", dataAbilityPredicates) @@ -55,19 +55,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") ``` @@ -83,19 +83,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.notEqualTo("NAME", "lisi") ``` @@ -111,13 +111,13 @@ Adds a left parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbilitylity.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") .beginWrap() @@ -138,13 +138,13 @@ Adds a right parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") .beginWrap() @@ -165,13 +165,13 @@ Adds the OR condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") .or() @@ -189,13 +189,13 @@ Adds the AND condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") .and() @@ -213,19 +213,19 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| | value | string | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.contains("NAME", "os") ``` @@ -241,19 +241,19 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| | value | string | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.beginsWith("NAME", "os") ``` @@ -269,18 +269,18 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| | value | string | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: +**Example** ``` let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.endsWith("NAME", "se") @@ -297,18 +297,18 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.isNull("NAME") ``` @@ -324,18 +324,18 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.isNotNull("NAME") ``` @@ -351,19 +351,19 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| | value | string | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.like("NAME", "%os%") ``` @@ -379,19 +379,19 @@ Sets a **DataAbilityPredicates** object to match the specified string. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| | value | string | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.glob("NAME", "?h*g") ``` @@ -407,20 +407,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | low | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| + | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| + | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.between("AGE", 10, 50) ``` @@ -436,20 +436,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | low | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| + | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| + | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.notBetween("AGE", 10, 50) ``` @@ -465,19 +465,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.greaterThan("AGE", 18) ``` @@ -493,19 +493,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.lessThan("AGE", 20) ``` @@ -521,19 +521,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.greaterThanOrEqualTo("AGE", 18) ``` @@ -549,19 +549,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | [ValueType](js-apis-data-rdb.md#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| + | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.lessThanOrEqualTo("AGE", 20) ``` @@ -577,18 +577,18 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.orderByAsc("NAME") ``` @@ -604,18 +604,18 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.orderByDesc("AGE") ``` @@ -631,13 +631,13 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") let promiseDistinct = rdbStore.query(predicates, ["NAME"]) @@ -659,18 +659,18 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | number | Yes| Maximum number of records.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").limitAs(3) ``` @@ -686,18 +686,18 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").offsetAs(3) ``` @@ -713,18 +713,18 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fields | Array<string> | Yes| Names of columns to group.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.groupBy(["AGE", "NAME"]) ``` @@ -738,18 +738,18 @@ indexedBy(field: string): DataAbilityPredicates Sets a **DataAbilityPredicates** object to specify the index column. -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | indexName | string | Yes| Name of the index column.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.indexedBy("SALARY_INDEX") ``` @@ -765,20 +765,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](js-apis-data-rdb.md#valuetype)> | Yes| Array of **ValueType**s to match.| + | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.in("AGE", [18, 20]) ``` @@ -794,20 +794,32 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](js-apis-data-rdb.md#valuetype)> | Yes| Array of **ValueType**s to match.| + | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| -- Example: - ``` +**Example** + ```js let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.notIn("NAME", ["Lisa", "Rose"]) ``` + +## ValueType + +Enumerates the value types. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +| Name | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string. | +| boolean | The value is of Boolean type.| diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md index ed0829f6f6789c2aac7180df3ba5bc0e1d6c275e..6670e2eefaea1bd07d85083bf5436833613f998e 100644 --- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -7,7 +7,7 @@ ## Modules to Import ```js -import distributedObject from '@ohos.data.distributedDataObject' +import distributedObject from '@ohos.data.distributedDataObject'; ``` @@ -25,11 +25,11 @@ Creates a distributed data object. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | source | object | Yes| Attribute of the distributed data object to create.| - + **Return Value** - | Type| Description| - | -------- | -------- | - | [DistributedObject](#distributedobject) | Distributed data object created.| +| Type| Description| +| -------- | -------- | +| [DistributedObject](#distributedobject) | Distributed data object created.| **Example** ```js @@ -83,7 +83,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo | Type| Description| | -------- | -------- | | boolean | Returns **true** if the session ID is set successfully;
returns **false** otherwise. | - + **Example** ```js @@ -171,8 +171,6 @@ Subscribes to the status changes (online or offline) of this distributed data ob | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.| | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the online or offline status.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the network ID of the device.
**status** indicates the status, which can be online or offline.| - - **Example** ```js import distributedObject from '@ohos.data.distributedDataObject' diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 95e2ed9fcdb3459ae9c818e149f2ce46b530b722..791908e6c9a8e8509f364c587fa132958e475c31 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -1,69 +1,71 @@ -# Lightweight Storage +# Preferences -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. +Preferences provide capabilities for processing key-value (KV) data for applications and supports lightweight data persistence, modification, and query. Data is stored in 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**
+> ![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' +```ts +import data_preferences from '@ohos.data.preferences'; ``` -## Attributes +## Constants **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.| +| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. 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. +Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```ts 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.put('startup', 'auto', function (err) { + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { - console.info("Put the value of startup failed with err: " + err) - return + console.info("Failed to get the preferences") + return; } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { + preferences.put('startup', 'auto', function (err) { if (err) { - console.info("Flush to file failed with err: " + err) + console.info("Failed to put the value of startup, err: " + err) return } - console.info("Flushed to file successfully.") + console.info("Put the value of startup successfully.") + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") + }) }) }) - }) + } ``` @@ -71,45 +73,47 @@ Reads a file and loads the data to the **Preferences** instance. This method use 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. +Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<[Preferences](#preferences)> | Promise used to return the result.| + | Promise<[Preferences](#preferences)> | Promise used to return the execution result.| -- Example - ``` +**Example** + ```ts 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.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.") - preferences.flush(function (err) { + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + preferences.put('startup', 'auto', function (err) { if (err) { - console.info("Flush to file failed with err: " + err) + console.info("Failed to put the value of startup, err: " + err) return } - console.info("Flushed to file successfully.") + console.info("Put the value of startup successfully.") + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") + }) }) + }).catch((err) => { + console.info("Failed to get the preferences") }) - }).catch((err) => { - console.info("Get the preferences failed, path: " + path + '/mystore') - }) + } ``` @@ -117,28 +121,32 @@ Reads a file and loads the data to the **Preferences** instance. This method use 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. +Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory. +Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```ts 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.") - }) + export default class MainAbility extends Ability { + + data_preferences.deletePreferences(this.context, 'mystore', function (err) { + if (err) { + console.info("Failed to delete data, err: " + err) + return + } + console.info("Deleted data successfully.") + }) + } ``` @@ -146,31 +154,35 @@ Removes the singleton **Preferences** instance of the specified file from the me 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. +Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory. +Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution result.| -- Example - ``` +**Example** + ```ts 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) - }) + export default class MainAbility extends Ability { + + let promise = data_preferences.deletePreferences(this.context, 'mystore') + promise.then(() => { + console.info("Deleted data successfully.") + }).catch((err) => { + console.info("Failed to delete data, err: " + err) + }) + } ``` @@ -178,30 +190,33 @@ Removes the singleton **Preferences** instance of the specified file from the me 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. +Removes a **Preferences** singleton instance from the memory. -This method uses an asynchronous callback to return the result. +When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```ts 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.") - }) + export default class MainAbility extends Ability { + + data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { + if (err) { + console.info("Failed to remove preferences from cache, err: " + err) + return + } + console.info("Removed preferences from cache successfully.") + }) + } ``` @@ -209,33 +224,36 @@ This method uses an asynchronous callback to return the result. 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. +Removes a **Preferences** singleton instance from the memory. -This method uses a promise to return the result. +When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution result.| -- Example - ``` +**Example** + ```ts 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) - }) + export default class MainAbility extends Ability { + + let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') + promise.then(() => { + console.info("Removed preferences from cache successfully.") + }).catch((err) => { + console.info("Failed to remove preferences from cache, err: " + err) + }) + } ``` @@ -248,28 +266,37 @@ Provides APIs for obtaining and modifying storage data. 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. +Obtains the value of a key. If the value is null or a non-default value, the default data is returned. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data to obtain. It cannot be empty.| + | defValue | [ValueType](#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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Get the preferences failed, err: " + err) + return + } + preferences.get('startup', 'default', function(err, value) { + if (err) { + console.info("Get the value of startup failed, err: " + err) + return + } + console.info("The value of startup is " + value) + }) + }) + } ``` @@ -277,31 +304,39 @@ This method uses an asynchronous callback to return the result. 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. +Obtains the value of a key. If the value is null or a non-default value, the default data is returned. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +- **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.| + | key | string | Yes| Key of the data to obtain. It cannot be empty.| + | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<ValueType> | Promise used to return the result.| + | Promise<ValueType> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promiseGet = preferences.get('startup', 'default') + promiseGet.then((value) => { + console.info("The value of startup is " + value) + }).catch((err) => { + console.info("Failed to get the value of startup, err: " + err) + }) + }).catch((err) => { + console.info("Get the preferences failed, err: " + err) + }) + } ``` @@ -309,28 +344,37 @@ This method uses a promise to return the result. 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. +Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data. It cannot be empty.| + | value | [ValueType](#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.") - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + }) + }) + } ``` @@ -338,31 +382,39 @@ This method uses an asynchronous callback to return the result. 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. +Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data. It cannot be empty.| + | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promisePut = preferences.put('startup', 'auto') + promisePut.then(() => { + console.info("Put the value of startup successfully.") + }).catch((err) => { + console.info("Failed to put the value of startup, err: " + err) + }) + }).catch((err) => { + console.info("Get the preferences failed, err: " + err) + }) + } ``` @@ -370,34 +422,45 @@ This method uses a promise to return the result. 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. +Checks whether the **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| + | key | string | Yes| Key of the data to check. It cannot be empty.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the execution result.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | boolean | Returns **true** if the **Preference** object contains data with the specified key; returns **false** otherwise.| + | boolean | Returns **true** if the **Preferences** instance 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.") - } - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.has('startup', function (err, isExist) { + if (err) { + console.info("Failed to check the key of startup, err: " + err) + return + } + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } + }) + }) + } ``` @@ -405,32 +468,42 @@ This method uses an asynchronous callback to return the result. 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. +Checks whether the **Preferences** instance contains data with a given key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| + | key | string | Yes| Key of the data to check. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<boolean> | Promise used to return the result.| + | Promise<boolean> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promiseHas = preferences.has('startup') + promiseHas.then((isExist) => { + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } + }).catch((err) => { + console.info("Check the key of startup failed, err: " + err) + }) + }).catch((err) => { + console.info("Get the preferences failed, err: " + err) + }) + } ``` @@ -438,27 +511,36 @@ This method uses a promise to return the result. 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. +Deletes the KV pair of the specified key from this **Preferences** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data. It cannot be empty.| + | key | string | Yes| Key of the KV pair to delete. 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.") - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.delete('startup', function (err) { + if (err) { + console.info("Failed to delete startup key, err: " + err) + return + } + console.info("Deleted startup key successfully.") + }) + }) + } ``` @@ -466,30 +548,38 @@ This method uses an asynchronous callback to return the result. delete(key: string): Promise<void> -Deletes data with the specified key from this **Preference** object. - -This method uses a promise to return the result. +Deletes the KV pair of the specified key from this **Preferences** instance. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | key | string | Yes| Key of the data.| + | key | string | Yes| Key of the KV pair to delete. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promiseDelete = preferences.delete('startup') + promiseDelete.then(() => { + console.info("Deleted startup key successfully.") + }).catch((err) => { + console.info("Failed to delete startup key, err: " + err) + }) + }).catch((err) => { + console.info("Failed to get the preferences, err: " + err) + }) + } ``` @@ -497,26 +587,35 @@ This method uses a promise to return the result. 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. +Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.") - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") + }) + }) + } ``` @@ -524,25 +623,33 @@ This method uses an asynchronous callback to return the result. 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. +Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promiseFlush = preferences.flush() + promiseFlush.then(() => { + console.info("Flushed data to file successfully.") + }).catch((err) => { + console.info("Failed to flush data to file, err: " + err) + }) + }).catch((err) => { + console.info("Failed to get the preferences, err: " + err) + }) + } ``` @@ -550,26 +657,35 @@ This method uses a promise to return the result. clear(callback: AsyncCallback<void>): void -Clears this **Preferences** object. - -This method uses an asynchronous callback to return the result. +Clears data of this **Preferences** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.") - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.clear(function (err) { + if (err) { + console.info("Failed to clear data, err: " + err) + return + } + console.info("Cleared to file successfully.") + }) + }) + } ``` @@ -577,25 +693,33 @@ This method uses an asynchronous callback to return the result. clear(): Promise<void> -Clears this **Preferences** object. - -This method uses a promise to return the result. +Clears data of this **Preferences** instance. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | - | Promise<void> | Promise used to return the result.| + | Promise<void> | Promise used to return the execution 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) - }) +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + let promise = data_preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + let promiseClear = preferences.clear() + promiseClear.then(() => { + console.info("Cleared to file successfully.") + }).catch((err) => { + console.info("Failed to clear data, err: " + err) + }) + }).catch((err) => { + console.info("Failed to get the preferences, err: " + err) + }) + } ``` @@ -603,36 +727,47 @@ This method uses a promise to return the result. 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. +Subscribes to data changes. When the value of the subscribed key changes, a callback will be invoked after **flush()** is executed. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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', function (err) { - if (err) { - console.info("Put the value of startup failed with err: " + err) - return +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + + var observer = function (key) { + console.info("The key of " + key + " changed.") } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { - console.info("Flush to file failed with err: " + err) + console.info("Failed to get the preferences, err: " + err) return } - console.info("Flushed to file successfully.") // observer will be called. + preferences.on('change', observer) + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") // The observer will be called. + }) + }) }) - }) + } ``` @@ -644,16 +779,53 @@ Unsubscribes from data changes. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.") +**Example** + ```ts + import Ability from '@ohos.application.Ability' + import data_preferences from '@ohos.data.preferences' + export default class MainAbility extends Ability { + var observer = function (key) { + console.info("The key of " + key + " changed.") + } + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences, err: " + err) + return + } + preferences.on('change', observer) + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed to file successfully.") // observer will be called. + preferences.off('change', observer) + }) + }) + }) } - preferences.off('change', observer) ``` + +## ValueType + +Enumerates the value types. + +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core + +| Name | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string. | +| boolean | The value is of Boolean type.| diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index 325884334bccb0e404116a44a8333faf0c0a3639..5a688b89db49c1d008e82a263024b45c6032bc40 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -7,59 +7,42 @@ ## Modules to Import +```js +import data_rdb from '@ohos.data.rdb'; ``` -import data_rdb from '@ohos.data.rdb' -``` - ## data_rdb.getRdbStore -getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void +getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void -Obtains a relational database (RDB) store. This method uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. +Obtains a relational database (RDB) store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context8+ | Context | Yes| Context of the app or functionality.| | config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.| | version | number | Yes| RDB store version.| | callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes| Callback invoked to return the RDB store obtained.| **Example** -``` -import data_rdb from '@ohos.data.rdb' +```js 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(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) - console.info('create table done.') -}) -``` - -The sample code of API9 is as follows: - -``` -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) + rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { console.info('create table done.') - }) -} + }) +}) ``` - ## data_rdb.getRdbStore -getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> +getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> -Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. +Obtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -67,7 +50,6 @@ Obtains an RDB store. This method uses a promise to return the result. You can s | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context8+ | Context | Yes| Context of the app or functionality.| | config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.| | version | number | Yes| RDB store version.| @@ -79,8 +61,7 @@ Obtains an RDB store. This method uses a promise to return the result. You can s **Example** -``` -import data_rdb from '@ohos.data.rdb' +```js 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(STORE_CONFIG, 1); @@ -96,75 +77,158 @@ promisegetRdb.then(async (rdbStore) => { }) ``` -The sample code of API9 is as follows: +## data_rdb.getRdbStore8+ + +getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void + +Obtains a relational database (RDB) store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| context8+ | Context | Yes| Context of the app or functionality.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.| +| version | number | Yes| RDB store version.| +| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes| Callback invoked to return the RDB store obtained.| + +**Example** + +```js +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, null, function() { + console.info('create table done.') + }) +}) ``` -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.") - }) + +## data_rdb.getRdbStore8+ + +getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> + +Obtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| context8+ | Context | Yes| Context of the app or functionality.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.| +| version | number | Yes| RDB store version.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<[RdbStore](#rdbstore)> | Promise used to return the RDB store obtained.| + +**Example** + +```js +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("getRdbStore err.") + console.log("executeSql creat err.") }) -} +}).catch((err) => { + console.log("getRdbStore err.") +}) ``` ## data_rdb.deleteRdbStore -deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void +deleteRdbStore(name: string, callback: AsyncCallback<void>): void -Deletes an RDB store. This method uses a callback to return the result. +Deletes an RDB store. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context8+ | Context | Yes| Context of the app or functionality.| | name | string | Yes| Name of the RDB store to delete.| | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ``` - import data_rdb from '@ohos.data.rdb' + ```js data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { console.info('delete store done.') }) ``` + ## data_rdb.deleteRdbStore -The sample code of API9 is as follows: +deleteRdbStore(name: string): Promise<void> -``` -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.') - }) -} -``` +Deletes an RDB store. This API uses a promise to return the result. -## data_rdb.deleteRdbStore +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the RDB store to delete.| + +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + ```js + let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") + promisedeleteRdb.then(()=>{ + console.info('delete store done.') + }).catch((err) => { + console.log("deleteRdbStore err.") + }) + ``` + +## data_rdb.deleteRdbStore8+ + +deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void + +Deletes an RDB store. This API uses a callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| context8+ | Context | Yes| Context of the app or functionality.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| name | string | Yes| Name of the RDB store to delete.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| + +**Example** + ```js + data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { + console.info('delete store done.') + }) + ``` + +## data_rdb.deleteRdbStore8+ deleteRdbStore(context: Context, name: string): Promise<void> -Deletes an RDB store. This method uses a promise to return the result. +Deletes an RDB store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context8+ | Context | Yes| Context of the app or functionality.| +| context8+ | Context | Yes| Context of the app or functionality.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| | name | string | Yes| Name of the RDB store to delete.| **Return value** @@ -173,8 +237,7 @@ Deletes an RDB store. This method uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ``` - import data_rdb from '@ohos.data.rdb' + ```js let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") promisedeleteRdb.then(()=>{ console.info('delete store done.') @@ -183,20 +246,6 @@ Deletes an RDB store. This method uses a promise to return the result. }) ``` -The sample code of API9 is as follows: - -``` -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 @@ -218,7 +267,7 @@ A constructor used to create an **RdbPredicates** object. | name | string | Yes| Database table name.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") ``` @@ -242,9 +291,9 @@ Specifies a remote device on the network during distributed database synchroniza | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicate.inDevices(['12345678abcde']) + predicates.inDevices(['12345678abcde']) ``` ### inAllDevices8+ @@ -262,7 +311,7 @@ Connects to all remote devices on the network during distributed database synchr | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.inAllDevices() ``` @@ -288,7 +337,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") ``` @@ -315,7 +364,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notEqualTo("NAME", "lisi") ``` @@ -336,7 +385,7 @@ Adds a left parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") .beginWrap() @@ -362,7 +411,7 @@ Adds a right parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") .beginWrap() @@ -388,7 +437,7 @@ Adds the OR condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") .or() @@ -411,7 +460,7 @@ Adds the AND condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") .and() @@ -439,7 +488,7 @@ Sets the **RdbPredicates** to match a string containing the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.contains("NAME", "os") ``` @@ -466,7 +515,7 @@ Sets the **RdbPredicates** to match a string that starts with the specified valu | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.beginsWith("NAME", "os") ``` @@ -493,7 +542,7 @@ Sets the **RdbPredicates** to match a string that ends with the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.endsWith("NAME", "se") ``` @@ -519,7 +568,7 @@ Sets the **RdbPredicates** to match the field whose value is null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| - Example - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.isNull("NAME") ``` @@ -545,7 +594,7 @@ Sets the **RdbPredicates** to match the field whose value is not null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.isNotNull("NAME") ``` @@ -572,7 +621,7 @@ Sets the **RdbPredicates** to match a string that is similar to the specified va | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.like("NAME", "%os%") ``` @@ -599,7 +648,7 @@ Sets the **RdbPredicates** to match the specified string. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.glob("NAME", "?h*g") ``` @@ -627,7 +676,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.between("AGE", 10, 50) ``` @@ -655,7 +704,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notBetween("AGE", 10, 50) ``` @@ -681,7 +730,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.greaterThan("AGE", 18) ``` @@ -708,7 +757,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.lessThan("AGE", 20) ``` @@ -736,7 +785,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.greaterThanOrEqualTo("AGE", 18) ``` @@ -764,7 +813,7 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.lessThanOrEqualTo("AGE", 20) ``` @@ -791,7 +840,7 @@ Sets the **RdbPredicates** to match the column with values sorted in ascending o | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.orderByAsc("NAME") ``` @@ -818,7 +867,7 @@ Sets the **RdbPredicates** to match the column with values sorted in descending | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.orderByDesc("AGE") ``` @@ -839,7 +888,7 @@ Sets the **RdbPredicates** to filter out duplicate records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") let promisequery = rdbStore.query(predicates, ["NAME"]) @@ -872,7 +921,7 @@ Sets the **RdbPredicates** to specify the maximum number of records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").limitAs(3) ``` @@ -898,7 +947,7 @@ Sets the **RdbPredicates** to specify the start position of the returned result. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").offsetAs(3) ``` @@ -924,7 +973,7 @@ Sets the **RdbPredicates** to group rows that have the same value into summary r | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.groupBy(["AGE", "NAME"]) ``` @@ -950,7 +999,7 @@ Sets the **RdbPredicates** object to specify the index column. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.indexedBy("SALARY_INDEX") ``` @@ -978,7 +1027,7 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.in("AGE", [18, 20]) ``` @@ -1006,7 +1055,7 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notIn("NAME", ["Lisa", "Rose"]) ``` @@ -1021,7 +1070,7 @@ Provides methods to manage an RDB store. insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void -Inserts a row of data into a table. This method uses a callback to return the result. +Inserts a row of data into a table. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1033,7 +1082,7 @@ Inserts a row of data into a table. This method uses a callback to return the re | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ``` + ```js const valueBucket = { "NAME": "Lisa", "AGE": 18, @@ -1050,7 +1099,7 @@ Inserts a row of data into a table. This method uses a callback to return the re insert(name: string, values: ValuesBucket):Promise<number> -Inserts a row of data into a table. This method uses a promise to return the result. +Inserts a row of data into a table. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1066,7 +1115,7 @@ Inserts a row of data into a table. This method uses a promise to return the res | Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ``` + ```js const valueBucket = { "NAME": "Lisa", "AGE": 18, @@ -1086,7 +1135,7 @@ Inserts a row of data into a table. This method uses a promise to return the res update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void -Updates data in the database based on the specified RdbPredicates object. This method uses a callback to return the result. +Updates data in the database based on the specified RdbPredicates object. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1098,7 +1147,7 @@ Updates data in the database based on the specified RdbPredicates object. This m | callback | AsyncCallback<number> | Yes| Callback used to return the number of rows updated.| **Example** - ``` + ```js const valueBucket = { "NAME": "Rose", "AGE": 22, @@ -1108,7 +1157,7 @@ Updates data in the database based on the specified RdbPredicates object. This m let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") rdbStore.update(valueBucket, predicates, function (err, ret) { - console.log("updated row count: " + changedRows)}) + console.log("updated row count: " + ret)}) ``` @@ -1116,7 +1165,7 @@ Updates data in the database based on the specified RdbPredicates object. This m update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number> -Updates data in the database based on the specified RdbPredicates object. This method uses a promise to return the result. +Updates data in the database based on the specified RdbPredicates object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1132,7 +1181,7 @@ Updates data in the database based on the specified RdbPredicates object. This m | Promise<number> | Promise used to return the number of rows updated.| **Example** - ``` + ```js const valueBucket = { "NAME": "Rose", "AGE": 22, @@ -1143,7 +1192,7 @@ Updates data in the database based on the specified RdbPredicates object. This m predicates.equalTo("NAME", "Lisa") let promiseupdate = rdbStore.update(valueBucket, predicates) promiseupdate.then(async (ret) => { - console.log("updated row count: " + changedRows) + console.log("updated row count: " + ret) }).catch((err) => { console.log("update err.") }) @@ -1155,7 +1204,7 @@ Updates data in the database based on the specified RdbPredicates object. This m delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void -Deletes data from the database based on the specified RdbPredicates object. This method uses a callback to return the result. +Deletes data from the database based on the specified RdbPredicates object. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1166,7 +1215,7 @@ Deletes data from the database based on the specified RdbPredicates object. This | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") rdbStore.delete(predicates, function (err, rows) { @@ -1179,7 +1228,7 @@ Deletes data from the database based on the specified RdbPredicates object. This delete(rdbPredicates: RdbPredicates):Promise<number> -Deletes data from the database based on the specified RdbPredicates object. This method uses a promise to return the result. +Deletes data from the database based on the specified RdbPredicates object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1194,7 +1243,7 @@ Deletes data from the database based on the specified RdbPredicates object. This | Promise<number> | Promise used to return the number of rows updated.| **Example** - ``` + ```js let predicatesdelete = new data_rdb.RdbPredicates("EMPLOYEE") predicatesdelete.equalTo("NAME", "Lisa") let promisedelete = rdbStore.delete(predicates) @@ -1210,7 +1259,7 @@ Deletes data from the database based on the specified RdbPredicates object. This query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void -Queries data in the database based on specified conditions. This method uses a callback to return the result. +Queries data in the database based on specified conditions. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1222,7 +1271,7 @@ Queries data in the database based on specified conditions. This method uses a c | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { @@ -1236,7 +1285,7 @@ Queries data in the database based on specified conditions. This method uses a c query(rdbPredicates: RdbPredicates, columns?: Array<string>):Promise<ResultSet> -Queries data in the database based on specified conditions. This method uses a promise to return the result. +Queries data in the database based on specified conditions. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1252,7 +1301,7 @@ Queries data in the database based on specified conditions. This method uses a p | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ``` + ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") let promisequery = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) @@ -1269,7 +1318,7 @@ Queries data in the database based on specified conditions. This method uses a p querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void -Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result. +Queries data in the RDB store using the specified SQL statement. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1281,7 +1330,7 @@ Queries data in the RDB store using the specified SQL statement. This method use | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ``` + ```js rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { console.log("resultSet column names:" + resultSet.columnNames) console.log("resultSet column count:" + resultSet.columnCount) @@ -1293,7 +1342,7 @@ Queries data in the RDB store using the specified SQL statement. This method use querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> -Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result. +Queries data in the RDB store using the specified SQL statement. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1309,7 +1358,7 @@ Queries data in the RDB store using the specified SQL statement. This method use | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ``` + ```js let promisequerySql = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) promisequerySql.then((resultSet) => { console.log("resultSet column names:" + resultSet.columnNames) @@ -1324,7 +1373,7 @@ Queries data in the RDB store using the specified SQL statement. This method use executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>):void -Runs the SQL statement that contains the specified parameters but does not return a value. This method uses a callback to return the execution result. +Runs the SQL statement that contains the specified parameters but does not return a value. This API uses a callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1336,7 +1385,7 @@ Runs the SQL statement that contains the specified parameters but does not retur | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ``` + ```js rdbStore.executeSql("DELETE FROM EMPLOYEE", null, function () { console.info('delete done.') }) @@ -1347,7 +1396,7 @@ Runs the SQL statement that contains the specified parameters but does not retur executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void> -Runs the SQL statement that contains the specified parameters but does not return a value. This method uses a promise to return the execution result. +Runs the SQL statement that contains the specified parameters but does not return a value. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1363,7 +1412,7 @@ Runs the SQL statement that contains the specified parameters but does not retur | Promise<void> | Promise used to return the result.| **Example** - ``` + ```js let promiseexecuteSql = rdbStore.executeSql("DELETE FROM EMPLOYEE") promiseexecuteSql.then(() => { console.info('delete done.') @@ -1381,7 +1430,7 @@ Starts the transaction before executing an SQL statement. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Example** -``` +```js rdbStore.beginTransaction() const valueBucket = { "name": "lisi", @@ -1405,7 +1454,7 @@ Commits the executed SQL statements. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Example** -``` +```js rdbStore.beginTransaction() const valueBucket = { "name": "lisi", @@ -1430,7 +1479,7 @@ Rolls back the SQL statements that have been executed. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Example** -``` +```js try { rdbStore.beginTransaction() const valueBucket = { @@ -1454,7 +1503,7 @@ Rolls back the SQL statements that have been executed. setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void -Sets a list of distributed tables. This method uses a callback to return the result. +Sets a list of distributed tables. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1465,7 +1514,7 @@ Sets a list of distributed tables. This method uses a callback to return the res | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ``` + ```js rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { if (err) { console.info('setDistributedTables failed.') @@ -1480,7 +1529,7 @@ Sets a list of distributed tables. This method uses a callback to return the res setDistributedTables(tables: Array<string>): Promise<void> -Sets a list of distributed tables. This method uses a promise to return the result. +Sets a list of distributed tables. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1495,7 +1544,7 @@ Sets a list of distributed tables. This method uses a promise to return the resu | Promise<void> | Promise used to return the result.| **Example** - ``` + ```js let promiseset = rdbStore.setDistributedTables(["EMPLOYEE"]) promiseset.then(() => { console.info("setDistributedTables success.") @@ -1508,7 +1557,7 @@ Sets a list of distributed tables. This method uses a promise to return the resu obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This method uses a callback to return the result. +Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1520,7 +1569,7 @@ Obtains the distributed table name for a remote device based on the local table | callback | AsyncCallback<string> | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ``` + ```js rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { console.info('obtainDistributedTableName failed.') @@ -1535,7 +1584,7 @@ Obtains the distributed table name for a remote device based on the local table obtainDistributedTableName(device: string, table: string): Promise<string> -Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This method uses a promise to return the result. +Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1551,7 +1600,7 @@ Obtains the distributed table name for a remote device based on the local table | Promise<string> | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ``` + ```js let promiseDistr = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") promiseDistr.then((tableName) => { console.info('obtainDistributedTableName success, tableName=' + tableName) @@ -1564,7 +1613,7 @@ Obtains the distributed table name for a remote device based on the local table sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void -Synchronizes data between devices. This method uses a callback to return the result. +Synchronizes data between devices. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1576,7 +1625,7 @@ Synchronizes data between devices. This method uses a callback to return the res | callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ``` + ```js let predicate = new rdb.RdbPredicates('EMPLOYEE') predicate.inDevices(['12345678abcde']) rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate, function (err, result) { @@ -1596,7 +1645,7 @@ Synchronizes data between devices. This method uses a callback to return the res sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>> -Synchronizes data between devices. This method uses a promise to return the result. +Synchronizes data between devices. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1613,7 +1662,7 @@ Synchronizes data between devices. This method uses a promise to return the resu | Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ``` + ```js let predicatesync = new data_rdb.RdbPredicates('EMPLOYEE') predicatesync.inDevices(['12345678abcde']) let promisesync = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicatesync) @@ -1644,10 +1693,10 @@ Registers an observer for this RDB store. When the data in the RDB store changes | observer | Callback<Array<string>> | Yes| Observer that listens for the data changes in the RDB store.| **Example** - ``` + ```js function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { - console.log('device=' + device[i] + ' data changed') + console.log('device=' + devices[i] + ' data changed') } } try { @@ -1661,7 +1710,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes off(event:'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void -Deletes the specified observer of the RDB store. This method uses a callback to return the result. +Deletes the specified observer of the RDB store. This API uses a callback to return the result. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -1675,10 +1724,10 @@ Deletes the specified observer of the RDB store. This method uses a callback to **Example** - ``` + ```js function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { - console.log('device=' + device[i] + ' data changed') + console.log('device=' + devices[i] + ' data changed') } } try { @@ -1688,7 +1737,6 @@ Deletes the specified observer of the RDB store. This method uses a callback to } ``` - ## StoreConfig Manages the configuration of an RDB store. diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index e383a530352cebdfac0124957f16957c88200223..3dca6cfcb0e84fdd90f9ce7b0cb6c79432d95eda 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -8,7 +8,7 @@ You need to use [RdbStore.query()](js-apis-data-rdb.md#query) to obtain the **resultSet** object. -``` +```js import dataRdb from '@ohos.data.rdb'; let predicates = new dataRdb.RdbPredicates("EMPLOYEE") predicates.equalTo("AGE", 18) @@ -18,10 +18,6 @@ promise.then((resultSet) => { console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);}) ``` - - - - ## ResultSet Provides methods to access the result set, which is obtained by querying the relational database (RDB) store. @@ -52,18 +48,18 @@ Obtains the column index based on the column name. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnName | string | Yes| Column name specified.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | number | Index of the column obtained.| -- Example - ``` +**Example** + ```js resultSet.goToFirstRow() const id = resultSet.getLong(resultSet.getColumnIndex("ID")) const name = resultSet.getString(resultSet.getColumnIndex("NAME")) @@ -80,18 +76,18 @@ Obtains the column name based on the column index. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Column index specified.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | string | Column name obtained.| -- Example - ``` +**Example** + ```js const id = resultSet.getColumnName(0) const name = resultSet.getColumnName(1) const age = resultSet.getColumnName(2) @@ -106,18 +102,18 @@ Moves the cursor to the row based on the specified offset. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | offset | number | Yes| Offset relative to the current position.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygoto.then((resultSet) { @@ -137,18 +133,18 @@ Moves the cursor to the specified row in the result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | position | number | Yes| Position to which the cursor is to be moved.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygotorow.then((resultSet) { @@ -169,13 +165,13 @@ Moves the cursor to the first row of the result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygoFirst.then((resultSet) { @@ -195,13 +191,13 @@ Moves the cursor to the last row of the result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygoLast.then((resultSet) { @@ -221,13 +217,13 @@ Moves the cursor to the next row in the result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygoNext.then((resultSet) { @@ -247,13 +243,13 @@ Moves the cursor to the previous row in the result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE") let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promisequerygoPrev.then((resultSet) { @@ -273,18 +269,18 @@ Obtains the value in the specified column in the current row as a byte array. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Index of the specified column, starting from 0.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Uint8Array | Value in the specified column as a byte array.| -- Example - ``` +**Example** + ```js const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES")) ``` @@ -297,18 +293,18 @@ Obtains the value in the specified column in the current row as a string. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Index of the specified column, starting from 0.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | string | Value in the specified column as a string.| -- Example - ``` +**Example** + ```js const name = resultSet.getString(resultSet.getColumnIndex("NAME")) ``` @@ -321,18 +317,18 @@ Obtains the value in the specified column in the current row as a Long. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Index of the specified column, starting from 0.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | number | Value in the specified column as a Long.| -- Example - ``` +**Example** + ```js const age = resultSet.getLong(resultSet.getColumnIndex("AGE")) ``` @@ -345,18 +341,18 @@ Obtains the value in the specified column in the current row as a double. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Index of the specified column, starting from 0.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | number | Value in the specified column as a double.| -- Example - ``` +**Example** + ```js const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")) ``` @@ -369,18 +365,18 @@ Checks whether the value in the specified column of the current row is null. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | columnIndex | number | Yes| Index of the specified column, starting from 0.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the value is null; returns **false** otherwise.| -- Example - ``` +**Example** + ```js const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES")) ``` @@ -393,13 +389,13 @@ Closes this result set. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -- Example - ``` - let predicatesclose = new dataRdb.RdbPredicates("EMPLOYEE") - let predicatesclose = rdbStore.query(predicatesclose, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - promisequerygoPrev.then((resultSet) { +**Example** + ```js + let predicatesClose = new dataRdb.RdbPredicates("EMPLOYEE") + let promiseClose = rdbStore.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", "CODES"]) + promiseClose.then((resultSet) { resultSet.close() }).catch((err) => { - console.log('query failed') + console.log('Failed to close resultset') }) ``` 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 85e44eb2cef79069548bd4cdc06158184644acfe..844b24576aa7a48f0b26207aa7886c7fb668e299 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -12,18 +12,18 @@ Lightweight storage provides applications with data processing capability and al ## Modules to Import -``` -import dataStorage from '@ohos.data.storage' +```js +import dataStorage from '@ohos.data.storage'; ``` -## Attributes +## Constants **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.| +| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It is 8192 bytes.| ## dataStorage.getStorageSync @@ -34,18 +34,18 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | [Storage](#storage) | **Storage** instance used for data storage operations.| -- Example - ``` +**Example** + ```js import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' @@ -67,18 +67,18 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. getStorage(path: string, callback: AsyncCallback<Storage>): void -Reads a file and loads the data to the **Storage** instance. This method uses an asynchronous callback to return the execution result. +Reads a file and loads the data to the **Storage** instance. This API uses an asynchronous callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| | callback | AsyncCallback<[Storage](#storage)> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```js import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' @@ -105,22 +105,22 @@ Reads a file and loads the data to the **Storage** instance. This method uses an getStorage(path: string): Promise<Storage> -Reads a file and loads the data to the **Storage** instance. This method uses a promise to return the execution result. +Reads a file and loads the data to the **Storage** instance. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[Storage](#storage)> | Promise used to return the result.| -- Example - ``` +**Example** + ```js import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' @@ -146,17 +146,17 @@ Reads a file and loads the data to the **Storage** instance. This method uses a deleteStorageSync(path: string): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This method uses a synchronous mode. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Example - ``` +**Example** + ```js dataStorage.deleteStorageSync(path + '/mystore') ``` @@ -165,18 +165,18 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string, callback: AsyncCallback<void>): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This method uses an asynchronous callback to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```js dataStorage.deleteStorage(path + '/mystore', function (err) { if (err) { console.info("Deleted failed with err: " + err) @@ -191,22 +191,22 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string): Promise<void> -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This method uses a promise to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promisedelSt = dataStorage.deleteStorage(path + '/mystore') promisedelSt.then(() => { console.info("Deleted successfully.") @@ -222,17 +222,17 @@ removeStorageFromCacheSync(path: string): void Removes the singleton **Storage** 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 synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Example - ``` +**Example** + ```js dataStorage.removeStorageFromCacheSync(path + '/mystore') ``` @@ -243,18 +243,18 @@ removeStorageFromCache(path: string, callback: AsyncCallback<void>): void Removes the singleton **Storage** 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. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```js dataStorage.removeStorageFromCache(path + '/mystore', function (err) { if (err) { console.info("Removed storage from cache failed with err: " + err) @@ -271,22 +271,22 @@ removeStorageFromCache(path: string): Promise<void> Removes the singleton **Storage** 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. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | path | string | Yes| Path of the target file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promiserevSt = dataStorage.removeStorageFromCache(path + '/mystore') promiserevSt.then(() => { console.info("Removed storage from cache successfully.") @@ -307,23 +307,23 @@ getSync(key: string, defValue: ValueType): 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 synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| - | defValue | ValueType | Yes| Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.| + | defValue | [ValueType](#valuetype) | Yes| Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned.| -- Example - ``` +**Example** + ```js let value = storage.getSync('startup', 'default') console.info("The value of startup is " + value) ``` @@ -335,19 +335,19 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<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 an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | defValue | [ValueType](#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 - ``` +**Example** + ```js storage.get('startup', 'default', function(err, value) { if (err) { console.info("Get the value of startup failed with err: " + err) @@ -364,23 +364,24 @@ 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. +This API 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.| +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | string | Yes| Key of the data. It cannot be empty.| +| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<ValueType> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promiseget = storage.get('startup', 'default') promiseget.then((value) => { console.info("The value of startup is " + value) @@ -396,18 +397,18 @@ putSync(key: string, value: ValueType): void Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. -This method uses a synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data. It cannot be empty.| + | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| -- Example - ``` +**Example** + ```js storage.putSync('startup', 'auto') ``` @@ -418,19 +419,19 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. -This method uses an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data. It cannot be empty.| + | value | [ValueType](#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 - ``` +**Example** + ```js storage.put('startup', 'auto', function (err) { if (err) { console.info("Put the value of startup failed with err: " + err) @@ -447,23 +448,23 @@ put(key: string, value: ValueType): Promise<void> Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. -This method uses an asynchronous callback to return the result. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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.| + | key | string | Yes| Key of the data. It cannot be empty.| + | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promiseput = storage.put('startup', 'auto') promiseput.then(() => { console.info("Put the value of startup successfully.") @@ -479,22 +480,22 @@ hasSync(key: string): boolean Checks whether the storage object contains data with a given key. -This method uses a synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| -- Example - ``` +**Example** + ```js let isExist = storage.hasSync('startup') if (isExist) { console.info("The key of startup is contained.") @@ -508,23 +509,23 @@ has(key: string, callback: AsyncCallback<boolean>): boolean Checks whether the storage object contains data with a given key. -This method uses an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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 +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| -- Example - ``` +**Example** + ```js storage.has('startup', function (err, isExist) { if (err) { console.info("Check the key of startup failed with err: " + err) @@ -543,22 +544,22 @@ has(key: string): Promise<boolean> Checks whether the storage object contains data with a given key. -This method uses an asynchronous callback to return the result. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promisehas = storage.has('startup') promisehas.then((isExist) => { if (isExist) { @@ -576,39 +577,39 @@ deleteSync(key: string): void Deletes data with the specified key from this storage object. -This method uses a synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| -- Example - ``` +**Example** + ```js storage.deleteSync('startup') ``` -### delete +### deletej delete(key: string, callback: AsyncCallback<void>): void Deletes data with the specified key from this storage object. -This method uses an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**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 - ``` +**Example** + ```js storage.delete('startup', function (err) { if (err) { console.info("Delete startup key failed with err: " + err) @@ -625,22 +626,22 @@ delete(key: string): Promise<void> Deletes data with the specified key from this storage object. -This method uses a promise to return the result. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promisedel = storage.delete('startup') promisedel.then(() => { console.info("Deleted startup key successfully.") @@ -656,12 +657,12 @@ flushSync(): void Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. -This method uses a synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Example - ``` +**Example** + ```js storage.flushSync() ``` @@ -672,17 +673,17 @@ flush(callback: AsyncCallback<void>): void Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. -This method uses an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```js storage.flush(function (err) { if (err) { console.info("Flush to file failed with err: " + err) @@ -699,17 +700,17 @@ flush(): Promise<void> Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. -This method uses an asynchronous callback to return the result. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promiseflush = storage.flush() promiseflush.then(() => { console.info("Flushed to file successfully.") @@ -725,12 +726,12 @@ clearSync(): void Clears this **Storage** object. -This method uses a synchronous mode. +This API uses a synchronous mode. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Example - ``` +**Example** + ```js storage.clearSync() ``` @@ -741,17 +742,17 @@ clear(callback: AsyncCallback<void>): void Clears this **Storage** object. -This method uses an asynchronous callback to return the result. +This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -- Example - ``` +**Example** + ```js storage.clear(function (err) { if (err) { console.info("Clear to file failed with err: " + err) @@ -768,17 +769,17 @@ clear(): Promise<void> Clears this **Storage** object. -This method uses an asynchronous callback to return the result. +This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example - ``` +**Example** + ```js let promiseclear = storage.clear() promiseclear.then(() => { console.info("Cleared to file successfully.") @@ -796,14 +797,14 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Description| | -------- | -------- | -------- | | type | string | Event type. The value **change** indicates data change events.| | callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes.| -- Example - ``` +**Example** + ```js var observer = function (key) { console.info("The key of " + key + " changed.") } @@ -821,14 +822,14 @@ Unsubscribes from data changes. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Description| | -------- | -------- | -------- | | type | string | Event type. The value **change** indicates data change events.| | callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes.| -- Example - ``` +**Example** + ```js var observer = function (key) { console.info("The key of " + key + " changed.") } @@ -843,3 +844,15 @@ Unsubscribes from data changes. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | No| Data changed.| + +## ValueType + +Enumerates the value types. + +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core + +| Name | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string. | +| boolean | The value is of Boolean type.| diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index d813b75b3e7a4f677fc96f87d9d38cb4719251e7..8f5b800d57488426664e514675c1af28864e962f 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -1,12 +1,14 @@ # Distributed Data Management +Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database. + >![](../../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 -``` +```js import distributedData from '@ohos.data.distributedData'; ``` @@ -15,7 +17,7 @@ import distributedData from '@ohos.data.distributedData'; createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void -Creates a **KVManager** object to manage key-value (KV) stores. This method uses an asynchronous callback to return the result. +Creates a **KVManager** object to manage key-value (KV) stores. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -27,7 +29,7 @@ Creates a **KVManager** object to manage key-value (KV) stores. This method uses | callback | AsyncCallback<[KVManager](#kvmanager)> | Yes | Callback invoked to return the **KVManager** object created.| **Example** -``` +```js let kvManager; try { const kvManagerConfig = { @@ -54,7 +56,7 @@ try { createKVManager(config: KVManagerConfig): Promise<KVManager> -Creates a **KVManager** object to manage KV stores. This method uses a promise to return the result. +Creates a **KVManager** object to manage KV stores. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -72,7 +74,7 @@ Creates a **KVManager** object to manage KV stores. This method uses a promise t **Example** -``` +```js let kvManager; try { const kvManagerConfig = { @@ -129,13 +131,13 @@ Defines the user type. ## KVManager -Creates a **KVManager** object to obtain KV store information. Before calling any method in **KVManager**, you must use **createKVManager** to create a **KVManager** object. +Creates a **KVManager** object to obtain KV store information. Before calling any method in **KVManager**, you must use [createKVManager](#distributeddatacreatekvmanager) to create a **KVManager** object. ### getKVStore getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void -Creates and obtains a KV store. This method uses an asynchronous callback to return the result. +Creates and obtains a KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -145,11 +147,11 @@ Creates and obtains a KV store. This method uses an asynchronous callback to ret | ----- | ------ | ------ | ------ | | storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | options | [Options](#options) | Yes | Configuration of the KV store.| -| callback | AsyncCallback<T>, <T extends KVStore>| Yes | Callback invoked to return the KV store created.| +| callback | AsyncCallback<T> , <T extends [KVStore](#kvstore)>| Yes | Callback invoked to return the KV store created.| **Example** -``` +```js let kvStore; let kvManager; try { @@ -179,7 +181,7 @@ try { getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> -Creates and obtains a KV store. This method uses a promise to return the result. +Creates and obtains a KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -195,11 +197,11 @@ Creates and obtains a KV store. This method uses a promise to return the result. | Type | Description | | -------------------------------------- | ------------------------ | -| Promise<T> <T extends KVStore> | Promise used to return the KV store created.| +| Promise<T> <T extends [KVStore](#kvstore)> | Promise used to return the KV store created.| **Example** -``` +```js let kvStore; let kvManager; try { @@ -226,7 +228,7 @@ try { closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback<void>): void -Closes a KV store. This method uses an asynchronous callback to return the result. +Closes a KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -236,13 +238,13 @@ Closes a KV store. This method uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | ------- | ----------------- | ---- | --------------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | -| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed the value of [MAX_STORE_ID_LENGTH](#constants).| -| kvStore | [KVStore](#kvstore) | Yes | KV store to close. | +| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| kvStore | [KVStore](#kvstore) | Yes | KV store to close. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned. | **Example** -``` +```js let kvStore; let kvManager; const options = { @@ -272,7 +274,7 @@ const options = { closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void> -Closes a KV store. This method uses a promise to return the result. +Closes a KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -281,18 +283,18 @@ Closes a KV store. This method uses a promise to return the result. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | -| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed the value of [MAX_STORE_ID_LENGTH](#constants).| +| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | kvStore | [KVStore](#kvstore) | Yes | KV store to close. | **Return value** | Type | Description | | ------------- | -------------- | -| Promise | Promise used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.| +| Promise\ | Promise used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.| **Example** -``` +```js let kvManager; let kvStore; const options = { @@ -326,7 +328,7 @@ const options = { deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void -Deletes a KV store. This method uses an asynchronous callback to return the result. +Deletes a KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -335,12 +337,12 @@ Deletes a KV store. This method uses an asynchronous callback to return the resu | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | -| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX_STORE_ID_LENGTH](#constants).| +| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the KV store is deleted, **true** will be returned. Otherwise, **false** will be returned. | **Example** -``` +```js let kvManager; let kvStore; const options = { @@ -369,7 +371,7 @@ try { deleteKVStore(appId: string, storeId: string): Promise<void> -Deletes a KV store. This method uses a promise to return the result. +Deletes a KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -378,7 +380,7 @@ Deletes a KV store. This method uses a promise to return the result. | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | appId | string | Yes | Bundle name of the app that invokes the KV store. | -| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX_STORE_ID_LENGTH](#constants).| +| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| **Return value** @@ -389,7 +391,7 @@ Deletes a KV store. This method uses a promise to return the result. **Example** -``` +```js let kvManager; let kvStore; const options = { @@ -402,7 +404,7 @@ const options = { securityLevel : distributedData.SecurityLevel.S2, } try { - kvManager.getKVStore('storId', options).then(async (store) => { + kvManager.getKVStore('storeId', options).then(async (store) => { console.log('getKVStore success'); kvStore = store; await kvManager.deleteKVStore('appId', 'storeId').then(() => { @@ -423,7 +425,7 @@ try { getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void -Obtains the IDs of all the KV stores that are created using **getKvStore** and have not been deleted using **deleteKvStore**. This method uses an asynchronous callback to return the result. +Obtains the IDs of all the KV stores that are created using [getKVStore](#getkvstore) and have not been deleted using [deleteKVStore](#deletekvstore8). This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -436,7 +438,7 @@ Obtains the IDs of all the KV stores that are created using **getKvStore** and h **Example** -``` +```js let kvManager; try { kvManager.getAllKVStoreId('appId', function (err, data) { @@ -453,7 +455,7 @@ try { getAllKVStoreId(appId: string): Promise<string[]> -Obtains the IDs of all the KV stores that are created using **getKvStore** and have not been deleted using **deleteKvStore**. This method uses a promise to return the result. +Obtains the IDs of all the KV stores that are created using [getKVStore](#getkvstore) and have not been deleted using [deleteKVStore](#deletekvstore8). This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -472,7 +474,7 @@ Obtains the IDs of all the KV stores that are created using **getKvStore** and h **Example** -``` +```js let kvManager; try { console.log('GetAllKVStoreId'); @@ -488,11 +490,11 @@ try { ``` -### on8+ ### +### on('distributedDataServiceDie')8+ ### on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void -Subscribes to the **distributedDataServiceDie** events. This method uses a synchronous callback to return the result. +Subscribes to the **distributedDataServiceDie** events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -500,12 +502,12 @@ Subscribes to the **distributedDataServiceDie** events. This method uses a synch | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event | 'distributedDataServiceDie' | Yes | Type of events to subscribe to. | +| event | string | Yes | Name of the event to subscribe to. The value is **distributedDataServiceDie**, which indicates the service status change event.| | deathCallback | Callback<void> | Yes | Callback invoked when the distributed data service is dead. | **Example** -``` +```js let kvManager; try { @@ -520,11 +522,11 @@ try { ``` -### off8+ ### +### off('distributedDataServiceDie')8+ ### off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void -Unsubscribes from the **distributedDataServiceDie** events. This method uses a synchronous callback to return the result. +Unsubscribes from the **distributedDataServiceDie** events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -532,13 +534,13 @@ Unsubscribes from the **distributedDataServiceDie** events. This method uses a s | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event | 'distributedDataServiceDie' | Yes | Type of events to unsubscribe from. | +| event | string | Yes | Name of the event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates the service status change event.| | deathCallback | Callback<void> | No | Callback used to return the **distributedDataServiceDie** events. | **Example** -``` +```js let kvManager; try { console.log('KVManagerOff'); @@ -563,7 +565,7 @@ Provides KV store configuration. | createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created. | | encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted. | | backup | boolean | No|Whether to back up database files. By default, database files are backed up. | -| autoSync | boolean | No|Whether to automatically synchronize database files. By default, database files are not automatically synchronized. | +| autoSync | boolean | No|Whether to automatically synchronize database files. By default, database files are not automatically synchronized.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | | kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.| | securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set. | | schema8+ | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.| @@ -621,7 +623,7 @@ Defines a database schema. When creating or opening a KV store, you can create a | Name | Type| Description | | --- | ---- | ----------------------- | -| root8+ | [FieldNode](#fieldnode8) | JSON root object. | +| root8+ | [FieldNode](#fieldnode8) | JSON root object.| | indexes8+ | Array\ | String array in JSON format. | | mode8+ | number | Schema mode. | | skip8+ | number | Size of a skip of the schema. | @@ -674,7 +676,6 @@ Appends a child node to this **FieldNode**. | ----- | ------ | ---- | ----------------------- | | child | [FieldNode](#fieldnode8) | Yes | Child node to append. | - **Return value** | Type | Description | @@ -683,7 +684,7 @@ Appends a child node to this **FieldNode**. **Example** -``` +```js import ddm from '@ohos.data.distributedData'; try { let node = new ddm.FieldNode("root"); @@ -725,7 +726,7 @@ Obtains the number of rows in the result set. **Example** -``` +```js let kvStore; try { let resultSet; @@ -758,7 +759,7 @@ Obtains the current data read position (position from which data is read) in the **Example** -``` +```js let kvStore; try { let resultSet; @@ -792,7 +793,7 @@ Moves the data read position to the first row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -826,7 +827,7 @@ Moves the data read position to the last row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -860,7 +861,7 @@ Moves the data read position to the next row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -894,7 +895,7 @@ Moves the data read position to the previous row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -934,7 +935,7 @@ Moves the data read position with the specified offset from the current position **Example** -``` +```js let kvStore; try { let resultSet; @@ -974,7 +975,7 @@ Moves the data read position from 0 to an absolute position. **Example** -``` +```js let kvStore; try { let resultSet; @@ -1008,7 +1009,7 @@ Checks whether the data read position is the first row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -1042,7 +1043,7 @@ Checks whether the data read position is the last row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -1075,7 +1076,7 @@ Checks whether the data read position is before the first row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -1109,7 +1110,7 @@ Checks whether the data read position is after the last row. **Example** -``` +```js let kvStore; try { let resultSet; @@ -1139,11 +1140,11 @@ Obtains a KV pair. | Type | Description | | ------ | ------- | -| Entry |KV pair obtained.| +| [Entry](#entry) |KV pair obtained.| **Example** -``` +```js let kvStore; try { let resultSet; @@ -1194,7 +1195,7 @@ Resets the **Query** object that contains common query options. **Example** -``` +```js try { let query = new distributedData.Query(); query.equalTo("key", "value"); @@ -1210,7 +1211,7 @@ try { ### equalTo8+ ### -equalTo(field: string, value: number|string|boolean): Query; +equalTo(field: string, value: number|string|boolean): Query Creates a **Query** object to match the specified field whose value is equal to the specified value. @@ -1221,17 +1222,17 @@ Creates a **Query** object to match the specified field whose value is equal to | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | fieId | string | Yes |Field to match. It must start with $ and cannot contain ^. | -| value | number/string/boolean | Yes | Value specified.| +| value | number\|string\|boolean | Yes | Value specified.| **Return value** | Type | Description | | ------ | ------- | -| [Query](#query8) |**Query** object created.| +| [Query](#query8) |**Query** object reset.| **Example** -``` +```js try { let query = new distributedData.Query(); query.equalTo("field", "value"); @@ -1256,7 +1257,7 @@ Creates a **Query** object to match the specified field whose value is not equal | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | fieId | string | Yes |Field to match. It must start with $ and cannot contain ^. | -| value | number/string/boolean | Yes | Value specified.| +| value | number\|string\|boolean | Yes | Value specified.| **Return value** @@ -1266,7 +1267,7 @@ Creates a **Query** object to match the specified field whose value is not equal **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value"); @@ -1301,7 +1302,7 @@ Creates a **Query** object to match the specified field whose value is greater t **Example** -``` +```js try { let query = new distributedData.Query(); query.greaterThan("field", "value"); @@ -1336,7 +1337,7 @@ Creates a **Query** object to match the specified field whose value is less than **Example** -``` +```js try { let query = new distributedData.Query(); query.lessThan("field", "value"); @@ -1371,7 +1372,7 @@ Creates a **Query** object to match the specified field whose value is greater t **Example** -``` +```js try { let query = new distributedData.Query(); query.greaterThanOrEqualTo("field", "value"); @@ -1406,7 +1407,7 @@ Creates a **Query** object to match the specified field whose value is less than **Example** -``` +```js try { let query = new distributedData.Query(); query.lessThanOrEqualTo("field", "value"); @@ -1441,7 +1442,7 @@ Creates a **Query** object to match the specified field whose value is **null**. **Example** -``` +```js try { let query = new distributedData.Query(); query.isNull("field"); @@ -1477,7 +1478,7 @@ Creates a **Query** object to match the specified field whose value is within th **Example** -``` +```js try { let query = new distributedData.Query(); query.inNumber("field", [0, 1]); @@ -1512,7 +1513,7 @@ Creates a **Query** object to match the specified field whose value is within th **Example** -``` +```js try { let query = new distributedData.Query(); query.inString("field", ['test1', 'test2']); @@ -1547,7 +1548,7 @@ Creates a **Query** object to match the specified field whose value is not withi **Example** -``` +```js try { let query = new distributedData.Query(); query.notInNumber("field", [0, 1]); @@ -1582,7 +1583,7 @@ Creates a **Query** object to match the specified field whose value is not withi **Example** -``` +```js try { let query = new distributedData.Query(); query.notInString("field", ['test1', 'test2']); @@ -1617,7 +1618,7 @@ Creates a **Query** object to match the specified field whose value is similar t **Example** -``` +```js try { let query = new distributedData.Query(); query.like("field", "value"); @@ -1652,7 +1653,7 @@ Creates a **Query** object to match the specified field whose value is not simil **Example** -``` +```js try { let query = new distributedData.Query(); query.unlike("field", "value"); @@ -1680,7 +1681,7 @@ Creates a **Query** object with the AND condition. **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value1"); @@ -1710,7 +1711,7 @@ Creates a **Query** object with the OR condition. **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value1"); @@ -1746,7 +1747,7 @@ Creates a **Query** object to sort the query results in ascending order. **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value"); @@ -1781,7 +1782,7 @@ Creates a **Query** object to sort the query results in descending order. **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value"); @@ -1817,7 +1818,7 @@ Creates a **Query** object to specify the number of results and where to start. **Example** -``` +```js try { let query = new distributedData.Query(); query.notEqualTo("field", "value"); @@ -1852,7 +1853,7 @@ Creates a **Query** object with a specified field that is not null. **Example** -``` +```js try { let query = new distributedData.Query(); query.isNotNull("field"); @@ -1880,7 +1881,7 @@ Creates a **Query** object for a query condition group with a left parenthesis. **Example** -``` +```js try { let query = new distributedData.Query(); query.beginGroup(); @@ -1910,7 +1911,7 @@ Creates a **Query** object for a query condition group with a right parenthesis. **Example** -``` +```js try { let query = new distributedData.Query(); query.beginGroup(); @@ -1946,7 +1947,7 @@ Creates a **Query** object with a specified key prefix. **Example** -``` +```js try { let query = new distributedData.Query(); query.prefixKey("$.name"); @@ -1981,7 +1982,7 @@ Creates a **Query** object with an index preferentially used for query. **Example** -``` +```js try { let query = new distributedData.Query(); query.setSuggestIndex("$.name"); @@ -2017,7 +2018,7 @@ Creates a **Query** object with the device ID as the key prefix. **Example** -``` +```js try { let query = new distributedData.Query(); query.deviceId("deviceId"); @@ -2044,7 +2045,7 @@ Obtains the query statement of this **Query** object. **Example** -``` +```js try { let query = new distributedData.Query(); let sql1 = query.getSqlLike(); @@ -2065,7 +2066,7 @@ Provides methods to manage data in a KV store, for example, adding or deleting d put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void -Adds a KV pair of the specified type to this KV store. This method uses an asynchronous callback to return the result. +Adds a KV pair of the specified type to this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2075,11 +2076,11 @@ Adds a KV pair of the specified type to this KV store. This method uses an async | ----- | ------ | ---- | ----------------------- | | key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | | value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). | -| callback | AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -2101,7 +2102,7 @@ try { put(key: string, value: Uint8Array | string | number | boolean): Promise<void> -Adds a KV pair of the specified type to this KV store. This method uses a promise to return the result. +Adds a KV pair of the specified type to this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2120,7 +2121,7 @@ Adds a KV pair of the specified type to this KV store. This method uses a promis **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -2140,7 +2141,7 @@ try { delete(key: string, callback: AsyncCallback<void>): void -Deletes a KV pair from this KV store. This method uses an asynchronous callback to return the result. +Deletes a KV pair from this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2149,11 +2150,11 @@ Deletes a KV pair from this KV store. This method uses an asynchronous callback | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | -| callback | AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -2182,7 +2183,7 @@ try { delete(key: string): Promise<void> -Deletes a KV pair from this KV store. This method uses a promise to return the result. +Deletes a KV pair from this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2200,7 +2201,7 @@ Deletes a KV pair from this KV store. This method uses a promise to return the r **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -2221,11 +2222,11 @@ try { ``` -### on +### on('dataChange') on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void -Subscribes to data changes of the specified type. This method uses a synchronous callback to return the result. +Subscribes to data changes of the specified type. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2233,13 +2234,13 @@ Subscribes to data changes of the specified type. This method uses a synchronous | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'dataChange' | Yes |Type of the events. | +| event |string | Yes |Name of the event to subscribe to. The value is **dataChange**, which indicates the data change event. | | type |[SubscribeType](#subscribetype) | Yes |Type of data changes. | -| observer |Callback<[ChangeNotification](#changenotification)> | Yes |Callback invoked to return the result.| +| observer |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return the result.| **Example** -``` +```js let kvStore; kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { console.log("dataChange callback call data: " + JSON.stringify(data)); @@ -2247,11 +2248,11 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun ``` -### on +### on('syncComplete') on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to data synchronization completion events. This method uses a synchronous callback to return the result. +Subscribes to data synchronization completion events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2259,23 +2260,23 @@ Subscribes to data synchronization completion events. This method uses a synchro | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'syncComplete' | Yes |Type of the events. | -| syncCallback |Callback<Array<[string, number]>> | Yes |Callback invoked to return the result. | +| event |string | Yes |Name of the event to subscribe to. The value is **syncComplete**, which indicates the synchronization complete event. | +| syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; kvStore.on('syncComplete', function (data) { - console.log("syncComplete callback call data: " + data); + console.log("callback call data: " + data); }); ``` -### off8+ +### off('dataChange')8+ off(event:'dataChange', observer?: Callback<ChangeNotification>): void -Unsubscribes from data change events. This method uses a synchronous callback to return the result. +Unsubscribes from data change events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2283,18 +2284,18 @@ Unsubscribes from data change events. This method uses a synchronous callback to | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'dataChange' | Yes |Type of the events. | +| event |string | Yes |Name of the event to unsubscribe from. The value is **dataChange**, which indicates the data change event. | | observer |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return the result.| **Example** -``` +```js let kvStore; kvStore.on('dataChange', function (data) { - console.log("syncComplete callback call data: " + data); + console.log("callback call data: " + data); }); kvStore.off('dataChange', function (data) { - console.log("syncComplete callback call data: " + data); + console.log("callback call data: " + data); }); ``` @@ -2303,7 +2304,7 @@ kvStore.off('dataChange', function (data) { putBatch(entries: Entry[], callback: AsyncCallback<void>): void -Inserts KV pairs in batches to this KV store. This method uses an asynchronous callback to return the result. +Inserts KV pairs in batches to this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2312,11 +2313,11 @@ Inserts KV pairs in batches to this KV store. This method uses an asynchronous c | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. | -| callback |Asyncallback<void> |Yes |Callback invoked to return the result.| +| callback |Asyncallback<void> |Yes |Callback used to return the result.| **Example** -``` +```js let kvStore; try { let entries = []; @@ -2350,7 +2351,7 @@ try { putBatch(entries: Entry[]): Promise<void> -Inserts KV pairs in batches to this KV store. This method uses a promise to return the result. +Inserts KV pairs in batches to this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2368,7 +2369,7 @@ Inserts KV pairs in batches to this KV store. This method uses a promise to retu **Example** -``` +```js let kvStore; try { let entries = []; @@ -2405,7 +2406,7 @@ try { deleteBatch(keys: string[], callback: AsyncCallback<void>): void -Deletes KV pairs in batches from this KV store. This method uses an asynchronous callback to return the result. +Deletes KV pairs in batches from this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2414,11 +2415,11 @@ Deletes KV pairs in batches from this KV store. This method uses an asynchronous | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | keys |string[] | Yes |KV pairs to delete in batches. | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; try { let entries = []; @@ -2452,7 +2453,7 @@ try { deleteBatch(keys: string[]): Promise<void> -Deletes KV pairs in batches from this KV store. This method uses a promise to return the result. +Deletes KV pairs in batches from this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2470,7 +2471,7 @@ Deletes KV pairs in batches from this KV store. This method uses a promise to re **Example** -``` +```js let kvStore; try { let entries = []; @@ -2508,7 +2509,7 @@ try { startTransaction(callback: AsyncCallback<void>): void -Starts the transaction in this KV store. This method uses an asynchronous callback to return the result. +Starts the transaction in this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2516,11 +2517,11 @@ Starts the transaction in this KV store. This method uses an asynchronous callba | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; function putBatchString(len, prefix) { let entries = []; @@ -2560,7 +2561,7 @@ try { startTransaction(): Promise<void> -Starts the transaction in this KV store. This method uses a promise to return the result. +Starts the transaction in this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2572,7 +2573,7 @@ Starts the transaction in this KV store. This method uses a promise to return th **Example** -``` +```js let kvStore; try { var count = 0; @@ -2595,7 +2596,7 @@ try { commit(callback: AsyncCallback<void>): void -Commits the transaction in this KV store. This method uses an asynchronous callback to return the result. +Commits the transaction in this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2603,11 +2604,11 @@ Commits the transaction in this KV store. This method uses an asynchronous callb | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; try { kvStore.commit(function (err,data) { @@ -2627,7 +2628,7 @@ try { commit(): Promise<void> -Commits the transaction in this KV store. This method uses a promise to return the result. +Commits the transaction in this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2639,7 +2640,7 @@ Commits the transaction in this KV store. This method uses a promise to return t **Example** -``` +```js let kvStore; try { kvStore.commit().then(async (err) => { @@ -2657,7 +2658,7 @@ try { rollback(callback: AsyncCallback<void>): void -Rolls back the transaction in this KV store. This method uses an asynchronous callback to return the result. +Rolls back the transaction in this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2665,11 +2666,11 @@ Rolls back the transaction in this KV store. This method uses an asynchronous ca | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; try { kvStore.rollback(function (err,data) { @@ -2689,7 +2690,7 @@ try { rollback(): Promise<void> -Rolls back the transaction in this KV store. This method uses a promise to return the result. +Rolls back the transaction in this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2701,7 +2702,7 @@ Rolls back the transaction in this KV store. This method uses a promise to retur **Example** -``` +```js let kvStore; try { kvStore.rollback().then(async (err) => { @@ -2719,7 +2720,7 @@ try { enableSync(enabled: boolean, callback: AsyncCallback<void>): void -Sets data synchronization, which can be enabled or disable. This method uses an asynchronous callback to return the result. +Sets data synchronization, which can be enabled or disable. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2728,11 +2729,11 @@ Sets data synchronization, which can be enabled or disable. This method uses an | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | Yes |Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite. | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; try { kvStore.enableSync(true, function (err,data) { @@ -2752,7 +2753,7 @@ try { enableSync(enabled: boolean): Promise<void> -Enables or disables data synchronization. This method uses a promise to return the result. +Enables or disables data synchronization. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2770,7 +2771,7 @@ Enables or disables data synchronization. This method uses a promise to return t **Example** -``` +```js let kvStore; try { kvStore.enableSync(true).then((err) => { @@ -2788,7 +2789,7 @@ try { setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback<void>): void -Sets the data synchronization range. This method uses an asynchronous callback to return the result. +Sets the data synchronization range. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2798,11 +2799,11 @@ Sets the data synchronization range. This method uses an asynchronous callback t | ----- | ------ | ---- | ----------------------- | | localLabels |string[] | Yes |Synchronization labels set for the local device. | | remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. | -| callback |AsyncCallback<void> | Yes |Callback invoked to return the result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** -``` +```js let kvStore; try { const localLabels = ['A', 'B']; @@ -2820,7 +2821,7 @@ try { setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<void> -Sets the data synchronization range. This method uses a promise to return the result. +Sets the data synchronization range. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2840,7 +2841,7 @@ Sets the data synchronization range. This method uses a promise to return the re **Example** -``` +```js let kvStore; try { const localLabels = ['A', 'B']; @@ -2902,7 +2903,7 @@ Defines the value in a KV pair. | Name | Type |Readable |Writable | Description | | ----- | ------- | -----| ------|------------------------ | | type | [ValueType](#value) | Yes | Yes|Type of the value. | -| value | Uint8Array / string / number / boolean| Yes | Yes|Value of the KV pair stored in the KV store. | +| value | Uint8Array \| string \| number \| boolean| Yes | Yes|Value of the KV pair stored in the KV store. | ## ValueType @@ -2923,7 +2924,7 @@ These value types can be used only by internal applications. ## SingleKVStore -Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use **getKVStore** to obtain a **SingleKVStore** object. +Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2931,7 +2932,7 @@ Provides methods to query and synchronize data in a single KV store. This class get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void -Obtains the value of a specified key. This method uses an asynchronous callback to return the result. +Obtains the value of a specified key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2944,7 +2945,7 @@ Obtains the value of a specified key. This method uses an asynchronous callback **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -2969,7 +2970,7 @@ try { get(key: string): Promise<Uint8Array | string | boolean | number> -Obtains the value of a specified key. This method uses a promise to return the result. +Obtains the value of a specified key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -2988,7 +2989,7 @@ Obtains the value of a specified key. This method uses a promise to return the r **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -3012,7 +3013,7 @@ try { getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void -Obtains the KV pairs that match the specified key prefix. This method uses an asynchronous callback to return the result. +Obtains the KV pairs that match the specified key prefix. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3025,7 +3026,7 @@ Obtains the KV pairs that match the specified key prefix. This method uses an as **Example** -``` +```js let kvStore; try { let entries = []; @@ -3058,7 +3059,7 @@ try { getEntries(keyPrefix: string): Promise<Entry[]> -Obtains the KV pairs that match the specified key prefix. This method uses a promise to return the result. +Obtains the KV pairs that match the specified key prefix. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3076,7 +3077,7 @@ Obtains the KV pairs that match the specified key prefix. This method uses a pro **Example** -``` +```js let kvStore; try { let entries = []; @@ -3116,7 +3117,7 @@ try { getEntries(query: Query, callback: AsyncCallback<Entry[]>): void -Obtains the KV pairs that match the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the KV pairs that match the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3129,7 +3130,7 @@ Obtains the KV pairs that match the specified **Query** object. This method uses **Example** -``` +```js let kvStore; try { var arr = new Uint8Array([21,31]); @@ -3167,7 +3168,7 @@ try { getEntries(query: Query): Promise<Entry[]> -Obtains the KV pairs that match the specified **Query** object. This method uses a promise to return the result. +Obtains the KV pairs that match the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3185,7 +3186,7 @@ Obtains the KV pairs that match the specified **Query** object. This method uses **Example** -``` +```js try { var arr = new Uint8Array([21,31]); let entries = []; @@ -3224,7 +3225,7 @@ try { getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void -Obtains the result set with the specified key prefix from this single KV store. This method uses an asynchronous callback to return the result. +Obtains the result set with the specified key prefix from this single KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3237,7 +3238,7 @@ Obtains the result set with the specified key prefix from this single KV store. **Example** -``` +```js let kvStore; try { let resultSet; @@ -3273,7 +3274,7 @@ try { getResultSet(keyPrefix: string): Promise<KvStoreResultSet> -Obtains the result set with the specified key prefix from this single KV store. This method uses a promise to return the result. +Obtains the result set with the specified key prefix from this single KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3291,7 +3292,7 @@ Obtains the result set with the specified key prefix from this single KV store. **Example** -``` +```js let kvStore; try { let resultSet; @@ -3333,7 +3334,7 @@ try { getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void -Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3346,7 +3347,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -3381,7 +3382,7 @@ try { getResultSet(query: Query): Promise<KvStoreResultSet> -Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses a promise to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3399,7 +3400,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -3437,7 +3438,7 @@ try { closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void -Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses an asynchronous callback to return the result. +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3450,7 +3451,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method **Example** -``` +```js let kvStore; try { let resultSet = null; @@ -3471,7 +3472,7 @@ try { closeResultSet(resultSet: KvStoreResultSet): Promise<void> -Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses a promise to return the result. +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3489,7 +3490,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method **Example** -``` +```js let kvStore; try { let resultSet = null; @@ -3508,7 +3509,7 @@ try { getResultSize(query: Query, callback: AsyncCallback<number>): void -Obtains the number of results that matches the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the number of results that matches the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3521,7 +3522,7 @@ Obtains the number of results that matches the specified **Query** object. This **Example** -``` +```js let kvStore; try { let entries = []; @@ -3554,7 +3555,7 @@ try { getResultSize(query: Query): Promise<number> -Obtains the number of results that matches the specified **Query** object. This method uses a promise to return the result. +Obtains the number of results that matches the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3572,7 +3573,7 @@ Obtains the number of results that matches the specified **Query** object. This **Example** -``` +```js let kvStore; try { let entries = []; @@ -3609,7 +3610,7 @@ try { removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void -Deletes data of a device. This method uses an asynchronous callback to return the result. +Deletes data of a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3622,7 +3623,7 @@ Deletes data of a device. This method uses an asynchronous callback to return th **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; @@ -3651,7 +3652,7 @@ try { removeDeviceData(deviceId: string): Promise<void> -Deletes data of a device. This method uses a promise to return the result. +Deletes data of a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3669,7 +3670,7 @@ Deletes data of a device. This method uses a promise to return the result. **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; @@ -3696,11 +3697,11 @@ try { ``` -### on8+ ### +### on('syncComplete')8+ ### on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to the synchronization completion events. This method uses a synchronous callback to return the result. +Subscribes to the synchronization completion events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3708,12 +3709,12 @@ Subscribes to the synchronization completion events. This method uses a synchron | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'syncComplete' | Yes |Event triggered when the synchronization is complete. | +| event |string | Yes |Name of the event to subscribe to. The value is **syncComplete**, which indicates the synchronization complete event. | | syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return the synchronization result. | **Example** -``` +```js let kvStore; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const VALUE_TEST_FLOAT_ELEMENT = 321.12; @@ -3732,11 +3733,11 @@ try { ``` -### off8+ ### +### off('syncComplete')8+ ### off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void -Unsubscribes from the synchronization completion events. This method uses a synchronous callback to return the result. +Unsubscribes from the synchronization completion events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3744,12 +3745,12 @@ Unsubscribes from the synchronization completion events. This method uses a sync | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'syncComplete' | Yes |Event triggered when the synchronization is complete. | +| event |string | Yes |Name of the event to unsubscribe from. The value is **syncComplete**, which indicates the synchronization complete event. | | syncCallback |Callback<Array<[string, number]>> | No |Callback used to return the synchronization result. | **Example** -``` +```js let kvStore; try { const func = function (data) { @@ -3768,6 +3769,7 @@ try { sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void Manually triggers KV store synchronization synchronously. + **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3782,7 +3784,7 @@ Manually triggers KV store synchronization synchronously. **Example** -``` +```js let kvStore; kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); ``` @@ -3791,7 +3793,7 @@ kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void -Sets the default delay of database synchronization. This method uses an asynchronous callback to return the result. +Sets the default delay of database synchronization. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3804,7 +3806,7 @@ Sets the default delay of database synchronization. This method uses an asynchro **Example** -``` +```js let kvStore; try { const defaultAllowedDelayMs = 500; @@ -3821,7 +3823,7 @@ try { setSyncParam(defaultAllowedDelayMs: number): Promise<void> -Sets the default delay of database synchronization. This method uses a promise to return the result. +Sets the default delay of database synchronization. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3840,7 +3842,7 @@ Sets the default delay of database synchronization. This method uses a promise t **Example** -``` +```js let kvStore; try { const defaultAllowedDelayMs = 500; @@ -3859,7 +3861,7 @@ try { getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void -Obtains the security level of this KV store. This method uses an asynchronous callback to return the result. +Obtains the security level of this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3871,7 +3873,7 @@ Obtains the security level of this KV store. This method uses an asynchronous ca **Example** -``` +```js let kvStore; try { kvStore.getSecurityLevel(function (err,data) { @@ -3887,7 +3889,7 @@ try { getSecurityLevel(): Promise<SecurityLevel> -Obtains the security level of this KV store. This method uses a promise to return the result. +Obtains the security level of this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -3899,7 +3901,7 @@ Obtains the security level of this KV store. This method uses a promise to retur **Example** -``` +```js let kvStore; try { kvStore.getSecurityLevel().then((data) => { @@ -3915,7 +3917,7 @@ try { ## DeviceKVStore8+ ## -Provides methods to manage distributed data by device in the distributed system. This class inherits from **KvStore** and provides data query and synchronization methods. Before calling any method in **DeviceKVStore**, you must use **getKVStore** to obtain a **DeviceKVStore** object. +Provides methods to manage distributed data by device in the distributed system. This class inherits from **KVStore** and provides data query and synchronization methods. Before calling any method in **DeviceKVStore**, you must use [getKVStore](#getkvstore) to obtain a **DeviceKVStore** object. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -3923,9 +3925,9 @@ Provides methods to manage distributed data by device in the distributed system. get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|number|Uint8Array>): void -Obtains the string value that matches the specified key for a device. This method uses an asynchronous callback to return the result. +Obtains the string value that matches the specified key for a device. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **Parameters** @@ -3937,7 +3939,7 @@ Obtains the string value that matches the specified key for a device. This metho **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; @@ -3958,7 +3960,7 @@ try{ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array> -Obtains the string value that matches the specified key for a device. This method uses a promise to return the result. +Obtains the string value that matches the specified key for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -3973,11 +3975,11 @@ Obtains the string value that matches the specified key for a device. This metho | Type | Description | | ------ | ------- | -|Promise<boolean/string/number/Uint8Array> |Promise used to return the value obtained.| +|Promise<boolean\|string\|number\|Uint8Array> |Promise used to return the value obtained.| **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; @@ -4002,7 +4004,7 @@ try { getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void -Obtains the KV pairs that match the specified key prefix for a device. This method uses an asynchronous callback to return the result. +Obtains the KV pairs that match the specified key prefix for a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4016,7 +4018,7 @@ Obtains the KV pairs that match the specified key prefix for a device. This meth **Example** -``` +```js let kvStore; try { let entries = []; @@ -4050,7 +4052,7 @@ try { getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> -Obtains the KV pairs that match the specified key prefix for a device. This method uses a promise to return the result. +Obtains the KV pairs that match the specified key prefix for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4069,7 +4071,7 @@ Obtains the KV pairs that match the specified key prefix for a device. This meth **Example** -``` +```js let kvStore; try { let entries = []; @@ -4109,7 +4111,7 @@ try { getEntries(query: Query, callback: AsyncCallback<Entry[]>): void -Obtains the KV pairs that match the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the KV pairs that match the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4122,7 +4124,7 @@ Obtains the KV pairs that match the specified **Query** object. This method uses **Example** -``` +```js let kvStore; try { var arr = new Uint8Array([21,31]); @@ -4162,7 +4164,7 @@ try { getEntries(query: Query): Promise<Entry[]> -Obtains the KV pairs that match the specified **Query** object. This method uses a promise to return the result. +Obtains the KV pairs that match the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4180,7 +4182,7 @@ Obtains the KV pairs that match the specified **Query** object. This method uses **Example** -``` +```js let kvStore; try { var arr = new Uint8Array([21,31]); @@ -4220,7 +4222,7 @@ try { getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void -Obtains the KV pairs that match the specified **Query** object for a device. This method uses an asynchronous callback to return the result. +Obtains the KV pairs that match the specified **Query** object for a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4234,7 +4236,7 @@ Obtains the KV pairs that match the specified **Query** object for a device. Thi **Example** -``` +```js let kvStore; try { var arr = new Uint8Array([21,31]); @@ -4274,7 +4276,7 @@ try { getEntries(deviceId: string, query: Query): Promise<Entry[]> -Obtains the KV pairs that match the specified **Query** object for a device. This method uses a promise to return the result. +Obtains the KV pairs that match the specified **Query** object for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4293,7 +4295,7 @@ Obtains the KV pairs that match the specified **Query** object for a device. Thi **Example** -``` +```js let kvStore; try { var arr = new Uint8Array([21,31]); @@ -4334,7 +4336,7 @@ try { getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void -Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This method uses an asynchronous callback to return the result. +Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4348,7 +4350,7 @@ Obtains the **KvStoreResultSet** object that matches the specified key prefix fo **Example** -``` +```js let kvStore; try { let resultSet; @@ -4369,7 +4371,7 @@ try { getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet> -Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This method uses a promise to return the result. +Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4388,7 +4390,7 @@ Obtains the **KvStoreResultSet** object that matches the specified key prefix fo **Example** -``` +```js let kvStore; try { let resultSet; @@ -4413,7 +4415,7 @@ try { getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void -Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4426,7 +4428,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -4465,7 +4467,7 @@ try { getResultSet(query: Query): Promise<KvStoreResultSet> -Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses a promise to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4483,7 +4485,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -4529,7 +4531,7 @@ try { getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreResultSet>): void -Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This method uses an asynchronous callback to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4543,7 +4545,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -4581,7 +4583,7 @@ try { getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> -Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This method uses a promise to return the result. +Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4600,7 +4602,7 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj **Example** -``` +```js let kvStore; try { let resultSet; @@ -4647,7 +4649,7 @@ try { closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void -Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses an asynchronous callback to return the result. +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4660,7 +4662,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method **Example** -``` +```js let kvStore; try { console.log('CloseResultSet success'); @@ -4682,7 +4684,7 @@ try { closeResultSet(resultSet: KvStoreResultSet): Promise<void> -Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses a promise to return the result. +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4700,7 +4702,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method **Example** -``` +```js let kvStore; try { console.log('CloseResultSet success'); @@ -4720,7 +4722,7 @@ try { getResultSize(query: Query, callback: AsyncCallback<number>): void -Obtains the number of results that matches the specified **Query** object. This method uses an asynchronous callback to return the result. +Obtains the number of results that matches the specified **Query** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4733,7 +4735,7 @@ Obtains the number of results that matches the specified **Query** object. This **Example** -``` +```js let kvStore; try { let entries = []; @@ -4767,7 +4769,7 @@ try { getResultSize(query: Query): Promise<number> -Obtains the number of results that matches the specified **Query** object. This method uses a promise to return the result. +Obtains the number of results that matches the specified **Query** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4785,7 +4787,7 @@ Obtains the number of results that matches the specified **Query** object. This **Example** -``` +```js let kvStore; try { let entries = []; @@ -4823,7 +4825,7 @@ try { getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void; -Obtains the number of results that matches the specified **Query** object for a device. This method uses an asynchronous callback to return the result. +Obtains the number of results that matches the specified **Query** object for a device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4837,7 +4839,7 @@ Obtains the number of results that matches the specified **Query** object for a **Example** -``` +```js let kvStore; try { let entries = []; @@ -4870,7 +4872,7 @@ try { getResultSize(deviceId: string, query: Query): Promise<number> -Obtains the number of results that matches the specified **Query** object for a device. This method uses a promise to return the result. +Obtains the number of results that matches the specified **Query** object for a device. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4889,7 +4891,7 @@ Obtains the number of results that matches the specified **Query** object for a **Example** -``` +```js let kvStore; try { let entries = []; @@ -4926,7 +4928,7 @@ try { removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void -Removes data of a device from this KV store. This method uses an asynchronous callback to return the result. +Removes data of a device from this KV store. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4939,7 +4941,7 @@ Removes data of a device from this KV store. This method uses an asynchronous ca **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; @@ -4968,7 +4970,7 @@ try { removeDeviceData(deviceId: string): Promise<void> -Removes data of a device from this KV store. This method uses a promise to return the result. +Removes data of a device from this KV store. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -4986,7 +4988,7 @@ Removes data of a device from this KV store. This method uses a promise to retur **Example** -``` +```js let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; @@ -5018,6 +5020,7 @@ try { sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void Manually triggers KV store synchronization synchronously. + **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -5032,7 +5035,7 @@ Manually triggers KV store synchronization synchronously. **Example** -``` +```js let kvStore; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; @@ -5051,11 +5054,11 @@ try { } ``` -### on8+ ### +### on('syncComplete')8+ ### on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void -Subscribes to the synchronization completion events. This method uses a synchronous callback to return the result. +Subscribes to the synchronization completion events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -5063,12 +5066,12 @@ Subscribes to the synchronization completion events. This method uses a synchron | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'syncComplete' | Yes |Event triggered when the synchronization is complete.| -| syncCallback |Callback | Yes |Callback used to return the synchronization result. | **Example** -``` +```js const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const VALUE_TEST_FLOAT_ELEMENT = 321.12; try { @@ -5086,11 +5089,11 @@ try { ``` -### off8+ ### +### off('syncComplete')8+ ### off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void -Unsubscribes from the synchronization completion events. This method uses a synchronous callback to return the result. +Unsubscribes from the synchronization completion events. This API uses a synchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -5098,12 +5101,12 @@ Unsubscribes from the synchronization completion events. This method uses a sync | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | -| event |'syncComplete' | Yes |Event triggered when the synchronization is complete.| +| event |string | Yes |Name of the event to unsubscribe from. The value is **syncComplete**, which indicates the synchronization complete event.| | syncCallback |Callback- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | @@ -662,7 +662,7 @@ Asynchronously reads data from a file. This method uses a callback to return the | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. | - Example @@ -695,7 +695,7 @@ Synchronously reads data from a file. | ------- | ----------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | @@ -867,7 +867,7 @@ Asynchronously writes data into a file. This method uses a promise to return the | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| - Return value | Type | Description | @@ -903,7 +903,7 @@ Asynchronously writes data into a file. This method uses a callback to return th | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | - Example @@ -935,7 +935,7 @@ Synchronously writes data into a file. | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| - Return value | Type | Description | @@ -1472,10 +1472,10 @@ Asynchronously reads data from a file. This method uses a promise to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name | Type | Mandatory | Description | - | ------- | ----------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| + | Name | Type | Mandatory| Description | + | ------- | ----------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| - Return value | Type | Description | @@ -1509,7 +1509,7 @@ Asynchronously reads data from a file. This method uses a callback to return the | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. | - Example @@ -2577,6 +2577,7 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu ``` + ## Stream7+ File stream. Before calling a method of the **Stream** class, use the **createStream()** method synchronously or asynchronously to create a **Stream** instance. @@ -2721,7 +2722,7 @@ Asynchronously writes data into the stream. This method uses a promise to return | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | @@ -2753,11 +2754,11 @@ Asynchronously writes data into the stream. This method uses a callback to retur **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name | Type | Mandatory | Description | - | -------- | ------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| - | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | - Example ```js @@ -2788,7 +2789,7 @@ Synchronously writes data into the stream. | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | @@ -2818,7 +2819,7 @@ Asynchronously reads data from the stream. This method uses a promise to return | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | @@ -2853,7 +2854,7 @@ Asynchronously reads data from the stream. This method uses a callback to return | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. | - Example @@ -2884,7 +2885,7 @@ Synchronously reads data from the stream. | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | - Return value | Type | Description | 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 3d9afc2b19595cd8d656e3081e9420b30d4b21a5..6a5ee3a36ab94c810f6ef9cc720ded250445f3de 100644 --- a/en/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -3,7 +3,7 @@ > ![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. -> - The APIs of this module are system APIs and cannot be called by third-party applications. +> - API version 9 is a canary release for trial use. The APIs of this version may be unstable. ## Modules to Import @@ -15,7 +15,7 @@ import storagestatistics from "@ohos.storageStatistics"; getTotalSizeOfVolume(volumeUuid: string): Promise<number> -Asynchronously obtains the total space of the specified volume. This method uses a promise to return the result. +Asynchronously obtains the total space of the specified volume. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -46,7 +46,7 @@ Asynchronously obtains the total space of the specified volume. This method uses getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void -Asynchronously obtains the total space of the specified volume. This method uses a callback to return the result. +Asynchronously obtains the total space of the specified volume. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -62,7 +62,7 @@ Asynchronously obtains the total space of the specified volume. This method uses ```js let uuid = ""; storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ - // Do something + // Do something. console.info("getTotalSizeOfVolume successfully:"+ number); }); ``` @@ -73,7 +73,7 @@ Asynchronously obtains the total space of the specified volume. This method uses getFreeSizeOfVolume(volumeUuid: string): Promise<number> -Asynchronously obtains the available space of the specified volume. This method uses a promise to return the result. +Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -105,7 +105,7 @@ Asynchronously obtains the available space of the specified volume. This method getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void -Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. +Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -121,7 +121,7 @@ Asynchronously obtains the available space of the specified volume. This method ```js let uuid = ""; storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ - // Do something + // Do something. console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` @@ -130,7 +130,7 @@ Asynchronously obtains the available space of the specified volume. This method getBundleStats(packageName: string): Promise<BundleStats> -Obtains the bundle status. This method uses a promise to return the result. +Asynchronously obtains app information. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -144,7 +144,7 @@ Obtains the bundle status. This method uses a promise to return the result. | Type | Description | | ------------------------------------------ | -------------------------- | - | Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.| + | Promise<[Bundlestats](#bundlestats)> | Promise used to return the app information.| - Example @@ -161,7 +161,7 @@ Obtains the bundle status. This method uses a promise to return the result. getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void -Obtains the bundle status. This method uses an asynchronous callback to return the result. +Asynchronously obtains app information. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics @@ -170,14 +170,14 @@ Obtains the bundle status. This method uses an asynchronous callback to return t | 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.| + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the app information.| - Example ```js let packageName = ""; storagestatistics.getBundleStats(packageName, function(error, BundleStats){ - // Do something + // Do something. console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }); ``` @@ -191,5 +191,5 @@ Obtains the bundle status. This method uses an asynchronous callback to return t | Name | Type | Description | | --------- | ------ | -------------- | | appSize9+ | number | Size of the app. | -| cacheSize9+ | number | Size of the cached data. | +| cacheSize9+ | number | Cache size of the app. | | dataSize9+ | number | Total data size of the app.| diff --git a/en/application-dev/reference/apis/js-apis-system-vibrate.md b/en/application-dev/reference/apis/js-apis-system-vibrate.md index f62074d37470aac7224888af2e10fda9cadf8bbf..dd61d58d398846368eb33004779a9ad89901eabc 100644 --- a/en/application-dev/reference/apis/js-apis-system-vibrate.md +++ b/en/application-dev/reference/apis/js-apis-system-vibrate.md @@ -1,7 +1,7 @@ # Vibrator -> ![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 4. 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 8. You are advised to use [`@ohos.vibrator`](js-apis-vibrator.md) instead. > - This module requires hardware support and can only be debugged on real devices. @@ -27,9 +27,12 @@ Triggers device vibration. **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | mode | string | No| Vibration mode. The value **long** indicates long vibration, and **short** indicates short vibration. The default value is **long**.| +| success | Function | Yes| Called when the vibrator data changes.| +| fail | Function | No| Called when the API call fails.| +| complete | Function | No| Called when the API call is complete.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md index e4e44b0db405165911335d3ee12a152a6e06f52a..16ca7a6a06903f063a22590981cc3ed3b3ed8cd1 100644 --- a/en/application-dev/reference/apis/js-apis-volumemanager.md +++ b/en/application-dev/reference/apis/js-apis-volumemanager.md @@ -2,8 +2,8 @@ > ![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. -> - The APIs of this module are system APIs and cannot be called by third-party applications. +> - The initial APIs of this module are supported since API version 9. +> - API version 9 is a canary release for trial use. The APIs of this version may be unstable. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-workScheduler.md b/en/application-dev/reference/apis/js-apis-workScheduler.md index 770f833363445e40fa738a4347ff68444125b3f6..bd8e95ec9ef21a1498b3dc4db0b5f1f4fb595c49 100644 --- a/en/application-dev/reference/apis/js-apis-workScheduler.md +++ b/en/application-dev/reference/apis/js-apis-workScheduler.md @@ -1,7 +1,7 @@ # 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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import @@ -220,13 +220,13 @@ Checks whether the last execution of the specified task timed out. This API uses | Name | Type | Mandatory | Description | | -------- | -------------------- | ---- | ---------------------------------------- | | workId | number | Yes | Task ID. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| **Return value** | Type | Description | | ------- | ---------------------------------------- | -| boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| +| boolean | Callback used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| **Example** @@ -276,20 +276,21 @@ 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. | +| 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. | +| isPersisted | boolean | No | Whether to enable persistent storage for the task. | ## NetworkType Enumerates the network types that can trigger the task. diff --git a/en/application-dev/reference/arkui-ts/ts-container-panel.md b/en/application-dev/reference/arkui-ts/ts-container-panel.md index a73447518e43234f226ca322d04418858f1df2da..4c032b32a8c40fe513661ff1030dd5f5a82e4f6c 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/en/application-dev/reference/arkui-ts/ts-container-panel.md @@ -2,6 +2,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -22,43 +23,43 @@ This component can contain child components. Panel(value:{show:boolean}) -- Parameter - | Name | Type | Mandatory | Default Value | Description | +- Parameters + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | show | boolean | Yes | - | Whether the panel is shown or hidden. | + | show | boolean | Yes | - | Whether the panel is shown or hidden. | ## Attributes - | Name | Type | Default Value | Description | +| Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| type | PanelType | PanelType.Foldable | Type of the panel. | -| mode | PanelMode | - | Initial status of the panel. | -| dragBar | boolean | true | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite. | -| fullHeight | Length | - | Panel height in the **PanelMode.Full** mode. | -| halfHeight | Length | - | Panel height in the **PanelMode.Half** mode. The default value is half of the screen height. | -| miniHeight | Length | - | Panel height in the **PanelMode.Mini** mode. | +| type | PanelType | PanelType.Foldable | Type of the panel. | +| mode | PanelMode | - | Initial status of the panel. | +| dragBar | boolean | true | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite. | +| fullHeight | Length | - | Panel height in the **PanelMode.Full** mode. | +| halfHeight | Length | - | Panel height in the **PanelMode.Half** mode. The default value is half of the screen height. | +| miniHeight | Length | - | Panel height in the **PanelMode.Mini** mode. | - PanelType enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Minibar | A minibar panel displays content in the minibar area or a large (fullscreen-like) area. | - | Foldable | A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area. | - | Temporary | A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area. | + | Minibar | A minibar panel displays content in the minibar area or a large (fullscreen-like) area. | + | Foldable | A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area. | + | Temporary | A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area. | - PanelMode enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Mini | Displays a **minibar** or **foldable** panel in its minimum size. This attribute does not take effect for **temporary** panels. | - | Half | Displays a **foldable** or **temporary** panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for **minibar** panels. | - | Full | Displays a panel in a large (fullscreen-like) area. | + | Mini | Displays a **minibar** or **foldable** panel in its minimum size. This attribute does not take effect for **temporary** panels. | + | Half | Displays a **foldable** or **temporary** panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for **minibar** panels. | + | Full | Displays a panel in a large (fullscreen-like) area. | ## Events - | Name | Description | +| Name | Description | | -------- | -------- | -| onChange(callback: (width: number, height: number, mode: PanelMode) => void) | Triggered when the status of the panel changes. The returned height value is the height of the content area. When the value of **dragbar** is **true**, the height of the panel is the dragbar height plus the height of the content area. | +| onChange(callback: (width: number, height: number, mode: PanelMode) => void) | Triggered when the status of the panel changes. The returned height value is the height of the content area. When the value of **dragbar** is **true**, the height of the panel is the drag bar height plus the height of the content area. | ## Example @@ -86,10 +87,10 @@ struct PanelExample { } } .type(PanelType.Foldable).mode(PanelMode.Half) - .dragBar(true) // The dragbar is enabled by default. - .halfHeight(500) // Half of the height by default - .onChange((value: any) => { - console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + .dragBar(true) // The drag bar is enabled by default. + .halfHeight(500) // The default value is half of the screen height. + .onChange((width: number, height: number, mode: PanelMode) => { + console.info(`width:${width},height:${height},mode:${mode}`) }) }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) } diff --git a/en/application-dev/security/Readme-EN.md b/en/application-dev/security/Readme-EN.md index f35f70483564be9f9fdba75a305ed5c4a03dcf8d..7cad7ef81507875e59c39007602ec5fd579e5170 100644 --- a/en/application-dev/security/Readme-EN.md +++ b/en/application-dev/security/Readme-EN.md @@ -9,6 +9,6 @@ - Key Management - [HUKS Overview](huks-overview.md) - [HUKS Development](huks-guidelines.md) -- hapsigntool - - [hapsigntool Guide](hapsigntool-guidelines.md) +- hapsigner + - [hapsigner Guide](hapsigntool-guidelines.md) diff --git a/en/application-dev/security/hapsigntool-guidelines.md b/en/application-dev/security/hapsigntool-guidelines.md index 35d530bf56b7f7b108bad153ad3ffef74af93e27..89f2711cb9ae50ad4a2967b0d6690c47158a48ad 100644 --- a/en/application-dev/security/hapsigntool-guidelines.md +++ b/en/application-dev/security/hapsigntool-guidelines.md @@ -246,7 +246,7 @@ The process of signing a HAP is as follows: > > For security purposes, the ECC algorithm is recommended for generating key pairs for application signing signatures. The RSA algorithm is not recommended.
> You are advised to place the HAP, profile, KS file **OpenHarmony.p12**, root CA certificate, intermediate CA certificate, and hapsigner in the same directory for easy operation. -> The **developtools_hapsigner/autosign/result/** directory has the following files:
- OpenHarmony KS file **OpenHarmony.p12**
- Root CA certificate **rootCA.cer**
- Intermediate CA certificate **subCA.cer**
- Profile signing certificate **OpenHarmonyProfileRelease.pem** +> The [**developtools_hapsigner/autosign/result**](https://gitee.com/openharmony/developtools_hapsigner/tree/master/autosign/result) directory has the following files:
- OpenHarmony KS file **OpenHarmony.p12**
- Root CA certificate **rootCA.cer**
- Intermediate CA certificate **subCA.cer**
- Profile signing certificate **OpenHarmonyProfileRelease.pem** **1. Generate a key pair for the application signing certificate.** diff --git a/en/application-dev/ui/ui-js-components-calendar.md b/en/application-dev/ui/ui-js-components-grid.md similarity index 100% rename from en/application-dev/ui/ui-js-components-calendar.md rename to en/application-dev/ui/ui-js-components-grid.md diff --git a/en/application-dev/ui/ui-ts-basic-components-button.md b/en/application-dev/ui/ui-ts-basic-components-button.md index 0d65412ecb0b19a1937d223cadb87696a890d9ee..e43a42df91c43c8e605d84617f853d58e2b235a3 100644 --- a/en/application-dev/ui/ui-ts-basic-components-button.md +++ b/en/application-dev/ui/ui-ts-basic-components-button.md @@ -76,7 +76,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or .borderRadius(20) ``` - ![zh-cn_image_0000001190463780](figures/zh-cn_image_0000001190463780.png) + ![en-us_image_0000001190463780](figures/en-us_image_0000001190463780.png) - Set the text style: @@ -90,7 +90,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or .fontWeight(800) ``` - ![zh-cn_image_0000001189744672](figures/zh-cn_image_0000001189744672.png) + ![en-us_image_0000001189744672](figures/en-us_image_0000001189744672.png) - Set the background color: diff --git a/en/application-dev/website.md b/en/application-dev/website.md index da1e2c676f8de88e50012cbe66e009682dce8091..4571ec150c8d50dcbbd2aef95794d37ad79f9a7b 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -9,20 +9,31 @@ - [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md) - [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md) - Development Fundamentals - - [Directory Structure](quick-start/package-structure.md) + - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) + - [Application Package Structure Configuration File (Stage Model)](quick-start/module-structure.md) - [Resource File Categories](quick-start/basic-resource-file-categories.md) + - [SysCap Usage Guidelines](quick-start/syscap.md) - Development - - [Ability Development](ability/Readme-EN.md) + - Ability Development - [Ability Framework Overview](ability/ability-brief.md) + - [Context Usage](ability/context-userguide.md) - 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) - + - [FA Widget Development](ability/fa-formability.md) + - Stage Model + - [Stage Model Overview](ability/stage-brief.md) + - [Ability Development](ability/stage-ability.md) + - [Service Extension Ability Development](ability/stage-serviceextension.md) + - [Ability Continuation Development](ability/stage-ability-continuation.md) + - [Ability Call Developmen](ability/stage-call.md) + - [Stage Widget Development](ability/stage-formextension.md) - Other + - [WantAgent Development](ability/wantagent.md) - [Ability Assistant Usage](ability/ability-assistant-guidelines.md) + - [Test Framework Usage](ability/ability-delegator.md) - UI - [ArkUI Overview](ui/arkui-overview.md) - JavaScript-based Web-Like Development Paradigm @@ -75,10 +86,11 @@ - [Qrcode Development](ui/ui-js-components-qrcode.md) - [Search Development](ui/ui-js-components-search.md) - Canvas Development + - [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) - - [Grid-container Development](ui/ui-js-components-calendar.md) + - [Grid-container Development](ui/ui-js-components-grid.md) - Svg - [Basics](ui/ui-js-components-svg-overview.md) - [Graph Drawing](ui/ui-js-components-svg-graphics.md) @@ -126,6 +138,7 @@ - [@Builder](ui/ts-component-based-builder.md) - [@Extend](ui/ts-component-based-extend.md) - [@CustomDialog](ui/ts-component-based-customdialog.md) + - [@Styles](ui/ts-component-based-styles.md) - About UI State Management - [Basic Concepts](ui/ts-ui-state-mgmt-concepts.md) - Managing Component States @@ -167,6 +180,14 @@ - [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 + - Common Event and Notification + - [Common Event and Notification Overview](notification/notification-brief.md) + - Common Event + - [Common Event Development](notification/common-event.md) + - Notification + - [Notification Development](notification/notification.md) + - Debugging Tools + - [Debugging Assistant Usage](notification/assistant-guidelines.md) - Window Manager - Window - [Window Overview](windowmanager/window-overview.md) @@ -184,9 +205,9 @@ - Audio - [Audio Overview](media/audio-overview.md) - [Audio Playback Development](media/audio-playback.md) - - [Audio Rendering Development](media/audio-renderer.md) - [Audio Recording Development](media/audio-recorder.md) - - [Audio Capture Development](media/audio-capturer) + - [Audio Rendering Development](media/audio-renderer.md) + - [Audio Capture Development](media/audio-capturer.md) - Video - [Video Playback Development](media/video-playback.md) - [Video Recording Development](media/video-recorder.md) @@ -196,13 +217,28 @@ - User Authentication - [User Authentication Overview](security/userauth-overview.md) - [User Authentication Development](security/userauth-guidelines.md) + - Key Management + - [HUKS Overview](security/huks-overview.md) + - [HUKS Development](security/huks-guidelines.md) - hapsigner - [hapsigner Guide](security/hapsigntool-guidelines.md) + - Access Control + - [Access Control Overview](security/accesstoken-overview.md) + - [Access Control Development](security/accesstoken-guidelines.md) - Connectivity + - Network Management + - [Network Management Overview](connectivity/net-mgmt-overview.md) + - [HTTP Data Request](connectivity/http-request.md) + - [WebSocket Connection](connectivity/websocket-connection.md) + - [Socket Connection](connectivity/socket-connection.md) - IPC & RPC - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) - [IPC & RPC Development Guidelines](connectivity/ipc-rpc-development-guideline.md) - [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md) + - Telephony + - [Telephony Service Overview](telephony/telephony-overview.md) + - [Redirecting to the Dial Screen](telephony/jumping-to-the-dial-screen.md) + - [Obtaining Current Cellular Network Signal Information](telephony/cellular-network-signal-info.md) - Data Management - Distributed Data Service - [Distributed Data Service Overview](database/database-mdds-overview.md) @@ -213,12 +249,18 @@ - Lightweight Data Store - [Lightweight Data Store Overview](database/database-preference-overview.md) - [Lightweight Data Store Development](database/database-preference-guidelines.md) + - Distributed Data Object + - [Distributed Data Object Overview](database/database-distributedobject-overview.md) + - [Distributed Data Object Development](database/database-distributedobject-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) + - [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) + - [Agent-Powered Scheduled Reminder Development](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) + - Work Scheduler + - [Work Scheduler Overview](work-scheduler/work-scheduler-overview.md) + - [Work Scheduler Development](work-scheduler/work-scheduler-dev-guide.md) - Device - USB Service - [USB Service Overview](device/usb-overview.md) @@ -233,6 +275,7 @@ - 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) @@ -250,12 +293,15 @@ - [Overview](internationalization/international-overview.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md) - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) + - + - [Using Native APIs in Application Projects](napi/napi-guidelines.md) - Tools - [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) + - [Codelabs](https://gitee.com/openharmony/codelabs) - API References - - Compent Reference (JavaScript-based Web-like Development Paradigm) + - Component Reference (JavaScript-based Web-like Development Paradigm) - Components - Common - [Universal Attributes](reference/arkui-js/js-components-common-attributes.md) @@ -265,6 +311,7 @@ - [Animation Styles](reference/arkui-js/js-components-common-animation.md) - [Gradient Styles](reference/arkui-js/js-components-common-gradient.md) - [Transition Styles](reference/arkui-js/js-components-common-transition.md) + - [Media Query](reference/arkui-js/js-components-common-mediaquery.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 Components @@ -354,8 +401,9 @@ - [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) - - [Type Attributes](reference/arkui-js/js-appendix-types.md) - - Compent Reference (TypeScript-based Declarative Development Paradigm) + - Appendix + - [Type Attributes](reference/arkui-js/js-appendix-types.md) + - Component Reference (TypeScript-based Declarative Development Paradigm) - Components - Universal Components - Universal Events @@ -440,7 +488,7 @@ - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - [Web](reference/arkui-ts/ts-basic-components-web.md) - - [Xcomponent](reference/arkui-ts/ts-basic-components-xcomponent.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) @@ -500,12 +548,13 @@ - [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) + - [Time Picker Dialog Box](reference/arkui-ts/ts-methods-timepicker-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) + - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - APIs - Ability Framework - + - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) @@ -546,10 +595,10 @@ - [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) + - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.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) @@ -606,10 +655,11 @@ - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - - [@ohos.settings](reference/apis/js-apis-settings.md) + - [@ohos.settings](reference/apis/js-apis-settings.md) - [resultSet](reference/apis/js-apis-data-resultset.md) - File Management - + + - [@ohos.document](reference/apis/js-apis-document.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) @@ -711,6 +761,7 @@ - [@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) @@ -719,6 +770,7 @@ - [@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) diff --git a/en/contribute/how-to-contribute.md b/en/contribute/how-to-contribute.md index 26a3bb146ec3cb2e80c898d668262fc98f0992ca..0e1f8ab9365b1a7f8c3c299992d6a816b02c89b6 100644 --- a/en/contribute/how-to-contribute.md +++ b/en/contribute/how-to-contribute.md @@ -8,7 +8,7 @@ You must sign the Developer Certificate of Origin (DCO) before you can contribute to the community. -Click [here](https://dco.openharmony.io/sign/Z2l0ZWUlMkZvcGVuX2hhcm1vbnk=) to sign the DCO, and click [here](https://dco.openharmony.io/check-sign-status) to check the signing status. +Click [here](https://dco.openharmony.cn/#/sign) to sign the DCO, and click [here](https://dco.openharmony.cn/#/check-sign-status) to check the signing status. **Code of Conduct** diff --git a/en/device-dev/kernel/kernel-standard-build.md b/en/device-dev/kernel/kernel-standard-build.md index 579ebeb72bfb2a37699a5eb684601114afb2331d..da43934349c9513ca45a88168d8b1cd8628b39dc 100644 --- a/en/device-dev/kernel/kernel-standard-build.md +++ b/en/device-dev/kernel/kernel-standard-build.md @@ -9,8 +9,8 @@ The following uses the Hi3516D V300 board and Ubuntu x86 server as an example. Perform a full build for the project to generate the **uImage** kernel image. ``` -./build.sh --product-name Hi3516DV300 # Build the Hi3516D V300 image. - --build-target build_kernel # Build the uImage kernel image of the Hi3516D V300 board. +./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. + --build-target build_kernel # Build the uImage kernel image of the hispark_taurus_standard. --gn-args linux_kernel_version=\"linux-5.10\" # Build the specified kernel version. ``` diff --git a/en/device-dev/porting/porting-chip-faqs.md b/en/device-dev/porting/porting-chip-faqs.md index 878feb66498ac8a4042c0f02e9da78e0e35716a3..188747865c20ab9ce16bede0a7774c986cb827de 100644 --- a/en/device-dev/porting/porting-chip-faqs.md +++ b/en/device-dev/porting/porting-chip-faqs.md @@ -1,4 +1,4 @@ -# FAQ +# FAQs ## How Do I Mount the Heap Memory to the Kernel? diff --git a/en/device-dev/porting/porting-linux-kernel.md b/en/device-dev/porting/porting-linux-kernel.md index e678980689031f38ce5c74efa5cfa89435e512cd..491355e6696898970d6ef3e3ca60445c32577e16 100644 --- a/en/device-dev/porting/porting-linux-kernel.md +++ b/en/device-dev/porting/porting-linux-kernel.md @@ -211,7 +211,7 @@ The procedure is as follows: Run the following command: ``` - ./build.sh --product-name Hi3516DV300 --build-target hdf_test + ./build.sh --product-name hispark_taurus_standard --build-target hdf_test ``` Wait until the build is complete. diff --git a/en/device-dev/porting/standard-system-porting-guide.md b/en/device-dev/porting/standard-system-porting-guide.md index 57531dbcabd48356bb8d67c1e8887edd702e4dad..bb56dacfd1b8c575d6c5eab01b1f02c23440ee03 100644 --- a/en/device-dev/porting/standard-system-porting-guide.md +++ b/en/device-dev/porting/standard-system-porting-guide.md @@ -6,51 +6,60 @@ This document describes the general process for porting a development board, rat This document uses the process of porting a development board named **MyProduct** as an example. This development board is provided by **MyProductVendor** and uses the SoC **MySOC** produced by **MySoCVendor**. -### Defining an SoC - -Create a JSON file named after the SoC name in the **//productdefine/common/device** directory and specify the CPU architecture. +### Defining a Product -For example, to port **MySOC**, which uses a 32-bit ARM kernel, configure the file as follows: +Create a config.json file in the directory with the name "//vendor/MyProductVendor/{product_name}. This file is used to describe the SoC used by the product and the required subsystems. configure the file as follows: -//productdefine/common/device/MySOC.json +//vendor/MyProductVendor/MyProduct/config.json + ``` { - "target_os": "ohos", - "target_cpu": "arm" + "product_name": "MyProduct", + "version": "3.0", + "type": "standard", + "target_cpu": "arm", + "ohos_version": "OpenHarmony 1.0", + "device_company": "MyProductVendor", + "board": "MySOC", + "enable_ramdisk": true, + "subsystems": [ + { + "subsystem": "ace", + "components": [ + { "component": "ace_engine_lite", "features":[""] } + ] + }, + … + ] } + + ``` -Currently, **target\_cpu** can be set to **arm** only. In the future, you can set the value depending on the CPU architecture, such as **arm64**, **riscv**, or **x86**. +The main configurations are as follows: -### Defining a Product +product_name:The product name.Required -Create a JSON file named after the product name in the **//productdefine/common/products** directory. This file is used to describe the SoC used by the product and the required subsystems. Configure the file as follows: +version:version.Required -//productdefine/common/products/MyProduct.json +type:Configured at the system level, select from (mini, small, standard).Required -``` -{ - "product_name": "MyProduct", - "product_company" : "MyProductVendor", - "product_device": "MySOC", - "version": "2.0", - "type": "standard", - "parts":{ - "ace:ace_engine_standard":{}, - "ace:napi":{}, - ... - "xts:phone_tests":{} - } -} +target_cpu :The CPU type of the device (depending on the actual situation, the target_cpu here may also be arm64, riscv, x86, etc..).Required -``` +ohos_version:Operating system version.Optional -The main configurations are as follows: +device_company:device manufacturer name.Required + +board:Board name.Required + +enable_ramdisk:Whether to start ramdisk.Required + +kernel_type and kernel_version: kernel_type with kernel_version is fixed in the standard and does not need to be written.Optional + +subsystems:The subsystem that the system needs to be enabled. Subsystems can simply understand a piece of function that is built independently. Required -1. **product\_device**: SoC used by the product. -2. **type**: system level. In this example, set it to **standard**. -3. **parts**: subsystem to enable. A subsystem can be treated as an independently built functional block. +product_company:Not reflected in the configuration, but in the directory name, the next directory of the vendor is product_company, build.gn script can still be accessed. You can find available subsystems in **//build/subsystem\_config.json**. You can also customize subsystems. @@ -83,7 +92,7 @@ Add the following subsystem configuration to the **//build/subsystem\_config.js }, ``` -Then, open the configuration file **//productdefine/common/products/MyProduct.json**, which is used to define the product, and add the new subsystem to the product. +Then, open the configuration file **//vendor/MyProductVendor/MyProduct/config.json**, which is used to define the product, and add the new subsystem to the product. ### 2. Building the Kernel diff --git a/en/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md b/en/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md index 3d686adeb81f6e2a33acdbff3e9d54e674fa4ba7..cec86501be9781ff64a262e838e512e3afc4040d 100644 --- a/en/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md +++ b/en/device-dev/quick-start/quickstart-ide-standard-running-hi3516-create.md @@ -19,9 +19,9 @@ applications/sample/hello ├── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── Hi3516DV300.json +vendor/hisilicon +└── Hi3516DV300 + └── config.json ``` diff --git a/en/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md b/en/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md index 3ef3b3589c1fd23e77056384c5f13828b819786b..6025ddf56951d33a8b0205f2368255273430f753 100644 --- a/en/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md +++ b/en/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md @@ -19,9 +19,9 @@ applications/sample/hello ├── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── rk3568.json +vendor/hihope +└── rk3568 + └── config.json ``` @@ -150,7 +150,7 @@ Perform the steps below in the source code directory: 4. Modify the product configuration file. - In the vendor\hisilicon\rk3568\config.json file, add the hello part after the existing part. + In the vendor\hihope\rk3568\config.json file, add the hello part after the existing part. ``` "usb:usb_manager_native":{}, diff --git a/en/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/en/device-dev/quick-start/quickstart-standard-running-hi3516-build.md index f40fa3b05b2f3cd16f86a2f9f8c11bf20945188b..7b170d1e45d1e6670a75af371e5c313a51eb65b3 100644 --- a/en/device-dev/quick-start/quickstart-standard-running-hi3516-build.md +++ b/en/device-dev/quick-start/quickstart-standard-running-hi3516-build.md @@ -45,4 +45,4 @@ Go to the root directory of the source code in the Ubuntu environment and perfor 5. Check the build result. If "build success" is displayed, the building is successful. > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** - > The build result and log files are stored in **out/hi3516dv300**. + > The build result and log files are stored in **out/hispark_taurus**. diff --git a/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md b/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md index e0ffea9670c0285a8731fd220e2d7173a1093bf0..7bae60ad6f2a1bc4a6bdb36c6c8593fc4ce4f581 100644 --- a/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md +++ b/en/device-dev/quick-start/quickstart-standard-running-hi3516-create.md @@ -19,9 +19,9 @@ applications/sample/hello │ └── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── Hi3568DV300.json +vendor/hisilicon +└── Hi3516DV300 + └── config.json ``` @@ -151,7 +151,7 @@ Perform the steps below in the source code directory: 4. Modify the product configuration file. - In the **productdefine/common/products/Hi3516DV300.json** file, add the **hello** part after the existing part. + In the **vendor\hisilicon\Hi3516DV300\config.json** file, add the **hello** part after the existing part. ``` diff --git a/en/device-dev/quick-start/quickstart-standard-running-rk3568-create.md b/en/device-dev/quick-start/quickstart-standard-running-rk3568-create.md index 523e9f334d4269af91a3244470d4d8438f14fe06..aa730ed0aa81d4f2aac49c4ea9b5b3cfe4c3b247 100644 --- a/en/device-dev/quick-start/quickstart-standard-running-rk3568-create.md +++ b/en/device-dev/quick-start/quickstart-standard-running-rk3568-create.md @@ -18,9 +18,9 @@ applications/sample/hello │ └── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── rk3568.json +vendor/hihope +└── rk3568 + └── config.json ``` @@ -149,7 +149,7 @@ Perform the steps below in the source code directory: 4. Modify the product configuration file. - In the **productdefine/common/products/rk3568.json** file, add the **hello** part after the existing part. + In the **vendor\hihope\rk3568\config.json** file, add the **hello** part after the existing part. ``` "usb:usb_manager_native":{}, diff --git a/en/device-dev/subsystems/subsys-build-standard-large.md b/en/device-dev/subsystems/subsys-build-standard-large.md index d47fbd1d235b46617d2471201eb874f9b557f4d1..8f6dad88baa4a1046da2fb014c00b84d42bc062f 100644 --- a/en/device-dev/subsystems/subsys-build-standard-large.md +++ b/en/device-dev/subsystems/subsys-build-standard-large.md @@ -207,20 +207,20 @@ The process to build OpenHarmony is as follows: 2. Add the module to the product configuration file. - Add the module to the product configuration file **productdefine/common/products/\{product-name\}.json**. + Add the module to the product configuration file **//vendor/{product_company}/{product-name}/config.json。**. Add "subsystem\_examples:partA" to the product configuration file. **partA** will be built and packaged into the distribution. 3. Build the module. - For example, run the following command to build Hi3516D V300: + For example, run the following command to build hispark_taurus_standard: ``` - ./build.sh --product-name Hi3516DV300 --ccache + ./build.sh --product-name hispark_taurus_standard --ccache ``` 4. Obtain the build result. - Files generated during the build process are stored in the **out/hi3516dv300/** directory, and the generated image is stored in the **out/hi3516dv300/packages/phone/images/** directory. + Files generated during the build process are stored in the **out/hispark_taurus/** directory, and the generated image is stored in the **out/hispark_taurus/packages/phone/images/** directory. diff --git a/en/device-dev/subsystems/subsys-testguide-test.md b/en/device-dev/subsystems/subsys-testguide-test.md index 0596e5397b9c891d01168f1db782fcd247075e09..c6ad47131a60b665506005bb249b46378de01b61 100644 --- a/en/device-dev/subsystems/subsys-testguide-test.md +++ b/en/device-dev/subsystems/subsys-testguide-test.md @@ -718,13 +718,13 @@ Before executing test cases, you need to modify the configuration based on the d Test cases cannot be built on Windows. You need to run the following command to build test cases on Linux: ``` -./build.sh --product-name Hi3516DV300 --build-target make_test +./build.sh --product-name hispark_taurus_standard --build-target make_test ``` >Note: ->- **product-name**: specifies the name of the product to build, for example, **Hi3516DV300**. +>- **product-name**: specifies the name of the product to build, for example, **hispark_taurus_standard**. >- **build-target**: specifies the test case to build. **make_test** indicates all test cases. You can specify the test cases based on requirements. -After the build is complete, the test cases are automatically saved in **out/hi3516dv300/packages/phone/tests**. +After the build is complete, the test cases are automatically saved in **out/hispark_taurus/packages/phone/tests**. #### Setting Up the Execution Environment 1. On Windows, create the **Test** directory in the test framework and then create the **testcase** directory in the **Test** directory. diff --git a/en/device-dev/website.md b/en/device-dev/website.md index d3fc645c6b26a7fc8aaafff70db332f2267cba5a..dfc0cd795d99acef502d3968f168bb8bc00717a6 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -1,5 +1,6 @@ # OpenHarmony Device Development Documentation - [Device Development Guide](device-dev-guide.md) + - Getting Started - Getting Started with Mini and Small Systems (IDE Mode, Recommended) - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md) @@ -94,11 +95,16 @@ - [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md) - [Reference](quick-start/quickstart-standard-reference.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) + - Porting + - Mini System SoC Porting Guide + - Porting Preparations - [Before You Start](porting/porting-chip-prepare-knows.md) - [Building Adaptation Process](porting/porting-chip-prepare-process.md) @@ -114,8 +120,10 @@ - [lwIP Module Adaptation](porting/porting-chip-board-lwip.md) - [Third-party Module Adaptation](porting/porting-chip-board-bundle.md) - [XTS](porting/porting-chip-board-xts.md) - - [FAQ](porting/porting-chip-faqs.md) + - [FAQs](porting/porting-chip-faqs.md) + - Small System SoC Porting Guide + - Porting Preparations - [Before You Start](porting/porting-smallchip-prepare-needs.md) - [Compilation and Building](porting/porting-smallchip-prepare-building.md) @@ -126,17 +134,23 @@ - [Overview](porting/porting-smallchip-driver-overview.md) - [Platform Driver Porting](porting/porting-smallchip-driver-plat.md) - [Device Driver Porting](porting/porting-smallchip-driver-oom.md) + - Standard System SoC Porting Guide + - [Standard System Porting Guide](porting/standard-system-porting-guide.md) - [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) + - Third-Party Library Porting Guide for Mini and Small Systems - [Overview](porting/porting-thirdparty-overview.md) - [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md) - [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md) + - Mini System SoC Porting Cases - - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md) - - [Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md) + - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md) + - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md) + - Subsystem Development + - Kernel - Kernel for Mini Systems - [Kernel Overview](kernel/kernel-mini-overview.md) @@ -285,8 +299,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) - [CPUP](kernel/kernel-small-debug-process-cpu.md) - Memory Debugging - [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md) @@ -438,23 +452,23 @@ - [Telephony Development](subsystems/subsys-tel-guide.md) - Security - [Overview](subsystems/subsys-security-overview.md) - - [Development Guidelines on Application Signature Verification](subsystems/subsys-security-sigverify.md) - - [Development Guidelines on Application Permission Management](subsystems/subsys-security-rightmanagement.md) - - [Development Guidelines on IPC Authentication](subsystems/subsys-security-communicationverify.md) + - [Development on Application Signature Verification](subsystems/subsys-security-sigverify.md) + - [Development on Application Permission Management](subsystems/subsys-security-rightmanagement.md) + - [Development on IPC Authentication](subsystems/subsys-security-communicationverify.md) - [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md) - Startup - [Startup](subsystems/subsys-boot-overview.md) - [init Module](subsystems/subsys-boot-init.md) - [appspawn Module](subsystems/subsys-boot-appspawn.md) + - [appspawn Module for the Standard System](subsystems/subsys-boot-appspawn-standard.md) - [bootstrap Module](subsystems/subsys-boot-bootstrap.md) - [syspara Module](subsystems/subsys-boot-syspara.md) - [FAQs](subsystems/subsys-boot-faqs.md) - [Reference](subsystems/subsys-boot-ref.md) - - [Test](subsystems/subsys-testguide-test.md) - DFX - [DFX](subsystems/subsys-dfx-overview.md) - [HiLog Development](subsystems/subsys-dfx-hilog-rich.md) - - [HiLog_Lite Development](subsystems/subsys-dfx-hilog-lite.md) + - [HiLog\_Lite Development](subsystems/subsys-dfx-hilog-lite.md) - [HiTrace Development](subsystems/subsys-dfx-hitrace.md) - [HiCollie Development](subsystems/subsys-dfx-hicollie.md) - HiSysEvent Development @@ -463,6 +477,8 @@ - [HiSysEvent Listening](subsystems/subsys-dfx-hisysevent-listening.md) - [HiSysEvent Query](subsystems/subsys-dfx-hisysevent-query.md) - [HiSysEvent Tool Usage](subsystems/subsys-dfx-hisysevent-tool.md) + - [HiDumper Development](subsystems/subsys-dfx-hidumper.md) + - [HiChecker Development](subsystems/subsys-dfx-hichecker.md) - Featured Topics - HPM Part - [HPM Part Overview](hpm-part/hpm-part-about.md) @@ -480,7 +496,7 @@ - [Photographing](guide/device-iotcamera-control-demo-photodevguide.md) - [Video Recording](guide/device-iotcamera-control-demo-videodevguide.md) - [Use Case](guide/device-iotcamera-control-example.md) - - Cameras with a Screen) + - Cameras with a Screen - Screen and Camera Control - [Overview](guide/device-camera-control-overview.md) - Development Guidelines @@ -502,19 +518,20 @@ - [Development Example for Platform Drivers](guide/device-driver-demo.md) - [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) - Debugging + - [Test Subsystem](subsystems/subsys-testguide-test.md) - Debugging Tools - - [bytrace Usage Guidelines](subsystems/subsys-toolchain-bytrace-guide.md) - - [hdc_std Usage Guidelines](subsystems/subsys-toolchain-hdc-guide.md) + - [bytrace](subsystems/subsys-toolchain-bytrace-guide.md) + - [hdc\_std](subsystems/subsys-toolchain-hdc-guide.md) + - [hiperf](subsystems/subsys-toolchain-hiperf.md) - [XTS Certification](subsystems/subsys-xts-guide.md) - Tools - [Docker Environment](get-code/gettools-acquire.md) - [IDE](get-code/gettools-ide.md) - Hands-On Tutorials - - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - References - - [Overview of FAQs](faqs/faqs-overview.md) + - [FAQs Overview](faqs/faqs-overview.md) - [Environment Setup](faqs/faqs-environment-setup.md) - [Compilation and Building Subsystem](faqs/faqs-building.md) - [Burning](faqs/faqs-burning.md) diff --git a/en/readme/Security.md b/en/readme/Security.md index c22201a03cca2a3762bf775f4a7c3f5618eb94b3..fe18e6e0da4175ec8bc0959cfaac374a45e71649 100644 --- a/en/readme/Security.md +++ b/en/readme/Security.md @@ -85,4 +85,22 @@ In OpenHarmony, the data transfer management module provides cross-device data t Security subsystem -[base/security](https://gitee.com/openharmony/security) +[security_dataclassification](https://gitee.com/openharmony/security_dataclassification) + +[security_access_token](https://gitee.com/openharmony/security_access_token) + +[security_huks](https://gitee.com/openharmony/security_huks) + +[security_selinux](https://gitee.com/openharmony/security_selinux) + +[security](https://gitee.com/openharmony/security) + +[security_deviceauth](https://gitee.com/openharmony/security_deviceauth) + +[security_permission](https://gitee.com/openharmony/security_permission) + +[security_device_security_level](https://gitee.com/openharmony/security_device_security_level) + +[security_appverify](https://gitee.com/openharmony/security_appverify) + +[security_itrustee_ree_lite](https://gitee.com/openharmony/security_itrustee_ree_lite) diff --git a/en/readme/account.md b/en/readme/account.md index d21a37c9b0832acb87e235d646f061b4b64b6b6d..604106428bc13c2fc74f6383ec47f659bc34b550 100755 --- a/en/readme/account.md +++ b/en/readme/account.md @@ -35,5 +35,5 @@ To query and update the login status of a distributed account, you must obtain t **Account subsystem** -[account\_os\_account](https://gitee.com/openharmony/account_os_account) +[account_os_account](https://gitee.com/openharmony/account_os_account) diff --git a/en/readme/development-toolchain.md b/en/readme/development-toolchain.md index 0c1f77fe7a76a29573e72405612fd8a57f15c381..ecff66ed87e2f4630342fc4ea8f9186b2025bed7 100644 --- a/en/readme/development-toolchain.md +++ b/en/readme/development-toolchain.md @@ -318,9 +318,12 @@ Examples: ### profiler -The profiler module consists of the system and application profiler frameworks. It provides a performance profiler platform for you to analyze system issues such as memory and performance. +The profiler module consists of the system and application profiler frameworks. It provides a performance profiler platform for you to analyze system issues related to the memory and performance. -This module provides capabilities respectively for the PC and for the device. The capabilities for the PC are released as a DevEco Studio plug-in, which contains the following sub-modules: UI drawing, device management, process management, plug-in management, data import, data storage, data analysis, session management, and configuration management. The capabilities for the device mainly contain the following sub-modules: the command line tool, service processes, plug-ins, and application components. The device-side profiler provides APIs for extending plug-ins. With these APIs, you can define your desired capabilities and integrate them into the framework. Currently, the real-time memory analysis and trace plug-ins are available. For details, see the profiler readme. +The profiler module provides the following capabilities: + +- Capabilities for the PC: The capabilities are released as a DevEco Studio plug-in, which contains UI drawing, device management, process management, plug-in management, data import, data storage, data analysis, session management, and configuration management. +- Capabilities for the device: The capabilities include the command line tool, service processes, plug-ins, and application components. The device-side profiler provides APIs for extending plug-ins. With these APIs, you can define capabilities and integrate them into the framework. Currently, the real-time memory analysis and trace plug-ins are available. For details, see the profiler readme. ## Repositories Involved diff --git a/en/readme/kernel.md b/en/readme/kernel.md index e973952865dfe4adb63911ed16f6d9cfb506a5cb..03395200e5d1873463fb231e8f65b2a0bf5c0f7c 100644 --- a/en/readme/kernel.md +++ b/en/readme/kernel.md @@ -182,13 +182,13 @@ For details, see "Usage" in LiteOS-A Kernel [README](https://gitee.com/openharmo ## Build -The following uses the Hi3516D V300 development board and Ubuntu x86 server as an example. +The following uses the hispark_taurus development board and Ubuntu x86 server as an example. Perform a full build for the project to generate the **uImage** kernel image. ``` -./build.sh --product-name Hi3516DV300 # Build the Hi3516D V300 image. - --build-target build_kernel # Build the uImage kernel image of Hi3516D V300. +./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. + --build-target build_kernel # Build the uImage kernel image of hispark_taurus_standard. --gn-args linux_kernel_version=\"linux-5.10\" # Build the specified kernel version. ``` diff --git a/en/readme/test.md b/en/readme/test.md index 1fa9301d233778b5c06181b2d7ee8b55c1b1706b..51f90fe867ccf7ebe94b5db32a7b718d01c4046d 100644 --- a/en/readme/test.md +++ b/en/readme/test.md @@ -663,11 +663,11 @@ Before executing test cases, you need to modify the configuration based on the d Test cases cannot be built on Windows. You need to run the following command to build test cases on Linux: ``` -./build.sh --product-name Hi3516DV300 --build-target make_test +./build.sh --product-name hispark_taurus_standard --build-target make_test ``` -When the build is complete, the test cases are automatically saved in **out/hi3516dv300/packages/phone/images/tests**. +When the build is complete, the test cases are automatically saved in **out/hispark_taurus/packages/phone/images/tests**. ->**NOTE:** In the command, **Hi3516DV300** is the platform supported by the current version, and **make_test** indicates all test cases. You can set the build options based on requirements: +>**NOTE:** In the command, **hispark_taurus_standard** is the product supported by the current version, and **make_test** indicates all test cases. You can set the build options based on requirements: > - --**product-name**: specifies the name of the product to build. It is mandatory. > - --**build-target**: specifies the target to build. It is optional. diff --git a/en/readme/utils.md b/en/readme/utils.md index e18254fd55165476ce96fc64ce98fce57314c6a5..a24dc67246c8aebd6a47144a23d502b59d7ae50c 100644 --- a/en/readme/utils.md +++ b/en/readme/utils.md @@ -30,7 +30,7 @@ The **utils** repository provides common enhanced APIs for development in C and **utils subsystem** -utils +[utils](https://gitee.com/openharmony/utils) [utils\_native](https://gitee.com/openharmony/utils_native) diff --git a/en/readme/xts.md b/en/readme/xts.md index e318e1ada4baf10230d0264d4729d1e0bba0ee56..c4558c9d947dda419b382382fa49421217f46fbe 100644 --- a/en/readme/xts.md +++ b/en/readme/xts.md @@ -632,3 +632,9 @@ Use the standard syntax of Jasmine to write test cases. The ES6 specification is For details about how to build a HAP, see the JS application development guide of the standard system [Building and Creating HAPs](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_overview-0000001055075201). + +## Repositories Involved + +[xts\_acts](https://gitee.com/openharmony/xts_acts) + +[xts\_tools](https://gitee.com/openharmony/xts_tools) \ No newline at end of file diff --git a/zh-cn/application-dev/IDL/idl-guidelines.md b/zh-cn/application-dev/IDL/idl-guidelines.md index 486f7c22c1b6d85e512d1370f033bfc2c8dbb737..e7f5d21751bdb391a2ab8f7c6c37b26872245a57 100644 --- a/zh-cn/application-dev/IDL/idl-guidelines.md +++ b/zh-cn/application-dev/IDL/idl-guidelines.md @@ -180,45 +180,29 @@ private: #endif // OHOS_IDLTESTSERVICESTUB_H ``` -开发者需要继承.idl文件中定义的接口类并实现其中的方法,同时在服务侧初始化时需要将定义的服务注册至SAMGR中,在本示例中,我们继承了IdlTestServiceStub接口类并实现了其中的TestIntTransaction和TestStringTransaction方法。具体的示例代码如下: +开发者需要继承.idl文件中定义的接口类并实现其中的方法,同时在服务侧初始化时需要将定义的服务注册至SAMGR中,在本示例中,TestService类继承了IdlTestServiceStub接口类并实现了其中的TestIntTransaction和TestStringTransaction方法。具体的示例代码如下: ``` +#ifndef OHOS_IPC_TEST_SERVICE_H +#define OHOS_IPC_TEST_SERVICE_H + +#include "hilog/log.h" +#include "log_tags.h" #include "idl_test_service_stub.h" namespace OHOS { -int IdlTest ::OnRemoteRequest( - /* [in] */ uint32_t code, - /* [in] */ MessageParcel& data, - /* [out] */ MessageParcel& reply, - /* [in] */ MessageOption& option) -{ - if (data.ReadInterfaceToken() != GetDescriptor()) { - return ERR_TRANSACTION_FAILED; - } - switch (code) { - case COMMAND_TEST_INT_TRANSACTION: { - int _data = data.ReadInt32(); - int result; - ErrCode ec = TestIntTransaction(_data, result); - reply.WriteInt32(ec); - if (SUCCEEDED(ec)) { - reply.WriteInt32(result); - } - return ERR_NONE; - } - case COMMAND_TEST_STRING_TRANSACTION: { - std::string _data = Str16ToStr8(data.ReadString16()); - ErrCode ec = TestStringTransaction(_data); - reply.WriteInt32(ec); - return ERR_NONE; - } - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - - return ERR_TRANSACTION_FAILED; -} -} +class TestService : public IdlTestServiceStub { +public: + TestService(); + ~TestService(); + static int Instantiate(); + ErrCode TestIntTransaction(int data, int &rep) override; + ErrCode TestStringTransaction(const std::string& data) override; +private: + static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "TestService" }; +}; +} // namespace OHOS +#endif // OHOS_IPC_TEST_SERVICE_H ``` 注册服务的示例代码如下: @@ -275,73 +259,6 @@ ErrCode TestService::TestStringTransaction(const std::string &data) } // namespace OHOS ``` -在服务实现接口后,需要向客户端公开该接口,以便客户端进程绑定。服务端向客户端提供的Proxy接口的代码示例如下: - -``` -#include "idl_test_service_proxy.h" - -namespace OHOS { -ErrCode IdlTestServiceProxy::TestIntTransaction( - /* [in] */ int _data, - /* [out] */ int& result) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - if (!data.WriteInterfaceToken(GetDescriptor())) { - return ERR_INVALID_VALUE; - } - - data.WriteInt32(_data); - - if (Remote() == nullptr) { - return ERR_INVALID_VALUE; - } - int32_t st = Remote()->SendRequest(COMMAND_TEST_INT_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - result = reply.ReadInt32(); - return ERR_OK; -} - -ErrCode IdlTestServiceProxy::TestStringTransaction( - /* [in] */ const std::string& _data) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - if (!data.WriteInterfaceToken(GetDescriptor())) { - return ERR_INVALID_VALUE; - } - - data.WriteString16(Str8ToStr16(_data)); - - if (Remote() == nullptr) { - return ERR_INVALID_VALUE; - } - int32_t st = Remote()->SendRequest(COMMAND_TEST_STRING_TRANSACTION, data, reply, option); - if (st != ERR_NONE) { - return st; - } - - ErrCode ec = reply.ReadInt32(); - if (FAILED(ec)) { - return ec; - } - - return ERR_OK; -} -} -``` #### 3.1.3 客户端调用IPC方法 @@ -523,7 +440,7 @@ export default { #### 3.2.3 客户端调用IPC方法 -客户端调用connectAbility()以连接服务时,客户端的onAbilityConnectDone中的onConnect回调会接收服务的onConnect()方法返回的IRemoteObject实例。由于客户端和服务在不同应用内,所以客户端应用的目录内必须包含.idl文件(SDK工具会自动生成Proxy代理类)的副本。当客户端onAbilityConnectDone()回调中收到IRemoteObject,使用IRemoteObject创建IdlTestServiceProxy类的实例对象testProxy,然后调用相关IPC方法。示例代码如下: +客户端调用connectAbility()以连接服务时,客户端的onAbilityConnectDone中的onConnect回调会接收服务的onConnect()方法返回的IRemoteObject实例。由于客户端和服务在不同应用内,所以客户端应用的目录内必须包含.idl文件(SDK工具会自动生成Proxy代理类)的副本。客户端的onAbilityConnectDone中的onConnect回调会接收服务的onConnect()方法返回的IRemoteObject实例,使用IRemoteObject创建IdlTestServiceProxy类的实例对象testProxy,然后调用相关IPC方法。示例代码如下: ``` import IdlTestServiceProxy from './idl_test_service_proxy' diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index c3c89aee8ed0c0e6dcc1ef14e7e131a7358e735d..bd2836b7c66e6a8c14c64fbec2e396abc218d714 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -35,6 +35,10 @@ Ability框架在API 8及更早版本使用FA模型。FA模型中Ability分为Pag ![fa-threading-nodel](figures/fa-threading-model.png) ## 相关实例 针对Ability开发,有以下相关实例可供参考: + +- [`DistributeCalc`:分布式计算器(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Preset/DistributeCalc) +- [`DistributeGraffti`:分布式涂鸦(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DistributedGraffiti) + - [分布式调度启动远程FA](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA) - [分布式新闻客户端](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo) - [分布式手写板(eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index bfd1e16e42ceb6fa5656a2936d6210e44871ec42..ea5b23a0b4a21a3c18d0e8314bcccd3e518348f4 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -235,4 +235,4 @@ export default { ## 相关实例 针对PageAbility开发,有以下相关实例可供参考: -- [`DMS`:分布式Demo(eTS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) \ No newline at end of file +- [`DMS`:分布式Demo(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index 4afa94f47ee503f544cdfd59e543a1473a519fe5..188a87b7f68eead3458b0a579f932b173af57d43 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -399,4 +399,4 @@ export default { 针对ServiceAbility开发,有以下相关实例可供参考: - [`ServiceAbility`:ServiceAbility的创建与使用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility) -- [`DMS`:分布式Demo(eTS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) +- [`DMS`:分布式Demo(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS) diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index 34606cb00d828d324295e21b31db50b8321136e8..1237da3144c7ca5ffc05922ee4e2a80cc8399014 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -89,29 +89,29 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte 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") } @@ -323,4 +323,4 @@ struct Index { ## 相关实例 针对Stage模型Ability开发,有以下相关示例可供参考: -- [`StageCallAbility`:StageAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md index 9b6018d42e17c9eb056b6d75d7d1e2aedc4d6bc3..d2b046f04617f0f0ea41e90bb298d9fbf7fc2891 100644 --- a/zh-cn/application-dev/ability/stage-call.md +++ b/zh-cn/application-dev/ability/stage-call.md @@ -248,4 +248,4 @@ try { ## 相关实例 针对Stage模型本地Call功能开发,有以下相关实例可供参考: -- [`StageCallAbility`:StageAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`:StageCallAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) diff --git a/zh-cn/application-dev/ability/stage-serviceextension.md b/zh-cn/application-dev/ability/stage-serviceextension.md index 4f8373993c89df651d6503354e7c01659198600a..dc08f94c1427592f465fb6f35ae9da9b1fe82784 100644 --- a/zh-cn/application-dev/ability/stage-serviceextension.md +++ b/zh-cn/application-dev/ability/stage-serviceextension.md @@ -79,4 +79,4 @@ ExtensionAbility,是Stage模型中新增的扩展组件的基类,一般用 ## 相关实例 针对ServiceExtensionAbility开发,有以下相关实例可供参考: -- [`ServiceExtAbility`:StageAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) +- [`ServiceExtAbility`:StageExtAbility的创建与使用(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) diff --git a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md index f4e30ddf8a03d0e6c9499a7c86e175cca53a3193..96b18a9a5ac001e5d9cfa82ab7d43b0b849ec9e5 100644 --- a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md +++ b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md @@ -283,4 +283,10 @@ export default { console.info('ServiceAbility onCommand'); } }; -``` \ No newline at end of file +``` + +## 相关实例 + +基于后台任务管理,有以下相关实例可供参考: + +- [`BackgroundTaskManager`:后台任务管理(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/BackgroundTaskManager) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/http-request.md b/zh-cn/application-dev/connectivity/http-request.md index 530dd1e2a0d3611096e873f7e718f1e2381ec91e..90b3bb9829236ee4d07acccc23fff6f714034092 100644 --- a/zh-cn/application-dev/connectivity/http-request.md +++ b/zh-cn/application-dev/connectivity/http-request.md @@ -71,3 +71,7 @@ httpRequest.request( } ); ``` + +## 相关实例 +针对HTTP数据请求,有以下相关实例可供参考: +- [`Http`:数据请求(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/socket-connection.md b/zh-cn/application-dev/connectivity/socket-connection.md index f89d163b3447dd070f1aaf9e4f5f6e2278da303a..2ca2bfbb82b53654fae9628025780d680ccdf4f4 100644 --- a/zh-cn/application-dev/connectivity/socket-connection.md +++ b/zh-cn/application-dev/connectivity/socket-connection.md @@ -122,3 +122,7 @@ UDP与TCP流程大体类似,下面以TCP为例: tcp.off('close'); }, 30 * 1000); ``` + +## 相关实例 +针对Socket连接开发,有以下相关实例可供参考: +- [`Socket`:Socket 连接(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket) diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index b2a44308880c2ab1d008b17b79f887f1d957d05a..0439bc71966f69a49f609a5b91a6c7a139fabc6e 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -309,4 +309,5 @@ ## 相关实例 针对关系型数据库开发,有以下相关实例可供参考: - [`Rdb`:关系型数据库(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) +- [`DistributedRdb`:分布式关系型数据库(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) - [关系型数据库](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) diff --git a/zh-cn/application-dev/dfx/hiappevent-guidelines.md b/zh-cn/application-dev/dfx/hiappevent-guidelines.md index 47e2f09b8c55fc72781f18c63bb68d65d7b07f5e..cd5a98b3f5c220ac36cf0a0fa00eea59e3df4b2b 100644 --- a/zh-cn/application-dev/dfx/hiappevent-guidelines.md +++ b/zh-cn/application-dev/dfx/hiappevent-guidelines.md @@ -77,4 +77,4 @@ 针对应用事件开发,有以下相关实例可供参考: -- [`JsDotTest`:测试打点(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) \ No newline at end of file +- [`JsDotTest`:测试打点(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest) \ No newline at end of file diff --git a/zh-cn/application-dev/internationalization/intl-guidelines.md b/zh-cn/application-dev/internationalization/intl-guidelines.md index f1c2181cb01ae0f233004b58a040ee6f735fc805..386b828755bf39045e9c81ad2cd26b8c116e5505 100644 --- a/zh-cn/application-dev/internationalization/intl-guidelines.md +++ b/zh-cn/application-dev/internationalization/intl-guidelines.md @@ -306,4 +306,4 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方 针对Intl开发,有以下相关实例可供参考: --[`International`:国际化(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) \ No newline at end of file +-[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) \ No newline at end of file diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index 7d547e15b370ea5b2532551699bec584a7ccdca2..9c39d85302086efca820bb40678674cbfe77f8ae 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -7,8 +7,9 @@ - [音频渲染开发指导](audio-renderer.md) - [音频采集开发指导](audio-capturer.md) - [OpenSL ES播放开发指导](opensles-playback.md) -- 视频 + - [OpenSL ES录音开发指导](opensles-capture.md) +- 视频 - [视频播放开发指导](video-playback.md) - [视频录制开发指导](video-recorder.md) diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 0bb72e8f6dade18281ab4d1a400efa728eafd2d2..ba5cb3045a57ccaa769ae7d0e60f0ab0607d21ad 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -257,6 +257,6 @@ export class AudioDemo { 针对音频播放开发,有以下相关实例可供参考: - [`JsDistributedMusicPlayer`:分布式音乐播放(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) -- [`JsAudioPlayer`:音频播放和管理(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) +- [`JsAudioPlayer`:音频播放和管理(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) - [`eTsAudioPlayer`: 音频播放器(eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [音频播放器](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 6ce349669def897a154a0b582662d066f543608e..91cb1835192acfebfcaa207d73e471c3c0895c8b 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -191,5 +191,6 @@ export class AudioRecorderDemo { 针对音频录制开发,有以下相关实例可供参考: - [`Recorder`:录音机(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) +- [`JsRecorder`:录音机(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder) - [`eTsAudioPlayer`: 音频播放器(eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) - [音频播放器](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/zh-cn/application-dev/media/opensles-capture.md b/zh-cn/application-dev/media/opensles-capture.md new file mode 100644 index 0000000000000000000000000000000000000000..74341e62eabd9cf461994ba370eb178c7d18b36b --- /dev/null +++ b/zh-cn/application-dev/media/opensles-capture.md @@ -0,0 +1,162 @@ +# OpenSL ES音频录制开发指导 + +## 场景介绍 + +开发者可以通过本文了解到在**OpenHarmony**如何使用**OpenSL ES**进行录音相关操作;当前仅实现了部分[**OpenSL ES**接口] +(https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h),未实现接口调用后会返回**SL_RESULT_FEATURE_UNSUPPORTED** + + + +## 开发步骤 + +以下步骤描述了在**OpenHarmony**如何使用 **OpenSL ES** 开发音频录音功能: + +1. 添加头文件 + + ```c++ + #include + #include + #include + ``` + +2. 使用 **slCreateEngine** 接口创建引擎对象和实例化引擎对象 **engine**。 + + ```c++ + SLObjectItf engineObject = nullptr; + slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); + (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); + ``` + + + +3. 获取接口 **SL_IID_ENGINE** 的引擎接口 **engineEngine** 实例 + + ```c++ + SLEngineItf engineItf = nullptr; + result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineItf); + ``` + + + +4. 配置录音器信息(配置输入源audiosource、输出源audiosink),创建录音对象**pcmCapturerObject** 。 + + ```c++ + SLDataLocator_IODevice io_device = { + SL_DATALOCATOR_IODEVICE, + SL_IODEVICE_AUDIOINPUT, + SL_DEFAULTDEVICEID_AUDIOINPUT, + NULL + }; + + SLDataSource audioSource = { + &io_device, + NULL + }; + + SLDataLocator_BufferQueue buffer_queue = { + SL_DATALOCATOR_BUFFERQUEUE, + 3 + }; + + //具体参数需要根据音频文件格式进行适配 + SLDataFormat_PCM format_pcm = { + SL_DATAFORMAT_PCM, + OHOS::AudioStandard::AudioChannel::MONO, + OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100, + OHOS::AudioStandard::AudioSampleFormat::SAMPLE_S16LE, + 0, + 0, + 0 + }; + + SLDataSink audioSink = { + &buffer_queue, + &format_pcm + }; + + SLObjectItf pcmCapturerObject = nullptr; + result = (*engineItf)->CreateAudioRecorder(engineItf, &pcmCapturerObject, + &audioSource, &audioSink, 0, nullptr, nullptr); + (*pcmCapturerObject)->Realize(pcmCapturerObject, SL_BOOLEAN_FALSE); + ``` + +5. 获取录音接口**SL_IID_RECORD** 的 **recordItf** 接口实例 + + ``` + SLRecordItf recordItf; + (*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_RECORD, &recordItf); + ``` + +6. 获取接口 **SL_IID_OH_BUFFERQUEUE** 的 **bufferQueueItf** 实例 + + ``` + SLOHBufferQueueItf bufferQueueItf; + (*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); + ``` + + + +7. 注册 **BuqqerQueueCallback** 回调 + + ```c++ + static void BufferQueueCallback(SLOHBufferQueueItf bufferQueueItf, void *pContext, SLuint32 size) + { + AUDIO_INFO_LOG("BufferQueueCallback"); + FILE *wavFile = (FILE *)pContext; + if (wavFile != nullptr) { + SLuint8 *buffer = nullptr; + SLuint32 pSize = 0; + (*bufferQueueItf)->GetBuffer(bufferQueueItf, &buffer, pSize); + if (buffer != nullptr) { + fwrite(buffer, 1, pSize, wavFile); + (*bufferQueueItf)->Enqueue(bufferQueueItf, buffer, size); + } + } + + return; + } + + //wavFile_ 需要设置为用户想要录音的文件描述符 + (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_); + ``` + + +8. 开始录音 + + ```c++ + static void CaptureStart(SLRecordItf recordItf, SLOHBufferQueueItf bufferQueueItf, FILE *wavFile) + { + AUDIO_INFO_LOG("CaptureStart"); + (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING); + if (wavFile != nullptr) { + SLuint8* buffer = nullptr; + SLuint32 pSize = 0; + (*bufferQueueItf)->GetBuffer(bufferQueueItf, &buffer, pSize); + if (buffer != nullptr) { + AUDIO_INFO_LOG("CaptureStart, enqueue buffer length: %{public}lu.", pSize); + fwrite(buffer, 1, pSize, wavFile); + (*bufferQueueItf)->Enqueue(bufferQueueItf, buffer, pSize); + } else { + AUDIO_INFO_LOG("CaptureStart, buffer is null or pSize: %{public}lu.", pSize); + } + } + + return; + } + ``` + + +9. 结束录音 + + ```c++ + static void CaptureStop(SLRecordItf recordItf) + { + AUDIO_INFO_LOG("Enter CaptureStop"); + fflush(wavFile_); + (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED); + (*pcmCapturerObject)->Destroy(pcmCapturerObject); + fclose(wavFile_); + wavFile_ = nullptr; + return; + } + ``` diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 198b33914a07297f1278285ea5da1b9c5d53b26c..c63d903bc3b40a157ba14eb9b5812d321e109b7f 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -462,3 +462,7 @@ export class VideoPlayerDemo { } } ``` + +## 相关实例 +针对视频播放开发,有以下相关实例可供参考: +- [`VideoPlayer`:视频播放(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) \ No newline at end of file diff --git a/zh-cn/application-dev/notification/common-event.md b/zh-cn/application-dev/notification/common-event.md index 0ac837926169bcbf0ab70dcd4f371ff969b0c276..fe6d9ebc7ab99a17aeff7eba0ad64532c30bab75 100644 --- a/zh-cn/application-dev/notification/common-event.md +++ b/zh-cn/application-dev/notification/common-event.md @@ -174,6 +174,6 @@ if (this.subscriber != null) { 针对公共事件开发,有以下相关实例可供参考: -- [`CommonEvent`:订阅公共事件(eTS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) +- [`CommonEvent`:订阅公共事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) diff --git a/zh-cn/application-dev/notification/notification.md b/zh-cn/application-dev/notification/notification.md index b5a183a467cea9a5404036b747508330e5aa4c29..98e57bbccdd16f372fff09c637e4eb5ac3b3de86 100644 --- a/zh-cn/application-dev/notification/notification.md +++ b/zh-cn/application-dev/notification/notification.md @@ -262,6 +262,6 @@ Notification.cancel(1, "label", cancelCallback) 针对通知开发,有以下相关可供参考: -- [`Notification`:通知-订阅、发送通知(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Notification/Notification) +- [`Notification`:订阅、发送通知(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Notification/Notification) -- [`Notification`:通知(eTS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) +- [`Notification`:通知(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) diff --git a/zh-cn/application-dev/quick-start/app-provision-structure.md b/zh-cn/application-dev/quick-start/app-provision-structure.md index 5e0b3d376945be6e2d28fdb64a857075a08baaa2..943036966c9671314b63f138fa22892684ddc1eb 100644 --- a/zh-cn/application-dev/quick-start/app-provision-structure.md +++ b/zh-cn/application-dev/quick-start/app-provision-structure.md @@ -5,21 +5,21 @@ HarmonyAppProvision文件包含基本信息、validity对象、bundle-info对象、acls对象、permissions对象、debug-info对象等部分组成。 表1 配置文件内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ----------- | ---------------------------------------------------------------------------------------- | -------- | -------- | -| 基本信息 | 表示HarmonyAppProvision文件的基本信息。参考[基本信息内部结构](#基本信息内部结构)。 | 对象 | 不可缺省 | -| validity | 表示HarmonyAppProvision文件有效期的信息。参考[validity对象内部结构](#validity对象内部结构)。 | 对象 | 不可缺省 | -| bundle-info | 表示应用包以及开发者的信息。参考[bundle-info对象内部结构](#bundle-info对象内部结构)。 | 对象 | 不可缺省 | -| acls | 表示授权的应用权限信息。参考[acls对象内部结构](#acls对象内部结构)。 | 对象 | 可缺省 | -| permissions | 表示允许使用的受限敏感权限信息。参考[permissions对象内部结构](#permissions对象内部结构)。 | 对象 | 可缺省 | -| debug-info | 表示应用调试场景下的额外信息。参考[debug-info对象内部结构](#debug-info对象内部结构)。 | 对象 | 可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ----------- | ---------------------------------------------------------------------------------------- | -------- | -------- | -------- | +| 基本信息 | 表示HarmonyAppProvision文件的基本信息。参考[基本信息内部结构](#基本信息内部结构)。 | 对象 | 必选 | 不可缺省 | +| validity | 表示HarmonyAppProvision文件有效期的信息。参考[validity对象内部结构](#validity对象内部结构)。 | 对象 | 必选 | 不可缺省 | +| bundle-info | 表示应用包以及开发者的信息。参考[bundle-info对象内部结构](#bundle-info对象内部结构)。 | 对象 | 必选 | 不可缺省 | +| acls | 表示授权的应用权限信息。参考[acls对象内部结构](#acls对象内部结构)。 | 对象 | 可选 | 不可缺省 | +| permissions | 表示允许使用的受限敏感权限信息。参考[permissions对象内部结构](#permissions对象内部结构)。 | 对象 | 可选 | 不可缺省 | +| debug-info | 表示应用调试场景下的额外信息。参考[debug-info对象内部结构](#debug-info对象内部结构)。 | 对象 | 可选 | 不可缺省 | HarmonyAppProvision文件示例: ```json { "version-code": 1, "version-name": "1.0.0", - "uuid": "fe686e1b-3770-4824-a938-961b140a7c98", + "uuid": "string", "type": "debug", "validity": { "not-before": 1586422743, @@ -27,7 +27,7 @@ HarmonyAppProvision文件示例: }, "bundle-info" : { "developer-id": "OpenHarmony", - "development-certificate": "-----BEGIN CERTIFICATE-----\nMIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMGMxCzAJBgNVBAYTAkNO\nMRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh\nbTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjEwMjAy\nMTIxOTMxWhcNNDkxMjMxMTIxOTMxWjBoMQswCQYDVQQGEwJDTjEUMBIGA1UEChML\nT3Blbkhhcm1vbnkxGTAXBgNVBAsTEE9wZW5IYXJtb255IFRlYW0xKDAmBgNVBAMT\nH09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJlbGVhc2UwWTATBgcqhkjOPQIBBggq\nhkjOPQMBBwNCAATbYOCQQpW5fdkYHN45v0X3AHax12jPBdEDosFRIZ1eXmxOYzSG\nJwMfsHhUU90E8lI0TXYZnNmgM1sovubeQqATo1IwUDAfBgNVHSMEGDAWgBTbhrci\nFtULoUu33SV7ufEFfaItRzAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFPtxruhl\ncRBQsJdwcZqLu9oNUVgaMAwGCCqGSM49BAMDBQADaAAwZQIxAJta0PQ2p4DIu/ps\nLMdLCDgQ5UH1l0B4PGhBlMgdi2zf8nk9spazEQI/0XNwpft8QAIwHSuA2WelVi/o\nzAlF08DnbJrOOtOnQq5wHOPlDYB4OtUzOYJk9scotrEnJxJzGsh/\n-----END CERTIFICATE-----\n", + "development-certificate": "Base64 string", "distribution-certificate": "Base64 string", "bundle-name": "com.OpenHarmony.app.test", "apl": "normal", @@ -41,7 +41,7 @@ HarmonyAppProvision文件示例: }, "debug-info" : { "device-id-type": "udid", - "device-ids": ["69C7505BE341BDA5948C3C0CB44ABCD530296054159EFE0BD16A16CD0129CC42"] + "device-ids": ["string"] }, "issuer": "OpenHarmony" } @@ -49,54 +49,54 @@ HarmonyAppProvision文件示例: ``` ### 基本信息内部结构 表2 基本信息的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------------------------------------ | -------- | ------------------ | -| version-code | 表示HarmonyAppProvision文件格式的版本号,取值范围为二进制32位以内的正整数 | 数值 | 不可缺省 | -| version-name | 表示版本号的文字描述,推荐使用三段数字版本号,如A.B.C | 字符串 | 不可缺省 | -| uuid | 表示文件的唯一ID号,用于OEM厂商标识HarmonyAppProvision文件,开源社区版本该属性不做强制要求 | 字符串 | 不可缺省 | -| type | 表示HarmonyAppProvision文件的类型, 系统预定义的文件类型包括: debug(用于应用调试场景)和release(用于应用发布场景) ,开源社区版本该属性值建议为debug | 字符串 | 不可缺省 | -| issuer | 表示HarmonyAppProvision签发者 | 字符串 | 可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ---------- | ------------------------------------------------------------ | -------- | -------- | ------------------ | +| version-code | 表示HarmonyAppProvision文件格式的版本号,取值范围为二进制32位以内的正整数 | 数值 | 必选 | 不可缺省 | +| version-name | 表示版本号的文字描述,推荐使用三段数字版本号,如A.B.C | 字符串 | 必选 | 不可缺省 | +| uuid | 表示文件的唯一ID号,用于OEM厂商标识HarmonyAppProvision文件,开源社区版本该属性不做强制要求 | 字符串 | 必选 | 不可缺省 | +| type | 表示HarmonyAppProvision文件的类型, 系统预定义的文件类型包括: debug(用于应用调试场景)和release(用于应用发布场景) ,开源社区版本该属性值建议为debug | 字符串 | 必选 | 不可缺省 | +| issuer | 表示HarmonyAppProvision签发者 | 字符串 | 必选 | 不可缺省 | ### validity对象内部结构 表3 validity对象的内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------- | ------- | --------- | -| not-before | 表示文件有效期的开始时间,非负整数 | 数值 | 不可缺省 | -| not-after | 表示文件有效期的结束时间,非负整数 | 数值 | 不可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ---------- | ------------------------------- | ------- | ------- | --------- | +| not-before | 表示文件有效期的开始时间,非负整数 | 数值 | 必选 | 不可缺省 | +| not-after | 表示文件有效期的结束时间,非负整数 | 数值 | 必选 | 不可缺省 | ### bundle-info对象内部结构 表4 bundle-info对象的内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------------ | ------------------------------- | ------- | --------- | -| developer-id | 表示开发者的唯一ID号,用于OEM厂商标识开发者,开源社区版本该属性不做强制要求 | 字符串 | 不可缺省 | -| development-certificate | 表示[调试证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为debug时,该属性不可缺省;否则,该属性可缺省 | -| distribution-certificate | 表示[发布证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为release时,该标签不可缺省;否则,该标签可缺省 | -| bundle-name | 表示应用程序的包名 | 字符串 | 不可缺省 | -| apl | 表示应用程序的[apl级别](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core | 字符串 | 不可缺省 | -| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用) | 字符串 | 不可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ------------------------ | ------------------------------- | ------- | -------- | --------- | +| developer-id | 表示开发者的唯一ID号,用于OEM厂商标识开发者,开源社区版本该属性不做强制要求 | 字符串 | 必选 | 不可缺省 | +| development-certificate | 表示[调试证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为debug时,该属性必选;否则,该属性可选 | 不可缺省 | +| distribution-certificate | 表示[发布证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为release时,该标签必选;否则,该标签可选 | 不可缺省 | +| bundle-name | 表示应用程序的包名 | 字符串 | 必选 | 不可缺省 | +| apl | 表示应用程序的[apl级别](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core | 字符串 | 必选 | 不可缺省 | +| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用) | 字符串 | 必选 | 不可缺省 | ### acls对象内部结构 acls对象包含已授权的acl权限,这类权限通常是指应用安装时即可授权的权限(system_grant权限)。需要指出的是,开发者仍然需要在应用包配置文件([config.json](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/quick-start/package-structure.md))将acls权限信息填写到reqPermissions属性中。 表5 acls对象的内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------------ | ------------------------------- | ------- | --------- | -| allowed-acls | 表示授权的[acl权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md)列表 | 字符串数组 | 可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ------------------------ | ------------------------------- | ------- | ------- | --------- | +| allowed-acls | 表示授权的[acl权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md)列表 | 字符串数组 | 可选 | 不可缺省 | ### permissions对象内部结构 permissions对象包含允许使用的受限敏感权限;不同于acls对象,permissions对象中的权限仅代表应用允许使用该敏感权限,权限最终由用户运行时授权。需要指出的是,开发者仍然需要在应用包配置文件([config.json](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/quick-start/package-structure.md))将permissions权限信息填写到reqPermissions属性中。 表6 permissions对象的内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------------ | ------------------------------- | ------- | --------- | -| restricted-permissions | 表示允许使用的[受限敏感权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md) | 字符串数组 | 可缺省 | +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ------------------------ | ------------------------------- | ------- | ------- | --------- | +| restricted-permissions | 表示允许使用的[受限敏感权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md) | 字符串数组 | 可选 | 不可缺省 | ### debug-info对象内部结构 debug-info对象包含应用调试场景下的信息,主要是设备管控的信息。 表7 debug-info对象的内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------------------ | ------------------------------- | ------- | --------- | -| device-id-type | 表示设备ID的类型,当前系统仅提供udid的设备ID类型 | 字符串 | 不可缺省 | -| device-ids | 表示应用调试场景下允许调试的设备ID列表 | 字符串数组 | 可缺省 | \ No newline at end of file +| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | +| ------------------------ | ------------------------------- | ------- | ------- | --------- | +| device-id-type | 表示设备ID的类型,当前系统仅提供udid的设备ID类型 | 字符串 | 可选 | 不可缺省 | +| device-ids | 表示应用调试场景下允许调试的设备ID列表 | 字符串数组 | 可选 | 不可缺省 | \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/module-structure.md b/zh-cn/application-dev/quick-start/module-structure.md index 921227f53f218669c201dd8db325d3557aa09bf6..dcbd07706a7be9f7ab072672ca5d24993b372152 100644 --- a/zh-cn/application-dev/quick-start/module-structure.md +++ b/zh-cn/application-dev/quick-start/module-structure.md @@ -173,14 +173,14 @@ module.json示例: | ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- | | bundleName | 该标签表示应用的包名,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则 :
1)字符串以字母、数字、下划线和符号”.”组成;
2)以字母开头;
3)最小长度7个字节,最大长度127个字节。
推荐采用反域名形式命名(如 :com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。
其中,随系统源码编译的应用需命名为”com.ohos.xxx”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 否 | | debug | 该标签标识应用是否可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 | -| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 | +| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 | | label | 该标签标识应用的的名称,标签值为资源文件的索引,以支持多语言。 | 字符串 | 该标签不可缺省。 | | description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | | vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 | -| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | | +| 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目标版本。 | 数值 | 该标签不可缺省。 | +| minCompatibleVersionCode | 该标签标识该app pack能够兼容的最低历史版本号。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 | +| minAPIVersion | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签不可缺省。 | | targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 | | apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
Canary :受限发布的版本。
Beta :公开发布的Beta版本。
Release :公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 | | distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 | @@ -213,13 +213,13 @@ hap包的配置信息,该标签下的配置只对当前hap包生效。 表4 deviceTypes对象的系统预定义设备 -| 中文 | 英文 | 枚举值 | 设备类型 | -| ------------ | ------------ | ------------ | -------------------------------------------------------- | -| 平板 | tablet | tablet | 平板,带屏音箱 | -| 智慧屏 | smart TV | tv | | -| 智能手表 | smart watch | wearable | 智能手表,儿童手表,特指资源较丰富的的手表,具备电话功能 | -| 车机 | head unit | car | | -| 路由器 | router | router | 路由器 | +| 中文 | 英文 | 枚举值 | 设备类型 | +| -------- | ----------- | -------- | -------------------------------------------------------- | +| 平板 | tablet | tablet | 平板,带屏音箱 | +| 智慧屏 | smart TV | tv | 智慧屏 | +| 智能手表 | smart watch | wearable | 智能手表,儿童手表,特指资源较丰富的的手表,具备电话功能 | +| 车机 | head unit | car | 车机 | +| 路由器 | router | router | 路由器 | deviceTypes示例 : @@ -447,7 +447,7 @@ skills示例 | description | 该标签标识extensionAbility的描述,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | | icon | 该标签标识extensionAbility图标,标签值为资源文件的索引。如果extensionAbility被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。 | | label | 该标签标识extensionAbility对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。
如果extensionAbility被配置为MainElement,该标签必须配置,且应用内唯一。 | 字符串 | 该标签不可缺省。 | -| type | 该标签标识extensionAbility的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper、backup其中之一。 | 字符串 | 该标签不可缺省。 | +| type | 该标签标识extensionAbility的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper、backup、window其中之一。 | 字符串 | 该标签不可缺省。 | | 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对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | 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 a65e74890ca39259be58b85f51fdaf07e0cbd2ac..112eacc069f748fce8c4e88bcc2cb2a1207a381e 100644 --- a/zh-cn/application-dev/quick-start/start-with-js.md +++ b/zh-cn/application-dev/quick-start/start-with-js.md @@ -215,4 +215,4 @@ 恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 ## 相关实例 针对使用JS语言(传统代码方式)开发快速入门,有以下相关实例可供参考: -- [`JsHelloWorld`:你好世界(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/JsHelloWorld) +- [`JsHelloWorld`:你好世界(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/JsHelloWorld) 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 index 4fa6b87cffc617ec1ed7562389fee67aa32bcced..a36f566438a05332e70bb4c0c921d5325819ea86 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -79,3 +79,58 @@ getApplicationContext(): Context; // 必选项。 let context = this.context.getApplicationContext(); ``` + + +## Context.switchArea + +switchArea(mode: AreaMode): void; + +切换需要访问的文件分区。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | mode | [AreaMode](#areamode) | 是 | 文件分区。 | + +**示例:** + + ```js + var areaMode = 0; + this.context.switchArea(areaMode); + ``` + + +## Context.getArea() + +getArea(): AreaMode; + +获取文件分级信息,可以查看当前是处于哪个分区。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | [AreaMode](#areamode) | 文件分区。 | + +**示例:** + + ```js + let mode = this.context.getArea(); + ``` + + +## AreaMode + +访问的文件分区,每个文件分区有对应自己的内容。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core + +| 变量 | 值 | 描述 | +| --------------- | ---- | --------------- | +| EL1 | 0 | 设备级加密区。 | +| EL2 | 1 | 用户凭据加密区。默认为EL2。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md index 48fc5c6ae62edb1b3506508233c20b6ae004c267..bd4c9f3b8282c1e912c29608225ad7e34e34a9b0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,6 @@ # DataAbility 谓词 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -19,9 +19,10 @@ createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): 从DataAabilityPredicates对象创建RdbPredicates对象。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 数据库表中的表名。 | @@ -53,7 +54,7 @@ equalTo(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且值等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -81,7 +82,7 @@ notEqualTo(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且值不等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -109,7 +110,7 @@ beginWrap(): DataAbilityPredicates 向谓词添加左括号。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **返回值:** | 类型 | 说明 | @@ -136,7 +137,7 @@ endWrap(): DataAbilityPredicates 向谓词添加右括号。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **返回值:** | 类型 | 说明 | @@ -163,7 +164,7 @@ or(): DataAbilityPredicates 将或条件添加到谓词中。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **返回值:** | 类型 | 说明 | @@ -187,7 +188,7 @@ and(): DataAbilityPredicates 将和条件添加到谓词中。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **返回值:** | 类型 | 说明 | @@ -211,7 +212,7 @@ contains(field: string, value: string): DataAbilityPredicates 配置谓词以匹配数据类型为string且value包含指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -239,7 +240,7 @@ beginsWith(field: string, value: string): DataAbilityPredicates 配置谓词以匹配数据类型为string且值以指定字符串开头的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -267,7 +268,7 @@ endsWith(field: string, value: string): DataAbilityPredicates 配置谓词以匹配数据类型为string且值以指定字符串结尾的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -295,7 +296,7 @@ isNull(field: string): DataAbilityPredicates 配置谓词以匹配值为null的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -322,7 +323,7 @@ isNotNull(field: string): DataAbilityPredicates 配置谓词以匹配值不为null的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -349,7 +350,7 @@ like(field: string, value: string): DataAbilityPredicates 配置谓词以匹配数据类型为string且值类似于指定字符串的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -377,7 +378,7 @@ glob(field: string, value: string): DataAbilityPredicates 配置谓词以匹配数据类型为string的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -405,7 +406,7 @@ between(field: string, low: ValueType, high: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且value在指定范围内的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -434,7 +435,7 @@ notBetween(field: string, low: ValueType, high: ValueType): DataAbilityPredicate 配置谓词以匹配数据类型为ValueType且value超出给定范围的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -463,7 +464,7 @@ greaterThan(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且值大于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -491,7 +492,7 @@ lessThan(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为valueType且value小于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -519,7 +520,7 @@ greaterThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且value大于或等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -547,7 +548,7 @@ lessThanOrEqualTo(field: string, value: ValueType): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType且value小于或等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -575,7 +576,7 @@ orderByAsc(field: string): DataAbilityPredicates 配置谓词以匹配其值按升序排序的列。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -602,7 +603,7 @@ orderByDesc(field: string): DataAbilityPredicates 配置谓词以匹配其值按降序排序的列。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -629,7 +630,7 @@ distinct(): DataAbilityPredicates 配置谓词以过滤重复记录并仅保留其中一个。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **返回值:** | 类型 | 说明 | @@ -657,7 +658,7 @@ limitAs(value: number): DataAbilityPredicates 设置最大数据记录数的谓词。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -684,7 +685,7 @@ offsetAs(rowOffset: number): DataAbilityPredicates 配置谓词以指定返回结果的起始位置。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -711,7 +712,7 @@ groupBy(fields: Array<string>): DataAbilityPredicates 配置谓词按指定列分组查询结果。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -763,7 +764,7 @@ in(field: string, value: Array<ValueType>): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType数组且值在给定范围内的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -792,7 +793,7 @@ notIn(field: string, value: Array<ValueType>): DataAbilityPredicates 配置谓词以匹配数据类型为ValueType数组且值不在给定范围内的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -816,7 +817,7 @@ notIn(field: string, value: Array<ValueType>): DataAbilityPredicates 用于表示允许的数据字段类型。 -**系统能力**:SystemCapability.DistributedDataManager.DataShare.Core。 +**系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 | 名称 | 说明 | | ------- | -------------------- | 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 2c3325a26d8bdd2b903086d616242e11467fd28d..f1979534ebd3b563660ce67508d0148af49c506b 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 @@ -1,6 +1,6 @@ # 分布式数据对象 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -10,8 +10,6 @@ import distributedObject from '@ohos.data.distributedDataObject'; ``` - - ## distributedDataObject.createDistributedObject createDistributedObject(source: object): DistributedObject @@ -19,7 +17,7 @@ createDistributedObject(source: object): DistributedObject 创建一个分布式对象。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -46,7 +44,7 @@ genSessionId(): string 随机创建一个sessionId。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **返回值:** | 类型 | 说明 | @@ -70,7 +68,7 @@ setSessionId(sessionId?: string): boolean 设置同步的sessionId,当可信组网中有多个设备时,多个设备间的对象如果设置为同一个sessionId,就能自动同步。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** @@ -103,7 +101,7 @@ on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<stri 监听分布式对象的变更。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -132,7 +130,7 @@ off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<st 当不再进行数据变更监听时,使用此接口删除对象的变更监听。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -163,7 +161,7 @@ on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, st 监听分布式对象的上下线。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -188,7 +186,7 @@ off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, s 当不再进行对象上下线监听时,使用此接口删除对象的上下线监听。 -**系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 +**系统能力:** SystemCapability.DistributedDataManager.DataObject.DistributedObject。 **参数:** | 参数名 | 类型 | 必填 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 3ae06819d6a9180b6c91762c7db99e6f3712f004..f480ac73afac72b698ea2fab3cf123198d772c7a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -3,7 +3,7 @@ 首选项为应用提供key-value键值型的数据处理能力,支持应用持久化轻量级数据,并对其修改和查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -15,7 +15,7 @@ import data_preferences from '@ohos.data.preferences'; ## 常量 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -30,43 +30,25 @@ getPreferences(context: Context, name: string, callback: AsyncCallback<Prefer 读取指定首选项持久化文件,将数据加载到Preferences实例,用于数据操作,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | | callback | AsyncCallback<[Preferences](#preferences)> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed") - return; - } - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed, err: " + err) - return - } - console.info("Flushed to file successfully.") - }) - }) - }) - } - ``` +```ts +data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Get preferences failed.") + return; + } + console.info("Get preferences successfully.") +}) +``` ## data_preferences.getPreferences @@ -75,12 +57,12 @@ getPreferences(context: Context, name: string): Promise<Preferences> 读取指定首选项持久化文件,将数据加载到Preferences实例,用于数据操作,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | **返回值:** @@ -89,32 +71,14 @@ getPreferences(context: Context, name: string): Promise<Preferences> | Promise<[Preferences](#preferences)> | Promise实例,用于异步获取结果。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed, err: " + err) - return - } - console.info("Flushed to file successfully.") - }) - }) - }).catch((err) => { - console.info("Get the preferences failed") - }) - } - ``` +```ts +let promise = data_preferences.getPreferences(this.context, 'mystore') +promise.then((preferences) => { + console.info("Get preferences successfully.") +}).catch((err) => { + console.info("Get preferences failed.") +}) +``` ## data_preferences.deletePreferences @@ -124,30 +88,25 @@ deletePreferences(context: Context, name: string, callback: AsyncCallback<voi 从内存中移除指定首选项持久化文件对应的Preferences单实例,并删除指定文件及其备份文件和损坏文件。 删除指定首选项持久化文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.deletePreferences(this.context, 'mystore', function (err) { - if (err) { - console.info("Deleted failed, err: " + err) - return - } - console.info("Deleted successfully.") - }) - } - ``` +```ts +data_preferences.deletePreferences(this.context, 'mystore', function (err) { + if (err) { + console.info("Deleted preferences failed, err: " + err) + return + } + console.info("Deleted preferences successfully.") +}) +``` ## data_preferences.deletePreferences @@ -157,12 +116,12 @@ deletePreferences(context: Context, name: string): Promise<void> 从内存中移除指定首选项持久化文件对应的Preferences单实例,并删除指定文件及其备份文件和损坏文件。 删除指定首选项持久化文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | **返回值:** @@ -171,19 +130,14 @@ deletePreferences(context: Context, name: string): Promise<void> | Promise<void> | Promise实例,用于异步获取结果。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.deletePreferences(this.context, 'mystore') - promise.then(() => { - console.info("Deleted successfully.") - }).catch((err) => { - console.info("Deleted failed, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.deletePreferences(this.context, 'mystore') +promise.then(() => { + console.info("Deleted preferences successfully.") +}).catch((err) => { + console.info("Deleted preferences failed, err: " + err) +}) +``` ## data_preferences.removePreferencesFromCache @@ -194,30 +148,25 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba 移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { - if (err) { - console.info("Removed preferences from cache failed, err: " + err) - return - } - console.info("Removed preferences from cache successfully.") - }) - } - ``` +```ts +data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { + if (err) { + console.info("Removed preferences from cache failed, err: " + err) + return + } + console.info("Removed preferences from cache successfully.") +}) +``` ## data_preferences.removePreferencesFromCache @@ -228,12 +177,12 @@ removePreferencesFromCache(context: Context, name: string): Promise<void> 移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用程序或功能的上下文。 | + | context | [Context](js-apis-ability-context.md) | 是 | 应用程序或功能的上下文。 | | name | string | 是 | 应用程序内部数据存储名称。 | **返回值:** @@ -242,19 +191,14 @@ removePreferencesFromCache(context: Context, name: string): Promise<void> | Promise<void> | Promise实例,用于异步获取结果。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') - promise.then(() => { - console.info("Removed preferences from cache successfully.") - }).catch((err) => { - console.info("Removed preferences from cache failed, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') +promise.then(() => { + console.info("Removed preferences from cache successfully.") +}).catch((err) => { + console.info("Removed preferences from cache failed, err: " + err) +}) +``` ## Preferences @@ -268,7 +212,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): 获取键对应的值,如果值为null或者非默认值类型,返回默认数据,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -278,26 +222,15 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): | callback | AsyncCallback<ValueType> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.get('startup', 'default', function(err, value) { - if (err) { - console.info("Get the value of startup failed, err: " + err) - return - } - console.info("The value of startup is " + value) - }) - }) - } - ``` +```ts + preferences.get('startup', 'default', function(err, value) { + if (err) { + console.info("Get value of startup failed, err: " + err) + return + } + console.info("Get value of startup is " + value) +}) +``` ### get @@ -306,7 +239,7 @@ get(key: string, defValue: ValueType): Promise<ValueType> 获取键对应的值,如果值为null或者非默认值类型,返回默认数据,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core - **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -320,24 +253,14 @@ get(key: string, defValue: ValueType): Promise<ValueType> | Promise<ValueType> | Promise实例,用于异步获取结果。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - 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, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.get('startup', 'default') +promise.then((value) => { + console.info("Get value of startup is " + value) +}).catch((err) => { + console.info("Get value of startup failed, err: " + err) +}) +``` ### put @@ -346,7 +269,7 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void 首先获取指定首选项持久化文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -356,26 +279,15 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed, err: " + err) - return - } - console.info("Put the value of startup successfully.") - }) - }) - } - ``` +```ts +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Put value of startup failed, err: " + err) + return + } + console.info("Put value of startup successfully.") +}) +``` ### put @@ -384,7 +296,7 @@ put(key: string, value: ValueType): Promise<void> 首先获取指定首选项持久化文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -398,24 +310,14 @@ put(key: string, value: ValueType): Promise<void> | Promise<void> | Promise实例,用于异步处理。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - 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, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.put('startup', 'auto') +promise.then(() => { + console.info("Put value of startup successfully.") +}).catch((err) => { + console.info("Put value of startup failed, err: " + err) +}) +``` ### has @@ -424,7 +326,7 @@ has(key: string, callback: AsyncCallback<boolean>): boolean 检查存储对象是否包含名为给定key的存储键值对,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -438,30 +340,19 @@ has(key: string, callback: AsyncCallback<boolean>): boolean | boolean | true表示存在,false表示不存在。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Check the key of startup failed, err: " + err) - return - } - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup dose not contain.") - } - }) - }) - } - ``` +```ts +preferences.has('startup', function (err, isExist) { + if (err) { + console.info("Check the key of startup failed, err: " + err) + return + } + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup dose not contain.") + } +}) +``` ### has @@ -470,7 +361,7 @@ has(key: string): Promise<boolean> 检查存储对象是否包含名为给定key的存储键值对,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -483,28 +374,18 @@ has(key: string): Promise<boolean> | Promise<boolean> | Promise实例,用于异步处理。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseHas = preferences.has('startup') - promiseHas.then((isExist) => { - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup dose not contain.") - } - }).catch((err) => { - console.info("Check the key of startup failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.has('startup') +promise.then((isExist) => { + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup dose not contain.") + } +}).catch((err) => { + console.info("Check the key of startup failed, err: " + err) +}) +``` ### delete @@ -513,7 +394,7 @@ delete(key: string, callback: AsyncCallback<void>): void 从存储对象中删除名为给定key的存储键值对,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -522,26 +403,15 @@ delete(key: string, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.delete('startup', function (err) { - if (err) { - console.info("Delete startup key failed, err: " + err) - return - } - console.info("Deleted startup key successfully.") - }) - }) - } - ``` +```ts +preferences.delete('startup', function (err) { + if (err) { + console.info("Delete startup key failed, err: " + err) + return + } + console.info("Deleted startup key successfully.") +}) +``` ### delete @@ -550,7 +420,7 @@ delete(key: string): Promise<void> 从存储对象删除名为给定key的存储键值对,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -563,24 +433,14 @@ delete(key: string): Promise<void> | Promise<void> | Promise实例,用于异步处理。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseDelete = preferences.delete('startup') - promiseDelete.then(() => { - console.info("Deleted startup key successfully.") - }).catch((err) => { - console.info("Delete startup key failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.delete('startup') +promise.then(() => { + console.info("Deleted startup key successfully.") +}).catch((err) => { + console.info("Delete startup key failed, err: " + err) +}) +``` ### flush @@ -589,7 +449,7 @@ flush(callback: AsyncCallback<void>): void 将当前preferences对象中的修改保存到当前的preferences,并异步存储到首选项持久化文件中,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -597,26 +457,15 @@ flush(callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed, err: " + err) - return - } - console.info("Flushed to file successfully.") - }) - }) - } - ``` +```ts +preferences.flush(function (err) { + if (err) { + console.info("Flush to file failed, err: " + err) + return + } + console.info("Flushed to file successfully.") +}) +``` ### flush @@ -625,7 +474,7 @@ flush(): Promise<void> 将当前preferences对象中的修改保存到当前的preferences,并异步存储到首选项持久化文件中,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **返回值:** | 类型 | 说明 | @@ -633,24 +482,14 @@ flush(): Promise<void> | Promise<void> | Promise实例,用于异步处理。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseFlush = preferences.flush() - promiseFlush.then(() => { - console.info("Flushed to file successfully.") - }).catch((err) => { - console.info("Flush to file failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.flush() +promise.then(() => { + console.info("Flushed to file successfully.") +}).catch((err) => { + console.info("Flush to file failed, err: " + err) +}) +``` ### clear @@ -659,7 +498,7 @@ clear(callback: AsyncCallback<void>): void 清除此存储对象中的所有存储,该方法使用callback方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -667,26 +506,15 @@ clear(callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.clear(function (err) { - if (err) { - console.info("Clear to file failed, err: " + err) - return - } - console.info("Cleared to file successfully.") - }) - }) - } - ``` +```ts +preferences.clear(function (err) { + if (err) { + console.info("Clear to file failed, err: " + err) + return + } + console.info("Cleared to file successfully.") +}) +``` ### clear @@ -695,7 +523,7 @@ clear(): Promise<void> 清除此存储对象中的所有存储,该方法使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **返回值:** | 类型 | 说明 | @@ -703,24 +531,14 @@ clear(): Promise<void> | Promise<void> | Promise实例,用于异步处理。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseClear = preferences.clear() - promiseClear.then(() => { - console.info("Cleared to file successfully.") - }).catch((err) => { - console.info("Clear to file failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` +```ts +let promise = preferences.clear() +promise.then(() => { + console.info("Cleared to file successfully.") +}).catch((err) => { + console.info("Clear to file failed, err: " + err) +}) +``` ### on('change') @@ -729,7 +547,7 @@ on(type: 'change', callback: Callback<{ key : string }>): void 订阅数据变更者类,订阅的key的值发生变更后,在执行flush方法后,callback方法会被回调。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 说明 | @@ -738,37 +556,30 @@ on(type: 'change', callback: Callback<{ key : string }>): void | callback | Callback<{ key : string }> | 回调对象实例。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed, err: " + err) - return - } - console.info("Flushed to file successfully.") // observer will be called. - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Put the value of startup failed, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Flush to file failed, err: " + err) + return + } + console.info("Flushed to file successfully.") // observer will be called. + }) +}) +``` ### off('change') @@ -777,7 +588,7 @@ off(type: 'change', callback: Callback<{ key : string }>): void 当不再进行订阅数据变更时,使用此接口取消订阅。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 说明 | @@ -786,43 +597,37 @@ off(type: 'change', callback: Callback<{ key : string }>): void | callback | Callback<{ key : string }> | 需要取消的回调对象实例。 | **示例:** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Get the preferences failed, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Put the value of startup failed, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Flush to file failed, err: " + err) - return - } - console.info("Flushed to file successfully.") // observer will be called. - preferences.off('change', observer) - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Put the value of startup failed, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Flush to file failed, err: " + err) + return + } + console.info("Flushed to file successfully.") // observer will be called. + preferences.off('change', observer) + }) +}) +``` ## ValueType 用于表示允许的数据字段类型。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core | 名称 | 说明 | | ------- | -------------------- | 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 a7a80185e977caa68ab1c7549e8e5ebe3237416e..e94468b462bb443d19768d720bfb94d79e90560c 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 @@ -1,30 +1,26 @@ # 关系型数据库 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - ## 导入模块 ```js import data_rdb from '@ohos.data.rdb'; ``` - ## data_rdb.getRdbStore -getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void +getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void 获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| context8+ | Context | 是 | 应用程序或功能的上下文 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | | version | number | 是 | 数据库版本。 | | callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数,返回一个RdbStore。 | @@ -32,43 +28,26 @@ getRdbStore(context: Context, config: StoreConfig, version: number, callback: As **示例**: ```js -import data_rdb from '@ohos.data.rdb' 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(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) - console.info('create table done.') -}) -``` - -API 9的示例请参考如下代码: - -```ts -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) + rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { console.info('create table done.') - }) -} + }) +}) ``` - ## data_rdb.getRdbStore -getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> +getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> 获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| context8+ | Context | 是 | 应用程序或功能的上下文 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | | version | number | 是 | 数据库版本。 | @@ -81,7 +60,6 @@ getRdbStore(context: Context, config: StoreConfig, version: number): Promise< **示例**: ```js -import data_rdb from '@ohos.data.rdb' 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(STORE_CONFIG, 1); @@ -97,75 +75,158 @@ promisegetRdb.then(async (rdbStore) => { }) ``` -API 9的示例请参考如下代码: - -```ts -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.") - }) + +## data_rdb.getRdbStore8+ + +getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void + +获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以callback形式返回。 + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| context8+ | Context | 是 | 应用程序或功能的上下文
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。| +| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | +| version | number | 是 | 数据库版本。 | +| callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数,返回一个RdbStore。 | + +**示例**: + +```js +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, null, function() { + console.info('create table done.') + }) +}) +``` + +## data_rdb.getRdbStore8+ + +getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> + +获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以Promise形式返回。 + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| context8+ | Context | 是 | 应用程序或功能的上下文
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | +| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | +| version | number | 是 | 数据库版本。 | + +**返回值**: + +| 类型 | 说明 | +| -------- | -------- | +| Promise<[RdbStore](#rdbstore)> | 指定Promise回调函数。返回一个RdbStore。 | + +**示例**: + +```js +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("getRdbStore err.") + console.log("executeSql creat err.") }) -} +}).catch((err) => { + console.log("getRdbStore err.") +}) ``` ## data_rdb.deleteRdbStore -deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void +deleteRdbStore(name: string, callback: AsyncCallback<void>): void 删除数据库,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| context8+ | Context | 是 | 应用程序或功能的上下文 | | name | string | 是 | 数据库名称。 | | callback | AsyncCallback<void> | 是 | 指定callback回调函数。 | **示例**: ```js - import data_rdb from '@ohos.data.rdb' data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { console.info('delete store done.') }) ``` + ## data_rdb.deleteRdbStore -API 9的示例请参考如下代码: +deleteRdbStore(name: string): Promise<void> -```ts -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.') - }) -} -``` +使用指定的数据库文件配置删除数据库,结果以Promise形式返回。 -## data_rdb.deleteRdbStore +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| name | string | 是 | 数据库名称。 | + +**返回值**: +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 指定Promise回调函数。 | + +**示例**: + ```js + let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") + promisedeleteRdb.then(()=>{ + console.info('delete store done.') + }).catch((err) => { + console.log("deleteRdbStore err.") + }) + ``` + +## data_rdb.deleteRdbStore8+ + +deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void + +删除数据库,结果以callback形式返回。 + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**参数**: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| context8+ | Context | 是 | 应用程序或功能的上下文
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。| +| name | string | 是 | 数据库名称。 | +| callback | AsyncCallback<void> | 是 | 指定callback回调函数。 | + +**示例**: + ```js + data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { + console.info('delete store done.') + }) + ``` + +## data_rdb.deleteRdbStore8+ deleteRdbStore(context: Context, name: string): Promise<void> 使用指定的数据库文件配置删除数据库,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| context8+ | Context | 是 | 应用程序或功能的上下文 | +| context8+ | Context | 是 | 应用程序或功能的上下文
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。| | name | string | 是 | 数据库名称。 | **返回值**: @@ -175,7 +236,6 @@ deleteRdbStore(context: Context, name: string): Promise<void> **示例**: ```js - import data_rdb from '@ohos.data.rdb' let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") promisedeleteRdb.then(()=>{ console.info('delete store done.') @@ -184,20 +244,6 @@ deleteRdbStore(context: Context, name: string): Promise<void> }) ``` -API 9的示例请参考如下代码: - -```ts -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 @@ -211,7 +257,7 @@ constructor(name: string) 构造函数。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -230,7 +276,7 @@ inDevices(devices: Array<string>): RdbPredicates 同步分布式数据库时指定组网内的远程设备。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -245,7 +291,7 @@ inDevices(devices: Array<string>): RdbPredicates **示例**: ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicate.inDevices(['12345678abcde']) + predicates.inDevices(['12345678abcde']) ``` ### inAllDevices8+ @@ -255,7 +301,7 @@ inAllDevices(): RdbPredicates 同步分布式数据库时连接到组网内的所有远程设备。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -275,7 +321,7 @@ equalTo(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为ValueType且值等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -302,7 +348,7 @@ notEqualTo(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为ValueType且值不等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -329,7 +375,7 @@ beginWrap(): RdbPredicates 向谓词添加左括号。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -355,7 +401,7 @@ endWrap(): RdbPredicates 向谓词添加右括号。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -381,7 +427,7 @@ or(): RdbPredicates 将或条件添加到谓词中。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -404,7 +450,7 @@ and(): RdbPredicates 向谓词添加和条件。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -426,7 +472,7 @@ contains(field: string, value: string): RdbPredicates 配置谓词以匹配数据字段为string且value包含指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -453,7 +499,7 @@ beginsWith(field: string, value: string): RdbPredicates 配置谓词以匹配数据字段为string且值以指定字符串开头的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -480,7 +526,7 @@ endsWith(field: string, value: string): RdbPredicates 配置谓词以匹配数据字段为string且值以指定字符串结尾的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -507,7 +553,7 @@ isNull(field: string): RdbPredicates 配置谓词以匹配值为null的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -533,7 +579,7 @@ isNotNull(field: string): RdbPredicates 配置谓词以匹配值不为null的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -559,7 +605,7 @@ like(field: string, value: string): RdbPredicates 配置谓词以匹配数据字段为string且值类似于指定字符串的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -586,7 +632,7 @@ glob(field: string, value: string): RdbPredicates 配置RdbPredicates匹配数据字段为string的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -613,7 +659,7 @@ between(field: string, low: ValueType, high: ValueType): RdbPredicates 将谓词配置为匹配数据字段为ValueType且value在给定范围内的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -641,7 +687,7 @@ notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates 配置RdbPredicates以匹配数据字段为ValueType且value超出给定范围的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -668,7 +714,7 @@ greaterThan(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为ValueType且值大于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -695,7 +741,7 @@ lessThan(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为valueType且value小于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -723,7 +769,7 @@ greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为ValueType且value大于或等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -751,7 +797,7 @@ lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates 配置谓词以匹配数据字段为ValueType且value小于或等于指定值的字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -779,7 +825,7 @@ orderByAsc(field: string): RdbPredicates 配置谓词以匹配其值按升序排序的列。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -806,7 +852,7 @@ orderByDesc(field: string): RdbPredicates 配置谓词以匹配其值按降序排序的列。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -832,7 +878,7 @@ distinct(): RdbPredicates 配置谓词以过滤重复记录并仅保留其中一个。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值**: | 类型 | 说明 | @@ -860,7 +906,7 @@ limitAs(value: number): RdbPredicates 设置最大数据记录数的谓词。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -886,7 +932,7 @@ offsetAs(rowOffset: number): RdbPredicates 配置RdbPredicates以指定返回结果的起始位置。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -912,7 +958,7 @@ groupBy(fields: Array<string>): RdbPredicates 配置RdbPredicates按指定列分组查询结果。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -937,7 +983,7 @@ indexedBy(field: string): RdbPredicates 配置RdbPredicates以指定索引列。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -964,7 +1010,7 @@ in(field: string, value: Array<ValueType>): RdbPredicates 配置RdbPredicates以匹配数据字段为ValueType数组且值在给定范围内的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -992,7 +1038,7 @@ notIn(field: string, value: Array<ValueType>): RdbPredicates 将RdbPredicates配置为匹配数据字段为ValueType且值超出给定范围的指定字段。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1024,7 +1070,7 @@ insert(name: string, values: ValuesBucket, callback: AsyncCallback<number> 向目标表中插入一行数据,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1053,7 +1099,7 @@ insert(name: string, values: ValuesBucket):Promise<number> 向目标表中插入一行数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1089,7 +1135,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallba 根据RdbPredicates的指定实例对象更新数据库中的数据,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1109,7 +1155,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallba let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") rdbStore.update(valueBucket, predicates, function (err, ret) { - console.log("updated row count: " + changedRows)}) + console.log("updated row count: " + ret)}) ``` @@ -1119,7 +1165,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number> 根据RdbPredicates的指定实例对象更新数据库中的数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1144,7 +1190,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number> predicates.equalTo("NAME", "Lisa") let promiseupdate = rdbStore.update(valueBucket, predicates) promiseupdate.then(async (ret) => { - console.log("updated row count: " + changedRows) + console.log("updated row count: " + ret) }).catch((err) => { console.log("update err.") }) @@ -1158,7 +1204,7 @@ delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void 根据rdbPredicates的指定实例对象从数据库中删除数据,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1182,7 +1228,7 @@ delete(rdbPredicates: RdbPredicates):Promise<number> 根据rdbPredicates的指定实例对象从数据库中删除数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1213,7 +1259,7 @@ query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: Asyn 根据指定条件查询数据库中的数据,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1239,7 +1285,7 @@ query(rdbPredicates: RdbPredicates, columns?: Array<string>):Promise<Re 根据指定条件查询数据库中的数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1272,7 +1318,7 @@ querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback& 根据指定SQL语句查询数据库中的数据,结果以callback形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1296,7 +1342,7 @@ querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> 根据指定SQL语句查询数据库中的数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1327,7 +1373,7 @@ executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallbac 执行包含指定参数但不返回值的SQL语句,结果以callbck形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1350,7 +1396,7 @@ executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void> 执行包含指定参数但不返回值的SQL语句,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1379,7 +1425,7 @@ beginTransaction():void 在开始执行SQL语句之前,开始事务。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **示例**: ```js @@ -1403,7 +1449,7 @@ commit():void 提交已执行的SQL语句。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **示例**: ```js @@ -1428,7 +1474,7 @@ rollBack():void; 回滚已经执行的SQL语句。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **示例**: ```js @@ -1457,7 +1503,7 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi 设置分布式列表,结果以callbck形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1483,7 +1529,7 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi 设置分布式列表,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1511,7 +1557,7 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac 根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 结果以callbck形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1538,7 +1584,7 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac 根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1567,7 +1613,7 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array 在设备之间同步数据, 结果以callbck形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1599,7 +1645,7 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array 在设备之间同步数据,结果以Promise形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: | 参数名 | 类型 | 必填 | 说明 | @@ -1634,7 +1680,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri 注册数据库的观察者。当分布式数据库中的数据发生更改时,将调用回调。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: @@ -1648,7 +1694,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri ```js function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { - console.log('device=' + device[i] + ' data changed') + console.log('device=' + devices[i] + ' data changed') } } try { @@ -1664,7 +1710,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 从数据库中删除指定类型的指定观察者, 结果以callbck形式返回。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数**: @@ -1679,7 +1725,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri ```js function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { - console.log('device=' + device[i] + ' data changed') + console.log('device=' + devices[i] + ' data changed') } } try { @@ -1693,7 +1739,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 管理关系数据库配置。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1704,7 +1750,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 用于表示允许的数据字段类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 名称 | 说明 | | -------- | -------- | @@ -1717,7 +1763,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 用于存储键值对。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1728,7 +1774,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 指数据库同步模式。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 名称 | 默认值 | 说明 | | -------- | ----- |----- | @@ -1739,7 +1785,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri 描述订阅类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 名称 | 默认值 | 说明 | | -------- | ----- |---- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md index a3881d8ac890e776a097828df7825934da8bf6fb..06ec113201daf460a291115807a8200db1ee114e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @@ -1,6 +1,6 @@ # 结果集 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -25,7 +25,7 @@ promise.then((resultSet) => { ### 属性 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -46,7 +46,7 @@ getColumnIndex(columnName: string): number 根据指定的列名获取列索引。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -74,7 +74,7 @@ getColumnName(columnIndex: number): string 根据指定的列索引获取列名。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -100,7 +100,7 @@ goTo(offset:number): boolean 向前或向后转至结果集的指定行,相对于其当前位置偏移。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -131,7 +131,7 @@ goToRow(position: number): boolean 转到结果集的指定行。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -163,7 +163,7 @@ goToFirstRow(): boolean 转到结果集的第一行。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值:** | 类型 | 说明 | @@ -189,7 +189,7 @@ goToLastRow(): boolean 转到结果集的最后一行。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值:** | 类型 | 说明 | @@ -215,7 +215,7 @@ goToNextRow(): boolean 转到结果集的下一行。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值:** | 类型 | 说明 | @@ -241,7 +241,7 @@ goToPreviousRow(): boolean 转到结果集的上一行。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **返回值:** | 类型 | 说明 | @@ -267,7 +267,7 @@ getBlob(columnIndex: number): Uint8Array 以字节数组的形式获取当前行中指定列的值。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -291,7 +291,7 @@ getString(columnIndex: number): string 以字符串形式获取当前行中指定列的值。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -315,7 +315,7 @@ getLong(columnIndex: number): number 以Long形式获取当前行中指定列的值。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -339,7 +339,7 @@ getDouble(columnIndex: number): number 以double形式获取当前行中指定列的值。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -363,7 +363,7 @@ isColumnNull(columnIndex: number): boolean 检查当前行中指定列的值是否为null。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -387,7 +387,7 @@ close(): void 关闭结果集。 -**系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **示例:** ```js 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 3d3029b2bd8249afc5444352ea745d5632c4494e..ecadcebf5ed5050a3a0d5d12e314813822b2c25d 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 @@ -3,7 +3,7 @@ 轻量级存储为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > > - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > @@ -18,7 +18,7 @@ import dataStorage from '@ohos.data.storage'; ## 常量 -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -30,9 +30,9 @@ import dataStorage from '@ohos.data.storage'; getStorageSync(path: string): Storage -读取指定文件,将数据加载到Storage实例,用于数据操作,此方法为同步方法。 +读取指定文件,将数据加载到Storage实例,用于数据操作。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -67,9 +67,9 @@ getStorageSync(path: string): Storage getStorage(path: string, callback: AsyncCallback<Storage>): void -读取指定文件,将数据加载到Storage实例,用于数据操作,使用callback形式返回结果。 +读取指定文件,将数据加载到Storage实例,用于数据操作,使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -105,9 +105,9 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void getStorage(path: string): Promise<Storage> -读取指定文件,将数据加载到Storage实例,用于数据操作,使用Promise方式作为异步方法。 +读取指定文件,将数据加载到Storage实例,用于数据操作,使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -146,9 +146,9 @@ getStorage(path: string): Promise<Storage> deleteStorageSync(path: string): void -从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,此方法为同步方法。 +从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -165,9 +165,9 @@ deleteStorageSync(path: string): void deleteStorage(path: string, callback: AsyncCallback<void>): void -从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 +从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -191,9 +191,9 @@ deleteStorage(path: string, callback: AsyncCallback<void>): void deleteStorage(path: string): Promise<void> -从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。 +从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -222,9 +222,7 @@ removeStorageFromCacheSync(path: string): void 从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -241,11 +239,9 @@ removeStorageFromCacheSync(path: string): void removeStorageFromCache(path: string, callback: AsyncCallback<void>): void -从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 - -此方法为异步方法。 +从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -269,11 +265,9 @@ removeStorageFromCache(path: string, callback: AsyncCallback<void>): void removeStorageFromCache(path: string): Promise<void> -从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 - -此方法为异步方法。 +从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -307,9 +301,7 @@ getSync(key: string, defValue: ValueType): ValueType 获取键对应的值,如果值为null或者非默认值类型,返回默认数据。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -333,11 +325,9 @@ getSync(key: string, defValue: ValueType): ValueType get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void -获取键对应的值,如果值为null或者非默认值类型,返回默认数据。 - -此方法为异步方法。 +获取键对应的值,如果值为null或者非默认值类型,返回默认数据。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -362,11 +352,9 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): get(key: string, defValue: ValueType): Promise<ValueType> -获取键对应的值,如果值为null或者非默认值类型,返默认数据。 +获取键对应的值,如果值为null或者非默认值类型,返默认数据。使用Promise方式返回结果,此方法为异步方法。 -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** @@ -397,9 +385,7 @@ putSync(key: string, value: ValueType): void 首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -417,11 +403,9 @@ putSync(key: string, value: ValueType): void put(key: string, value: ValueType, callback: AsyncCallback<void>): void -首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 - -此方法为异步方法。 +首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -446,11 +430,9 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void put(key: string, value: ValueType): Promise<void> -首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 - -此方法为异步方法。 +首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -480,9 +462,7 @@ hasSync(key: string): boolean 检查存储对象是否包含名为给定key的存储。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -507,11 +487,9 @@ hasSync(key: string): boolean has(key: string, callback: AsyncCallback<boolean>): boolean -检查存储对象是否包含名为给定key的存储。 - -此方法为异步方法。 +检查存储对象是否包含名为给定key的存储。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -542,11 +520,9 @@ has(key: string, callback: AsyncCallback<boolean>): boolean has(key: string): Promise<boolean> -检查存储对象是否包含名为给定key的存储。 - -此方法为异步方法。 +检查存储对象是否包含名为给定key的存储。使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -577,9 +553,7 @@ deleteSync(key: string): void 从存储对象中删除名为给定key的存储。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -592,15 +566,13 @@ deleteSync(key: string): void ``` -### deletej +### delete delete(key: string, callback: AsyncCallback<void>): void -从存储对象中删除名为给定key的存储。 - -此方法为异步方法。 +从存储对象中删除名为给定key的存储。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -624,11 +596,9 @@ delete(key: string, callback: AsyncCallback<void>): void delete(key: string): Promise<void> -从存储对象删除名为给定key的存储。 - -此方法为异步方法。 +从存储对象删除名为给定key的存储。使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -657,9 +627,7 @@ flushSync(): void 将当前storage对象中的修改保存到当前的storage,并同步存储到文件中。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **示例:** ```js @@ -671,11 +639,9 @@ flushSync(): void flush(callback: AsyncCallback<void>): void -将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。 - -此方法为异步方法。 +将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -698,11 +664,9 @@ flush(callback: AsyncCallback<void>): void flush(): Promise<void> -将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。 +将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。使用Promise方式返回结果,此方法为异步方法。 -此方法为异步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **返回值:** | 类型 | 说明 | @@ -726,9 +690,7 @@ clearSync(): void 清除此存储对象中的所有存储。 -此方法为同步方法。 - -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **示例:** ```js @@ -740,11 +702,9 @@ clearSync(): void clear(callback: AsyncCallback<void>): void -清除此存储对象中的所有存储。 - -此方法为异步方法。 +清除此存储对象中的所有存储。使用callback方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -767,11 +727,9 @@ clear(callback: AsyncCallback<void>): void clear(): Promise<void> -清除此存储对象中的所有存储。 - -此方法为异步方法。 +清除此存储对象中的所有存储。使用Promise方式返回结果,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **返回值:** | 类型 | 说明 | @@ -795,7 +753,7 @@ on(type: 'change', callback: Callback<StorageObserver>): void 订阅数据变更者类需要实现StorageObserver接口,订阅的key的值发生变更后,在执行flush/flushSync方法后,callback方法会被回调。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 说明 | @@ -820,7 +778,7 @@ off(type: 'change', callback: Callback<StorageObserver>): void 当不再进行订阅数据变更时,使用此接口取消订阅。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** | 参数名 | 类型 | 说明 | @@ -839,7 +797,7 @@ off(type: 'change', callback: Callback<StorageObserver>): void ## StorageObserver -**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -849,7 +807,7 @@ off(type: 'change', callback: Callback<StorageObserver>): void 用于表示允许的数据字段类型。 -**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core | 名称 | 说明 | | ------- | -------------------- | 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 7ac0763a1eab1b52e65ae741a771c67f1e980106..4e6836d751ac64375ac1348206b0ee226d83a974 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -1,6 +1,6 @@ # 屏幕属性 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -14,7 +14,7 @@ import display from '@ohos.display'; 用于表示显示设备的状态。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | @@ -31,7 +31,7 @@ import display from '@ohos.display'; 描述display对象的属性。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -56,7 +56,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void 获取当前默认的display对象。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -82,7 +82,7 @@ getDefaultDisplay(): Promise<Display> 获取当前默认的display对象。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -107,7 +107,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void 获取当前所有的display对象。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -133,7 +133,7 @@ getAllDisplay(): Promise<Array<Display>> 获取当前所有的display对象。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -158,7 +158,7 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void 开启监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -182,7 +182,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void 关闭监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | 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 ca97f8dac20778154dcc2eb9e201d05be7cc2df4..9cddedcc8321d147111a7b9706f16da7f3386dac 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 @@ -2,7 +2,7 @@ 分布式数据管理为应用程序提供不同设备间数据库的分布式协同能力。通过调用分布式数据各个接口,应用程序可将数据保存到分布式数据库中,并可对分布式数据库中的数据进行增/删/改/查等各项操作。 ->![](../../public_sys-resources/icon-note.gif) **说明:** +>**说明:** >本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -19,7 +19,7 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> 创建一个KVManager对象实例,用于管理数据库对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**:SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -58,7 +58,7 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> 创建一个KVManager对象实例,用于管理数据库对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -99,7 +99,7 @@ try { 提供KVManager实例的配置信息,包括调用方的包名和用户信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | @@ -110,7 +110,7 @@ try { 用户信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 参数类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | @@ -122,7 +122,7 @@ try { 用户类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | ----- | ------ | ------ | @@ -139,7 +139,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: 通过指定Options和storeId,创建并获取KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -183,7 +183,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& 通过指定Options和storeId,创建并获取KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -230,7 +230,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa 通过storeId的值关闭指定的KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -276,7 +276,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& 通过storeId的值关闭指定的KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -330,7 +330,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> 通过storeId的值删除指定的KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -373,7 +373,7 @@ deleteKVStore(appId: string, storeId: string): Promise<void> 通过storeId的值删除指定的KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -427,7 +427,7 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void 获取所有通过[getKVStore](#getkvstore)方法创建的且没有调用[deleteKVStore](#deletekvstore8)方法删除的KVStore数据库的storeId,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -457,7 +457,7 @@ getAllKVStoreId(appId: string): Promise<string[]> 获取所有通过[getKVStore](#getkvstore)方法创建的且没有调用[deleteKVStore](#deletekvstore8)方法删除的KVStore数据库的storeId,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -496,7 +496,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi 订阅服务状态变更通知,并通过callback方式返回,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -505,7 +505,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi | event | string | 是 | 订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | | deathCallback | Callback<void> | 是 | 回调函数,在设备状态改变时获取通知。 | -**示例** +**示例:** ```js let kvManager; @@ -528,7 +528,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v 取消订阅服务状态变更通知,并通过callback方式返回,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -538,7 +538,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v | deathCallback | Callback<void> | 否 | 回调函数,取消设备状态改变时获取通知。 | -**示例** +**示例:** ```js let kvManager; @@ -558,7 +558,7 @@ try { 用于提供创建数据库的配置信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -575,7 +575,7 @@ try { 用于指定创建的数据库类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | --- | ---- | ----------------------- | @@ -588,7 +588,7 @@ try { 用于指定创建的数据库的安全级别。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | --- | ---- | ----------------------- | @@ -604,7 +604,7 @@ try { KVStore常量。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | --- | ---- | ----------------------- | @@ -619,7 +619,7 @@ KVStore常量。 表示数据库模式,可以在创建或打开数据库时创建 Schema 对象并将它们放入 Options 中。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 | 名称 | 类型 | 说明 | | --- | ---- | ----------------------- | @@ -634,13 +634,13 @@ constructor() 用于创建Schema实例的构造函数。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 ## FieldNode8+ ## 表示 Schema 实例的节点,提供定义存储在数据库中的值的方法。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 | 名称 | 类型 | 说明 | | --- | ---- | ----------------------- | @@ -654,7 +654,7 @@ constructor(name: string) 用于创建带有string字段FieldNode实例的构造函数。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -668,7 +668,7 @@ appendChild(child: FieldNode): boolean 向这个 FieldNode 添加一个子节点。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -682,7 +682,7 @@ appendChild(child: FieldNode): boolean | ------------- | -------------- | | boolean |如果子节点成功添加到这个FieldNode,则返回 true;否则返回 false。 | -**示例** +**示例:** ```js import ddm from '@ohos.data.distributedData'; @@ -716,7 +716,7 @@ getCount(): number 获取结果集中的行数。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -724,7 +724,7 @@ getCount(): number | ------ | -------------- | | number |返回行数。 | -**示例** +**示例:** ```js let kvStore; @@ -749,7 +749,7 @@ getPosition(): number 获取结果集中当前的读取位置。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -757,7 +757,7 @@ getPosition(): number | ------ | -------------- | | number |返回当前读取位置。 | -**示例** +**示例:** ```js let kvStore; @@ -783,7 +783,7 @@ moveToFirst(): boolean 将读取位置移动到第一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -791,7 +791,7 @@ moveToFirst(): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -817,7 +817,7 @@ moveToLast(): boolean 将读取位置移动到最后一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -825,7 +825,7 @@ moveToLast(): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -851,7 +851,7 @@ moveToNext(): boolean 将读取位置移动到下一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -859,7 +859,7 @@ moveToNext(): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -885,7 +885,7 @@ moveToPrevious(): boolean 将读取位置移动到上一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -893,7 +893,7 @@ moveToPrevious(): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -919,7 +919,7 @@ move(offset: number): boolean 将读取位置移动到当前位置的相对偏移量。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -933,7 +933,7 @@ move(offset: number): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -959,7 +959,7 @@ moveToPosition(position: number): boolean 将读取位置从 0 移动到绝对位置。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -973,7 +973,7 @@ moveToPosition(position: number): boolean | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -999,7 +999,7 @@ isFirst(): boolean 检查读取位置是否为第一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1007,7 +1007,7 @@ isFirst(): boolean | ------ | -------------- | | boolean |如果读取位置是第一行,则返回 true;否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -1033,7 +1033,7 @@ isLast(): boolean 检查读取位置是否为最后一行。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1041,7 +1041,7 @@ isLast(): boolean | ------ | -------------- | | boolean |如果读取位置是最后一行,则返回 true;否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -1066,7 +1066,7 @@ isBeforeFirst(): boolean 检查读取位置是否在第一行之前。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1074,7 +1074,7 @@ isBeforeFirst(): boolean | ------ | -------------- | | boolean |如果读取位置在第一行之前,则返回 true;否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -1100,7 +1100,7 @@ isAfterLast(): boolean 检查读取位置是否在最后一行之后。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1108,7 +1108,7 @@ isAfterLast(): boolean | ------ | -------------- | | boolean |如果读取位置在最后一行之后,则返回 true;否则返回 false。 | -**示例** +**示例:** ```js let kvStore; @@ -1134,7 +1134,7 @@ getEntry(): Entry 获取键值对。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1142,7 +1142,7 @@ getEntry(): Entry | ------ | ------- | | [Entry](#entry) |返回键值对。| -**示例** +**示例:** ```js let kvStore; @@ -1167,7 +1167,7 @@ try { 使用谓词表示数据库查询,提供创建Query实例、查询数据库中的数据和添加谓词的方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 ### constructor8+ ### @@ -1175,7 +1175,7 @@ constructor() 用于创建Schema实例的构造函数。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 ### reset8+ ### @@ -1184,7 +1184,7 @@ reset(): Query 公共查询重置。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1193,7 +1193,7 @@ reset(): Query | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -**示例** +**示例:** ```js try { @@ -1215,7 +1215,7 @@ equalTo(field: string, value: number|string|boolean): Query 构造一个Query对象来查询具有指定字段的条目,其值等于指定的值。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1230,7 +1230,7 @@ equalTo(field: string, value: number|string|boolean): Query | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -**示例** +**示例:** ```js try { @@ -1250,7 +1250,7 @@ notEqualTo(field: string, value: number|string|boolean): Query 构造一个Query对象以查询具有指定字段且值不等于指定值的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1265,7 +1265,7 @@ notEqualTo(field: string, value: number|string|boolean): Query | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -**示例** +**示例:** ```js try { @@ -1285,7 +1285,7 @@ greaterThan(field: string, value: number|string|boolean): Query 构造一个Query对象以查询具有大于指定值的指定字段的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1300,7 +1300,7 @@ greaterThan(field: string, value: number|string|boolean): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1320,7 +1320,7 @@ lessThan(field: string, value: number|string): Query 构造一个Query对象以查询具有小于指定值的指定字段的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1335,7 +1335,7 @@ lessThan(field: string, value: number|string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1355,7 +1355,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query 构造一个Query对象以查询具有指定字段且值大于或等于指定值的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1370,7 +1370,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1390,7 +1390,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query 构造一个Query对象以查询具有指定字段且值小于或等于指定值的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1405,7 +1405,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1426,7 +1426,7 @@ isNull(field: string): Query 构造一个Query对象以查询具有值为null的指定字段的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1440,7 +1440,7 @@ isNull(field: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1461,7 +1461,7 @@ inNumber(field: string, valueList: number[]): Query 构造一个Query对象以查询具有指定字段的条目,其值在指定的值列表中。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1476,7 +1476,7 @@ inNumber(field: string, valueList: number[]): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1496,7 +1496,7 @@ inString(field: string, valueList: string[]): Query 构造一个Query对象以查询具有指定字段的条目,其值在指定的字符串值列表中。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1511,7 +1511,7 @@ inString(field: string, valueList: string[]): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1531,7 +1531,7 @@ notInNumber(field: string, valueList: number[]): Query 构造一个Query对象以查询具有指定字段的条目,该字段的值不在指定的值列表中。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1546,7 +1546,7 @@ notInNumber(field: string, valueList: number[]): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1566,7 +1566,7 @@ notInString(field: string, valueList: string[]): Query 构造一个Query对象以查询具有指定字段且值不在指定字符串值列表中的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1581,7 +1581,7 @@ notInString(field: string, valueList: string[]): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1601,7 +1601,7 @@ like(field: string, value: string): Query 构造一个Query对象以查询具有与指定字符串值相似的指定字段的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1616,7 +1616,7 @@ like(field: string, value: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1636,7 +1636,7 @@ unlike(field: string, value: string): Query 构造一个Query对象以查询具有与指定字符串值不相似的指定字段的条目。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1651,7 +1651,7 @@ unlike(field: string, value: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1671,7 +1671,7 @@ and(): Query 构造一个带有与条件的查询对象。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1679,7 +1679,7 @@ and(): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1701,7 +1701,7 @@ or(): Query 构造一个带有或条件的Query对象。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1709,7 +1709,7 @@ or(): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1731,7 +1731,7 @@ orderByAsc(field: string): Query 构造一个Query对象,将查询结果按升序排序。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1745,7 +1745,7 @@ orderByAsc(field: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1766,7 +1766,7 @@ orderByDesc(field: string): Query 构造一个Query对象,将查询结果按降序排序。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1780,7 +1780,7 @@ orderByDesc(field: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1801,7 +1801,7 @@ limit(total: number, offset: number): Query 构造一个Query对象来指定结果的数量和开始位置。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1816,7 +1816,7 @@ limit(total: number, offset: number): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1837,7 +1837,7 @@ isNotNull(field: string): Query 使用不为空的指定字段创建查询条件。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1851,7 +1851,7 @@ isNotNull(field: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1871,7 +1871,7 @@ beginGroup(): Query 创建一个带有左括号的查询条件组。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1879,7 +1879,7 @@ beginGroup(): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1901,7 +1901,7 @@ endGroup(): Query 创建一个带有右括号的查询条件组。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -1909,7 +1909,7 @@ endGroup(): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1931,7 +1931,7 @@ prefixKey(prefix: string): Query 创建具有指定键前缀的查询条件。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1945,7 +1945,7 @@ prefixKey(prefix: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -1966,7 +1966,7 @@ setSuggestIndex(index: string): Query 设置一个指定的索引,将优先用于查询。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -1980,7 +1980,7 @@ setSuggestIndex(index: string): Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -2001,7 +2001,7 @@ deviceId(deviceId:string):Query 添加设备ID作为key的前缀。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2016,7 +2016,7 @@ deviceId(deviceId:string):Query | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -2035,7 +2035,7 @@ getSqlLike():string 获取指定Query对象的查询语句。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -2043,7 +2043,7 @@ getSqlLike():string | ------ | ------- | | [Query](#query8) |返回查询对象。| -**示例** +**示例:** ```js try { @@ -2060,7 +2060,7 @@ try { KVStore数据库实例,提供增加数据、删除数据和订阅数据变更、订阅同步完成的方法。在调用KVStore的方法前,需要先通过getKVStore构建一个KVStore实例。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 ### put @@ -2068,7 +2068,7 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC 添加指定类型键值对到数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2078,7 +2078,7 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC | value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2104,7 +2104,7 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void 添加指定类型键值对到数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2119,7 +2119,7 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2143,7 +2143,7 @@ delete(key: string, callback: AsyncCallback<void>): void 从数据库中删除指定键值的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2152,7 +2152,7 @@ delete(key: string, callback: AsyncCallback<void>): void | key | string | 是 |要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2185,7 +2185,7 @@ delete(key: string): Promise<void> 从数据库中删除指定键值的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2199,7 +2199,7 @@ delete(key: string): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2228,7 +2228,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific 订阅指定类型的数据变更通知,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2238,7 +2238,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific | type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 | | observer |Callback<[ChangeNotification](#changenotification)> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2254,7 +2254,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2263,7 +2263,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2278,7 +2278,7 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void 取消订阅数据变更通知,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2287,7 +2287,7 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void | event |string | 是 |取消订阅的事件名,固定为'dataChange',表示数据变更事件。 | | observer |Callback<[ChangeNotification](#changenotification)> |否 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2306,7 +2306,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void 批量插入键值对到KVStore数据库中,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2315,7 +2315,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | | callback |Asyncallback<void> |是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2353,7 +2353,7 @@ putBatch(entries: Entry[]): Promise<void> 批量插入键值对到KVStore数据库中,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2367,7 +2367,7 @@ putBatch(entries: Entry[]): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2408,7 +2408,7 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void 批量删除KVStore数据库中的键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2417,7 +2417,7 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void | keys |string[] | 是 |表示要批量删除的键值对。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2455,7 +2455,7 @@ deleteBatch(keys: string[]): Promise<void> 批量删除KVStore数据库中的键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2469,7 +2469,7 @@ deleteBatch(keys: string[]): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2511,7 +2511,7 @@ startTransaction(callback: AsyncCallback<void>): void 启动KVStore数据库中的事务,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2519,7 +2519,7 @@ startTransaction(callback: AsyncCallback<void>): void | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2563,7 +2563,7 @@ startTransaction(): Promise<void> 启动KVStore数据库中的事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -2571,7 +2571,7 @@ startTransaction(): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2598,7 +2598,7 @@ commit(callback: AsyncCallback<void>): void 提交KVStore数据库中的事务,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2606,7 +2606,7 @@ commit(callback: AsyncCallback<void>): void | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2630,7 +2630,7 @@ commit(): Promise<void> 提交KVStore数据库中的事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -2638,7 +2638,7 @@ commit(): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2660,7 +2660,7 @@ rollback(callback: AsyncCallback<void>): void 在KVStore数据库中回滚事务,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2668,7 +2668,7 @@ rollback(callback: AsyncCallback<void>): void | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2692,7 +2692,7 @@ rollback(): Promise<void> 在KVStore数据库中回滚事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -2700,7 +2700,7 @@ rollback(): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2722,7 +2722,7 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void 设定是否开启同步,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2731,7 +2731,7 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void | enabled |boolean | 是 |指定是否开启同步,ture表示开启同步,false表示不启用同步。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2755,7 +2755,7 @@ enableSync(enabled: boolean): Promise<void> 设定是否开启同步,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2769,7 +2769,7 @@ enableSync(enabled: boolean): Promise<void> | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2791,7 +2791,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy 设置同步范围标签,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2801,7 +2801,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy | remoteSupportLabels |string[] | 是 |表示要同步数据的设备的同步标签。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -2823,7 +2823,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v 设置同步范围标签,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2839,7 +2839,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -**示例** +**示例:** ```js let kvStore; @@ -2861,7 +2861,7 @@ try { 描述订阅类型。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | ----- | ------ | ----------------------- | @@ -2873,7 +2873,7 @@ try { 数据变更时通知的对象,包括数据插入的数据、更新的数据、删除的数据和设备ID。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 参数类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | @@ -2886,7 +2886,7 @@ try { 存储在数据库中的键值对。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 参数类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | @@ -2898,7 +2898,7 @@ try { 存储在数据库中的对象。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 参数类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | @@ -2911,7 +2911,7 @@ try { 只能被内部应用使用。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 默认值 | 说明 | | ----- | ------ | ----------------------- | @@ -2926,7 +2926,7 @@ try { 单版本分布式数据库,继承自KVStore,提供查询数据和同步数据的方法。在调用 SingleKVStore 的方法前,需要先通过 [getKVStore](#getkvstore) 构建一个 SingleKVStore 实例。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 ### get @@ -2934,7 +2934,7 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb 获取指定键的值,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2943,7 +2943,7 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | 是 |回调函数,获取查询的值。 | -**示例** +**示例:** ```js let kvStore; @@ -2972,7 +2972,7 @@ get(key: string): Promise<Uint8Array | string | boolean | number> 获取指定键的值,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -2987,7 +2987,7 @@ get(key: string): Promise<Uint8Array | string | boolean | number> | ------ | ------- | |Promise<Uint8Array \| string \| boolean \| number> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3015,7 +3015,7 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void 获取匹配指定键前缀的所有键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3024,7 +3024,7 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,获取指定前缀的键值对列表。 | -**示例** +**示例:** ```js let kvStore; @@ -3061,7 +3061,7 @@ getEntries(keyPrefix: string): Promise<Entry[]> 获取匹配指定键前缀的所有键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3075,7 +3075,7 @@ getEntries(keyPrefix: string): Promise<Entry[]> | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3119,7 +3119,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void 获取与指定 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3128,7 +3128,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void | query |[Query](#query8) | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,获取指定前缀的键值对列表。 | -**示例** +**示例:** ```js let kvStore; @@ -3170,7 +3170,7 @@ getEntries(query: Query): Promise<Entry[]> 获取匹配指定键前缀的所有键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3184,7 +3184,7 @@ getEntries(query: Query): Promise<Entry[]> | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js try { @@ -3227,7 +3227,7 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>) 从 KvStore 数据库中获取具有指定前缀的结果集,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3236,7 +3236,7 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>) | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -3276,7 +3276,7 @@ getResultSet(keyPrefix: string): Promise<KvStoreResultSet> 从 KVStore 数据库中获取具有指定前缀的结果集,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3290,7 +3290,7 @@ getResultSet(keyPrefix: string): Promise<KvStoreResultSet> | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3336,7 +3336,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi 获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3345,7 +3345,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi | query |Query | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获取与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -**示例** +**示例:** ```js let kvStore; @@ -3384,7 +3384,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> 获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3398,7 +3398,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3440,7 +3440,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) 关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3449,7 +3449,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) | resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的 KvStoreResultSet 对象。 | | callback |AsyncCallback<void> | 是 |回调函数,获取由 getResultSet 返回的 KvStoreResultSet 对象。 | -**示例** +**示例:** ```js let kvStore; @@ -3474,7 +3474,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> 关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3488,7 +3488,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3511,7 +3511,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void 获取与指定 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3520,7 +3520,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,获取与指定 Query 对象匹配的结果数。 | -**示例** +**示例:** ```js let kvStore; @@ -3557,7 +3557,7 @@ getResultSize(query: Query): Promise<number> 获取与指定 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3571,7 +3571,7 @@ getResultSize(query: Query): Promise<number> | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3612,7 +3612,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void 删除指定设备的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3621,7 +3621,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void | deviceId |string | 是 |表示要删除设备的名称。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -3654,7 +3654,7 @@ removeDeviceData(deviceId: string): Promise<void> 删除指定设备的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3668,7 +3668,7 @@ removeDeviceData(deviceId: string): Promise<void> | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3703,7 +3703,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3712,7 +3712,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 是 |用于向调用方发送同步结果的回调。 | -**示例** +**示例:** ```js let kvStore; @@ -3739,7 +3739,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& 取消订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3748,7 +3748,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& | event |string | 是 |取消订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 否 |用于向调用方发送同步结果的回调。 | -**示例** +**示例:** ```js let kvStore; @@ -3772,7 +3772,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3795,7 +3795,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) 设置允许数据库同步的默认延迟,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3804,7 +3804,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -3825,7 +3825,7 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> 设置允许数据库同步的默认延迟,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3840,7 +3840,7 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3863,7 +3863,7 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void 获取数据库的安全级别,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -3871,7 +3871,7 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<[SecurityLevel](#securitylevel)> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -3891,7 +3891,7 @@ getSecurityLevel(): Promise<SecurityLevel> 获取数据库的安全级别,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **返回值:** @@ -3899,7 +3899,7 @@ getSecurityLevel(): Promise<SecurityLevel> | ------ | ------- | |Promise<[SecurityLevel](#securitylevel)> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -3919,7 +3919,7 @@ try { 在分布式系统中按设备管理分布式数据,继承自KVStore,提供查询数据和同步数据的方法。在调用DeviceKVStore的方法前,需要先通过[getKVStore](#getkvstore)构建一个DeviceKVStore实例。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 ### get8+ ### @@ -3927,7 +3927,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num 获取与指定设备 ID 和 key 匹配的 String 值,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -3937,7 +3937,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num | key |string | 是 |表示要查询 key 值的键。 | | callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | 是 |回调函数,返回匹配给定条件的字符串值。 | -**示例** +**示例:** ```js let kvStore; @@ -3962,7 +3962,7 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& 获取与指定设备 ID 和 key 匹配的 String 值,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -3977,7 +3977,7 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& | ------ | ------- | |Promise<boolean\|string\|number\|Uint8Array> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4006,7 +4006,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry 获取与指定设备 ID 和 key 前缀匹配的所有键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4016,7 +4016,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回满足给定条件的所有键值对的列表。 | -**示例** +**示例:** ```js let kvStore; @@ -4054,7 +4054,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> 获取与指定设备 ID 和 key 前缀匹配的所有键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4069,7 +4069,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4113,7 +4113,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void 获取与指定 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4122,7 +4122,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | -**示例** +**示例:** ```js let kvStore; @@ -4166,7 +4166,7 @@ getEntries(query: Query): Promise<Entry[]> 获取与指定 Query 对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4180,7 +4180,7 @@ getEntries(query: Query): Promise<Entry[]> | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4224,7 +4224,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> 获取与指定设备 ID 和 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4234,7 +4234,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | -**示例** +**示例:** ```js let kvStore; @@ -4278,7 +4278,7 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> 获取与指定设备 ID 和 Query 对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4293,7 +4293,7 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4338,7 +4338,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS 获取与指定设备 ID 和 key 前缀匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4348,7 +4348,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回 KvStoreResultSet 对象。 | -**示例** +**示例:** ```js let kvStore; @@ -4373,7 +4373,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g 获取与指定设备 ID 和 key 前缀匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4388,7 +4388,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4417,7 +4417,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi 获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4426,7 +4426,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -**示例** +**示例:** ```js let kvStore; @@ -4469,7 +4469,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> 获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4483,7 +4483,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4533,7 +4533,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR 获取与指定设备ID和Query对象匹配的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4543,7 +4543,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -**示例** +**示例:** ```js let kvStore; @@ -4585,7 +4585,7 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> 获取与指定设备ID和Query对象匹配的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4600,7 +4600,7 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4651,7 +4651,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) 关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4660,7 +4660,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) | resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的 KvStoreResultSet 对象。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -4686,7 +4686,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> 关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4700,7 +4700,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4724,7 +4724,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void 获取与指定 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4733,7 +4733,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | -**示例** +**示例:** ```js let kvStore; @@ -4771,7 +4771,7 @@ getResultSize(query: Query): Promise<number> 获取与指定 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4785,7 +4785,7 @@ getResultSize(query: Query): Promise<number> | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4827,7 +4827,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& 获取与指定设备 ID 和 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4837,7 +4837,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | -**示例** +**示例:** ```js let kvStore; @@ -4874,7 +4874,7 @@ getResultSize(deviceId: string, query: Query): Promise<number> 获取与指定设备 ID 和 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4889,7 +4889,7 @@ getResultSize(deviceId: string, query: Query): Promise<number> | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -4930,7 +4930,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void 从当前数据库中删除指定设备的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4939,7 +4939,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void | deviceId |string | 是 |标识要删除其数据的设备。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -**示例** +**示例:** ```js let kvStore; @@ -4972,7 +4972,7 @@ removeDeviceData(deviceId: string): Promise<void> 从当前数据库中删除指定设备的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 **参数:** @@ -4986,7 +4986,7 @@ removeDeviceData(deviceId: string): Promise<void> | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -**示例** +**示例:** ```js let kvStore; @@ -5023,7 +5023,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -5033,7 +5033,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | mode |[SyncMode](#syncmode) | 是 |表示同步方式,PUSH、PULL或PUSH_PULL。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | -**示例** +**示例:** ```js let kvStore; @@ -5060,7 +5060,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,该方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -5069,7 +5069,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback | 是 |用于向调用方发送同步结果的回调。 | -**示例** +**示例:** ```js const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; @@ -5095,7 +5095,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& 取消订阅同步完成事件回调通知,该方法为同步方法。 -**系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 **参数:** @@ -5104,7 +5104,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& | event |string | 是 |取消订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback9+ + +getPrivateDirty(): bigint + +获取进程的私有脏内存大小。 + +**系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**返回值:** +| 类型 | 说明 | +| ------ | -------------------------- | +| bigint | 返回进程的私有脏内存大小。 | + + +**示例:** + ```js + let privateDirty = hidebug.getPrivateDirty(); + ``` + +## hidebug.getCpuUsage9+ + +getCpuUsage(): number + +获取进程的cpu占用率。 + +如占用率为50%,则返回0.5。 + +**系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**返回值:** +| 类型 | 说明 | +| ------ | -------------------------- | +| number | 获取进程的cpu占用率。 | + + +**示例:** + ```js + let cpuUsage = hidebug.getCpuUsage(); + ``` ## hidebug.startProfiling @@ -179,4 +220,32 @@ dumpHeapData(filename : string) : void ```js hidebug.dumpHeapData("heap-20220216"); +``` + +## hidebug.getServiceDump9+ + +getServiceDump(serviceid : number) : string + +获取系统服务信息。 + +此接口为系统接口,三方应用不可用。 + +**系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| serviceid | number | 是 | 基于该用户输入的service id获取系统服务信息。| + +**返回值:** +| 类型 | 说明 | +| ------ | -------------------------- | +| string | 返回dump的service信息文件的绝对路径。 | + +**示例:** + +```js +let serviceId = 10; +let pathName = hidebug.getServiceDump(serviceId); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 5d1e6d2c4a619eee379b47ffc08e15c89ed1bec1..798b366a2a8d3b5508492c29da13d86957dd90c4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -40,13 +40,13 @@ getInputMethodController(): InputMethodController **系统能力**:SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | -------- | -------- | | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | -- 示例 +**示例:** ```js var InputMethodController = inputMethod.getInputMethodController(); ``` @@ -58,14 +58,14 @@ getInputMethodSetting(): InputMethodSetting **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | ----------------------------------------- | ---------------------------- | | [InputMethodSetting](#InputMethodSetting) | 回调返回当前客户端设置实例。 | -- 示例 +**示例:** ```js var InputMethodSetting = inputMethod.getInputMethodSetting(); ``` @@ -82,13 +82,13 @@ stopInput(callback: AsyncCallback<boolean>): void **系统能力**:SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 返回输入法隐藏是否成功。 | -- 示例 +**示例:** ```js InputMethodController.stopInput((error)=>{ @@ -104,13 +104,13 @@ stopInput(): Promise<boolean> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 返回输入法隐藏是否成功。 | -- 示例 +**示例:** ```js @@ -130,12 +130,12 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | -- 示例 +**示例:** ```js InputMethodSetting.listInputMethod((properties)=>{ for (var i = 0;i < properties.length; i++) { @@ -153,12 +153,12 @@ listInputMethod(): Promise<Array<InputMethodProperty>> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ---------------------- | | Promise> | 返回已安装输入法列表。 | -- 示例 +**示例:** ```js var properties = InputMethodSetting.listInputMethod(); for (var i = 0;i < properties.length; i++) { @@ -175,13 +175,13 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | -- 示例 +**示例:** ```js InputMethodSetting.displayOptionalInputMethod(()=>{ console.info('displayOptionalInputMethod is called'); @@ -196,13 +196,13 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | 回调函数。 | - - 示例 +**示例:** ```js InputMethodSetting.displayOptionalInputMethod(); ``` \ No newline at end of file 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 74c5220408b55b74764a8198c49cd4b8deb26b22..1b6bae7a64b10704f1f9be3c4569de44069b0e98 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -52,13 +52,13 @@ getInputMethodEngine(): InputMethodEngine **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | --------------------------------------- | ------------ | | [InputMethodEngine](#InputMethodEngine) | 服务端实例。 | -- 示例 +**示例:** ```js var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); @@ -72,13 +72,13 @@ createKeyboardDelegate(): KeyboardDelegate **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | ------------------------------------- | ---------------- | | [KeyboardDelegate](#KeyboardDelegate) | 客户端监听实例。 | -- 示例 +**示例:** ```js var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); @@ -96,14 +96,14 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | | callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | 是 | 回调返回输入法操作相关实例。 | -- 示例: +**示例:** ```js InputMethodEngine.on('inputStart', (kbController, textInputClient) => { @@ -120,7 +120,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | @@ -129,7 +129,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC -- 示例: +**示例:** ```js InputMethodEngine.off('inputStart'); @@ -143,14 +143,14 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | | callback | void | 否 | 回调函数。 | -- 示例: +**示例:** ```js InputMethodEngine.on('keyboardShow', (err) => { @@ -166,14 +166,14 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | | callback | void | 否 | 回调函数。 | -- 示例: +**示例:** ```js InputMethodEngine.off('keyboardShow'); @@ -192,7 +192,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | @@ -201,7 +201,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void -- 示例: +**示例:** ```js KeyboardDelegate.on('keyDown', (event) => { @@ -217,14 +217,14 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | | callback | [KeyEvent](#KeyEvent) | 否 | 回调返回按键信息。 | -- 示例: +**示例:** ```js KeyboardDelegate.off('keyDown'); @@ -238,7 +238,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | @@ -247,7 +247,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = - - 示例: + **示例:** ```js KeyboardDelegate.on('cursorContextChange', (x, y, height) => { @@ -263,7 +263,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | @@ -271,7 +271,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) | callback | number | 否 | 回调返回光标信息。 | - - 示例: + **示例:** ```js KeyboardDelegate.off('cursorContextChange'); @@ -284,14 +284,14 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | | callback | number | 是 | 回调返回文本选择信息。 | - - 示例: + **示例:** ```js KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { @@ -307,14 +307,14 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | | callback | number | 否 | 回调返回文本选择信息。 | - - 示例: + **示例:** ```js KeyboardDelegate.off('selectionChange'); @@ -329,14 +329,14 @@ on(type: 'textChange', callback: (text: string) => void): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | | callback | string | 是 | 回调返回当前文本内容。 | - - 示例: + **示例:** ```js KeyboardDelegate.on('textChange', (text) => { @@ -352,14 +352,14 @@ off(type: 'textChange', callback?: (text: string) => void): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数: + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | | callback | string | 否 | 回调返回当前文本内容。 | - - 示例: + **示例:** ```js KeyboardDelegate.off('textChange'); @@ -377,13 +377,13 @@ hideKeyboard(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | -------- | | callback | AsyncCallback<void> | 否 | 回调函数 | -- 示例 +**示例:** ```js @@ -399,14 +399,13 @@ hideKeyboard(): Promise<void> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** | 类型 | 说明 | | ---------------- | -------- | | Promise<void> | 回调函数 | -- 示例 - +**示例:** ```js KeyboardController.hideKeyboard(); @@ -424,14 +423,15 @@ getForward(length:number, callback: AsyncCallback<string>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | | callback | AsyncCallback<string> | 是 | 返回文本。 | -- 示例 +**示例:** + ```js TextInputClient.getForward(5,(text) =>{ console.info("text = " + text); @@ -446,18 +446,20 @@ getForward(length:number): Promise<string> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<string> | 返回文本。 | -- 示例 +**示例:** + ```js var text = TextInputClient.getForward(5); console.info("text = " + text); @@ -471,14 +473,15 @@ getBackward(length:number, callback: AsyncCallback<string>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | | callback | AsyncCallback<string> | 是 | 返回文本。 | -- 示例 +**示例:** + ```js TextInputClient.getBackward(5,(text)=>{ console.info("text = " + text); @@ -493,18 +496,20 @@ getBackward(length:number): Promise<string> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<string> | 返回文本。 | -- 示例 +**示例:** + ```js var text = TextInputClient.getBackward(5); console.info("text = " + text); @@ -518,14 +523,15 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | -- 示例 +**示例:** + ```js TextInputClient.deleteForward(5,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); @@ -539,18 +545,20 @@ deleteForward(length:number): Promise<boolean> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<boolean> | 操作成功与否。 | - - 示例 +**示例:** + ```js var isSuccess = TextInputClient.deleteForward(5); console.info("isSuccess = " + isSuccess); @@ -564,14 +572,15 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数 + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - - 示例 + **示例:** + ```js TextInputClient.deleteBackward(5, (isSuccess)=>{ console.info("isSuccess = " + isSuccess); @@ -586,17 +595,18 @@ deleteBackward(length:number): Promise<boolean> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | length | number | 是 | 文本长度。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<boolean> | 操作成功与否。 | -- 示例 +**示例:** ```js var isSuccess = TextInputClient.deleteBackward(5); @@ -610,14 +620,15 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework - - 参数 + **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | action | number | 是 | 编辑框属性。 | | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - - 示例 + **示例:** + ```js TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); @@ -632,17 +643,19 @@ sendKeyFunction(action:number): Promise<boolean> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | action | number | 是 | 编辑框属性。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<boolean> | 操作成功与否。 | -- 示例 +**示例:** ```js var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); @@ -657,14 +670,15 @@ insertText(text:string, callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | text | string | 是 | 文本。 | | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | -- 示例 +**示例:** + ```js TextInputClient.insertText("test", (isSuccess)=>{ console.info("isSuccess = " + isSuccess); @@ -679,17 +693,19 @@ insertText(text:string): Promise<boolean> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | text | string | 是 | 文本。 | -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<boolean> | 操作成功与否。 | -- 示例 +**示例:** ```js var isSuccess = TextInputClient.insertText("test"); @@ -704,12 +720,14 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 参数 +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | 是 | 编辑框属性值。 | -- 示例 +**示例:** + ```js TextInputClient.getEditorAttribute((EditorAttribute)=>{ }); @@ -723,12 +741,14 @@ getEditorAttribute(): Promise<EditorAttribute> **系统能力**: SystemCapability.Miscservices.InputMethodFramework -- 返回值 +**返回值:** + | 类型 | 说明 | | ------------------------------- | ------------------------------------------------------------ | | Promise<[EditorAttribute](#EditorAttribute)> | 返回编辑框属性值。 | -- 示例 +**示例:** + ```js var EditorAttribute = TextInputClient.getEditorAttribute(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 66c1f7e3360f57646c404398f6a64cb63834f3e5..14dabd5c30976a3a7d86732f22c14e42872b74dc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -69,17 +69,19 @@ upload(config: UploadConfig): Promise<UploadTask> **系统能力**: SystemCapability.MiscServices.Upload -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [UploadConfig](#uploadconfig) | 是 | 上传的配置信息。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<[UploadTask](#uploadtask)> | 返回上传任务。 | -- 示例: +**示例:** ```js request.upload({ url: 'https://patch' }).then((data) => { @@ -100,13 +102,14 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void **系统能力**: SystemCapability.MiscServices.Upload -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [UploadConfig](#uploadconfig) | 是 | 上传的配置信息。 | | callback | AsyncCallback<[UploadTask](#uploadtask)> | 否 | 回调函数,异步返回UploadTask对象。 | -- 示例: +**示例:** ```js request.upload({ url: 'https://patch' }, (err, data) => { @@ -134,20 +137,21 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo **系统能力**: SystemCapability.MiscServices.Upload -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型,取值为'progress'(上传的进度信息)。 | | callback | function | 是 | 上传进度的回调函数。 | - 回调函数的参数: + 回调函数的参数 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | -- 示例: +**示例:** ```js uploadTask.on('progress', function callback(uploadedSize, totalSize) { @@ -167,8 +171,9 @@ on(type: 'headerReceive', callback: (header: object) => void): void **系统能力**: SystemCapability.MiscServices.Upload -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型,取值为'headerReceive'(接收响应头)。 | | callback | function | 是 | HTTP Response Header事件的回调函数。 | @@ -179,7 +184,7 @@ on(type: 'headerReceive', callback: (header: object) => void): void | -------- | -------- | -------- | -------- | | header | object | 是 | HTTP Response Header。 | -- 示例: +**示例:** ```js uploadTask.on('headerReceive', function callback(headers){ @@ -199,8 +204,9 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g **系统能力**: SystemCapability.MiscServices.Upload -- 参数: - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型,取值为'progress'(上传的进度信息)。 | | callback | function | 否 | 上传任务的回调函数。 | @@ -212,7 +218,7 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | -- 示例: +**示例:** ```js uploadTask.off('progress', function callback(uploadedSize, totalSize) { @@ -232,8 +238,9 @@ off(type: 'headerReceive', callback?: (header: object) => void): void **系统能力**: SystemCapability.MiscServices.Upload -- 参数: - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型,取值为'headerReceive'(接收响应头)。 | | callback | function | 否 | HTTP Response Header事件的回调函数。 | @@ -244,7 +251,7 @@ off(type: 'headerReceive', callback?: (header: object) => void): void | -------- | -------- | -------- | -------- | | header | object | 是 | HTTP Response Header。 | -- 示例: +**示例:** ```js uploadTask.off('headerReceive', function callback(headers) { @@ -264,12 +271,13 @@ remove(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Upload -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 移除任务是否成功。true:成功,false:不成功。 | -- 示例 +**示例:** ```js uploadTask.remove().then((result) => { @@ -294,12 +302,13 @@ remove(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Upload -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 移除任务的回调函数。 | -- 示例 +**示例:** ```js uploadTask.remove((err, result) => { @@ -361,17 +370,19 @@ download(config: DownloadConfig): Promise<DownloadTask> **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [DownloadConfig](#downloadconfig) | 是 | 下载的配置信息。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<[DownloadTask](#downloadtask)> | 返回下载任务。 | -- 示例 +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { @@ -392,13 +403,14 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v **系统能力**: SystemCapability.MiscServices.Download -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [DownloadConfig](#downloadconfig) | 是 | 下载的配置信息。 | | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 否 | 下载接口的回调函数。 | -- 示例 +**示例:** ```js request.download({ url: 'https://xxxx/xxxxx.hap', @@ -427,8 +439,9 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型,取值为'progress'(下载的进度信息)。 | | callback | function | 是 | 下载的回调函数。 | @@ -440,7 +453,7 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo | receivedSize | number | 是 | 当前下载的进度,单位为KB。 | | totalSize | number | 是 | 下载文件的总大小,单位为KB。 | -- 示例: +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -467,8 +480,9 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型,取值为'progress'(下载的进度信息)。 | | callback | function | 否 | 下载任务的回调函数。 | @@ -480,7 +494,7 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => | receivedSize | number | 是 | 当前下载的进度。 | | totalSize | number | 是 | 下载文件的总大小。 | -- 示例: +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -507,13 +521,14 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型。
- 取值为'complete',表示下载任务完成;
- 取值为'pause',表示下载任务暂停;
- 取值为'remove',表示下载任务移除。 | | callback | function | 是 | 回调函数。 | -- 示例: +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -540,13 +555,14 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型。
- 取值为'complete',表示下载任务完成;
- 取值为'pause',表示下载任务暂停;
- 取值为'remove',表示下载任务移除。 | | callback | function | 否 | 回调函数。 | -- 示例: +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -573,8 +589,9 @@ on(type: 'fail', callback: (err: number) => void): void **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型,取值为'fail'(下载失败)。 | | callback | function | 是 | 下载失败的回调函数。 | @@ -585,7 +602,7 @@ on(type: 'fail', callback: (err: number) => void): void | -------- | -------- | -------- | -------- | | err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | -- 示例 +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -612,8 +629,9 @@ off(type: 'fail', callback?: (err: number) => void): void **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型,取值为'fail'(下载失败)。 | | callback | function | 否 | 取消下载失败的回调函数。 | @@ -624,7 +642,7 @@ off(type: 'fail', callback?: (err: number) => void): void | -------- | -------- | -------- | -------- | | err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | -- 示例 +**示例:** ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { @@ -651,12 +669,13 @@ remove(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Download -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 移除任务是否成功。 | -- 示例 +**示例:** ```js downloadTask.remove().then((result) => { @@ -681,12 +700,13 @@ remove(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Download -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 移除任务是否成功。 | -- 示例 +**示例:** ```js downloadTask.remove((err, result)=>{ @@ -713,12 +733,12 @@ query(): Promise<DownloadInfo> **系统能力**: SystemCapability.MiscServices.Download -- 参数: +**参数:** | 类型 | 说明 | | -------- | -------- | | Promise<[DownloadInfo](#downloadinfo7)> | 查询下载任务信息。 | -- 示例 +**示例:** ```js downloadTask.query().then((downloadInfo) => { @@ -739,12 +759,13 @@ query(callback: AsyncCallback<DownloadInfo>): void **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | 是 | 查询下载任务的回调函数。 | -- 示例: +**示例:** ```js downloadTask.query((err, downloadInfo)=>{ @@ -767,12 +788,13 @@ queryMimeType(): Promise<string> **系统能力**: SystemCapability.MiscServices.Download -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<string> | 查询下载任务的MimeType。 | -- 示例 +**示例:** ```js downloadTask.queryMimeType().then((data) => { @@ -793,12 +815,13 @@ queryMimeType(callback: AsyncCallback<string>): void; **系统能力**: SystemCapability.MiscServices.Download -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<string> | 是 | 查询下载任务的MimeType的回调函数。 | -- 示例 +**示例:** ```js downloadTask.queryMimeType((err, data)=>{ @@ -821,12 +844,13 @@ pause(): Promise<void> **系统能力**: SystemCapability.MiscServices.Download -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 暂停下载任务是否成功。 | -- 示例 +**示例:** ```js downloadTask.pause().then((result) => { @@ -851,12 +875,13 @@ pause(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Download -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 暂停下载任务的回调函数。 | -- 示例 +**示例:** ```js downloadTask.pause((err, result)=>{ @@ -883,12 +908,13 @@ resume(): Promise<void> **系统能力**: SystemCapability.MiscServices.Download -- 参数: - | 类型 | 说明 | +**参数:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 重新启动暂停的下载任务是否成功。 | -- 示例 +**示例:** ```js downloadTask.resume().then((result) => { @@ -914,12 +940,13 @@ resume(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Download -- 参数 - | 参数名 | 参数类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | 是 | 重新启动暂停的下载任务的回调函数。 | -- 示例 +**示例:** ```js downloadTask.resume((err, result)=>{ @@ -947,7 +974,7 @@ resume(callback: AsyncCallback<void>): void | enableMetered | boolean | 否 | 允许在按流量计费的连接下下载。 | | enableRoaming | boolean | 否 | 允许在漫游网络中下载。 | | description | string | 否 | 设置下载会话的描述。 | -| filePath7+ | string | 否 | 设置下载路径(默认在[ERROR:Invalid link:zh-cn_topic_0000001135742582.xml#xref8132147102215,link:zh-cn_topic_0000001127125012.xml#section1856519365229](zh-cn_topic_0000001127125012.xml#section1856519365229)路径下)。
- filePath:'workspace/test.txt':默认路径下创建workspace路径,并将文件存储在workspace路径下。
- filePath:'test.txt':将文件存储在默认路径下。
- filePath:'workspace/':默认路径下创建workspace路径,并将文件存储在workspace路径下。 | +| filePath7+ | string | 否 | 设置下载路径(默认在'internal://cache/'路径下)。
- filePath:'workspace/test.txt':默认路径下创建workspace路径,并将文件存储在workspace路径下。
- filePath:'test.txt':将文件存储在默认路径下。
- filePath:'workspace/':默认路径下创建workspace路径,并将文件存储在workspace路径下。 | | networkType | number | 否 | 设置允许下载的网络类型。 | | title | string | 否 | 设置下载会话标题。 | 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 911c6faa7656fca84b127044cd0b55e38f66edcb..98647b2b1b395ef9f7594135fb7732eff4fc608f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -1,6 +1,6 @@ # 屏幕截图 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -13,7 +13,7 @@ import screenshot from '@ohos.screenshot'; 设置截取图像的信息。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 | 参数名 | 类型 | 必填 | 说明 | @@ -27,7 +27,7 @@ import screenshot from '@ohos.screenshot'; 表示截取图像的区域。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | @@ -41,7 +41,7 @@ import screenshot from '@ohos.screenshot'; 表示截取图像的大小。 -**系统能力**:以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.WindowManager.WindowManager.Core。 | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | @@ -54,7 +54,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) 获取屏幕截图。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **需要权限**:ohos.permission.CAPTURE_SCREEN @@ -94,15 +94,15 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> 获取屏幕截图。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **需要权限**:ohos.permission.CAPTURE_SCREEN **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation三个参数,需要分别设置这三个参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect、imageSize、rotation三个参数,需要分别设置这三个参数。 | **返回值:** 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 b6893023f20e063ec8cf8ab7f01b1609632a7d6c..2b2d824d1019b72cc3796462e163272d3d2fca7e 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 @@ -1,6 +1,6 @@ # 数据存储 -> ![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)。 > @@ -21,7 +21,7 @@ get(Object): void 通过索引读取缓存中存储的值。 -**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** @@ -61,7 +61,7 @@ set(Object): void 修改缓存中索引对应的值。 -**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** @@ -99,7 +99,7 @@ clear(Object): void 清空缓存中存储的键值对。 -**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** @@ -133,7 +133,7 @@ delete(Object): void 删除缓存中索引对应的键值对。 -**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index fed9e6b00426546f2ca02159afaf2fbc170c73c5..8fe3e976fc12825b8207e5b303635696c9db7984 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -1,5 +1,6 @@ # 设置系统时间 +本模块用来设置、获取当前系统时间,设置、获取当前系统日期和设置、获取当前系统时区。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -22,13 +23,14 @@ setTime(time : number, callback : AsyncCallback<void>) : void **系统能力:** SystemCapability.Miscservices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | + | time | number | 是 | 目标时间戳(ms)。 | | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | -- 示例: +**示例:** ```js // time对应的时间为2021-01-20 02:36:25 @@ -53,17 +55,19 @@ setTime(time : number) : Promise<void> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | + | time | number | 是 | 目标时间戳(ms)。 | + +**返回值:** -- 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 返回的异步回调函数。 | -- 示例: +**示例:** ```js // time对应的时间为2021-01-20 02:36:25 @@ -84,13 +88,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | -- 示例: +**示例:** ```js systemTime.getCurrentTime(true, (error, data) => { @@ -111,17 +116,19 @@ getCurrentTime(isNano?: boolean): Promise<number> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | -- 示例: +**示例:** ```js systemTime.getCurrentTime().then((data) => { @@ -140,13 +147,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | -- 示例: +**示例:** ```js systemTime.getRealActiveTime(true, (error, data) => { @@ -167,17 +175,19 @@ getRealActiveTime(isNano?: boolean): Promise<number> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来经过的时间,但不包括深度睡眠时间。 | -- 示例: +**示例:** ```js systemTime.getCurrentTime().then((data) => { @@ -196,13 +206,14 @@ getRealTime(callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。 | -- 示例: +**示例:** ```js systemTime.getRealTime(true, (error, data) => { @@ -223,17 +234,19 @@ getRealTime(): Promise<number> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来经过的时间,包括深度睡眠时间。 | -- 示例: +**示例:** ```js systemTime.getRealTime().then((data) => { @@ -254,13 +267,14 @@ setDate(date: Date, callback: AsyncCallback<void>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | date | Date | 是 | 目标日期。 | | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | -- 示例: +**示例:** ```js var data = new Date("October 13, 2020 11:13:00"); @@ -284,17 +298,19 @@ setDate(date: Date): Promise<void> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | date | Date | 是 | 目标日期。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 返回的异步回调函数。 | -- 示例: +**示例:** ```js var data = new Date("October 13, 2020 11:13:00"); @@ -314,12 +330,13 @@ getDate(callback: AsyncCallback<Date>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | -- 示例: +**示例:** ```js systemTime.getDate((error, data) => { @@ -340,12 +357,13 @@ getDate(): Promise<Date> **系统能力:** SystemCapability.MiscServices.Time -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | -- 示例: +**示例:** ```js systemTime.getDate().then((data) => { @@ -366,13 +384,14 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | timezone | string | 是 | 系统时区。 | | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | -- 示例: +**示例:** ```js systemTime.setTimezone('Asia/Shanghai', (error, data) => { @@ -395,17 +414,19 @@ setTimezone(timezone: string): Promise<void> **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | timezone | string | 是 | 系统时区。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 返回的异步回调函数。 | -- 示例: +**示例:** ```js systemTime.setTimezone('Asia/Shanghai').then((data) => { @@ -424,12 +445,13 @@ getTimezone(callback: AsyncCallback<string>): void **系统能力:** SystemCapability.MiscServices.Time -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | -- 示例: +**示例:** ```js systemTime.getTimezone((error, data) => { @@ -450,12 +472,13 @@ getTimezone(): Promise<string> **系统能力:** SystemCapability.MiscServices.Time -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<string> | 以Promise形式返回结果,返回系统时区。 | -- 示例: +**示例:** ```js systemTime.getTimezone().then((data) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index 0965e87e8be781726ae6844252f9f18171bd3602..8b29d3db39010ff58d7b15fb5afb4b7ecaae66f4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -1,6 +1,6 @@ # USB管理 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -15,9 +15,10 @@ getDevices(): Array<Readonly<USBDevice>> 获取USB设备列表。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **返回值:** + | 类型 | 说明 | | -------- | -------- | | Array<Readonly<[USBDevice](#usbdevice)>> | 设备信息列表。 | @@ -87,7 +88,7 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe> 需要调用[usb.getDevices](#usbgetdevices)获取设备信息以及device;再调用[usb.requestRight](#usbrequestright)获取设备请求权限。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -112,7 +113,7 @@ hasRight(deviceName: string): boolean 判断是否有权访问该设备。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -138,7 +139,7 @@ requestRight(deviceName: string): Promise<boolean> 请求软件包的临时权限以访问设备。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -167,7 +168,7 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): numbe 需要调用[usb.getDevices](#usbgetdevices)获取设备信息以及interfaces;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)接口得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -196,7 +197,7 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number 需要调用[usb.claimInterface](#usbclaiminterface)先获取接口,才能使用此方法释放接口。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -224,7 +225,7 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfig): number 需要调用[usb.getDevices](#usbgetdevices)获取设备信息以及config;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -252,7 +253,7 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number 需要调用[usb.getDevices](#usbgetdevices)获取设备列表以及interfaces;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -280,7 +281,7 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array 需要调用[usb.getDevices](#usbgetdevices)获取设备列表;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)接口得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -306,17 +307,18 @@ getFileDescriptor(pipe: USBDevicePipe): number 需要调用[usb.getDevices](#usbgetdevices)获取设备列表;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)接口得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定总线号和设备地址。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 返回设备对应的文件描述符。 | +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 返回设备对应的文件描述符。 | **示例:** ```js @@ -332,7 +334,7 @@ controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: nu 需要调用[usb.getDevices](#usbgetdevices)获取设备列表;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)接口得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -362,7 +364,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim 需要调用[usb.getDevices](#usbgetdevices)获取设备信息列表以及endpoint;再调用[usb.requestRight](#usbrequestright)获取设备请求权限;然后调用[usb.connectDevice](#usbconnectdevice)接口得到返回数据devicepipe之后,再次获取接口[usb.claimInterface](#usbclaiminterface);再调用usb.bulkTransfer接口。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -396,7 +398,7 @@ closePipe(pipe: USBDevicePipe): number 需要调用[usb.getDevices](#usbgetdevices)获取设备列表;调用[usb.requestRight](#usbrequestright)获取设备请求权限;调用[usb.connectDevice](#usbconnectdevice)得到devicepipe作为参数。 -**系统能力**: SystemCapability.USB.USBManager +**系统能力:** SystemCapability.USB.USBManager **参数:** | 参数名 | 类型 | 必填 | 说明 | 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 372ca96ad2be5c343d39b875e291607bddbd737b..6147c5a404c3ad81b3e16f31d35d3e745b52dd18 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -32,13 +32,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | -- 示例: +**示例:** ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -59,17 +60,19 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | -- 示例: +**示例:** ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -88,13 +91,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数 - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | -- 示例: +**示例:** ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -116,17 +120,19 @@ getId(wallpaperType: WallpaperType): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | -- 示例: +**示例:** ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -145,12 +151,13 @@ getMinHeight(callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | -- 示例: +**示例:** ```js wallpaper.getMinHeight((error, data) => { @@ -172,12 +179,13 @@ getMinHeight(): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | -- 示例: +**示例:** ```js wallpaper.getMinHeight().then((data) => { @@ -197,12 +205,13 @@ getMinWidth(callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | -- 示例: +**示例:** ```js wallpaper.getMinWidth((error, data) => { @@ -223,12 +232,13 @@ getMinWidth(): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | -- 示例: +**示例:** ```js wallpaper.getMinWidth().then((data) => { @@ -247,12 +257,13 @@ isChangePermitted(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | -- 示例: +**示例:** ```js wallpaper.isChangePermitted((error, data) => { @@ -273,12 +284,13 @@ isChangePermitted(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | -- 示例: +**示例:** ```js wallpaper.isChangePermitted().then((data) => { @@ -297,12 +309,13 @@ isOperationAllowed(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | -- 示例: +**示例:** ```js wallpaper.isOperationAllowed((error, data) => { @@ -323,12 +336,13 @@ isOperationAllowed(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | -- 示例: +**示例:** ```js wallpaper.isOperationAllowed().then((data) => { @@ -349,13 +363,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | -- 示例: +**示例:** ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -378,17 +393,19 @@ reset(wallpaperType: WallpaperType): Promise<void> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | -- 示例: +**示例:** ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -409,14 +426,15 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 | -- 示例: +**示例:** ```js // source类型为string @@ -462,18 +480,20 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | -- 示例: +**示例:** ```js // source类型为string @@ -514,13 +534,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | -- 示例: +**示例:** ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -542,17 +563,19 @@ getFile(wallpaperType: WallpaperType): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | -- 返回值: - | 类型 | 说明 | +**返回值:** + + | 类型 | 说明 | | -------- | -------- | | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | -- 示例: +**示例:** ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -571,13 +594,14 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取值为'colorChange',表示壁纸颜色变化结果上报事件。 | | callback | function | 是 | 壁纸颜色变化触发该回调方法,返回壁纸类型和壁纸的主要颜色信息。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | -- 示例: +**示例:** ```js let listener = (colors, wallpaperType) => { @@ -595,13 +619,14 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy **系统能力**: SystemCapability.MiscServices.Wallpaper -- 参数: - | 参数名 | 类型 | 必填 | 说明 | +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | -- 示例: +**示例:** ```js let listener = (colors, wallpaperType) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl.md b/zh-cn/application-dev/reference/apis/js-apis-webgl.md index a75ff297d84a092281fd83f60d067dfd2310094a..4665a9b2f71a6e21baffb1330f2eb7569976b99b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl.md @@ -1,6 +1,6 @@ # webgl -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -34,7 +34,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ## Type -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 **表1** Type @@ -62,7 +62,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ## Interface -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 **表2** Interface diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md index 59f475ff37f45ea7ae8ff4827ee3867d3947e720..aca7ad62d3759c953a3235563b2d57c1ad416f22 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md @@ -1,6 +1,6 @@ # webgl2 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -34,7 +34,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ## Type -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。 **表1** Type @@ -48,7 +48,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ## Interface -**系统能力**:以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。 **表2** Interface 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 aa4719cc458eac45456bc542fe32ecd7903bfdec..507f67d85cf93cf3b8c0abfc7546213e10b0236b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -1,10 +1,9 @@ # 窗口 -窗口提供管理窗口的一些基础能力,包括对窗口的创建、销毁,以及对串口的属性设置等各项功能。 +窗口提供管理窗口的一些基础能力,包括对窗口的创建、销毁,以及对窗口的属性设置等各项功能。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> ## 导入模块 @@ -16,7 +15,7 @@ import window from '@ohos.window'; 窗口类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 默认值 | 说明 | | ----------------- | ------ | ------------------ | @@ -27,7 +26,7 @@ import window from '@ohos.window'; 窗口内容需要规避区域的类型。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 默认值 | 说明 | | ----------- | ------ | ------------------ | @@ -40,7 +39,7 @@ import window from '@ohos.window'; 此接口为系统接口,三方应用不支持调用。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 默认值 | 说明 | | ---------- | ------ | ----------------------------- | @@ -54,7 +53,7 @@ import window from '@ohos.window'; 状态栏导航栏的属性。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | @@ -71,7 +70,7 @@ import window from '@ohos.window'; 此接口为系统接口,三方应用不支持调用。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | @@ -87,7 +86,7 @@ import window from '@ohos.window'; 此接口为系统接口,三方应用不支持调用。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ---------- | --------------------------------------------------- | ---- | ---- | -------------------------- | @@ -96,9 +95,9 @@ import window from '@ohos.window'; ## Rect7+ -矩形。 +窗口矩形区域。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | ------------------ | @@ -111,7 +110,7 @@ import window from '@ohos.window'; 表示窗口内容规避区域。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ---------- | ------------- | ---- | ---- | ------------------ | @@ -124,7 +123,7 @@ import window from '@ohos.window'; 窗口大小。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | ---------- | @@ -135,7 +134,7 @@ import window from '@ohos.window'; 窗口属性。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | @@ -156,7 +155,7 @@ import window from '@ohos.window'; 色域模式。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 | 名称 | 默认值 | 说明 | | ---------- | ------ | -------------- | @@ -171,7 +170,7 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi 从API version 8开始,此接口废弃,推荐使用[window.create8+](#windowcreate8)接口。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -204,7 +203,7 @@ create(id: string, type: WindowType): Promise<Window> 从API version 8开始,此接口废弃,推荐使用[window.create8+](#windowcreate8)接口。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -240,7 +239,7 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi 从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -274,7 +273,7 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> 从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -309,7 +308,7 @@ find(id: string, callback: AsyncCallback<Window>): void 查找id所对应的窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -338,7 +337,7 @@ find(id: string): Promise<Window> 查找id所对应的窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -371,7 +370,9 @@ getTopWindow(callback: AsyncCallback<Window>): void 获取当前应用内最后显示的窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +从API version 8开始,此接口废弃,推荐使用[window.getTopWindow8+](#windowgettopwindow8)接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -399,7 +400,9 @@ getTopWindow(): Promise<Window> 获取当前应用内最后显示的窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +从API version 8开始,此接口废弃,推荐使用[window.getTopWindow8+](#windowgettopwindow8)接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -426,7 +429,7 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void 获取当前应用内最后显示的窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -455,7 +458,7 @@ getTopWindow(ctx: Context): Promise<Window> 获取当前应用内最后显示的窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -490,7 +493,7 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -516,7 +519,7 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -544,7 +547,7 @@ hide (callback: AsyncCallback<void>): void 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -572,7 +575,7 @@ hide(): Promise<void> 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -597,7 +600,7 @@ show(callback: AsyncCallback<void>): void 显示当前窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -623,7 +626,7 @@ show(): Promise<void> 显示当前窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -648,7 +651,7 @@ destroy(callback: AsyncCallback<void>): void 销毁当前窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -674,7 +677,7 @@ destroy(): Promise<void> 销毁当前窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -699,7 +702,7 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void 移动窗口位置,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -728,7 +731,7 @@ moveTo(x: number, y: number): Promise<void> 移动窗口位置,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -760,7 +763,7 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v 改变当前窗口大小,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -788,7 +791,7 @@ resetSize(width: number, height: number): Promise<void> 改变当前窗口大小,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -822,7 +825,7 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -852,7 +855,7 @@ setWindowType(type: WindowType): Promise<void> 此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -884,7 +887,7 @@ getProperties(callback: AsyncCallback<WindowProperties>): void 获取当前窗口的属性,使用callback方式作为异步方法返回WindowProperties。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -910,7 +913,7 @@ getProperties(): Promise<WindowProperties> 获取当前窗口的属性,使用promise方式作为异步方法返回WindowProperties。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -935,7 +938,7 @@ getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): voi 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -963,7 +966,7 @@ getAvoidArea(type: AvoidAreaType): Promise<AvoidArea> 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -994,7 +997,7 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void 设置是否为全屏状态,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1022,7 +1025,7 @@ setFullScreen(isFullScreen: boolean): Promise<void> 设置是否为全屏状态,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1054,7 +1057,7 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void 设置窗口的布局是否为全屏显示状态,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1082,7 +1085,7 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> 设置窗口的布局是否为全屏显示状态,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1114,7 +1117,7 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac 设置导航栏、状态栏的可见模式,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1142,7 +1145,7 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> 设置导航栏、状态栏的可见模式,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1174,7 +1177,7 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async 设置窗口内导航栏、状态栏的属性,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1211,7 +1214,7 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi 设置窗口内导航栏、状态栏的属性,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1252,7 +1255,7 @@ loadContent(path: string, callback: AsyncCallback<void>): void 当前窗口加载具体页面内容,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1279,7 +1282,7 @@ loadContent(path: string): Promise<void> 当前窗口加载具体页面内容,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1310,7 +1313,7 @@ isShowing(callback: AsyncCallback<boolean>): void 判断当前窗口是否已显示,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1336,7 +1339,7 @@ isShowing(): Promise<boolean> 判断当前窗口是否已显示,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1361,7 +1364,7 @@ on(type: 'windowSizeChange', callback: Callback<Size>): void 开启监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1385,7 +1388,7 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void 关闭监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1407,7 +1410,7 @@ on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void 开启监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1431,7 +1434,7 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void 关闭监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1455,7 +1458,7 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1481,7 +1484,7 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1503,7 +1506,7 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void 判断当前窗口是否支持广色域模式,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1529,7 +1532,7 @@ isSupportWideGamut(): Promise<boolean> 判断当前窗口是否支持广色域模式,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1554,7 +1557,7 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void 设置当前窗口为广色域模式或默认色域模式,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1581,7 +1584,7 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> 设置当前窗口为广色域模式或默认色域模式,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1612,7 +1615,7 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void 获取当前窗口色域模式,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1638,7 +1641,7 @@ getColorSpace(): Promise<ColorSpace> 获取当前窗口色域模式,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1665,7 +1668,7 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1695,7 +1698,7 @@ setBackgroundColor(color: string): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1729,7 +1732,7 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1759,7 +1762,7 @@ setBrightness(brightness: number): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1793,7 +1796,7 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1822,7 +1825,7 @@ setDimBehind(dimBehindValue: number): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1855,7 +1858,7 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1885,7 +1888,7 @@ setFocusable(isFocusable: boolean): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1919,7 +1922,7 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1949,7 +1952,7 @@ setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1983,7 +1986,7 @@ setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): vo 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2012,7 +2015,7 @@ setOutsideTouchable(touchable: boolean): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2045,7 +2048,7 @@ setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): voi 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2076,7 +2079,7 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2110,7 +2113,7 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2141,7 +2144,7 @@ setTouchable(isTouchable: boolean): Promise<void> 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2171,7 +2174,7 @@ setTouchable(isTouchable: boolean): Promise<void> WindowStage生命周期。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core +**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core | 名称 | 默认值 | 说明 | | ---------- | ------ | -------- | @@ -2190,7 +2193,7 @@ getMainWindow(): Promise<Window> 获取该WindowStage实例下的主窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -2222,7 +2225,7 @@ getMainWindow(callback: AsyncCallback<Window>): void 获取该WindowStage实例下的主窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2255,7 +2258,7 @@ createSubWindow(name: string): Promise<Window> 创建该WindowStage实例下的子窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2293,7 +2296,7 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void 创建该WindowStage实例下的子窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2328,7 +2331,7 @@ getSubWindow(): Promise<Array<Window>> 获取该WindowStage实例下的所有子窗口,使用Promise方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -2360,7 +2363,7 @@ getSubWindow(callback: AsyncCallback<Array<Window>>): void 获取该WindowStage实例下的所有子窗口,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2393,7 +2396,7 @@ loadContent(path: string, callback: AsyncCallback<void>): void 为当前WindowStage的主窗口加载具体页面内容,使用callback方式作为异步方法。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Coretype为'windowSizeChange' +**系统能力:** SystemCapability.WindowManager.WindowManager.Coretype为'windowSizeChange' **参数:** @@ -2425,7 +2428,7 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType> 开启WindowStage生命周期变化的监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2454,7 +2457,7 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g 关闭WindowStage生命周期变化的监听。 -**系统能力**:SystemCapability.WindowManager.WindowManager.Core +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index b9c0fbfb166fab6f2c22f60630af11cda0a18a40..c21dd3c89091814a4e2fabfd31fbe34481b49fa6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -39,9 +39,10 @@ SideBarContainer( type?: SideBarContainerType ) | showSideBar | boolean | true | 设置是否显示侧边栏。 | | controlButton | ButtonStyle | - | 设置侧边栏控制按钮的属性。 | | showControlButton | boolean | true | 设置是否显示控制按钮。 | -| sideBarWidth | number | 200 | 设置侧边栏的宽度。 | -| minSideBarWidth | number | 200 | 设置侧边栏最小宽度。 | -| maxSideBarWidth | number | 280 | 设置侧边栏最大宽度。 | +| sideBarWidth | Length | 200 | 设置侧边栏的宽度。 | +| minSideBarWidth | Length | 200 | 设置侧边栏最小宽度。 | +| maxSideBarWidth | Length | 280 | 设置侧边栏最大宽度。 | +| autoHide9+ | boolean | true | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。 | - ButtonStyle对象说明 | 名称 | 参数类型 | 必填 | 默认值 | 描述 | diff --git a/zh-cn/application-dev/security/accesstoken-overview.md b/zh-cn/application-dev/security/accesstoken-overview.md index 0863c9152266fe1fd96da4d78c87e5d92ebb02bb..47f590536ab4066f4bc002bb9f46ff0d02c0d394 100644 --- a/zh-cn/application-dev/security/accesstoken-overview.md +++ b/zh-cn/application-dev/security/accesstoken-overview.md @@ -48,7 +48,7 @@ ATM(AccessTokenManager)是OpenHarmony上基于AccessToken构建的统一的应 ### 基本原则 -在进行权限的申请和使用时,需要满足以下以下基本原则: +在进行权限的申请和使用时,需要满足以下基本原则: - 应用申请的权限,都必须有明确、合理的使用场景和功能说明,确保用户能够清晰明了地知道申请权限的目的、场景、用途;禁止诱导、误导用户授权;应用使用权限必须与申请所述一致。 - 应用权限申请遵循最小化原则,只申请业务功能所必要的权限,禁止申请不必要的权限。 diff --git a/zh-cn/application-dev/ui/ts-application-resource-access.md b/zh-cn/application-dev/ui/ts-application-resource-access.md index 52e742cad26ac38489e7949ec835838b1d8b3223..84997c709c68214127c8af8d93912051b2e91f65 100644 --- a/zh-cn/application-dev/ui/ts-application-resource-access.md +++ b/zh-cn/application-dev/ui/ts-application-resource-access.md @@ -168,4 +168,4 @@ Image($rawfile('newDir/newTest.png')) //rawfile$r引用rawfile目录下图片 针对访问应用资源,有以下相关实例可供参考: -- [`ResourceManager`:资源管理器(eTS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/ResourceManager) +- [`ResourceManager`:资源管理器(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/ResourceManager) diff --git a/zh-cn/application-dev/ui/ui-js-animate-transform.md b/zh-cn/application-dev/ui/ui-js-animate-transform.md index 0a062acc8680b127fa23bcaad09c8839a5696702..4a0dfed33828eefabc90d42c648b875b4122ae0e 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-transform.md +++ b/zh-cn/application-dev/ui/ui-js-animate-transform.md @@ -580,11 +580,11 @@ transform可以设置多个值并且多个值可同时设置,下面案例中 针对transform样式动画开发,有以下相关实例可供参考: -- [`JsAnimation`:动效示例应用(JS)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation) +- [`JsAnimation`:动效示例应用(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation) -- [`JsAnimationStyle`:动画与自定义字体(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimationStyle) +- [`JsAnimationStyle`:动画与自定义字体(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimationStyle) -- [`Clock`:时钟(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock) +- [`Clock`:时钟(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock) - [动画样式(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo) diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-component.md b/zh-cn/application-dev/ui/ui-js-building-ui-component.md index e9650af37314da5249206dfb766e9bc75e575432..d57c8c901cca78e1cf07c9b13a11ebff581081d7 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-component.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-component.md @@ -25,19 +25,21 @@ 针对组件开发,有以下相关实例可供参考: -- [`JsPanel`:内容展示面板(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel) +- [`JsPanel`:内容展示面板(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel) -- [`Popup`:气泡(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Popup) +- [`Popup`:气泡(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Popup) -- [`RefreshContainer`:下拉刷新容器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/RefreshContainer) +- [`RefreshContainer`:下拉刷新容器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/RefreshContainer) - [`JSComponments`:Js组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSComponments) - [`JsUserRegistration`:用户注册(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsUserRegistration) -- [`ECG`:心率检测(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/ECG) +- [`ECG`:心率检测(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/ECG) -- [`Badge`:事件标记控件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) +- [`Badge`:事件标记控件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) + +- [`JsVideo`:视频播放(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsVideo) - [rating(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication) diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-routes.md b/zh-cn/application-dev/ui/ui-js-building-ui-routes.md index 93d3eecda18e5b38b75095ea133c73bc0442e2a9..eaa20d1aa8db22928bbd55d19447d71168de6ea6 100644 --- a/zh-cn/application-dev/ui/ui-js-building-ui-routes.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-routes.md @@ -89,4 +89,4 @@ export default { 针对页面路由开发,有以下相关实例可供参考: -- [`JsRouter`:页面路由(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsRouter) +- [`JsRouter`:页面路由(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsRouter) diff --git a/zh-cn/application-dev/ui/ui-js-component-tabs.md b/zh-cn/application-dev/ui/ui-js-component-tabs.md index 2a71638ee0828780b6623bf15823ca910e4e8f73..59421b9fefdaba9363a61368da04b71cc6821446 100644 --- a/zh-cn/application-dev/ui/ui-js-component-tabs.md +++ b/zh-cn/application-dev/ui/ui-js-component-tabs.md @@ -314,4 +314,4 @@ export default { 针对Tabs开发,有以下相关实例可供参考: -- [`Tabs`:页签容器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs) \ No newline at end of file +- [`Tabs`:页签容器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-canvas.md b/zh-cn/application-dev/ui/ui-js-components-canvas.md index a719fafcbe6836dbcc3ad784509e1e0d68ad05b5..5eb3b7ac4d5cf0051ad0db76c87755992abe339a 100644 --- a/zh-cn/application-dev/ui/ui-js-components-canvas.md +++ b/zh-cn/application-dev/ui/ui-js-components-canvas.md @@ -144,4 +144,4 @@ export default { 针对Canvas开发,有以下相关实例可供参考: -- [`JsCanvas`:画布组件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsCanvas) +- [`JsCanvas`:画布组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsCanvas) diff --git a/zh-cn/application-dev/ui/ui-js-components-chart.md b/zh-cn/application-dev/ui/ui-js-components-chart.md index 643471aa767b543ecf99f2289dd8ef6db81a33bb..7c4d1ee6d9907c5c2c12de9f638d42af1d20a254 100644 --- a/zh-cn/application-dev/ui/ui-js-components-chart.md +++ b/zh-cn/application-dev/ui/ui-js-components-chart.md @@ -619,6 +619,6 @@ export default { 针对Chart开发,有以下相关实例可供参考: -- [`Chart`:图表组件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) +- [`Chart`:图表组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) - [chart(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SwitchApplication) diff --git a/zh-cn/application-dev/ui/ui-js-components-dialog.md b/zh-cn/application-dev/ui/ui-js-components-dialog.md index f1374aa3c0d8818de784e9bb6846e18599aa6eb4..00e1f1c7cd5504c46acb79e9200024bd240cfe07 100644 --- a/zh-cn/application-dev/ui/ui-js-components-dialog.md +++ b/zh-cn/application-dev/ui/ui-js-components-dialog.md @@ -325,6 +325,6 @@ export default { 针对Dialog开发,有以下相关实例可供参考: -- [`JsDialog`:页面弹窗(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) +- [`JsDialog`:页面弹窗(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) - [dialog(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/DialogDemo) diff --git a/zh-cn/application-dev/ui/ui-js-components-grid.md b/zh-cn/application-dev/ui/ui-js-components-grid.md index ec3fd8941309b8b4208f9acd495072d3dd5b61d1..e17190343be5be83ce9093b5442358748db529d4 100644 --- a/zh-cn/application-dev/ui/ui-js-components-grid.md +++ b/zh-cn/application-dev/ui/ui-js-components-grid.md @@ -248,4 +248,4 @@ export default { 针对Grid开发,有以下相关实例可供参考: -- [`JsGrid`:栅格组件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsGrid) +- [`JsGrid`:栅格组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsGrid) 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 ddd7128a8a970c9f42902e9d594fe5c089fddd1f..858e7ce407f85079702f317a2d7af9d4f6ee5085 100644 --- a/zh-cn/application-dev/ui/ui-js-components-list.md +++ b/zh-cn/application-dev/ui/ui-js-components-list.md @@ -314,4 +314,4 @@ export default { 针对List开发,有以下相关实例可供参考: -- [`JsList`:商品列表(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsList) \ No newline at end of file +- [`JsList`:商品列表(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsList) \ No newline at end of file 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 e1d1d693887526c59f7c7d34277329a3bc3679fb..5f30f662d8b8b15cd4e41fba230ba359474bcae2 100644 --- a/zh-cn/application-dev/ui/ui-js-components-menu.md +++ b/zh-cn/application-dev/ui/ui-js-components-menu.md @@ -283,4 +283,4 @@ export default { 针对Menu开发,有以下相关实例可供参考: -- [`JSMenu`:菜单(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSMenu) +- [`JSMenu`:菜单(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSMenu) diff --git a/zh-cn/application-dev/ui/ui-js-components-picker.md b/zh-cn/application-dev/ui/ui-js-components-picker.md index 320db095a4801cadf7cf2542d6768cb6f9a04920..eea53de79480a2ed54a58a4fdcb20dc3d5be06e4 100644 --- a/zh-cn/application-dev/ui/ui-js-components-picker.md +++ b/zh-cn/application-dev/ui/ui-js-components-picker.md @@ -301,4 +301,4 @@ export default { 针对Picker开发,有以下相关实例可供参考: -- [`Picker`:滑动选择器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Picker) +- [`Picker`:滑动选择器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Picker) 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 a3d20f27f76a3863bda59d73817fc5bdc9cad37c..99bd1e3fda6630b6d02157cde16fe74e4f30aefe 100644 --- a/zh-cn/application-dev/ui/ui-js-components-slider.md +++ b/zh-cn/application-dev/ui/ui-js-components-slider.md @@ -217,6 +217,6 @@ export default{ 针对Slider开发,有以下相关实例可供参考: -- [`Slider`:滑动条(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Slider) +- [`Slider`:滑动条(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Slider) - [slider(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SliderApplication) \ No newline at end of file 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 9aa36109849562e9902a7158d8b02acf72243fb6..0c3489679485b33cd3f54c5a274cc9dda4b1479a 100644 --- a/zh-cn/application-dev/ui/ui-js-components-stepper.md +++ b/zh-cn/application-dev/ui/ui-js-components-stepper.md @@ -407,4 +407,4 @@ export default { 针对Stepper开发,有以下相关实例可供参考: -- [`StepNavigator`:步骤导航器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/StepNavigator) +- [`StepNavigator`:步骤导航器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/StepNavigator) diff --git a/zh-cn/application-dev/ui/ui-js-components-svg-overview.md b/zh-cn/application-dev/ui/ui-js-components-svg-overview.md index 34a0b1ef4e4b6962cb7f2e01fe1a8d14a16e7b0a..aa13c248a854c5864de1e5c504a198bd38bd0415 100644 --- a/zh-cn/application-dev/ui/ui-js-components-svg-overview.md +++ b/zh-cn/application-dev/ui/ui-js-components-svg-overview.md @@ -84,4 +84,4 @@ svg{ 针对Svg开发,有以下相关实例可供参考: -- [`JsSvg`:可缩放矢量图形(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsSvg) +- [`JsSvg`:可缩放矢量图形(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsSvg) 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 e4c539292598a383fec8aa029f604c5f94dfaa96..96cff3844a12a75cc5cba38f6ac3af4129e61ed4 100644 --- a/zh-cn/application-dev/ui/ui-js-components-swiper.md +++ b/zh-cn/application-dev/ui/ui-js-components-swiper.md @@ -369,4 +369,4 @@ export default { 针对Swiper开发,有以下相关实例可供参考: -- [`Swiper`:内容滑动容器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Swiper) +- [`Swiper`:内容滑动容器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Swiper) 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 7b005260d0c6d40837096e6d32fb06458ca0b5a0..6d71893d1d35313aae2528622eb4694d96cbf889 100644 --- a/zh-cn/application-dev/ui/ui-js-components-toolbar.md +++ b/zh-cn/application-dev/ui/ui-js-components-toolbar.md @@ -235,4 +235,4 @@ export default { 针对Toolbar开发,有以下相关实例可供参考: -- [`Toolbar`:工具栏(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Toolbar) +- [`Toolbar`:工具栏(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Toolbar) diff --git a/zh-cn/application-dev/ui/ui-js-custom-components.md b/zh-cn/application-dev/ui/ui-js-custom-components.md index b8b4e91d48990c467fb7a1a2692cd6e129623527..3537724b05e0b34b3bdc789bc891dedfc85fb376 100755 --- a/zh-cn/application-dev/ui/ui-js-custom-components.md +++ b/zh-cn/application-dev/ui/ui-js-custom-components.md @@ -103,6 +103,6 @@ 针对自定义组件开发,有以下相关实例可供参考: -- [`JSUICustomComponent`:自定义组件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSUICustomComponent) +- [`JSUICustomComponent`:自定义组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSUICustomComponent) - [自定义组件(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/JSCanvasComponet) diff --git a/zh-cn/application-dev/ui/ui-js-overview.md b/zh-cn/application-dev/ui/ui-js-overview.md index 4d541fbce55cddd6d7bc00fe1dea00a8a93b4efc..c94a28c66b7c6f45c80a8ed2b30a422de5f0450a 100755 --- a/zh-cn/application-dev/ui/ui-js-overview.md +++ b/zh-cn/application-dev/ui/ui-js-overview.md @@ -34,13 +34,13 @@ 基于JS扩展的类Web开发范式的方舟开发框架,有以下相关实例可供参考: -- [`AtomicLayout`:原子布局(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/AtomicLayout) +- [`AtomicLayout`:原子布局(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/AtomicLayout) - [`JsFA`:FA示例应用(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsFA) - [`JsShopping`:购物示例应用(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsShopping) -- [`Stack`:堆叠容器(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Stack) +- [`Stack`:堆叠容器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Stack) - [`JsAdaptivePortalList`:多设备自适应的效率型首页(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAdaptivePortalList) @@ -48,8 +48,8 @@ - [`JsGallery`:图库示例应用(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsGallery) -- [`AirQuality`:空气质量(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/common/AirQuality) +- [`AirQuality`:空气质量(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/AirQuality) -- [`Badge`:事件标记控件(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) +- [`Badge`:事件标记控件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) - [购物应用(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ShoppingOpenHarmony) diff --git a/zh-cn/application-dev/ui/ui-ts-components-web.md b/zh-cn/application-dev/ui/ui-ts-components-web.md index 7ab3f2cd2fe8ee0be7286b9600401665c31ba989..8d223f77587c83475f2720b8b62d11776af7e507 100644 --- a/zh-cn/application-dev/ui/ui-ts-components-web.md +++ b/zh-cn/application-dev/ui/ui-ts-components-web.md @@ -198,4 +198,4 @@ struct WebComponent { 针对Web开发,有以下相关实例可供参考: -- [`Web`:ArkUI-Web(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Web) \ No newline at end of file +- [`Web`:Web(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Web) \ No newline at end of file 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 57345d1720c689f987851f8dd69df2a8814eb9bd..b5ee557e6d2eb9a8d08b4b810a344a30aef11ae2 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 @@ -531,6 +531,6 @@ 针对创建简单视图,有以下示例工程可供参考: -- [eTSBuildCommonView](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/BuildCommonView) +- [`BuildCommonView`:创建简单视图(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/BuildCommonView) 本示例为构建了简单页面展示食物番茄的图片和营养信息,主要为了展示简单页面的Stack布局和Flex布局。 diff --git a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md index 380a6b8a0713c0d77c96ee464f05c153cb8700ff..11a08f36e61d599bc956732dce4019c26262fc80 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md @@ -152,5 +152,5 @@ listener.on('change', onPortrait) 针对媒体查询开发,有以下相关实例可供参考: -- [`MediaQuery`:Ets媒体查询(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/MediaQuery) +- [`MediaQuery`:媒体查询(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/MediaQuery) diff --git a/zh-cn/application-dev/ui/ui-ts-overview.md b/zh-cn/application-dev/ui/ui-ts-overview.md index 6aeb273bda5d7eb8914f5fe8a2cf7e5c4e27dbbc..bd01231a5e8f99cfd3ecb47b1f4f0a0b67708e98 100644 --- a/zh-cn/application-dev/ui/ui-ts-overview.md +++ b/zh-cn/application-dev/ui/ui-ts-overview.md @@ -63,13 +63,23 @@ - [`Canvas`:画布组件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Canvas) -- [`Drag`:ArkUI-拖拽事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Drag) +- [`Drag`:拖拽事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Drag) -- [`ArkUIAnimation`:Ets动画(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/ArkUIAnimation) +- [`ArkUIAnimation`:动画(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/ArkUIAnimation) -- [`Xcomponent`:ArkUI-XComponent(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/XComponent) +- [`Xcomponent`:XComponent(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/XComponent) -- [`MouseEvent`:ArkUI-鼠标事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/MouseEvent) +- [`MouseEvent`:鼠标事件(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/MouseEvent) + +- [`Gallery`:组件集合(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Gallery) + +- [`BringApp`:拉起系统应用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/BringApp) + +- [`Clock`:简单时钟(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Preset/Clock) + +- [`Flybird`:小鸟避障游戏(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/Flybird) + +- [`News`:新闻浏览(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/News) - [极简声明式UI范式(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SimpleGalleryEts) 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 7aaf302a3043f9699a41bd37517bc2b8c5fec6d0..02db871f12db11b97be6d30f1bb23d21a86e2e30 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 @@ -267,6 +267,6 @@ 针对页面布局与连接,有以下示例工程可供参考: -- [eTSDefiningPageLayoutAndConnection](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/DefiningPageLayoutAndConnection) +- [`DefiningPageLayoutAndConnection`:页面布局和连接(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/DefiningPageLayoutAndConnection) 本示例构建了食物分类列表页面和食物详情页,向开发者展示了List布局、Grid布局以及页面路由的基本用法。 diff --git a/zh-cn/application-dev/webgl/webgl-guidelines.md b/zh-cn/application-dev/webgl/webgl-guidelines.md index 48e4c98715f74acb9729f37f7cadbefe94182b5d..f447acd3a74f932a8b9db94a25b2b2cb4c1eb112 100644 --- a/zh-cn/application-dev/webgl/webgl-guidelines.md +++ b/zh-cn/application-dev/webgl/webgl-guidelines.md @@ -699,3 +699,9 @@ WebGL主要帮助开发者在前端开发中完成图形图像的相关处理, **图2** 点击按钮绘制彩色三角形的效果图 ![zh-cn_image_0000001192429306](figures/zh-cn_image_0000001192429306.gif) + +## 相关实例 + +针对WebGL开发,有以下相关实例可供参考: + +- [`JsWbgGL`:WebGL(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Graphics/JsWebGL) diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 171986129c78889c3d24ecd7ffb26eaea20b7ddc..41f14d945e63247a875960bb3c33ce1ed22a17d2 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -558,7 +558,6 @@ - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) - 接口参考 - Ability框架 - - [@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) @@ -601,78 +600,66 @@ - [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.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) - [EventHub (EventHub)](reference/apis/js-apis-eventhub.md) - - 应用程序包管理 - - - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.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) + - 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.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) - - 媒体 - - - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) + - 媒体 + - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) - [@ohos.multimedia.camera (相机管理)](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image (图片处理)](reference/apis/js-apis-image.md) - [@ohos.multimedia.media (媒体服务)](reference/apis/js-apis-media.md) - [@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.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - - 定制管理 - - - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) + - 定制管理 + - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) - [@ohos.enterpriseDeviceManager (企业设备管理)](reference/apis/js-apis-enterprise-device-manager.md) - - 安全 - - - [@ohos.abilityAccessCtrl (访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.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) - - 数据管理 - - - [@ohos.data.dataAbility (DataAbility谓词)](reference/apis/js-apis-data-ability.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.preferences (首选项)](reference/apis/js-apis-data-preferences.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) - - 文件管理 - - - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) + - 文件管理 + - [@ohos.document (文件交互)](reference/apis/js-apis-document.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) - [@ohos.volumeManager (卷管理)](reference/apis/js-apis-volumemanager.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) @@ -680,24 +667,19 @@ - [@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) - - 网络管理 - [@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) - - 通信与连接 - - [@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) @@ -713,9 +695,7 @@ - [@ohos.systemTime (设置系统时间)](reference/apis/js-apis-system-time.md) - [@ohos.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) - [Timer (定时器)](reference/apis/js-apis-timer.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) @@ -733,15 +713,11 @@ - [@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) - - 语言基础类库 - - [@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) @@ -763,13 +739,10 @@ - [@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) diff --git a/zh-cn/application-dev/windowmanager/screenshot-guidelines.md b/zh-cn/application-dev/windowmanager/screenshot-guidelines.md index 749d93c7aafc2a69ab63484e2b85a65d9d36598d..0efd7e4205ffed5fbf567ce7d0041798c6432392 100644 --- a/zh-cn/application-dev/windowmanager/screenshot-guidelines.md +++ b/zh-cn/application-dev/windowmanager/screenshot-guidelines.md @@ -37,5 +37,5 @@ screenshot.save(ScreenshotOptions).then((image) => { ``` ## 相关实例 针对屏幕截图开发,有以下相关实例可供参考: -- [`Screenshot`:基础功能-屏幕截图(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Basic/Screenshot) +- [`Screenshot`:屏幕截图(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Basic/Screenshot) diff --git "a/zh-cn/contribute/\345\217\202\344\270\216\350\264\241\347\214\256.md" "b/zh-cn/contribute/\345\217\202\344\270\216\350\264\241\347\214\256.md" index 6c8c3f8fdf91f1c7f02cad449557630154cdfc82..913739bca6eb672cec8f98df532dbca10323d881 100755 --- "a/zh-cn/contribute/\345\217\202\344\270\216\350\264\241\347\214\256.md" +++ "b/zh-cn/contribute/\345\217\202\344\270\216\350\264\241\347\214\256.md" @@ -8,7 +8,7 @@ 您必须首先签署“开发者原创声明”,然后才能参与社区贡献。 -点击[这里](https://dco.openharmony.io/sign/Z2l0ZWUlMkZvcGVuX2hhcm1vbnk=)签署,点击[这里](https://dco.openharmony.io/check-sign-status)查询签署状态。 +点击[这里](https://dco.openharmony.cn/#/sign)签署,点击[这里](https://dco.openharmony.cn/#/check-sign-status)查询签署状态。 #### 行为准则 diff --git a/zh-cn/device-dev/driver/driver-hdf-development.md b/zh-cn/device-dev/driver/driver-hdf-development.md index 4afade3a32591e2a89737f374dc2cdd9ef693509..49bd0a14ab56cf5d63b6268a61949d95a4805f2d 100755 --- a/zh-cn/device-dev/driver/driver-hdf-development.md +++ b/zh-cn/device-dev/driver/driver-hdf-development.md @@ -3,7 +3,7 @@ ## 驱动模型介绍 -HDF框架以组件化的驱动模型作为核心设计思路,为开发者提供更精细化的驱动管理,让驱动开发和部署更加规范。HDF框架将一类设备驱动放在同一个host里面,开发者也可以将驱动功能分层独立开发和部署,支持一个驱动多个node,HDF驱动模型如下图所示: +HDF(Hardware Driver Foundation)框架以组件化的驱动模型作为核心设计思路,为开发者提供更精细化的驱动管理,让驱动开发和部署更加规范。HDF框架将一类设备驱动放在同一个host里面,开发者也可以将驱动功能分层独立开发和部署,支持一个驱动多个node。HDF驱动模型如下图所示: **图1** HDF驱动模型 @@ -12,7 +12,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 ## 驱动开发步骤 -基于HDF框架进行驱动的开发主要分为两个部分,驱动实现和驱动配置,详细开发流程如下所示: +基于HDF框架进行驱动的开发主要分为两个部分,驱动实现和驱动配置。详细开发流程如下所示: 1. 驱动实现 @@ -22,11 +22,11 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 ``` #include "hdf_device_desc.h" // HDF框架对驱动开发相关能力接口的头文件 - #include "hdf_log.h" // HDF 框架提供的日志接口头文件 + #include "hdf_log.h" // HDF框架提供的日志接口头文件 #define HDF_LOG_TAG "sample_driver" // 打印日志所包含的标签,如果不定义则用默认定义的HDF_TAG标签 - //驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架 + // 驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架 int32_t HdfSampleDriverBind(struct HdfDeviceObject *deviceObject) { HDF_LOGD("Sample driver bind success"); @@ -59,7 +59,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 .Release = HdfSampleDriverRelease, }; - // 调用HDF_INIT将驱动入口注册到HDF框架中,在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动,当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。 + // 调用HDF_INIT将驱动入口注册到HDF框架中,在加载驱动时HDF框架会先调用Bind函数,再调用Init函数加载该驱动,当Init调用异常时,HDF框架会调用Release释放驱动资源并退出 HDF_INIT(g_sampleDriverEntry); ``` @@ -79,7 +79,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 LOCAL_INCLUDE := #本驱动的头文件目录 LOCAL_SRCS := #本驱动的源代码文件 LOCAL_CFLAGS := #自定义的编译选项 - include $(HDF_DRIVER) #导入模板makefile完成编译 + include $(HDF_DRIVER) #导入Makefile模板完成编译 ``` 编译结果文件链接到内核镜像,添加到drivers/adapter/khdf/liteos目录下的hdf_lite.mk里面,示例如下: @@ -213,7 +213,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 - 驱动私有配置信息(可选) - 如果驱动有私有配置,则可以添加一个驱动的配置文件,用来填写一些驱动的默认配置信息,HDF框架在加载驱动的时候,会将对应的配置信息获取并保存在HdfDeviceObject 中的property里面,通过Bind和Init(参考步骤1)传递给驱动,驱动的配置信息示例如下: + 如果驱动有私有配置,则可以添加一个驱动的配置文件,用来填写一些驱动的默认配置信息,HDF框架在加载驱动的时候,会将对应的配置信息获取并保存在HdfDeviceObject中的property里面,通过Bind和Init(参考步骤1)传递给驱动,驱动的配置信息示例如下: ``` @@ -221,7 +221,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 SampleDriverConfig { sample_version = 1; sample_bus = "I2C_0"; - match_attr = "sample_config"; //该字段的值必须和device_info.hcs中的deviceMatchAttr值一致 + match_attr = "sample_config"; // 该字段的值必须和device_info.hcs中的deviceMatchAttr值一致 } } ``` @@ -235,7 +235,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 ``` -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 驱动加载方式支持按需加载和按序加载两种方式,具体使用方法如下: > > - 按需加载 @@ -249,7 +249,7 @@ HDF框架以组件化的驱动模型作为核心设计思路,为开发者提 > } DevicePreload; > ``` > -> 配置文件中preload 字段配成 0(DEVICE_PRELOAD_ENABLE),则系统启动过程中默认加载;配成1(DEVICE_PRELOAD_ENABLE_STEP2),当系统支持快启的时候,则在系统完成之后再加载这一类驱动,否则和DEVICE_PRELOAD_ENABLE含义相同;配成2(DEVICE_PRELOAD_DISABLE),则系统启动过程中默认不加载,支持后续动态加载,当用户态获取驱动服务(参考[消息机制](../driver/driver-hdf-message-management.md))时,如果驱动服务不存在,HDF框架会尝试动态加载该驱动。 +> 配置文件中preload字段配成0(DEVICE_PRELOAD_ENABLE),则系统启动过程中默认加载;配成1(DEVICE_PRELOAD_ENABLE_STEP2),当系统支持快启的时候,则在系统完成之后再加载这一类驱动,否则和DEVICE_PRELOAD_ENABLE含义相同;配成2(DEVICE_PRELOAD_DISABLE),则系统启动过程中默认不加载,支持后续动态加载,当用户态获取驱动服务(参考[消息机制](../driver/driver-hdf-message-management.md))时,如果驱动服务不存在,HDF框架会尝试动态加载该驱动。 > > - 按序加载(需要驱动为默认加载) -> 配置文件中的priority(取值范围为整数0到200)是用来表示host和驱动的优先级,不同的host内的驱动,host的priority值越小,驱动加载优先级越高;同一个host内驱动的priority值越小,加载优先级越高。 +> 配置文件中的priority(取值范围为整数0到200)是用来表示host和驱动的优先级。不同的host内的驱动,host的priority值越小,驱动加载优先级越高;同一个host内驱动的priority值越小,加载优先级越高。 diff --git a/zh-cn/device-dev/driver/driver-hdf-manage.md b/zh-cn/device-dev/driver/driver-hdf-manage.md index a7f10fb632d742d0a76e52bb2f2d738db61a5351..483d60a3b6a0f89045e460803254aadde00c94a5 100644 --- a/zh-cn/device-dev/driver/driver-hdf-manage.md +++ b/zh-cn/device-dev/driver/driver-hdf-manage.md @@ -42,7 +42,7 @@ HCS配置语法保留了以下关键字。 ### 基本结构 -HCS主要分为属性(Attribute)和节点(Node)两种结构。 +HCS主要分为属性(Attribute)和节点(Node)两种结构。 **属性** @@ -53,7 +53,7 @@ HCS主要分为属性(Attribute)和节点(Node)两种结构。 attribute_name = value; ``` -- attribute_name 是**字母、数字、下划线**的组合且必须以字母或下划线开头,字母区分大小写。 +- attribute_name是**字母、数字、下划线**的组合且必须以字母或下划线开头,字母区分大小写。 - value的可用格式如下: @@ -61,7 +61,7 @@ HCS主要分为属性(Attribute)和节点(Node)两种结构。 - 字符串,内容使用双引号("")引用。 - 节点引用。 -- attribute 必须以分号(;)结束且必须属于一个node。 +- attribute必须以分号(;)结束且必须属于一个node。 **节点** @@ -75,7 +75,7 @@ HCS主要分为属性(Attribute)和节点(Node)两种结构。 } ``` -- node_name 是**字母、数字、下划线**的组合且必须以字母或下划线开头,字母区分大小写。 +- node_name是**字母、数字、下划线**的组合且必须以字母或下划线开头,字母区分大小写。 - 大括号后无需添加结束符“;”。 @@ -103,11 +103,11 @@ HCS主要分为属性(Attribute)和节点(Node)两种结构。 **字符串** -字符串使用双引号("")表示。 +字符串使用双引号("")表示。 **数组** -数组元素支持整型、字符串,不支持混合类型。整型数组中uint32_t uint64_t混用会向上转型为uint64_t 数组。整型数组与字符串数组示例如下: +数组元素支持整型、字符串,不支持混合类型。整型数组中uint32_t uint64_t混用会向上转型为uint64_t数组。整型数组与字符串数组示例如下: ``` @@ -132,7 +132,7 @@ bool类型中**true**表示真,**false**表示假。 #include "../bar.hcs" ``` -- 文件名必须使用双引号(""),不在同一目录使用相对路径引用。被include文件也必须是合法的HCS文件。 +- 文件名必须使用双引号(""),不在同一目录使用相对路径引用。被include文件也必须是合法的HCS文件。 - 多个include,如果存在相同的节点,后者覆盖前者,其余的节点依次展开。 @@ -157,7 +157,7 @@ bool类型中**true**表示真,**false**表示假。 */ ``` - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 多行注释不支持嵌套。 @@ -295,7 +295,7 @@ root { } ``` -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 在同一个HCS文件中不允许使用delete,建议直接删除不需要的属性。 @@ -403,14 +403,14 @@ options: -h show this help message ``` -生成.c/.h 配置文件方法: +生成.c/.h配置文件方法: ``` hc-gen -o [OutputCFileName] -t [SourceHcsFileName] ``` -生成HCB 配置文件方法: +生成HCB配置文件方法: ``` diff --git a/zh-cn/device-dev/driver/driver-hdf-sample.md b/zh-cn/device-dev/driver/driver-hdf-sample.md index a8e78b6998e0d415a2c225566486165783f426ff..1ae83ff0e1e231063b2552546c8162ebdafcb5c2 100644 --- a/zh-cn/device-dev/driver/driver-hdf-sample.md +++ b/zh-cn/device-dev/driver/driver-hdf-sample.md @@ -232,7 +232,7 @@ int main() } ``` -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 用户态应用程序使用了HDF框架中的消息发送接口,因此在编译用户态程序的过程中需要依赖HDF框架对外提供的hdf_core和osal的动态库,在gn编译文件中添加如下依赖项: > > deps = [ diff --git a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md index a7595b6a5398e207e05ff80533a9e334a6b837fd..09d32e8904a7259254ef7d09141176b7b7d7aa54 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md @@ -27,9 +27,9 @@ - 全功能执行器:执行器可独立处理一次凭据注册和身份认证请求,即可提供用户认证数据采集、处理、储存及比对能力。 - - 采集器:执行器提供用户认证时的数据采集能力,需要和认证期配合完成用户认证。 + - 采集器:执行器提供用户认证时的数据采集能力,需要和认证器配合完成用户认证。 - - 认证器:认证器提供用户认证是时数据处理,读取存储凭据模板信息并完成比对。 + - 认证器:认证器提供用户认证时数据处理能力,读取存储的凭据模板与当前认证信息完成比对。 - 执行器类型 @@ -37,15 +37,15 @@ - 用户认证框架公钥 & 执行器公钥 - 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架于基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交互各自的公钥,其中: + 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交换各自的公钥,其中: - 1)执行器通过用户认证框架公钥校验调度指令的准确性,如锁定一个口令模板,这种情况导致无法使用口令认证能力,属于敏感操作,需要确保指令准确,才可处理。 + 1)执行器通过用户认证框架公钥校验调度指令的准确性,例如一个口令模板被锁定后,相关口令认证能力无法使用。由于口令认证属于敏感操作,此时需要通过校验来确保调度指令的准确性后,方可进行后续解锁操作。 2)执行器公钥可被用户认证框架用于校验认证结果的准确性,同时用于执行器交互认证时的校验交互信息的完整性。 - 口令认证凭据模板 - 认证凭据时在用户设置认证凭据时由认证服务产生并存储,每个模板有一个ID。用于索引模板信息文件,再认证时读取模板信息并用于与当次认证过程中产生的认证数据做对比,完成身份认证。 + 认证凭据是在用户设置认证凭据时由认证服务产生并存储,每个模板有一个ID,用于索引模板信息文件,再认证时读取模板信息并用于与当次认证过程中产生的认证数据做对比,完成身份认证。 - 执行器对账 diff --git "a/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\345\212\237\350\203\275\346\225\264\344\275\223\346\241\206\346\236\266\345\233\276.png" "b/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\345\212\237\350\203\275\346\225\264\344\275\223\346\241\206\346\236\266\345\233\276.png" index a379fd8877a03b435912cd51fc221c6bb12449ca..42885a434a206446d0cc682b26148706c476371f 100644 Binary files "a/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\345\212\237\350\203\275\346\225\264\344\275\223\346\241\206\346\236\266\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\345\212\237\350\203\275\346\225\264\344\275\223\346\241\206\346\236\266\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\346\234\215\345\212\241\345\222\214faceauth\351\251\261\345\212\250\346\216\245\345\217\243.png" "b/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\346\234\215\345\212\241\345\222\214faceauth\351\251\261\345\212\250\346\216\245\345\217\243.png" index ff90b39b70486569ff01226df2f75955a66296f9..c026fa287b87d93578fb2b28d560f9cdbb527f7a 100644 Binary files "a/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\346\234\215\345\212\241\345\222\214faceauth\351\251\261\345\212\250\346\216\245\345\217\243.png" and "b/zh-cn/device-dev/driver/figures/\344\272\272\350\204\270\350\257\206\345\210\253\346\234\215\345\212\241\345\222\214faceauth\351\251\261\345\212\250\346\216\245\345\217\243.png" differ diff --git a/zh-cn/device-dev/kernel/kernel-standard-build.md b/zh-cn/device-dev/kernel/kernel-standard-build.md index 84a64a60f86070bb9d9946e6d0b3fd2f4554747a..f822f6daedab4504a3cb3ed29655f649b6c84bcc 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-build.md +++ b/zh-cn/device-dev/kernel/kernel-standard-build.md @@ -1,6 +1,7 @@ # Linux内核编译与构建指导 -- [开发示例1](#开发示例1) +- [Linux内核编译与构建指导](#linux内核编译与构建指导) + - [开发示例1](#开发示例1) ## 开发示例1 @@ -11,7 +12,7 @@ ``` -./build.sh --product-name Hi3516DV300 # 编译hi3516dv300镜像 - --build-target build_kernel # 编译hi3516dv300的uImage内核镜像 +./build.sh --product-name hispark_taurus_standard # 编译hispark_taurus_standard镜像 + --build-target build_kernel # 编译hispark_taurus_standard的uImage内核镜像 --gn-args linux_kernel_version=\"linux-5.10\" # 编译指定内核版本 ``` diff --git a/zh-cn/device-dev/porting/porting-linux-kernel.md b/zh-cn/device-dev/porting/porting-linux-kernel.md index 4d46702e6c156f6f7954c3c46125736de6802885..2dee67659185b5cef8ae4b0559c362f4dd21d46a 100644 --- a/zh-cn/device-dev/porting/porting-linux-kernel.md +++ b/zh-cn/device-dev/porting/porting-linux-kernel.md @@ -230,7 +230,7 @@ HDF(Hardware Driver Foundation)自测试用例,用于测试HDF框架和外 ``` - ./build.sh --product-name Hi3516DV300 --build-target hdf_test + ./build.sh --product-name hispark_taurus_standard --build-target hdf_test ``` 等待编译完成。 diff --git a/zh-cn/device-dev/porting/standard-system-porting-guide.md b/zh-cn/device-dev/porting/standard-system-porting-guide.md index f0a883211873d2e6dcb4cb07ab3d41d4375443b7..e3b284775f780df49a9d05091f22407e10c9ab40 100644 --- a/zh-cn/device-dev/porting/standard-system-porting-guide.md +++ b/zh-cn/device-dev/porting/standard-system-porting-guide.md @@ -24,7 +24,7 @@ "target_cpu": "arm", "ohos_version": "OpenHarmony 1.0", "device_company": "MyProductVendor", - "board": "MyProduct", + "board": "MySOC", "enable_ramdisk": true, "subsystems": [ { @@ -41,7 +41,7 @@ ``` 主要的配置内容 -product_name: 产品名称 必填 +product_name:产品名称 必填 version:版本 必填 @@ -101,7 +101,7 @@ product_company:不体现在配置中,而是目录名,vendor下一级目 }, ``` -接着需要修改定义产品的配置文件//productdefine/common/products/MyProduct.json,将刚刚定义的子系统加入到产品中。 +接着需要修改定义产品的配置文件//vendor/MyProductVendor/MyProduct/config.json,将刚刚定义的子系统加入到产品中。 ### 2. 编译内核 diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index 93f6cd8a77099718bb886726151c78a1531f0f00..79c9d4d7dae7fa1fce97d936389eb35b3f34ee86 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -61,6 +61,11 @@ - [编译](quickstart-ide-standard-running-hi3516-build.md) - [烧录](quickstart-ide-standard-running-hi3516-burning.md) - [运行](quickstart-ide-standard-running-hi3516-running.md) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-hi3751-create.md) + - [编译](quickstart-ide-standard-running-hi3751-build.md) + - [烧录](quickstart-ide-standard-running-hi3751-burning.md) + - [运行](quickstart-ide-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) - [编译](quickstart-ide-standard-running-rk3568-build.md) @@ -69,6 +74,7 @@ - 附录 - 开发板介绍 - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-ide-standard-board-introduction-hi3751.md) - [RK3568开发板介绍](quickstart-ide-standard-board-introduction-rk3568.md) - 标准系统快速入门(安装包方式) - [标准系统入门概述](quickstart-standard-overview.md) @@ -79,6 +85,11 @@ - [编译](quickstart-standard-running-hi3516-build.md) - [烧录](quickstart-standard-running-hi3516-burning.md) - [运行](quickstart-standard-running-hi3516-running.md) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-standard-running-hi3751-create.md) + - [编译](quickstart-standard-running-hi3751-build.md) + - [烧录](quickstart-standard-running-hi3751-burning.md) + - [运行](quickstart-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quickstart-standard-running-rk3568-create.md) - [编译](quickstart-standard-running-rk3568-build.md) @@ -91,5 +102,6 @@ - 附录 - 开发板介绍 - [Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-standard-board-introduction-hi3751.md) - [RK3568开发板介绍](quickstart-standard-board-introduction-rk3568.md) - [参考信息](quickstart-standard-reference.md) \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428163840.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428163840.png new file mode 100644 index 0000000000000000000000000000000000000000..2fffdf48b530fd0dd0635c6dd116562b715fecf8 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428163840.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428164441.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428164441.png new file mode 100644 index 0000000000000000000000000000000000000000..901e504ba50ac58c88126717e9cd0ff4791ae96e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428164441.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165528.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165528.png new file mode 100644 index 0000000000000000000000000000000000000000..c939684d3c5644e203176084b269b60f071cb724 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165528.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165737.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165737.png new file mode 100755 index 0000000000000000000000000000000000000000..131f768c3c4552b5a113e4cc230cef0a19b26820 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428165737.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428170003.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428170003.png new file mode 100644 index 0000000000000000000000000000000000000000..e5de0e51f4f737bd3fcb45d3ef88ee42dce86984 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428170003.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428183538.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428183538.png new file mode 100644 index 0000000000000000000000000000000000000000..a5454246edbd3b4aa6139359085b8684ba668e5e Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428183538.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185417.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185417.png new file mode 100644 index 0000000000000000000000000000000000000000..867f30a5be8828c91a641176ee799b0b34992002 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185417.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185546.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185546.png new file mode 100644 index 0000000000000000000000000000000000000000..e3290c264a70b46d5fed530270c781239990d226 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428185546.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428190729.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428190729.png new file mode 100644 index 0000000000000000000000000000000000000000..2466421c9b52fa7af8548b8ca3ff00362d200149 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428190729.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191331.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191331.png new file mode 100644 index 0000000000000000000000000000000000000000..a32a186ea2e7163894f8ffb9a2111c53240c2a27 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191331.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191437.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191437.png new file mode 100644 index 0000000000000000000000000000000000000000..e325ca0dbea9e7209dd1f3296e8102944b57928f Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428191437.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192044.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192044.png new file mode 100644 index 0000000000000000000000000000000000000000..1ff75351c5dd5664649fd9b83a8638ff57ddb0c3 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192044.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192849.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192849.png new file mode 100755 index 0000000000000000000000000000000000000000..51fe8d8f6967da61698ab20a1ca5e5f30d12fb65 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428192849.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428194317.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428194317.png new file mode 100755 index 0000000000000000000000000000000000000000..96c09ac56127155b5f520fcf69ec062885f2a460 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428194317.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428195249.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428195249.png new file mode 100644 index 0000000000000000000000000000000000000000..0cc4c306f74d7a516f00a9186206c77680981c66 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428195249.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428201119.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428201119.png new file mode 100644 index 0000000000000000000000000000000000000000..a884a743a8c7adc6de8af143658099566229ac76 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428201119.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428202139.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428202139.png new file mode 100644 index 0000000000000000000000000000000000000000..339ab5e8c290a3624649ab1d11ec069fe5b572e6 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220428202139.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429102934.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429102934.png new file mode 100755 index 0000000000000000000000000000000000000000..16d36626bacb685f59bc885b3fcb782824e90013 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429102934.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429104918.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429104918.png new file mode 100644 index 0000000000000000000000000000000000000000..7d95efd2e04d9b11636dd8642876f2ec494e4645 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429104918.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429105447.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429105447.png new file mode 100644 index 0000000000000000000000000000000000000000..5a287f836e126cc7258fcbf32a72d9313fbe58e4 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429105447.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429111229.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429111229.png new file mode 100644 index 0000000000000000000000000000000000000000..00bc2016c627a50408f44280d8ad7648de749573 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_20220429111229.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zn-cn_image_Hi3751V350.png b/zh-cn/device-dev/quick-start/figures/zn-cn_image_Hi3751V350.png new file mode 100644 index 0000000000000000000000000000000000000000..93eaaef2a928f255ae6eb00d506f6626adb2e648 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/zn-cn_image_Hi3751V350.png differ diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3751.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3751.md new file mode 100644 index 0000000000000000000000000000000000000000..1ab5d20b139d10dcebcb955b5fce1b0cc12b9e1c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-board-introduction-hi3751.md @@ -0,0 +1,20 @@ +# Hi3751开发板介绍 + + +## 开发板简介 + +HiSpark-Phoenix是基于海思Hi3751V350智能电视芯片的一块高性能开发板,内置高性能多核 ARM A53 CPU,多核MALI T450 GPU,支持NTSC/PAL/SECAM制式解调,支持DTMB/DVB-C/ATSC/ISDB-T等全球数字Demod,可以扩展DVB-T/T2/S/S2,支持USB播放,支持主流的视频格式包括MPGE2、H.264、H.265、RMVB、AVS+等,支持主流音频解码及音效处理,以及海思自研的SWS音效处理,支持LVDS和miniLVDS接口,支持主流的Tconless屏。 + + **图1** HiSpark_Phoenix单板正面外观图 + + ![zn-cn_image_Hi3751V350](figures/zn-cn_image_Hi3751V350.png) + + +## 开发板规格 + + **表1** HiSpark_Phoenix开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3751V350芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 支持2路立体声输入
  - 支持2路立体声输出
  - MicroHDMI(3路HDMI 1.4)
  - 3D GPU渲染
- 摄像头
- 显示屏
   - LCD连接器(7寸)
- 外部器件及接口
  - I2C接口
  - ADC接口
  - PWM 接口
  - 2个UART 接口
  - 3个USB2.0(Type C)
  - 功能按键2个,2个用户自定义按键
  - LED指示灯,绿灯,红灯
  - 支持NFC
  | 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 index ed8ec794b4c41d062627bf8da28791ab49535f4d..91274a742600a53732cc0169f26459faae212e5a 100644 --- 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 @@ -3,5 +3,5 @@ - **[Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md)** - +- **[Hi3751开发板介绍](quickstart-ide-standard-board-introduction-hi3751.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 index 2a5a0cd98d7d3891275b543fa610684dd5968a01..060cb41b75390f23b8a7a0d6efedd2533d1ecd21 100644 --- 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 @@ -28,6 +28,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - Hi3516DV300开发板Product选择“Hi3516DV300”。 > + > - Hi3751V350开发板Product选择“Hi3751V350”。 + > > - RK3568开发板Product选择“rk3568”。 ![zh-cn_image_0000001271448821](figures/zh-cn_image_0000001271448821.png) 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 index 48fef1c494d139ae3ec58ef49074571631d01f4f..13be8094a1bda4cc2d8d40c1341beba287af338c 100644 --- 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 @@ -20,8 +20,6 @@ ## 搭建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。 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 index 0b3ff6ea3b9896a9c816845be7223fc274b51bd2..798c3ef54147649b0a423623b7bbf74c4a9f2f40 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-overview.md @@ -28,7 +28,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, ## 开发板 -本文选取了两款典型开发板:Hi3516DV300、RK3568,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 +本文选取了三款典型开发板:Hi3516DV300、Hi3751V350和RK3568,并基于上述三款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 ## 开发流程 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 index c7048712ad9dab9171b7069981843f62d564f21f..642bf816d96fef213d80671647d11c13df1c4f58 100644 --- 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 @@ -19,9 +19,9 @@ applications/sample/hello ├── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── Hi3516DV300.json +vendor/hisilicon +└── Hi3516DV300 + └── config.json ``` @@ -151,7 +151,7 @@ productdefine/common 4. 修改产品配置文件。 - 在productdefine\common\products\Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 + 在vendor\hisilicon\Hi3516DV300\config.json中添加对应的hello部件,直接添加到原有部件后即可。 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-build.md new file mode 100644 index 0000000000000000000000000000000000000000..6edb21380962abe0a2bac29fe5d25e7a2bceaaa1 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-build.md @@ -0,0 +1,31 @@ +# 编译 + + +1. 在Projects中,点击**Settings**按钮,进入Hi3751V350配置界面。 + + ![zn-cn_image_20220428163840](figures/zn-cn_image_20220428163840.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)进行修改,完成尝试重新安装。 + + ![zn-cn_image_20220428164441](figures/zn-cn_image_20220428164441.png) + + 工具链自动安装完成后如下图所示。 + + ![zn-cn_image_20220428165528](figures/zn-cn_image_20220428165528.png) + +3. 在“hi3751v350”配置页签中,设置源码的编译类型**build_type**,默认为“debug“类型,请根据需要进行修改。然后点击**Save**按钮进行保存。 + + ![zn-cn_image_20220428165737](figures/zn-cn_image_20220428165737.png) + +4. 在“PROJECT TASKS”中,点击对应开发板下的**Build**按钮,执行编译。 + + ![zn-cn_image_20220428170003](figures/zn-cn_image_20220428170003.png) + + 等待**TERMINAL**窗口输出“SUCCESS”,编译完成。 + + ![zn-cn_image_20220428183538](figures/zn-cn_image_20220428183538.png) + + 编译完成后,可以在工程的**out**目录下,查看编译生成的文件,用于后续的[Hi3751V350开发板烧录](./quickstart-ide-standard-running-hi3751-burning.md)。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..0d9072b6c8289f93f58f31a76ec22d90e464ebcf --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-burning.md @@ -0,0 +1,104 @@ +# 烧录 + + +在Windows下采用网口烧录方式进行Hi3751V350的烧录。 + + +1. 请使用串口线连接电脑USB口和待烧录开发板miniUSB debug接口,同时需要连接开发板和电脑到同一个局域网,保证两侧网口可互通。 + +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,查看并记录对应的串口号。 + + ![zn-cn_image_20220428191331](figures/zn-cn_image_20220428191331.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3751V350/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zn-cn_image_20220428191437](figures/zn-cn_image_20220428191437.png) + +5. 在“hi3751v350”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、bootargs、bootargsbak、slaveboot等全部分区。 + - upload_port:选择已查询到的串口号,可通过Windows设备管理器查看。 + - upload_protocol:选择烧录协议,固定选择“hiburn-net”。 + + ![zn-cn_image_20220428192044](figures/zn-cn_image_20220428192044.png) + +6. 根据下表分别检查待烧录分区是否完整,DevEco Device Tool已按照默认的烧录分区文件配置烧录信息,可根据实际情况进行调整。 + + | 分区 | 烧录文件路径 | 内容 | + | --------- | ------- | ---- | + | fastboot | //out/hispark_phoenix/packages/phone/images/fastboot.bin | uboot镜像 | + | bootargs | //out/hispark_phoenix/packages/phone/images/bootargs.bin | 启动参数 | + | bootargsbak | //out/hispark_phoenix/packages/phone/images/bootargs.bin | 启动参数 | + | slaveboot | //out/hispark_phoenix/packages/phone/images/slaveboot.bin | 从核启动镜像 | + | panelparam | //out/hispark_phoenix/packages/phone/images/panel.img | 屏幕参数 | + | logo | //out/hispark_phoenix/packages/phone/images/logo.img | 开机logo | + | boot | //out/hispark_phoenix/packages/phone/images/uImage | 内核镜像 | + | ramdisk | //out/hispark_phoenix/ramdisk.img | RAMDisk启动镜像 | + | dtbo | //out/hispark_phoenix/packages/phone/images/dtbo.img | 内核DTS | + | atf | //out/hispark_phoenix/packages/phone/images/atf.bin | ARM trusted firmware | + | system | //out/hispark_phoenix/packages/phone/images/system.img | system分区镜像 | + | vendor | //out/hispark_phoenix/packages/phone/images/vendor.img | vendor分区镜像 | + | userdata | //out/hispark_phoenix/packages/phone/images/userdata.img | data分区镜像 | + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 特殊需要则可以按如下步骤进行手动配置 + + 1. 在“hi3751v350”页签中的“Partitions Options”,选择需要修改的分区,点击右侧的展开按钮,可配置如partition_type(分区类型)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zn-cn_image_20220428192849](figures/zn-cn_image_20220428192849.png) + + 2. 选中partition_bin,可自定义指定烧写文件。 + + 3. 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + 4. 按照相同的方法调整修改剩余烧录文件信息。 + +7. 在保证开发板和电脑连接到同一个局域网后,进行Hiburn_net网络配置,配置项如下表。 + |配置信息|介绍| + |-------|----| + |upload_net_server_ip|在烧录时作为server端向开发板传输镜像文件,此处为Windows IP。| + |upload_net_client_mask|设置开发板网络的掩码,与当前局域网掩码一致。| + |upload_net_client_gw|设置开发版本网络的网关,与当前局域网掩码一致。| + |upload_net_client_ip|设置开发板的IP,需要避免和当前网络环境的其他主机的IP冲突。| + + 1. 选择“Network Upload Options”栏配置“upload_net_server_ip”,工具将自动检测Windows主机的所有IP地址,然后需要手动选择IP,选择IP时要选择Windows主机和单板所在局域网的IP地址。 + + 2. 默认情况下“upload_net_client_mask”、“upload_net_client_gw”和“upload_net_client_ip”会在前一步选择IP后自动配置,依然需要根据当前局域网环境检查自动配置的信息,避免掩码错误,网关错误或者IP冲突,否则可能会导致烧录失败。 + + ![zn-cn_image_20220428194317](figures/zn-cn_image_20220428194317.png) + +8. 前述配置都调整修改完成后,在“hi3751v350”页签的顶部,点击**Save**进行保存。 + +9. 点击“PROJECT TASKS”下hi3751v350的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果开始烧录时,其他串口工具如MobaXterm连接了开发板的串口,则需要断开与开发板串口的连接,否则烧录会失败。 + + ![zn-cn_image_20220428195249](figures/zn-cn_image_20220428195249.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 点击“Upload”按钮后,会完整烧录第5点“upload_partitions”内容的所有分区。如要单独烧录某个分区, + > 则在“PROJECT TASKS”下点击对应的分区的**Upload**按钮,比如hi3751v350_fastboot。 + +10. 在终端窗口显示“Please power off, then power on the device”信息时,开关电源键对单板(下电并)上电,启动烧录。 + + ![zn-cn_image_20220428201119](figures/zn-cn_image_20220428201119.png) + + 启动烧录后,界面提示“SUCCESS”信息时,表示烧录成功。 + + ![zn-cn_image_20220428202139](figures/zn-cn_image_20220428202139.png) + +11. 烧录成功后,请根据“[运行](./quickstart-ide-standard-running-hi3751-running)”章节进行操作,启动系统。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-create.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-create.md new file mode 100644 index 0000000000000000000000000000000000000000..d8a38903b36c88c7fbec94fafccf2288b64bc58c --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-create.md @@ -0,0 +1,162 @@ +# 编写“Hello World”程序 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下。 + + +``` +applications/sample/hello +│── BUILD.gn +│── include +│ └── helloworld.h +│── src +│ └── helloworld.c +├── bundle.json +build +└── subsystem_config.json +vendor/hisilicon +└── hispark_phoenix + └── config.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. 修改产品配置文件。 + + 在vendor\hisilicon\hispark_phoenix\config.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-hi3751-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-running.md new file mode 100644 index 0000000000000000000000000000000000000000..a49d75214f9b5352e43a0169ed58560dc1822e43 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-hi3751-running.md @@ -0,0 +1,54 @@ +# 运行 + + +## 启动系统 + +烧录完成后通过以下步骤启动系统: + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 + +1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 + + ![zn-cn_image_20220429104918](figures/zn-cn_image_20220429104918.png) + +2. 重启开发板,进入串口检查是否有日志打印,是否能够输入。 + + ``` + # 可输入如下内容检查输入是否正常 + ls + cat /proc/version + ``` + ![zn-cn_image_20220429105447](figures/zn-cn_image_20220429105447.png) + +## 修改启动参数 + +默认情况,Hi3751V350不用修改启动参数,特殊需要可参考如下步骤修改。 + +1. 使用其他串口工具连接串口,在开发板上电时,按“ctrl + c”进入uboot。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在使用其他串口工具时,需要点击“TERMINAL”右侧删除按钮关闭Monitor串口。 + + ![zn-cn_image_20220429111229](figures/zn-cn_image_20220429111229.png) + +2. 通过以下命令按需调整修改启动参数、保存配置并重启,然后进入系统。 + + ``` + // 设置参数 + set bootargs 'hardware=Hi3751V350 selinux=1 firmware_class.path=/vendor/firmware/ console=ttyAMA0,115200 loglevel=7 no_console_suspend blkdevparts=mmcblk0:1M(fastboot),1M(bootargs),1M(bootargsbak),2M(slaveboot),40M(recovery),8M(panelparam),2M(deviceinfo),40M(logo),30M(boot),10M(ramdisk),1M(dtbo),2M(atf),8M(trustedcore),10M(securestore),1M(versioninfo),1M(misc),10M(bootmusic),10M(bootmusicsec),80M(tconparam),4M(demura),3307M(system)ro,300M(vendor)ro,50M(atv),60M(log),100M(cache),-(userdata) skip_initramfs initrd=0xc000000,0xa00000 init=/init root=/dev/ram0 mtdparts=hi_sfc:-(hi_sfc) pci=nomsi mem=1024M mmz=ddr,0,0,8M vmalloc=400M irqflood=20000 cgroup.memory=nokmem swapaccount=0' + + saveenv //保存 + reset //重启单板 + ``` + +## 运行“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-ide-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-create.md index 40beafc0ed8a27762ef6afbcdfb83ef93deb1fd0..3317bbbb2fc620fa0d2fd4282df3fdb1e3736048 100644 --- 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 @@ -19,9 +19,9 @@ applications/sample/hello ├── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── rk3568.json +vendor/hihope +└── rk3568 + └── config.json ``` @@ -150,7 +150,7 @@ productdefine/common 4. 修改产品配置文件。 - 在productdefine\common\products\rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 + 在vendor\hihope\rk3568\config.json中添加对应的hello部件,直接添加到原有部件后即可。 ``` "usb:usb_manager_native":{}, diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3751.md b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3751.md new file mode 100644 index 0000000000000000000000000000000000000000..de5ed4db5255e2647bfde1a4b323686115bc8fc3 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction-hi3751.md @@ -0,0 +1,20 @@ +# Hi3751开发板介绍 + + +## 开发板简介 + +HiSpark-Phoenix是基于海思Hi3751V350智能电视芯片的一块高性能开发板,内置高性能多核 ARM A53 CPU,多核MALI T450 GPU,支持NTSC/PAL/SECAM制式解调,支持DTMB/DVB-C/ATSC/ISDB-T等全球数字Demod,可以扩展DVB-T/T2/S/S2,支持USB播放,支持主流的视频格式包括MPGE2、H.264、H.265、RMVB、AVS+等,支持主流音频解码及音效处理,以及海思自研的SWS音效处理,支持LVDS和miniLVDS接口,支持主流的Tconless屏。 + + **图1** HiSpark_Phoenix单板正面外观图 + + ![zn-cn_image_Hi3751V350](figures/zn-cn_image_Hi3751V350.png) + + +## 开发板规格 + + **表1** HiSpark_Phoenix开发板规格清单 + +| 规格类型 | 规格清单 | +| -------- | -------- | +| **处理器及内部存储** | - Hi3751V350芯片
- DDR3 1GB
- eMMC4.5,8GB容量 | +| **外部器件** | - 以太网口
- 音频视频
  - 支持2路立体声输入
  - 支持2路立体声输出
  - MicroHDMI(3路HDMI 1.4)
  - 3D GPU渲染
- 摄像头
- 显示屏
   - LCD连接器(7寸)
- 外部器件及接口
  - I2C接口
  - ADC接口
  - PWM 接口
  - 2个UART 接口
  - 3个USB2.0(Type C)
  - 功能按键2个,2个用户自定义按键
  - LED指示灯,绿灯,红灯
  - 支持NFC
  | 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 index 23dc0e0349cb6a55d41c75dc5979ec4317b14929..df0f709271d2b935f0d24d70a666e59d4016abb8 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-board-introduction.md @@ -3,5 +3,5 @@ - **[Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md)** - +- **[Hi3751开发板介绍](quickstart-standard-board-introduction-hi3751.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-ide-directory.md b/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md index 9ca9bac3fd5dabcc59ec76a46edf3f56de7da6f5..47eb3d927af54262cfd6515cde008827dacdc1fb 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-ide-directory.md @@ -10,6 +10,11 @@ - [编译](quickstart-ide-standard-running-hi3516-build.md) - [烧录](quickstart-ide-standard-running-hi3516-burning.md) - [运行](quickstart-ide-standard-running-hi3516-running.md) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-hi3751-create.md) + - [编译](quickstart-ide-standard-running-hi3751-build.md) + - [烧录](quickstart-ide-standard-running-hi3751-burning.md) + - [运行](quickstart-ide-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quickstart-ide-standard-running-rk3568-create.md) - [编译](quickstart-ide-standard-running-rk3568-build.md) @@ -18,5 +23,6 @@ - 附录 - 开发板介绍 - [Hi3516开发板介绍](quickstart-ide-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-ide-standard-board-introduction-hi3751.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-overview.md b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md index 669cb227e46cd0f6488828daf2e0abb2a7a89942..8cd49215b3f9fb5267f0ceb5a034283568f92511 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-overview.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-overview.md @@ -28,7 +28,7 @@ OpenHarmony标准系统适用于参考内存≥128MiB的设备。通过本文, ## 开发板 -本文选取了两款典型开发板:Hi3516DV300、RK3516,并基于上述两款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 +本文选取了三款典型开发板:Hi3516DV300、Hi3751V350和RK3516,并基于上述三款开发板进行开发介绍。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-standard-board-introduction-hi3516.md),开发者可根据需要自行购买开发板。 ## 开发流程 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 index 0472dae64b11083fb2772b78a13ca6964282ba05..1273b8f05d8a6fc48e883dd270fe2c2c23a0070d 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-package-directory.md @@ -7,6 +7,11 @@ - [编译](quickstart-standard-running-hi3516-build.md) - [烧录](quickstart-standard-running-hi3516-burning.md) - [运行](quickstart-standard-running-hi3516-running.md) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-standard-running-hi3751-create.md) + - [编译](quickstart-standard-running-hi3751-build.md) + - [烧录](quickstart-standard-running-hi3751-burning.md) + - [运行](quickstart-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quickstart-standard-running-rk3568-create.md) - [编译](quickstart-standard-running-rk3568-build.md) @@ -19,6 +24,7 @@ - 附录 - 开发板介绍 - [Hi3516开发板介绍](quickstart-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-standard-board-introduction-rk3568.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-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md index 6e49f79f8e2ea6d3423fa5befad0bd0618ec69f1..12c95ef3cfb9833b988bbd37abdf21aafe008fac 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 @@ -45,4 +45,4 @@ OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build. 5. 编译结束后,出现“build success”字样,说明构建成功。 > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** - > 编译结果文件及编译日志文件获取路径:out/hi3516dv300。 + > 编译结果文件及编译日志文件获取路径:out/hispark_taurus。 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 b0cef24b4d2dba209ff14b954380a9e5061f91fc..e9f5296716d57588c9c3cace7a254a6270a1fb05 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 @@ -19,9 +19,9 @@ applications/sample/hello │ └── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── Hi3568DV300.json +vendor/hisilicon +└── Hi3516DV300 + └── config.json ``` @@ -151,7 +151,7 @@ productdefine/common 4. 修改产品配置文件。 - 在productdefine/common/products/Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 + 在vendor\hisilicon\Hi3516DV300\config.json中添加对应的hello部件,直接添加到原有部件后即可。 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-build.md new file mode 100644 index 0000000000000000000000000000000000000000..ee0ebe30f249705a8b7e769994355d1ea6fa9450 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-build.md @@ -0,0 +1,48 @@ +# 编译 + + +OpenHarmony支持hb和build.sh两种编译方式。此处介绍hb方式,build.sh脚本编译方式请参考[使用build.sh脚本编译源码](../quick-start/quickstart-standard-reference.md)。 + + +在Ubuntu环境下进入源码根目录,执行如下命令进行编译: + + +1. 设置编译路径。 + + ``` + hb set + ``` + +2. 选择当前路径。 + + ``` + . + ``` + +3. 在built-in下选择“hispark_phoenix”并回车。 + +4. 执行编译。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > - 单独编译一个部件(例如hello),可使用“hb build -T _目标名称_”进行编译。 + > + > - 增量编译整个产品,可使用“hb build”进行编译。 + > + > - 完整编译整个产品,可使用“hb build -f”进行编译。 + > + > 此处以完整编译整个产品为例进行说明。 + + + ``` + hb build -f + ``` + + + **图1** Hi3751V350编译设置图例 + + ![zn-cn_image_20220429102934](figures/zn-cn_image_20220429102934.png) + +5. 编译结束后,出现“build success”字样,则说明构建成功。 + + > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** + > 编译结果文件及编译日志文件获取路径:out/hispark_phoenix。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-burning.md new file mode 100644 index 0000000000000000000000000000000000000000..1cdd2efd289d17d951d13014cda491508b5d929d --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-burning.md @@ -0,0 +1,137 @@ +# 烧录 + + +在Windows下采用USB烧录方式进行Hi3751V350的烧录,具体步骤如下: + + +### 导入源码 + +在编译完成后,[保证Windows系统可以远程访问Ubuntu环境](../quick-start/quickstart-standard-env-setup.md)的情况下,您还需要通过以下步骤导入源码后,方可进行烧录。 + +1. 打开DevEco Device Tool,进入Home页,点击**Import Project**打开工程。 + + ![zn-cn_image_20220428185417](figures/zn-cn_image_20220428185417.png) + +2. 选择要导入的源码目录(需要访问Ubuntu下的源码目录),点击**Import**打开。 + + ![zn-cn_image_20220428185546](figures/zn-cn_image_20220428185546.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源码版本。此处Product选择“hispark_phoenix”。 + + ![zn-cn_image_20220428190729](figures/zn-cn_image_20220428190729.png) + +6. 点击**Open**打开工程或源码。 + + +### 烧录 + + +完成源码导入后,通过以下步骤进行烧录: + + +1. 请使用串口线连接电脑USB口和待烧录开发板miniUSB debug接口,同时需要连接开发板和电脑到同一个局域网,保证两侧网口可互通。 + +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,查看并记录对应的串口号。 + + ![zn-cn_image_20220428191331](figures/zn-cn_image_20220428191331.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果对应的串口异常,请根据[Hi3516DV300/Hi3751V350/Hi3518EV300开发板串口驱动安装指导](https://device.harmonyos.com/cn/docs/documentation/guide/hi3516_hi3518-drivers-0000001050743695)安装USB转串口的驱动程序。 + +4. 在QUICK ACCESS > DevEco Home > Projects中,点击**Settings**打开工程配置界面。 + + ![zn-cn_image_20220428191437](figures/zn-cn_image_20220428191437.png) + +5. 在“hi3751v350”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 + + - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、bootargs、bootargsbak、slaveboot等全部分区。 + - upload_port:选择已查询到的串口号,可通过Windows设备管理器查看。 + - upload_protocol:选择烧录协议,固定选择“hiburn-net”。 + + ![zn-cn_image_20220428192044](figures/zn-cn_image_20220428192044.png) + +6. 根据下表分别检查待烧录分区是否完整,DevEco Device Tool已按照默认的烧录分区文件配置烧录信息,可根据实际情况进行调整。 + + | 分区 | 烧录文件路径 | 内容 | + | --------- | ------- | ---- | + | fastboot | //out/hispark_phoenix/packages/phone/images/fastboot.bin | uboot镜像 | + | bootargs | //out/hispark_phoenix/packages/phone/images/bootargs.bin | 启动参数二进制 | + | bootargsbak | //out/hispark_phoenix/packages/phone/images/bootargs.bin | 启动参数二进制 | + | slaveboot | //out/hispark_phoenix/packages/phone/images/slaveboot.bin | 从核启动镜像 | + | panelparam | //out/hispark_phoenix/packages/phone/images/panel.img | 屏幕参数 | + | logo | //out/hispark_phoenix/packages/phone/images/logo.img | 开机logo | + | boot | //out/hispark_phoenix/packages/phone/images/uImage | 内核镜像 | + | ramdisk | //out/hispark_phoenix/ramdisk.img | RAMDisk启动镜像 | + | dtbo | //out/hispark_phoenix/packages/phone/images/dtbo.img | 内核DTS | + | atf | //out/hispark_phoenix/packages/phone/images/atf.bin | ARM trusted firmware | + | system | //out/hispark_phoenix/packages/phone/images/system.img | system分区镜像 | + | vendor | //out/hispark_phoenix/packages/phone/images/vendor.img | vendor分区镜像 | + | userdata | //out/hispark_phoenix/packages/phone/images/userdata.img | data分区镜像 | + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 特殊需要则可以按如下步骤进行手动配置 + + 1. 在“hi3751v350”页签中的“Partitions Options”,选择需要修改的分区,点击右侧的展开按钮,可配置如partition_type(分区类型)、partition_addr(烧录文件起始地址)、partition_length(烧录文件分区长度)等。 + + ![zn-cn_image_20220428192849](figures/zn-cn_image_20220428192849.png) + + 2. 选中partition_bin,可自定义指定烧写文件。 + + 3. 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 + + 4. 按照相同的方法调整修改剩余烧录文件信息。 + +7. 在保证开发板和电脑连接到同一个局域网后,进行Hiburn_net网络配置,配置项如下表。 + |配置信息|介绍| + |-------|----| + |upload_net_server_ip|在烧录时作为server端向开发板传输镜像文件,此处为Windows IP。| + |upload_net_client_mask|设置开发板网络的掩码,与当前局域网掩码一致。| + |upload_net_client_gw|设置开发版本网络的网关,与当前局域网掩码一致。| + |upload_net_client_ip|设置开发板的IP,需要避免和当前网络环境的其他主机的IP冲突。| + + 1. 选择“Network Upload Options”栏配置“upload_net_server_ip”,工具将自动检测Windows主机的所有IP地址,然后需要手动选择IP,选择IP时要选择Windows主机和单板所在局域网的IP地址。 + + 2. 默认情况下“upload_net_client_mask”、“upload_net_client_gw”和“upload_net_client_ip”会在前一步选择IP后自动配置,依然需要根据当前局域网环境检查自动配置的信息,避免掩码错误,网关错误或者IP冲突,否则可能会导致烧录失败。 + + ![zn-cn_image_20220428194317](figures/zn-cn_image_20220428194317.png) + +8. 前述配置都调整修改完成后,在“hi3751v350”页签的顶部,点击**Save**进行保存。 + +9. 点击“PROJECT TASKS”下hi3751v350的**Upload**按钮,启动烧录。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果开始烧录时,其他串口工具如MobaXterm连接了开发板的串口,则需要断开与开发板串口的连接,否则烧录会失败。 + + ![zn-cn_image_20220428195249](figures/zn-cn_image_20220428195249.png) + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 点击“Upload”按钮后,会完整烧录第5点“upload_partitions”内容的所有分区。如要单独烧录某个分区, + > 则在“PROJECT TASKS”下点击对应的分区的**Upload**按钮,比如hi3751v350_fastboot。 + +10. 在终端窗口显示Please power off, then power on the device信息时,开关电源键对单板(下电并)上电,启动烧录。 + + ![zn-cn_image_20220428201119](figures/zn-cn_image_20220428201119.png) + + 启动烧录后,界面提示“SUCCESS”信息时,表示烧录成功。 + + ![zn-cn_image_20220428202139](figures/zn-cn_image_20220428202139.png) + +11. 烧录成功后,请根据“[运行](./quickstart-ide-standard-running-hi3751-running)”章节进行操作,启动系统。 \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-create.md new file mode 100644 index 0000000000000000000000000000000000000000..1176a3ddc2324b10c1313317cabbd661a7f879b4 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-create.md @@ -0,0 +1,162 @@ +# 编写“Hello World”程序 + + +下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。 + + +## 示例目录 + +示例完整目录如下。 + + +``` +applications/sample/hello +│ │── BUILD.gn +│ │── include +│ │ └── helloworld.h +│ │── src +│ │ └── helloworld.c +│ └── bundle.json +build +└── subsystem_config.json +vendor/hisilicon +└── hispark_phoenix + └── config.json +``` + + +## 开发步骤 + +请在源码目录中通过以下步骤创建“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. 修改产品配置文件。 + + 在vendor\hisilicon\hispark_phoenix\config.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-hi3751-running.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-running.md new file mode 100644 index 0000000000000000000000000000000000000000..c852719b964cedf1357e665fb18995975a57d532 --- /dev/null +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3751-running.md @@ -0,0 +1,54 @@ +# 运行 + + +## 启动系统 + +烧录完成后在Windows下通过以下步骤启动系统: + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 初次烧写标准系统,需要完成以下配置,后续烧写或者启动,可以跳过以下操作。 + +1. 在DevEco Device Tool中,点击Monitor,打开串口工具。 + + ![zn-cn_image_20220429104918](figures/zn-cn_image_20220429104918.png) + +2. 重启开发板,进入串口检查是否有日志打印,是否能够输入。 + + ``` + # 可输入如下内容检查输入是否正常 + ls + cat /proc/version + ``` + ![zn-cn_image_20220429105447](figures/zn-cn_image_20220429105447.png) + +## 修改启动参数 + +默认情况,Hi3751V350不用修改启动参数,特殊需要可参考如下步骤修改。 + +1. 使用其他串口工具连接串口,在开发板上电时,按“ctrl + c”进入uboot。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 在使用其他串口工具时,需要点击“TERMINAL”右侧删除按钮关闭Monitor串口。 + + ![zn-cn_image_20220429111229](figures/zn-cn_image_20220429111229.png) + +2. 通过以下命令按需调整修改启动参数、保存配置并重启,然后进入系统。 + + ``` + // 设置参数 + set bootargs 'hardware=Hi3751V350 selinux=1 firmware_class.path=/vendor/firmware/ console=ttyAMA0,115200 loglevel=7 no_console_suspend blkdevparts=mmcblk0:1M(fastboot),1M(bootargs),1M(bootargsbak),2M(slaveboot),40M(recovery),8M(panelparam),2M(deviceinfo),40M(logo),30M(boot),10M(ramdisk),1M(dtbo),2M(atf),8M(trustedcore),10M(securestore),1M(versioninfo),1M(misc),10M(bootmusic),10M(bootmusicsec),80M(tconparam),4M(demura),3307M(system)ro,300M(vendor)ro,50M(atv),60M(log),100M(cache),-(userdata) skip_initramfs initrd=0xc000000,0xa00000 init=/init root=/dev/ram0 mtdparts=hi_sfc:-(hi_sfc) pci=nomsi mem=1024M mmz=ddr,0,0,8M vmalloc=400M irqflood=20000 cgroup.memory=nokmem swapaccount=0' + + saveenv //保存 + reset //重启单板 + ``` + +## 运行“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-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md index 0ad654203fc5a0fa892de27cf2d3173a2a7bbc9a..544792e495a058720ceee4a5639f3aa14bcf49ff 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 @@ -18,9 +18,9 @@ applications/sample/hello │ └── bundle.json build └── subsystem_config.json -productdefine/common -└── products - └── rk3568.json +vendor/hihope +└── rk3568 + └── config.json ``` @@ -149,7 +149,7 @@ productdefine/common 4. 修改产品配置文件。 - 在productdefine/common/products/rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 + 在vendor\hihope\rk3568\config.json中添加对应的hello部件,直接添加到原有部件后即可。 ``` "usb:usb_manager_native":{}, diff --git a/zh-cn/device-dev/subsystems/subsys-boot-overview.md b/zh-cn/device-dev/subsystems/subsys-boot-overview.md index 0e93b8dc847144259e83102ef9b63964c61021f4..db47d4345bcc2ba38c6bc54683a658c8c7998094 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-overview.md @@ -1,65 +1,343 @@ # 启动恢复子系统概述 + ## 启动恢复子系统上下文 -启动子系统上下文结构如下图所示。 +下图是启动子系统上下文结构图: + + **图1** 启动子系统上下文结构图 - **图1** 启动子系统上下文结构 - ![zh-cn_image_0000001217858866](figures/zh-cn_image_0000001217858866.png) 系统上电加载内核后,按照以下流程完成系统各个服务和应用的启动: 1. 内核加载init进程,一般在bootloader启动内核时通过设置内核的cmdline来指定init的位置。 - 2. init进程启动后,会挂载tmpfs,procfs,创建基本的dev设备节点,提供最基本的根文件系统。 - -3. init也会启动ueventd监听内核热插拔设备事件,为这些设备创建dev设备节点;各个分区设备(包括block设备)都是通过此事件创建。 - +3. init也会启动ueventd监听内核热插拔设备事件,为这些设备创建dev设备节点。包括block设备各个分区设备都是通过此事件创建。 4. init进程挂载block设备各个分区(system,vendor)后,开始扫描各个系统服务的init启动脚本,并拉起各个SA服务。 - 5. samgr是各个SA的服务注册中心,每个SA启动时,都需要向samgr注册,每个SA会分配一个ID,应用可以通过该ID访问SA。 - -6. foundation是一个特殊的SA服务进程,提供了用户程序管理框架及基础服务;由该进程负责应用的生命周期管理。 - +6. foundation是一个特殊的SA服务进程,提供了用户程序管理框架及基础服务。由该进程负责应用的生命周期管理。 7. 由于应用都需要加载JS的运行环境,涉及大量准备工作,因此appspawn作为应用的孵化器,在接收到foundation里的应用启动请求时,可以直接孵化出应用进程,减少应用启动时间。 -启动子系统内部包含以下组件: +启动子系统内部涉及以下组件: -- init启动引导组件 - init启动引导组件对应的进程为init进程,是内核完成初始化后启动的第一个用户态进程。init进程启动之后,读取init.cfg配置文件,根据解析结果,执行相应命令(见[第2章表2](../subsystems/subsys-boot-init.md))并依次启动各关键系统服务进程,在启动系统服务进程的同时设置其对应权限。 +- init启动引导组件: + init启动引导组件对应的进程为init进程,是内核完成初始化后启动的第一个用户态进程。init进程启动之后,读取init.cfg配置文件,根据解析结果,执行相应命令(见[第2章表2](../subsystems/subsys-boot-init.md)描述)并依次启动各关键系统服务进程,在启动系统服务进程的同时设置其对应权限。 -- ueventd启动引导组件 +- ueventd启动引导组件: ueventd负责监听内核设备驱动插拔的netlink事件,根据事件类型动态管理相应设备的dev节点。 -- appspawn应用孵化组件 +- appspawn应用孵化组件: 负责接收**用户程序框架**的命令孵化应用进程,设置新进程的权限,并调用应用程序框架的入口函数。 -- bootstrap服务启动组件 - 提供了各服务和功能的启动入口标识。在samgr启动时,会调用bootstrap标识的入口函数,并启动系统服务。 +- bootstrap服务启动组件: + 提供了各服务和功能的启动入口标识。在SAMGR启动时,会调用bootstrap标识的入口函数,并启动系统服务。 -- syspara系统属性组件 +- syspara系统属性组件: 系统属性组件,根据OpenHarmony产品兼容性规范提供获取设备信息的接口,如:产品名、品牌名、厂家名等,同时提供设置/读取系统属性的接口。 ## 约束与限制 - 下表为启动恢复子系统源代码目录和适配平台。 + 启动恢复子系统源代码目录和适配平台: **表1** 启动恢复子系统源代码目录和适配平台 -| 名称 | 适配平台 | +| 名称 | 适配平台 | | -------- | -------- | -| base/startup/appspawn_lite | 小型系统设备(参考内存 ≥ 1 MiB),如Hi3516DV300 、Hi3518EV300 | -| base/startup/bootstrap_lite | 轻量系统设备(参考内存 ≥ 128 KiB),如Hi3861V100 | -| base/startup/init_lite | 小型系统设备(参考内存 ≥ 1 MiB),如Hi3516DV300、Hi3518EV300 | -| base/startup/syspara_lite | - 轻量系统设备(参考内存 ≥ 128 KiB),如Hi3861V100
- 小型系统设备(参考内存 ≥ 1 MiB),如Hi3516DV300、Hi3518EV300 | +| base/startup/appspawn_lite | 小型系统设备(参考内存≥1MB),如Hi3516DV300 、Hi3518EV300 | +| base/startup/bootstrap_lite | 轻量系统设备(参考内存≥128KB),如Hi3861V100 | +| base/startup/init_lite | 小型系统设备(参考内存≥1MB),如Hi3516DV300、Hi3518EV300 | +| base/startup/syspara_lite | - 轻量系统设备(参考内存≥128KB),如Hi3861V100
- 小型系统设备(参考内存≥1MB),如Hi3516DV300、Hi3518EV300 | - init启动引导组件: - 每个系统服务启动时都需要编写各自的启动脚本文件init.cfg,定义各自的服务名、可执行文件路径、权限和其他信息。 - - 每个系统服务各自安装其启动脚本到/system/etc/init目录下,init进程统一扫描执行。 + - 每个系统服务各自安装其启动脚本到/system/etc/init目录下,init进程统一扫码执行。 + +- 新芯片平台移植时,平台相关的初始化配置需要增加平台相关的初始化配置文件/vendor/etc/init/init.{hardware}.cfg;该文件完成平台相关的初始化设置,如安装ko驱动,设置平台相关的/proc节点信息。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -- 新芯片平台移植时,平台相关的初始化配置需要增加平台相关的初始化配置文件/vendor/etc/init/init.{hardware}.cfg。该文件完成平台相关的初始化设置,如安装ko驱动,设置平台相关的/proc节点信息。配置文件init.cfg仅支持json格式。 + > 配置文件init.cfg仅支持json格式。 - bootstrap服务启动组件:需要在链接脚本中配置zInit代码段。 + +## 启动引导OpenHarmony标准系统的详细流程 + +当前OpenHarmony标准系统默认支持以下几个镜像: + +| 镜像名称 | 挂载点 | 说明 | +| ------------ | ------- | ---------------------------------------------------- | +| boot.img | NA | 内核和ramdisk镜像,bootloader加载的第一个镜像 | +| system.img | /system | 系统组件镜像,存放与芯片方案无关的平台业务 | +| vendor.img | /vendor | 芯片组件镜像,存放芯片相关的硬件抽象服务 | +| updater.img | / | 升级组件镜像,用于完成升级;正常启动时不加载次镜像 | +| userdata.img | /data | 可写的用户数据镜像 | + +每个开发板都需要在存储器上划分好分区来存放上述镜像,SOC启动时都由bootloader来加载这些镜像,具体过程包括以下几个大的步骤: + +- bootloader初始化ROM和RAM等硬件,加载分区表信息。 +- bootloader根据分区表加载boot.img,从中解析并加载ramdisk.img到内存中。 +- bootloader准备好分区表信息,ramdisk地址等信息,进入内核,内核加载ramdisk并执行init。 +- init准备初始文件系统,挂载required.fstab(包括system.img和vendor.img的挂载)。 +- 扫描system.img和vendor.img中etc/init目录下的启动配置脚本,执行各个启动命令。 + +### uboot启动引导过程 + +本文以常见的[uboot](https://elinux.org/U-Boot)为例介绍bootloader加载OpenHarmony各个系统镜像的关键过程。u-boot启动OpenHarmony系统时,主要通过bootargs向系统传递启动信息。 + +- u-boot加载解析boot.img + + - boot.img格式 + + boot.img镜像的构建和加载是与平台相关的,下面以OpenHarmony目前的一些主流平台为例进行介绍: + + - Hi3516DV300 + + 在Hi3516DV300平台上的boot.img采用了FIT(flattened image tree)格式,将kernel编译生成的zImage-dtb和cpio格式的ramdisk镜像通过打包工具Mkimage根据its文件中的信息打包生成一个镜像,这个镜像就是boot.img。 + + 下面对上述boot.img文件生成过程中使用的文件和工具进行简要介绍: + + 1. its文件 + + image source file,负责描述要生成的image的信息。需要自行构造,例如Hi3516平台中的ohos.its文件。 + + 2. Mkimage打包工具 + + 能够解析its文件,将其中按照其中镜像的配置将对应镜像打包生成itb文件,这里也就是boot.img文件。 + + 3. ramdisk + + 使用cpio打包的ramdisk.img镜像文件。 + + 4. zImage-dtb + + 包含压缩的内核镜像和设备描述文件镜像。 + + - rk3568 + + 在rk3568平台上相应的镜像文件为boot_linux.img,其中打包的文件与Hi3516DV300平台不尽相同,下面分别列举: + + 1. Image + + kernel编译生成的镜像文件。 + + 2. toybrick.dtb + + 类似于由dts编译而来的设备描述文件镜像。 + + 3. ramdisk.img + + 使用cpio打包的ramdisk.img镜像文件。 + + - u-boot加载 + + 支持了ramdisk的启动过程,此场景需要修改productdefine中的产品配置文件,通过"enable_ramdisk"开关开启ramdisk生成,这一部分与平台相关,不同的平台对于ramdisk 的处理方式不一样。以Hi3516DV300平台为例,需要将u-boot中的原启动参数修改为root=/dev/ram0 initrd=0x84000000,0x292e00。 + + +- u-boot进入 + + u-boot启动进入内核时,可以通过bootargs传递关键信息给内核,这一部分内容是与平台相关的,主要信息如下: + + | 名称 | 示例 | 说明 | + | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | + | initrd | 0x84000000,0x292e00 | 参考内核文档。
[ramfs-rootfs-initramfs.rst](https://gitee.com/openharmony/kernel_linux_5.10/blob/master/Documentation/filesystems/ramfs-rootfs-initramfs.rst)
[initrd.rst](https://gitee.com/openharmony/kernel_linux_5.10/blob/master/Documentation/admin-guide/initrd.rst) | + | init | /init | | + | blkdevparts | mmcblk0:1M(boot),15M(kernel),200M(system),200M(vendor),
2M(misc),20M(updater),-(userdata) | 分区表信息,kernel会根据此信息创建物理分区。 | + | hardware | Hi3516DV300、rk3568等 | (必要信息)硬件平台。 | + | root | /dev/ram0(Hi3516DV00)、root=PARTUUID=614e0000-0000 rw(rk3568) | kernel加载的启动设备。 | + | rootfstype | ext4 | 根文件系统类型。 | + | default_boot_device | soc/10100000.himci.eMMC | (建议配置信息)默认启动设备,在启动第一阶段会根据这个参数创建required设备的软链接。 | + +- init挂载required分区 + + 所谓required分区,就是系统启动引导过程的必要分区,必须在二级启动开始前进行挂载。比如system、vendor等必选镜像,挂载这些镜像前,需要先创建对应的块设备文件。这些块设备文件是通过内核上报UEVENT事件来创建的。init需要知道存储器的主设备目录,需要bootloader通过default_boot_device传递。 + + 目前init支持两种方式获取required分区信息,一是通过保存在/proc/cmdline中的bootargs,init会首先尝试从cmdline读取required分区信息;二是通过读取ramdisk中的fstab.required文件,只有在前一种方式获取失败的情况下才会尝试通过这种方式获取。 + + - 块设备的创建逻辑 + + - 准备工作 + + 1. init从cmdline中读取required fstab,若获取失败,则尝试读fstab.required文件,从中获取必须挂载的块设备的PARTNAME,例如system和vendor. + 2. 创建接收内核上报uevent事件广播消息的socket,从/proc/cmdline里读取default_boot_device。 + 3. 带着fstab信息和socket句柄遍历/sys/devices目录,准备开始触发内核上报uevent事件。 + + - 触发事件 + + 1. 通过ueventd触发内核上报uevent事件 + 2. 匹配uevent事件中的partitionName与required fstab中的device信息。 + 3. 匹配成功后将会进一步处理,格式化设备节点路径,准备开始创建设备节点。 + + - 创建节点 + + 1. 为了便于用户态下对设备节点的访问以及提高设备节点的可读性,会对即将创建的required块设备节点同时创建软链接,这就需要先格式化软链接的路径。 + 2. 以上工作都完成后,将执行最后的创建设备节点的步骤,根据传入的uevent中的主次设备号、前置步骤中构建的设备节点路径和软链接路径等创建设备节点,并创建相应软链接。 + + 至此,块设备节点创建完毕。 + + - 与default_boot_device匹配关系 + + 内核将bootargs信息写入/proc/cmdline,其中就包含了default_boot_device,这个值是内核当中约定好的系统启动必要的主设备目录。 + + 在创建块设备节点的过程中,会有一个将设备路径与default_boot_device的值匹配的操作,匹配成功后,会在/dev/block/by-name目录下创建指向真实块设备节点的软链接,以此在访问设备节点的过程中实现芯片平台无关化。 + + - 实例 + + 下面以OpenHarmony系统在Hi3516DV300平台启动过程中必要的system分区为例,详细介绍init进程启动后,从读取required fstab信息到创建required分区块设备节点再到最后完成required分区挂载的全部流程。其中会包含一些关键代码段和关键的log信息供开发者调试参考。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + + > 从此处开始出现的代码是按逻辑顺序展示的关键代码行,不代表其在源码当中真正的相邻关系。 + + 1. 获取required设备信息 + ``` + Fstab* LoadRequiredFstab(void) + { + Fstab *fstab = NULL; + fstab = LoadFstabFromCommandLine(); + if (fstab == NULL) { + INIT_LOGI("Cannot load fstab from command line, try read from fstab.required"); + const char *fstabFile = "/etc/fstab.required"; + if (access(fstabFile, F_OK) != 0) { + fstabFile = "/system/etc/fstab.required"; + } + INIT_ERROR_CHECK(access(fstabFile, F_OK) == 0, abort(), "Failed get fstab.required"); + fstab = ReadFstabFromFile(fstabFile, false); + } + return fstab; + } + ``` + 以上代码分别展示了获取fstab信息的两种方式,首先调用LoadFstabFromCommandLine(),从cmdline中获取fstab信息,如果获取失败,则输出log,表示继续尝试从fstab.required文件中获取fstab信息。 + + 对于system分区来说,其读到devices中的关键信息如下所示: + ``` + /dev/block/platform/fe310000.sdhci/by-name/system + ``` + + 2. 创建socket,触发内核上报uevent事件 + ``` + static int StartUeventd(char **requiredDevices, int num) + { + INIT_ERROR_CHECK(requiredDevices != NULL && num > 0, return -1, "Failed parameters"); + int ueventSockFd = UeventdSocketInit(); + if (ueventSockFd < 0) { + INIT_LOGE("Failed to create uevent socket"); + return -1; + } + RetriggerUevent(ueventSockFd, requiredDevices, num); + close(ueventSockFd); + return 0; + } + ``` + + 3. 读取cmdline,获得default_boot_device + ``` + char *buffer = ReadFileData("/proc/cmdline"); + int ret = GetProcCmdlineValue("default_boot_device", buffer, bootDevice, CMDLINE_VALUE_LEN_MAX); + INIT_CHECK_ONLY_ELOG(ret == 0, "Failed get default_boot_device value from cmdline"); + ``` + 这里取得的default_boot_device的值应该是soc/10100000.himci.eMMC,也就对应了system分区设备所在目录,这一值存放在了bootDevice这个全局变量当中,将在后续创建system分区设备软链接前进行匹配。 + + 4. 处理required设备uevent事件 + ``` + if (uevent->partitionName == NULL) { + INIT_LOGI("Match with %s for %s", devices[i], uevent->syspath); + deviceName = strstr(devices[i], "/dev/block"); + INIT_INFO_CHECK(deviceName != NULL, continue, + "device %s not match \"/dev/block\".", devices[i]); + deviceName += sizeof("/dev/block") - 1; + INIT_INFO_CHECK(strstr(uevent->syspath, deviceName) != NULL, continue, + "uevent->syspath %s not match deviceName %s", uevent->syspath, deviceName); + HandleBlockDeviceEvent(uevent); + break; + } else if (strstr(devices[i], uevent->partitionName) != NULL) { + INIT_LOGI("Handle block device partitionName %s", uevent->partitionName); + HandleBlockDeviceEvent(uevent); + break; + } + ``` + 存在devices中的设备信息,就是在此处与内核上报的uevent事件进行匹配的。对于system分区设备的uevent消息,其uevent->partitionName值应该为system,与devices中存在的/dev/block/platform/fe310000.sdhci/by-name/system字段匹配成功,则开始处理system分区设备的uevent消息。 + + 5. 创建required设备节点和对应软链接 + + 首先应该格式化对应软链接的路径,这一部分就用到了bootargs中default_boot_device的值,与上报的required设备节点路径进行匹配,以创建平台无关的可读性更高的指向该设备节点的软链接,关键部分代码如下: + ``` + if (STRINGEQUAL(bus, "/sys/bus/platform")) { + INIT_LOGV("Find a platform device: %s", parent); + parent = FindPlatformDeviceName(parent); + if (parent != NULL) { + BuildDeviceSymbolLinks(links, linkNum, parent, uevent->partitionName, uevent->deviceName); + } + linkNum++; + if ((parent != NULL) && STRINGEQUAL(parent, bootDevice)) { + BuildBootDeviceSymbolLink(links, linkNum, uevent->partitionName); + linkNum++; + } + } + ``` + 首先解释一下这段代码中出现的关键变量。 + + bus: 这是一个保存了路径信息的字符串,路径是当前处理的设备所连接的总线路径。 + parent: 同样是一个保存了路径信息的字符串,路径是从uevent->syspath取出的当前处理的设备路径。 + links:事先申请好的指向保存软链接路径内存的指针 + bootDevice: 存放bootargs中default_boot_device值的字符串 + 根据代码可知,只有处理到所连接总线类型为platform时的设备才会创建对应软链接,这一软链接所在的目录是: + ``` + /dev/block/platform/soc/10100000.himci.eMMC/by-name + ``` + 而只有匹配到设备目录为bootDevice中路径的设备时,才会创建平台无关目录的软链接。 + + 对于system分区设备来说,其所在目录如下: + ``` + /sys/devices/platform/soc/10100000.himci.eMMC/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p5 + ``` + 因此在处理内核上报的该设备uevent消息时,会与bootDevice中的路径soc/10100000.himci.eMMC相匹配,因此而创建相应的软链接,这一软连接的路径是: + ``` + /dev/block/by-name/system + ``` + + 软链接路径格式化完成后,将根据uevent中的信息进行最后的创建设备节点和软链接的动作,至此,system分区设备的设备节点创建完毕。 + + 6. 挂载required分区 + + 设备节点创建完成后,即可挂载对应分区,主要接口如下: + ``` + int MountRequriedPartitions(const Fstab *fstab) + { + INIT_ERROR_CHECK(fstab != NULL, return -1, "Failed fstab is NULL"); + int rc; + INIT_LOGI("Mount required partitions"); + rc = MountAllWithFstab(fstab, 1); + return rc; + } + ``` + 因此,当我们看到"Mount required partitions"打印的时候,表示required分区设备已经准备完成,即将执行挂载动作。分区挂载过程中,还有一些关键打印如下: + ``` + BEGET_LOGE("Unsupported file system \" %s \"", item->fsType); + 表示当前文件系统类型不支持 + + BEGET_LOGE("Cannot get stat of \" %s \", err = %d", target, errno); + 表示无法获取挂载点目录信息 + + BEGET_LOGE("Failed to create dir \" %s \", err = %d", target, errno); + 表示无法创建挂载点目录 + + BEGET_LOGI("Mount %s to %s successful", item->deviceName, item->mountPoint); + 表示成功挂载设备,打印中还包含了挂载的设备名和挂载点信息 + ``` + + +- init执行system和vendor中的启动脚本,挂载vendor中更多的分区 + +​ 挂载完必要的分区后,init扫描各个脚本文件。vendor中与芯片或开发板相关的初始化脚本入口如/vendor/etc/init.{ohos.boot.hardware}.cfg。vendor中扩展的挂载分区文件是/vendor/etc/fstab.{ohos.boot.hardware}。hardware的来源是bootloader传递给内核的bootargs。 + + +### 无ramdisk的启动加载流程 + +有些开发板没有采用ramdisk启动引导,直接通过内核挂载system.img。此场景需要修改productdefine中的产品配置文件,通过"enable_ramdisk"开关关闭ramdisk生成,init也不会从ramdisk里二次启动到system。 + +此场景的主要启动过程与上述流程类似,只是有ramdisk时,init会把system.img挂载到/usr目录,然后chroot到/usr下,并且执行/etc/init.cfg入口脚本文件;而没有ramdisk时,没有chroot过程,切init执行的入口启动脚本是init.without_two_stages.cfg文件。 + +对于无ramdisk的启动加载,即system as root. 在bootloader阶段将根文件系统所在的块设备通过bootargs传给内核,如root=/dev/mmcblk0p5,rootfstype=ext4。内核在初始化根文件系统时,解析bootargs中root,完成根文件系统的挂载。 diff --git a/zh-cn/device-dev/subsystems/subsys-build-standard-large.md b/zh-cn/device-dev/subsystems/subsys-build-standard-large.md index 4d30761d43832d6af465472143ab25393249c87f..ed6ba67128b5c128c06ac75f76aa3b68ba05c5e7 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-standard-large.md +++ b/zh-cn/device-dev/subsystems/subsys-build-standard-large.md @@ -211,19 +211,19 @@ OpenHarmony侧的编译构建流程主要包括编译命令行解析,调用gn - test_list:组件中对应模块的测试用例; 2. 将组件添加到产品配置中。 - 在产品的配置中添加组件,产品对应的配置文件:productdefine/common/products/{product-name}.json。 + 在产品的配置中添加组件,产品对应的配置文件://vendor/{product_company}/{product-name}/config.json。 在产品配置文件中添加 "subsystem_examples:partA",表示该产品中会编译并打包partA到版本中。 3. 编译。 - 以编译Hi3516DV300为例,编译命令如下: + 以编译hispark_taurus_standard为例,编译命令如下: ``` - ./build.sh --product-name Hi3516DV300 --ccache + ./build.sh --product-name hispark_taurus_standard --ccache ``` 4. 编译输出。 - 编译所生成的文件都归档在out/hi3516dv300/目录下,结果镜像输出在 out/hi3516dv300/packages/phone/images/ 目录下。 + 编译所生成的文件都归档在out/hispark_taurus/目录下,结果镜像输出在 out/hispark_taurus/packages/phone/images/ 目录下。 ## 常见问题 @@ -370,7 +370,7 @@ ohos_shared_library("module2") { ohos.build文件包含两个部分,第一部分subsystem说明了子系统的名称,parts定义了该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module_list,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test_list中说明,inner_kits与test_list没有也可以不添加。 -3. 在productdefine/common/products目录下的产品配置文件(json格式)中添加对应的部件,直接添加到原有部件后即可。 +3. 在//vendor/{product_company}/{product-name}/config.json中添加对应的部件,直接添加到原有部件后即可。 ``` { @@ -400,7 +400,7 @@ ohos_shared_library("module2") { 该文件定义了有哪些子系统以及这些子系统所在文件夹路径,添加子系统时需要说明子系统path与name,分别表示子系统路径和子系统名。 -4. 在productdefine/common/products目录下的产品配置如Hi3516DV300.json中添加对应的部件,直接添加到原有部件后即可。 +4. 在//vendor/{product_company}/{product-name}目录下的产品配置如product-name是Hi3516DV300时,在config.json中添加对应的部件,直接添加到原有部件后即可。 ``` { diff --git a/zh-cn/device-dev/subsystems/subsys-testguide-test.md b/zh-cn/device-dev/subsystems/subsys-testguide-test.md index 83f4e683332845d5e48906ac2a14557de15bae0b..7a6c267923649214b0bb4f38e2692476b250f6f8 100644 --- a/zh-cn/device-dev/subsystems/subsys-testguide-test.md +++ b/zh-cn/device-dev/subsystems/subsys-testguide-test.md @@ -718,13 +718,13 @@ subsystem # 子系统 由于Windows环境下无法实现用例编译,因此执行用例前需要在Linux环境下进行用例编译,用例编译命令: ``` -./build.sh --product-name Hi3516DV300 --build-target make_test +./build.sh --product-name hispark_taurus_standard --build-target make_test ``` >说明: ->- product-name:指定编译产品名称,例如Hi3516DV300。 +>- product-name:指定编译产品名称,例如hispark_taurus_standard。 >- build-target:指定所需要编译的用例,make_test表示指定全部用例,实际开发中可指定特定用例。 -编译完成后,测试用例将自动保存在out/hi3516dv300/packages/phone/tests目录下。 +编译完成后,测试用例将自动保存在out/hispark_taurus/packages/phone/tests目录下。 #### 搭建执行环境 1. 在Windows环境创建测试框架目录Test,并在此目录下创建testcase目录 diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 6e3d65750cbaad3a08d71c96ed23ea07ac204a3d..edf90f5cbda80b26afeaa41f86e51e48d2b1c82f 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -63,6 +63,11 @@ - [编译](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) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-ide-standard-running-hi3751-create.md) + - [编译](quickstart-ide-standard-running-hi3751-build.md) + - [烧录](quickstart-ide-standard-running-hi3751-burning.md) + - [运行](quickstart-ide-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quick-start/quickstart-ide-standard-running-rk3568-create.md) - [编译](quick-start/quickstart-ide-standard-running-rk3568-build.md) @@ -70,6 +75,7 @@ - [运行](quick-start/quickstart-ide-standard-running-rk3568-running.md) - 附录 - [Hi3516开发板介绍](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-ide-standard-board-introduction-hi3751.md) - [RK3568开发板介绍](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) - 标准系统快速入门(安装包方式) - [标准系统入门概述](quick-start/quickstart-standard-overview.md) @@ -80,6 +86,11 @@ - [编译](quick-start/quickstart-standard-running-hi3516-build.md) - [烧录](quick-start/quickstart-standard-running-hi3516-burning.md) - [运行](quick-start/quickstart-standard-running-hi3516-running.md) + - Hi3751开发板 + - [编写“Hello World”程序](quickstart-standard-running-hi3751-create.md) + - [编译](quickstart-standard-running-hi3751-build.md) + - [烧录](quickstart-standard-running-hi3751-burning.md) + - [运行](quickstart-standard-running-hi3751-running.md) - RK3568开发板 - [编写“Hello World”程序](quick-start/quickstart-standard-running-rk3568-create.md) - [编译](quick-start/quickstart-standard-running-rk3568-build.md) @@ -92,6 +103,7 @@ - 附录 - 开发板介绍 - [Hi3516开发板介绍](quick-start/quickstart-standard-board-introduction-hi3516.md) + - [Hi3751开发板介绍](quickstart-standard-board-introduction-hi3751.md) - [RK3568开发板介绍](quick-start/quickstart-standard-board-introduction-rk3568.md) - [参考信息](quickstart-standard-reference.md) - [获取源码](get-code/sourcecode-acquire.md) diff --git "a/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" "b/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" index 2374624f980c313e44b3f33fb54560eba57ed085..a2022d3765087cbf8f1cfc069da111aafa46bfb5 100755 --- "a/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" +++ "b/zh-cn/readme/\345\205\254\345\205\261\345\237\272\347\241\200\345\272\223.md" @@ -33,7 +33,7 @@ **公共基础库子系统** -utils +[utils](https://gitee.com/openharmony/utils) [utils\_native](https://gitee.com/openharmony/utils_native) diff --git "a/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" index e8e29fbd3fe47e00a448e5047dbedf783150bccf..747c945ffd6b5c074942072a1bcff0081fc50e1e 100755 --- "a/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" @@ -198,7 +198,7 @@ Hi3518EV300默认使用jffs2文件系统,Hi3516DV300默认使用FAT文件系 使用工程的全量编译命令,编译生成uImage内核镜像 ``` -./build.sh --product-name Hi3516DV300 # 编译hi3516dv300镜像 +./build.sh --product-name hispark_taurus_standard # 编译hi3516dv300镜像 --build-target build_kernel # 编译hi3516dv300的uImage内核镜像 --gn-args linux_kernel_version=\"linux-5.10\" # 编译指定内核版本 ``` diff --git "a/zh-cn/readme/\345\220\257\345\212\250\346\201\242\345\244\215\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\220\257\345\212\250\346\201\242\345\244\215\345\255\220\347\263\273\347\273\237.md" index 7a48733cb1de332717c8ff48f8298a5facc05c1c..d8c9947fa5b0d1be7837f2b9479d7171660d0f71 100755 --- "a/zh-cn/readme/\345\220\257\345\212\250\346\201\242\345\244\215\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\220\257\345\212\250\346\201\242\345\244\215\345\255\220\347\263\273\347\273\237.md" @@ -295,11 +295,10 @@ base/startup/ 启动恢复子系统 -startup\_syspara\_lite +[startup_init_lite](https://gitee.com/openharmony/startup_init_lite) -startup\_appspawn\_lite +[startup_syspara_lite](https://gitee.com/openharmony/startup_syspara_lite) -startup\_bootstrap\_lite - -startup\_init\_lite +[startup_bootstrap_lite](https://gitee.com/openharmony/startup_bootstrap_lite) +[startup_appspawn_lite](https://gitee.com/openharmony/startup_appspawn_lite) \ No newline at end of file diff --git "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" index 8664289223279cf48d88a7fbf9901d92c7bd93dd..ec9084268c7d4ce1ada318a06f4ee4215387ed6c 100755 --- "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" @@ -661,11 +661,11 @@ subsystem # 子系统 由于Windows环境下无法实现用例编译,因此执行用例前需要在Linux环境下进行用例编译,用例编译命令: ``` -./build.sh --product-name Hi3516DV300 --build-target make_test +./build.sh --product-name hispark_taurus_standard --build-target make_test ``` -编译完成后,测试用例将自动保存在out/hi3516dv300/packages/phone/images/tests目录下。 +编译完成后,测试用例将自动保存在out/hispark_taurus/packages/phone/images/tests目录下。 ->说明: Hi3516DV300为当前版本所支持的平台,make_test表示全部用例。根据不同需求,编译选项可进行不同选择: +>说明: hispark_taurus_standard为当前版本所支持的产品,make_test表示全部用例。根据不同需求,编译选项可进行不同选择: > - --product-name # 编译产品名称(必选) > - --build-target # 指定编译目标(可选) 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 8ea3bb7930be102ee2e38c3078e76449f7d36af8..5b05b8930b290ea1a14c11e00d2009409f35a5c4 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" @@ -41,21 +41,21 @@ OpenHarmony 3.1 Release版本,仅图库系统应用代码可配套发布的IDE **系统应用** -applications\_settings +[applications\_settings](https://gitee.com/openharmony/applications_settings) -applications\_launcher +[applications\_launcher](https://gitee.com/openharmony/applications_launcher) -applications\_systemui +[applications\_systemui](https://gitee.com/openharmony/applications_systemui) -applications\_hap +[applications\_hap](https://gitee.com/openharmony/applications_hap) -applications\_contacts +[applications\_contacts](https://gitee.com/openharmony/applications_contacts) -applications\_mms +[applications\_mms](https://gitee.com/openharmony/applications_mms) -applications\_call +[applications\_call](https://gitee.com/openharmony/applications_call) -applications\_camera +[applications\_camera](https://gitee.com/openharmony/applications_camera) -applications\_photos +[applications\_photos](https://gitee.com/openharmony/applications_photos) diff --git "a/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" index 9abefe201ccc059c17bfa58ab213a646bc8dfac6..66d2acdad2e1e70a80d2c4ac4903acfaa6e8a646 100644 --- "a/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" @@ -59,5 +59,5 @@ OpenHarmony侧的编译构建流程主要包括编译命令行解析,调用gn [build\_lite](https://gitee.com/openharmony/build_lite) -build +[build](https://gitee.com/openharmony/build) diff --git "a/zh-cn/readme/\350\257\255\350\250\200\350\277\220\350\241\214\346\227\266\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\350\257\255\350\250\200\350\277\220\350\241\214\346\227\266\345\255\220\347\263\273\347\273\237.md" index bfbc84788c0a8f4e9e33d8def2733509dd0783c7..6c2a7c85b7774698087593e7ce21d4143ed01489 100755 --- "a/zh-cn/readme/\350\257\255\350\250\200\350\277\220\350\241\214\346\227\266\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\350\257\255\350\250\200\350\277\220\350\241\214\346\227\266\345\255\220\347\263\273\347\273\237.md" @@ -41,13 +41,13 @@ 涉及引用的三方软件及预编译工具链仓如下: -/third\_party/boost +[third_party_boost](https://gitee.com/openharmony/third_party_boost) -/third\_party/quickjs +[third_party_quickjs](https://gitee.com/openharmony/third_party_quickjs) -/third\_party/jerryscript +[third_party_jerryscript](https://gitee.com/openharmony/third_party_jerryscript) -/third\_party/mingw-w64 +[third_party_mingw-w64](https://gitee.com/openharmony/third_party_mingw-w64) ## 相关仓 diff --git "a/zh-cn/readme/\351\251\261\345\212\250\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\351\251\261\345\212\250\345\255\220\347\263\273\347\273\237.md" index 453912461c59346d3fbdac613c511a19129b8ef4..a8fda9ccced514d6cd070b3a03d0812eb48aa1d3 100644 --- "a/zh-cn/readme/\351\251\261\345\212\250\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\351\251\261\345\212\250\345\255\220\347\263\273\347\273\237.md" @@ -142,7 +142,7 @@ OpenHarmony驱动主要部署在内核态,当前主要采用静态链接方式 **图 3** 驱动安装部署图 ![](figures/驱动安装部署图.png "驱动安装部署图") -## 涉及仓 +## 相关仓 **驱动子系统**