提交 f884a46c 编写于 作者: Y yxn22 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nyxn22 <yexinnian2@huawei.com>
...@@ -199,9 +199,9 @@ zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShi ...@@ -199,9 +199,9 @@ zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShi
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001 zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-battery-info.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-brightness.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-brightness.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-buffer.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh zh-cn/application-dev/reference/apis/js-apis-buffer.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh
zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @shuaytao @RayShih @wangzhen107 @inter515
...@@ -321,7 +321,7 @@ zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yaf ...@@ -321,7 +321,7 @@ zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yaf
zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh
zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-power.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-power.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @nianCode @zengyawen @shuqinglin2 @jinhaihw zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @nianCode @zengyawen @shuqinglin2 @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-process.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh zh-cn/application-dev/reference/apis/js-apis-process.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh
zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
...@@ -334,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-request.md @feng-aiwen @ningningW @ ...@@ -334,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-request.md @feng-aiwen @ningningW @
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ningningW @mengjingzhimo @yangqing3 zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ningningW @mengjingzhimo @yangqing3
zh-cn/application-dev/reference/apis/js-apis-router.md @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-router.md @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-runninglock.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
...@@ -349,9 +349,9 @@ zh-cn/application-dev/reference/apis/js-apis-stack.md @gongjunsong @ge-yafang @f ...@@ -349,9 +349,9 @@ zh-cn/application-dev/reference/apis/js-apis-stack.md @gongjunsong @ge-yafang @f
zh-cn/application-dev/reference/apis/js-apis-statfs.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-statfs.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-system-app.md @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-system-app.md @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-system-battery.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-system-battery.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @gaoyong @zengyawen @niejiteng @jumozhanjiang zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @Buda-Liu @ningningW @budda-wang @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @Buda-Liu @ningningW @budda-wang @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-system-date-time.md @feng-aiwen @ningningW @illybyy @murphy1984 zh-cn/application-dev/reference/apis/js-apis-system-date-time.md @feng-aiwen @ningningW @illybyy @murphy1984
...@@ -374,7 +374,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-timer.md @feng-aiwen @ningni ...@@ -374,7 +374,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-timer.md @feng-aiwen @ningni
zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-testRunner.md @inter515 @littlejerry1 @RayShih @inter515 @jiyong zh-cn/application-dev/reference/apis/js-apis-testRunner.md @inter515 @littlejerry1 @RayShih @inter515 @jiyong
zh-cn/application-dev/reference/apis/js-apis-thermal.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-thermal.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-timer.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh zh-cn/application-dev/reference/apis/js-apis-timer.md @gongjunsong @ge-yafang @flyingwolf @blackstone-oh
zh-cn/application-dev/reference/apis/js-apis-touchevent.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-touchevent.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-shortKey.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-shortKey.md @mayunteng_1 @ningningW @cococoler @alien0208
...@@ -425,7 +425,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-configuration.md @littl ...@@ -425,7 +425,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-configuration.md @littl
zh-cn/application-dev/reference/apis/js-apis-application-configurationConstant.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-configurationConstant.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-avsession.md @liuyuehua1 @zengyawen @saga2020 @currydavids zh-cn/application-dev/reference/apis/js-apis-avsession.md @liuyuehua1 @zengyawen @saga2020 @currydavids
zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md @zengyawen @alien0208
zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md @shuaytao @RayShih @wangzhen107 @inter515
......
# Multi-device Collaboration (for System Applications Only) # Multi-device Collaboration
## When to Use ## When to Use
...@@ -57,29 +57,31 @@ On device A, touch the **Start** button provided by the initiator application to ...@@ -57,29 +57,31 @@ On device A, touch the **Start** button provided by the initiator application to
3. Obtain the device ID of the target device. 3. Obtain the device ID of the target device.
```ts ```ts
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedDeviceManager';
let dmClass; let dmClass: deviceManager.DeviceManager;
function initDmClass() { function initDmClass() {
// createDeviceManager is a system API. // createDeviceManager is a system API.
deviceManager.createDeviceManager('ohos.samples.demo', (err, dm) => { try{
if (err) { dmClass = deviceManager.createDeviceManager('ohos.samples.demo');
... } catch(err) {
return console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
} }
dmClass = dm
})
} }
function getRemoteDeviceId() { function getRemoteDeviceId() {
if (typeof dmClass === 'object' && dmClass !== null) { if (typeof dmClass === 'object' && dmClass !== null) {
let list = dmClass.getTrustedDeviceListSync() let list = dmClass.getAvailableDeviceListSync();
if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') { if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') {
console.info('EntryAbility onButtonClick getRemoteDeviceId err: list is null') console.info('getRemoteDeviceId err: list is null');
return;
}
if (list.length === 0) {
console.info("getRemoteDeviceId err: list is empty");
return; return;
} }
return list[0].deviceId return list[0].networkId;
} else { } else {
console.info('EntryAbility onButtonClick getRemoteDeviceId err: dmClass is null') console.info('getRemoteDeviceId err: dmClass is null');
} }
} }
``` ```
...@@ -90,8 +92,8 @@ On device A, touch the **Start** button provided by the initiator application to ...@@ -90,8 +92,8 @@ On device A, touch the **Start** button provided by the initiator application to
let want = { let want = {
deviceId: getRemoteDeviceId(), deviceId: getRemoteDeviceId(),
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'EntryAbility',
moduleName: 'module1', // moduleName is optional. moduleName: 'entry', // moduleName is optional.
} }
// context is the AbilityContext of the initiator UIAbility. // context is the AbilityContext of the initiator UIAbility.
this.context.startAbility(want).then(() => { this.context.startAbility(want).then(() => {
...@@ -217,7 +219,7 @@ A system application can connect to a service on another device by calling [conn ...@@ -217,7 +219,7 @@ A system application can connect to a service on another device by calling [conn
2. Display a dialog box to ask for authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization). 2. Display a dialog box to ask for authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
3. (Optional) [Implement a background service](serviceextensionability.md#implementing-a-background-service). Perform this operation only if no background service is available. 3. (Optional) [Implement a background service](serviceextensionability.md#implementing-a-background-service-for-system-applications-only). Perform this operation only if no background service is available.
4. Connect to the background service. 4. Connect to the background service.
- Implement the **IAbilityConnection** class. **IAbilityConnection** provides the following callbacks that you should implement: **onConnect()**, **onDisconnect()**, and **onFailed()**. The **onConnect()** callback is invoked when a service is connected, **onDisconnect()** is invoked when a service is unexpectedly disconnected, and **onFailed()** is invoked when the connection to a service fails. - Implement the **IAbilityConnection** class. **IAbilityConnection** provides the following callbacks that you should implement: **onConnect()**, **onDisconnect()**, and **onFailed()**. The **onConnect()** callback is invoked when a service is connected, **onDisconnect()** is invoked when a service is unexpectedly disconnected, and **onFailed()** is invoked when the connection to a service fails.
...@@ -477,8 +479,8 @@ The following describes how to implement multi-device collaboration through cros ...@@ -477,8 +479,8 @@ The following describes how to implement multi-device collaboration through cros
```ts ```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'; const MSG_SEND_METHOD: string = 'CallSendMsg';
originMsg: string = ''; let originMsg: string = '';
backMsg: string = ''; let backMsg: string = '';
async onButtonCallWithResult(originMsg, backMsg) { async onButtonCallWithResult(originMsg, backMsg) {
try { try {
let msg = new MyParcelable(1, originMsg); let msg = new MyParcelable(1, originMsg);
......
...@@ -20,12 +20,15 @@ In OpenHarmony, distributed operations across devices are called continuation (a ...@@ -20,12 +20,15 @@ In OpenHarmony, distributed operations across devices are called continuation (a
- **Multi-device collaboration** - **Multi-device collaboration**
Multi-device collaboration provides users with more efficient and immersive experience than with a single device. A typical multi-device collaboration scenario is as follows: You open the same note on devices A and B. On device A, you select images from the local Gallery, insert them to the note, and edit them. On device B, you edit the text. Another typical scenario is as follows: You are chatting with a customer on device A, and the customer asks for a file, which is stored on device B. You can use the chat software to open the file application on device B, select the required file, and send it back to device A. Then, you use the chat software to send it to the customer. From the perspective of application development, multi-device collaboration enables different UIAbility or ServiceExtensionAbility components to run simultaneously or alternately on multiple devices to provide a complete service, or enables the same UIAbility and ServiceExtensionAbility component to run simultaneously on multiple devices to provide a complete service. Multi-device collaboration provides users with more efficient and immersive experience than with a single device. Multi-device collaboration is used in the following typical scenarios:
- Scenario 1: You open the same note on devices A and B. On device A, you select images from the local Gallery, insert them to the note, and edit them. On device B, you edit the text.
- Scenario 2: : You are chatting with a customer on device A, and the customer asks for a file, which is stored on device B. You can use the chat software to open the file application on device B, select the required file, and send it back to device A. Then, you use the chat software to send it to the customer. From the perspective of application development, multi-device collaboration enables different UIAbility or ServiceExtensionAbility components to run simultaneously or alternately on multiple devices to provide a complete service, or enables the same UIAbility and ServiceExtensionAbility component to run simultaneously on multiple devices to provide a complete service.
## Continuation Architecture ## Continuation Architecture
OpenHarmony provides a set of APIs for you to implement continuation in your applications. The continuation architecture has the following advantages: OpenHarmony provides APIs for you to implement continuation in your applications. The continuation architecture has the following advantages:
- Capabilities such as remote service invocation to facilitate service design - Capabilities such as remote service invocation to facilitate service design
...@@ -39,9 +42,9 @@ The following figure shows the continuation architecture. ...@@ -39,9 +42,9 @@ The following figure shows the continuation architecture.
![hop-structure](figures/hop-structure.png) ![hop-structure](figures/hop-structure.png)
- Cross-device migration mission management: The initiator accepts a migration request from the user, provides a migration entry, and displays the migration result. (This capability is unavailable yet.) - Cross-device migration mission management: The initiator accepts a migration request from the user, provides a migration entry, and displays the migration result.
- Multi-device collaboration mission management: The initiator accepts an application registration request and provides management capabilities such as starting or stopping collaboration and status display. (This capability is unavailable yet.) - Multi-device collaboration mission management: The initiator accepts an application registration request and provides management capabilities such as starting or stopping collaboration and status display.
- Distributed component management: provides capabilities such as remote service startup, remote service connection, and remote migration, and provides applications with cross-device migration or multi-device collaboration based on a combination of these capabilities. - Distributed component management: provides capabilities such as remote service startup, remote service connection, and remote migration, and provides applications with cross-device migration or multi-device collaboration based on a combination of these capabilities.
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
| onShow?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br>Listens for the switching to the [foreground](../reference/apis/js-apis-window.md#windowstageeventtype9).| | onShow?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br>Listens for the switching to the [foreground](../reference/apis/js-apis-window.md#windowstageeventtype9).|
| onHide?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br>Listens for the switching to the [background](../reference/apis/js-apis-window.md#windowstageeventtype9).| | onHide?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br>Listens for the switching to the [background](../reference/apis/js-apis-window.md#windowstageeventtype9).|
| onDestroy?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onDestroy(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityondestroy) | | onDestroy?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onDestroy(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityondestroy) |
| onCreate?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate) | | onCreate?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate) |
| onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; | There is no corresponding API in the stage model.| No corresponding API is provided.| | onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; | There is no corresponding API in the stage model.| No corresponding API is provided.|
| onStartContinuation?(): boolean; | There is no corresponding API in the stage model.| In the stage model, an application does not need to detect whether the continuation is successful (detected when the application initiates the continuation request). Therefore, the **onStartContinuation()** callback is deprecated.| | onStartContinuation?(): boolean; | There is no corresponding API in the stage model.| In the stage model, an application does not need to detect whether the continuation is successful (detected when the application initiates the continuation request). Therefore, the **onStartContinuation()** callback is deprecated.|
| onSaveData?(data: Object): boolean; | \@ohos.app.ability.UIAbility.d.ts | [onContinue(wantParam : {[key: string]: Object}): AbilityConstant.OnContinueResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) | | onSaveData?(data: Object): boolean; | \@ohos.app.ability.UIAbility.d.ts | [onContinue(wantParam : {[key: string]: Object}): AbilityConstant.OnContinueResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) |
| onCompleteContinuation?(result: number): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) | | onCompleteContinuation?(result: number): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) |
| onRestoreData?(data: Object): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br>[onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)<br>In multiton or singleton mode, the target ability completes data restoration in the **onCreate()** callback. In the callback, **launchParam.launchReason** is used to determine whether it is a continuation-based launch scenario. If it is, the data saved before continuation can be obtained from the **want** parameter.| | onRestoreData?(data: Object): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br>[onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)<br>In multiton or singleton mode, the target ability completes data restoration in the **onCreate()** callback. In the callback, **launchParam.launchReason** is used to determine whether it is a continuation-based launch scenario. If it is, the data saved before continuation can be obtained from the **want** parameter.|
| onRemoteTerminated?(): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) | | onRemoteTerminated?(): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) |
| onSaveAbilityState?(outState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonsavestate) | | onSaveAbilityState?(outState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonsavestate) |
| onRestoreAbilityState?(inState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br>After an application is restarted, the **onCreate()** callback is triggered. In the callback, **launchParam.launchReason** is used to determine whether it is a self-recovery scenario. If it is, the data saved before the restart can be obtained from the **want** parameter.| | onRestoreAbilityState?(inState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br>After an application is restarted, the **onCreate()** callback is triggered. In the callback, **launchParam.launchReason** is used to determine whether it is a self-recovery scenario. If it is, the data saved before the restart can be obtained from the **want** parameter.|
| onInactive?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onBackground(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonbackground) | | onInactive?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onBackground(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonbackground) |
| onActive?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onForeground(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonforeground) | | onActive?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onForeground(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonforeground) |
| onNewWant?(want: Want): void; | \@ohos.app.ability.UIAbility.d.ts | [onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) | | onNewWant?(want: Want): void; | \@ohos.app.ability.UIAbility.d.ts | [onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) |
| onMemoryLevel?(level: number): void | \@ohos.app.ability.UIAbility.d.ts | [onMemoryLevel(level: AbilityConstant.MemoryLevel): void;](../reference/apis/js-apis-app-ability-ability.md#abilityonmemorylevel) | | onMemoryLevel?(level: number): void | \@ohos.app.ability.UIAbility.d.ts | [onMemoryLevel(level: AbilityConstant.MemoryLevel): void;](../reference/apis/js-apis-app-ability-ability.md#abilityonmemorylevel) |
...@@ -8,18 +8,19 @@ The PageAbility component in the FA model corresponds to the UIAbility component ...@@ -8,18 +8,19 @@ The PageAbility component in the FA model corresponds to the UIAbility component
2. Migrate the PageAbility code to the UIAbility. 2. Migrate the PageAbility code to the UIAbility.
The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The table below describes the details. The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The table below describes the details.
| PageAbility| UIAbility| Mapping Description| | PageAbility| UIAbility| Mapping Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| onCreate(): void| onCreate(want: Want, param: AbilityConstant.LaunchParam): void | The two methods have the same meaning and invoking time. In the stage model, parameters are added to the callback so that you can obtain startup-related data during creation.| | onCreate(): void| onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void | The two methods have the same meaning and invoking time. In the stage model, parameters are added to the callback so that you can obtain startup-related data during creation.|
| NA | onWindowStageCreate(windowStage: window.WindowStage): void| This method is available only in the stage model. The callback is invoked when a window is created.| | NA | onWindowStageCreate(windowStage: window.WindowStage): void| This method is available only in the stage model. The callback is invoked when a window is created.|
| onActive(): void | on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;<br>WindowStageEventType.ACTIVE | The two methods have the same meaning and invoking time. In the stage model, this method is moved to the window object.| | onActive(): void | on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;<br>WindowStageEventType.ACTIVE | The two methods have the same meaning and invoking time. In the stage model, this method is moved to the window object.|
| onShow(): void | onForeground(): void | The two methods have the same meaning, invoking time, and parameters.| | onShow(): void | onForeground(): void | The two methods have the same meaning, invoking time, and parameters.|
| onNewWant(want: Want): void| onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void| The two methods have the same meaning and invoking time. In the stage model, the **LaunchParam** parameter is added to notify the application of the startup cause.| | onNewWant(want: Want): void| onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void | The two methods have the same meaning and invoking time. In the stage model, the **LaunchParam** parameter is added to notify the application of the startup cause.|
| onInactive(): void| on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;<br>WindowStageEventType.INACTIVE | The two methods have the same meaning and invoking time. In the stage model, this method is moved to the window object.| | onInactive(): void| on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void;<br>WindowStageEventType.INACTIVE | The two methods have the same meaning and invoking time. In the stage model, this method is moved to the window object.|
| onHide(): void | onBackground(): void | The two methods have the same meaning, invoking time, and parameters.| | onHide(): void | onBackground(): void | The two methods have the same meaning, invoking time, and parameters.|
| NA | onWindowStageDestroy(): void | This method is available only in the stage model. The callback is invoked when a window is destroyed.| | NA | onWindowStageDestroy(): void | This method is available only in the stage model. The callback is invoked when a window is destroyed.|
| onDestroy(): void | onDestroy(): void | The two methods have the same meaning, invoking time, and parameters.| | onDestroy(): void | onDestroy(): void | The two methods have the same meaning, invoking time, and parameters.|
![pageability-switch](figures/pageability-switch.png) ![pageability-switch](figures/pageability-switch.png)
...@@ -31,7 +32,6 @@ The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The ...@@ -31,7 +32,6 @@ The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The
For example, to load the **pages/Index** page after the ability is started, use the following code in the **config.json** file in the FA model: For example, to load the **pages/Index** page after the ability is started, use the following code in the **config.json** file in the FA model:
```json ```json
"pages" : [ "pages" : [
"pages/Index" "pages/Index"
...@@ -40,7 +40,6 @@ The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The ...@@ -40,7 +40,6 @@ The PageAbility lifecycle is basically the same as the UIAbility lifecycle. The
In the stage model, implement the following method in **MainAbility**: In the stage model, implement the following method in **MainAbility**:
```ts ```ts
import Window from '@ohos.window' import Window from '@ohos.window'
......
# Service Widget Overview # Service Widget Overview
A service widget (also called widget) is a set of UI components that display important information or operations specific to an application. It provides users with direct access to a desired application service, without the need to open the application first. A widget usually appears as a part of the UI of another application (which currently can only be a system application, such as the home screen) and provides basic interactive features such as opening a UI page or sending a message. A service widget (also called widget) is a set of UI components that display important information or operations specific to an application. It provides users with direct access to a desired application service, without the need to open the application first. A widget is usually displayed as part of the UI of another application (which can only be a system application, such as the home screen) and provides basic interactive features such as opening a UI page or sending a message.
## Service Widget Architecture ## Service Widget Architecture
...@@ -14,17 +14,17 @@ Before you get started, it would be helpful if you have a basic understanding of ...@@ -14,17 +14,17 @@ Before you get started, it would be helpful if you have a basic understanding of
- Widget host: an application that displays the widget content and controls the widget location. An example is the home screen in the preceding figure. - Widget host: an application that displays the widget content and controls the widget location. An example is the home screen in the preceding figure.
- Application icon: an application entry icon, clicking which starts the application process. The icon content does not support interactions. - Application icon: an icon for entry to an application, clicking which starts the application process. The icon content does not support interactions.
- Widget: an interactive UI in various sizes. It may provide buttons to implement different functions, such as the button to [update the widget content](arkts-ui-widget-event-formextensionability.md) or [switch to an application](arkts-ui-widget-event-router.md). - Widget: an interactive UI in various sizes. It may provide buttons to implement different features, such as the button to [update the widget content](arkts-ui-widget-event-formextensionability.md) or [switch to an application](arkts-ui-widget-event-router.md).
- Card provider: an application that provides service widget content to be displayed. It controls the display content, display logic, and component click events triggered on a service widget. - Widget provider: an application that provides widget content to be displayed. It controls the display content, display logic, and component click events triggered on a widget.
- FormExtensionAbility: widget service logic module, which provides lifecycle callbacks invoked when a widget is created, destroyed, or updated. - FormExtensionAbility: a widget service logic module, which provides lifecycle callbacks invoked when a widget is created, destroyed, or updated.
- Widget page: widget UI module, which contains display and interaction information such as components, layouts, and events. - Widget page: a widget UI module, which contains display and interaction information such as components, layouts, and events.
Below is the typical procedure of using the widget: Below is the typical procedure of using a widget:
**Figure 2** Typical procedure of using the widget **Figure 2** Typical procedure of using a widget
![WidgetUse](figures/WidgetUse.png) ![WidgetUse](figures/WidgetUse.png)
...@@ -35,7 +35,7 @@ Below is the typical procedure of using the widget: ...@@ -35,7 +35,7 @@ Below is the typical procedure of using the widget:
3. Touch the **Add to home** button. The widget is then added to the home screen. 3. Touch the **Add to home** button. The widget is then added to the home screen.
## Widget UI Development Mode ## Widget UI Development Modes
In the stage model, the UI of a widget can be developed in [ArkTS](arkts-ui-widget-working-principles.md) or [JS](js-ui-widget-development.md). In the stage model, the UI of a widget can be developed in [ArkTS](arkts-ui-widget-working-principles.md) or [JS](js-ui-widget-development.md).
...@@ -45,7 +45,7 @@ In the stage model, the UI of a widget can be developed in [ArkTS](arkts-ui-widg ...@@ -45,7 +45,7 @@ In the stage model, the UI of a widget can be developed in [ArkTS](arkts-ui-widg
ArkTS widgets and JS widgets have different implementation principles and features. The following table lists the differences in capabilities. ArkTS widgets and JS widgets have different implementation principles and features. The following table lists the differences in capabilities.
| Category| JS widget| ArkTS widget| | Category| JS Widget| ArkTS Widget|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| Development paradigm| Web-like paradigm| Declarative paradigm| | Development paradigm| Web-like paradigm| Declarative paradigm|
| Component capability| Supported| Supported| | Component capability| Supported| Supported|
......
...@@ -350,8 +350,8 @@ The window mode is specified by the **windowMode** field in the [StartOptions](. ...@@ -350,8 +350,8 @@ The window mode is specified by the **windowMode** field in the [StartOptions](.
> **NOTE** > **NOTE**
> >
> 1. If the **windowMode** field is not specified, the UIAbility is started in the default window mode. > - If the **windowMode** field is not specified, the UIAbility is started in the default window mode.
> 2. To ensure that the application can be displayed in the required window mode, check the **supportWindowMode** field under [abilities](../quick-start/module-configuration-file.md#abilities) in the [module.json5 file](../quick-start/module-configuration-file.md) of the UIAbility and make sure the specified window mode is supported. > - To ensure that the application can be displayed in the required window mode, check the **supportWindowMode** field under [abilities](../quick-start/module-configuration-file.md#abilities) in the [module.json5 file](../quick-start/module-configuration-file.md) of the UIAbility and make sure the specified window mode is supported.
The following describes how to start the FuncAbility from the EntryAbility page and display it in floating window mode. The following describes how to start the FuncAbility from the EntryAbility page and display it in floating window mode.
...@@ -521,7 +521,7 @@ The development procedure is as follows: ...@@ -521,7 +521,7 @@ The development procedure is as follows:
funcAbilityWant: Want; funcAbilityWant: Want;
uiContext: UIContext; uiContext: UIContext;
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam) { onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
if (want?.parameters?.router && want.parameters.router === 'funcA') { if (want?.parameters?.router && want.parameters.router === 'funcA') {
let funcAUrl = 'pages/Second'; let funcAUrl = 'pages/Second';
let router: Router = this.uiContext.getRouter(); let router: Router = this.uiContext.getRouter();
...@@ -624,6 +624,7 @@ For the CalleeAbility, implement the callback to receive data and the methods to ...@@ -624,6 +624,7 @@ For the CalleeAbility, implement the callback to receive data and the methods to
``` ```
3. Define the agreed parcelable data. 3. Define the agreed parcelable data.
The data formats sent and received by the CallerAbility and CalleeAbility must be consistent. In the following example, the data formats are number and string. The data formats sent and received by the CallerAbility and CalleeAbility must be consistent. In the following example, the data formats are number and string.
...@@ -631,7 +632,6 @@ For the CalleeAbility, implement the callback to receive data and the methods to ...@@ -631,7 +632,6 @@ For the CalleeAbility, implement the callback to receive data and the methods to
export default class MyParcelable { export default class MyParcelable {
num: number = 0; num: number = 0;
str: string = ''; str: string = '';
constructor(num, string) { constructor(num, string) {
this.num = num; this.num = num;
this.str = string; this.str = string;
......
...@@ -30,9 +30,9 @@ The preference persistent file of an application is stored in the application sa ...@@ -30,9 +30,9 @@ The preference persistent file of an application is stored in the application sa
The following table lists the APIs used for persisting user preference data. For more information about the APIs, see [User Preferences](../reference/apis/js-apis-data-preferences.md). The following table lists the APIs used for persisting user preference data. For more information about the APIs, see [User Preferences](../reference/apis/js-apis-data-preferences.md).
| API | Description | | API | Description |
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------| | ------------------------------------------------------------ | ------------------------------------------------------------ |
| getPreferences(context: Context, name: string, callback: AsyncCallback&lt;Preferences&gt;): void | Obtain a **Preferences** instance. | | getPreferences(context: Context, name: string, callback: AsyncCallback&lt;Preferences&gt;): void | Obtains a **Preferences** instance. |
| putSync(key: string, value: ValueType): void | Writes data to the Preferences instance. You can use **flush()** to persist the **Preferences** instance data. An asynchronous API is also provided. | | putSync(key: string, value: ValueType): void | Writes data to the Preferences instance. You can use **flush()** to persist the **Preferences** instance data. An asynchronous API is also provided. |
| hasSync(key: string): void | Checks whether the **Preferences** instance contains a KV pair with the given key. The key cannot be empty. An asynchronous API is also provided. | | hasSync(key: string): void | Checks whether the **Preferences** instance contains a KV pair with the given key. The key cannot be empty. An asynchronous API is also provided. |
| getSync(key: string, defValue: ValueType): void | Obtains the value of the specified key. If the value is null or not of the default value type, **defValue** is returned. An asynchronous API is also provided. | | getSync(key: string, defValue: ValueType): void | Obtains the value of the specified key. If the value is null or not of the default value type, **defValue** is returned. An asynchronous API is also provided. |
...@@ -40,7 +40,7 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -40,7 +40,7 @@ The following table lists the APIs used for persisting user preference data. For
| flush(callback: AsyncCallback&lt;void&gt;): void | Flushes the data of this **Preferences** instance to a file for data persistence. | | flush(callback: AsyncCallback&lt;void&gt;): void | Flushes the data of this **Preferences** instance to a file for data persistence. |
| on(type: 'change', callback: Callback&lt;{ key : string }&gt;): void | Subscribes to data changes of the specified key. When the value of the specified key is changed and saved by **flush()**, a callback will be invoked to return the new data. | | on(type: 'change', callback: Callback&lt;{ key : string }&gt;): void | Subscribes to data changes of the specified key. When the value of the specified key is changed and saved by **flush()**, a callback will be invoked to return the new data. |
| off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void | Unsubscribes from data changes. | | off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void | Unsubscribes from data changes. |
| deletePreferences(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void | Deletes a **Preferences** instance from memory. If the **Preferences** instance has a persistent file, this API also deletes the persistent file.| | deletePreferences(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void | Deletes a **Preferences** instance from memory. If the **Preferences** instance has a persistent file, this API also deletes the persistent file. |
## How to Develop ## How to Develop
...@@ -58,11 +58,13 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -58,11 +58,13 @@ The following table lists the APIs used for persisting user preference data. For
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import { BusinessError } from '@ohos.base';
import window from '@ohos.window';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage: window.WindowStage) {
try { try {
dataPreferences.getPreferences(this.context, 'mystore', (err, preferences) => { dataPreferences.getPreferences(this.context, 'myStore', (err: BusinessError, preferences: dataPreferences.Preferences) => {
if (err) { if (err) {
console.error(`Failed to get preferences. Code:${err.code},message:${err.message}`); console.error(`Failed to get preferences. Code:${err.code},message:${err.message}`);
return; return;
...@@ -82,12 +84,13 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -82,12 +84,13 @@ The following table lists the APIs used for persisting user preference data. For
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import { BusinessError } from '@ohos.base';
// Obtain the context. // Obtain the context.
let context = featureAbility.getContext(); let context = featureAbility.getContext();
try { try {
dataPreferences.getPreferences(context, 'mystore', (err, preferences) => { dataPreferences.getPreferences(this.context, 'myStore', (err: BusinessError, preferences: dataPreferences.Preferences) => {
if (err) { if (err) {
console.error(`Failed to get preferences. Code:${err.code},message:${err.message}`); console.error(`Failed to get preferences. Code:${err.code},message:${err.message}`);
return; return;
...@@ -102,7 +105,7 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -102,7 +105,7 @@ The following table lists the APIs used for persisting user preference data. For
3. Write data. 3. Write data.
Use **putSync()** to write data to the cached **Preferences** instance. After data is written, you can use **flush()** to persist the **Preferences** instance data to a file if necessary. Use **putSync()** to save data to the cached **Preferences** instance. After data is written, you can use **flush()** to persist the **Preferences** instance data to a file if necessary.
> **NOTE** > **NOTE**
> >
...@@ -157,7 +160,7 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -157,7 +160,7 @@ The following table lists the APIs used for persisting user preference data. For
```js ```js
try { try {
preferences.flush((err) => { preferences.flush((err: BusinessError) => {
if (err) { if (err) {
console.error(`Failed to flush. Code:${err.code}, message:${err.message}`); console.error(`Failed to flush. Code:${err.code}, message:${err.message}`);
return; return;
...@@ -174,18 +177,20 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -174,18 +177,20 @@ The following table lists the APIs used for persisting user preference data. For
Specify an observer as the callback to return the data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data. Example: Specify an observer as the callback to return the data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data. Example:
```js ```js
let observer = function (key) { interface observer {
console.info('The key' + key + 'changed.'); key: string
} }
preferences.on('change', observer); preferences.on('change', (key: observer) => {
console.info('The key' + key + 'changed.');
});
// The data is changed from 'auto' to 'manual'. // The data is changed from 'auto' to 'manual'.
preferences.put('startup', 'manual', (err) => { preferences.put('startup', 'manual', (err: BusinessError) => {
if (err) { if (err) {
console.error(`Failed to put the value of 'startup'. Code:${err.code},message:${err.message}`); console.error(`Failed to put the value of 'startup'. Code:${err.code},message:${err.message}`);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush((err) => { preferences.flush((err: BusinessError) => {
if (err) { if (err) {
console.error(`Failed to flush. Code:${err.code}, message:${err.message}`); console.error(`Failed to flush. Code:${err.code}, message:${err.message}`);
return; return;
...@@ -210,7 +215,7 @@ The following table lists the APIs used for persisting user preference data. For ...@@ -210,7 +215,7 @@ The following table lists the APIs used for persisting user preference data. For
```js ```js
try { try {
dataPreferences.deletePreferences(this.context, 'mystore', (err, val) => { dataPreferences.deletePreferences(this.context, 'myStore', (err: BusinessError) => {
if (err) { if (err) {
console.error(`Failed to delete preferences. Code:${err.code}, message:${err.message}`); console.error(`Failed to delete preferences. Code:${err.code}, message:${err.message}`);
return; return;
......
...@@ -32,7 +32,7 @@ The underlying devices manage the data by device. The device KV stores support d ...@@ -32,7 +32,7 @@ The underlying devices manage the data by device. The device KV stores support d
The **DatamgrService** provides the following synchronization types: The **DatamgrService** provides the following synchronization types:
- Manual synchronization: The application calls **sync()** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL_ONLY** (pulling remote data to the local end), **PUSH_ONLY** (pushing local data to the remote end), or **PUSH_PULL** (pushing local data to the remote end and pulling remote data to the local end). You can use the [**sync()** with the **query** parameter](../reference/apis/js-apis-distributedKVStore.md#sync-1) to synchronize the data that meets the specified conditions. The manual synchronization is available only for system applications. - Manual synchronization: The application calls **sync()** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL_ONLY** (pulling remote data to the local end), **PUSH_ONLY** (pushing local data to the remote end), or **PUSH_PULL** (pushing local data to the remote end and pulling remote data to the local end). You can use the [**sync()** with the **query** parameter](../reference/apis/js-apis-distributedKVStore.md#sync-1) to synchronize the data that meets the specified conditions.
- Automatic synchronization: The distributed database automatically pushes local data to the remote end and pulls remote data to the local end. An automatic synchronization is triggered when a device goes online or an application updates data. - Automatic synchronization: The distributed database automatically pushes local data to the remote end and pulls remote data to the local end. An automatic synchronization is triggered when a device goes online or an application updates data.
...@@ -72,8 +72,6 @@ When data is added, deleted, or modified, a notification is sent to the subscrib ...@@ -72,8 +72,6 @@ When data is added, deleted, or modified, a notification is sent to the subscrib
- Each KV store supports a maximum of eight callbacks for subscription of data change notifications. - Each KV store supports a maximum of eight callbacks for subscription of data change notifications.
- The manual synchronization is available only for system applications.
## Available APIs ## Available APIs
...@@ -247,24 +245,21 @@ The following uses a single KV store as an example to describe how to implement ...@@ -247,24 +245,21 @@ The following uses a single KV store as an example to describe how to implement
> **NOTE** > **NOTE**
> >
> If manual synchronization is used, **deviceIds** is obtained by using [devManager.getTrustedDeviceListSync](../reference/apis/js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are all system interfaces and available only to system applications. > If manual synchronization is used, **deviceIds** can be obtained by [devManager.getAvailableDeviceListSync](../reference/apis/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedDeviceManager';
let devManager; let devManager;
try {
// create deviceManager // create deviceManager
deviceManager.createDeviceManager('bundleName', (err, value) => { devManager = deviceManager.createDeviceManager(context.applicationInfo.name);
if (!err) { // deviceIds is obtained by devManager.getAvailableDeviceListSync.
devManager = value;
// deviceIds is obtained by devManager.getTrustedDeviceListSync.
let deviceIds = []; let deviceIds = [];
if (devManager !== null) { if (devManager != null) {
// The ohos.permission.ACCESS_SERVICE_DM permission is required. This permission is available only for system applications. let devices = devManager.getAvailableDeviceListSync();
let devices = devManager.getTrustedDeviceListSync();
for (let i = 0; i < devices.length; i++) { for (let i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId; deviceIds[i] = devices[i].networkId;
} }
} }
try { try {
...@@ -273,6 +268,8 @@ The following uses a single KV store as an example to describe how to implement ...@@ -273,6 +268,8 @@ The following uses a single KV store as an example to describe how to implement
} catch (e) { } catch (e) {
console.error(`An unexpected error occurred. Code:${e.code},message:${e.message}`); console.error(`An unexpected error occurred. Code:${e.code},message:${e.message}`);
} }
} catch (err) {
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
} }
});
``` ```
\ No newline at end of file
...@@ -10,9 +10,16 @@ You can synchronize the application data in a local RDB store on a device to oth ...@@ -10,9 +10,16 @@ You can synchronize the application data in a local RDB store on a device to oth
OpenHamony supports synchronization of the relational data of an application across multiple devices. OpenHamony supports synchronization of the relational data of an application across multiple devices.
- Distributed table list<br>After a table is created for an application in an RDB store, you can set it as a distributed table. When querying the RDB store of a remote device, you can obtain the distributed table name of the remote device based on the local table name. - Distributed table list
- Synchronization mode<br>Data can be synchronized between devices in either of the following ways: <br>- Pushing data from a local device to a remote device. <br>- Pulling data from a remote device to a local device. After a table is created for an application in an RDB store, you can set it as a distributed table. When querying the RDB store of a remote device, you can obtain the distributed table name of the remote device based on the local table name.
- Synchronization mode
Data can be synchronized between devices in either of the following ways:
- Pushing data from a local device to a remote device.
- Pulling data from a remote device to a local device.
## Working Principles ## Working Principles
...@@ -44,12 +51,10 @@ When data is added, deleted, or modified, a notification is sent to the subscrib ...@@ -44,12 +51,10 @@ When data is added, deleted, or modified, a notification is sent to the subscrib
- Each RDB store supports a maximum of eight callbacks for subscription of data change notifications. - Each RDB store supports a maximum of eight callbacks for subscription of data change notifications.
- Third-party applications cannot call the distributed APIs that must be specified with the device.
## Available APIs ## Available APIs
The following table lists the APIs for cross-device data synchronization of RDB stores. Most of the APIs are executed asynchronously, using a callback or promise to return the result. The following table uses the callback-based APIs as an example. For more information about the APIs, see [RDB Store](../reference/apis/js-apis-data-relationalStore.md). Most of the APIs for cross-device data synchronization of RDB stores are executed asynchronously in callback or promise mode. The following table uses the callback-based APIs as an example. For more information about the APIs, see [RDB Store](../reference/apis/js-apis-data-relationalStore.md).
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
...@@ -73,7 +78,7 @@ The following table lists the APIs for cross-device data synchronization of RDB ...@@ -73,7 +78,7 @@ The following table lists the APIs for cross-device data synchronization of RDB
import relationalStore from '@ohos.data.relationalStore'; import relationalStore from '@ohos.data.relationalStore';
``` ```
2. Request permissions. 2. Apply for the required permission.
1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization). 2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
...@@ -142,20 +147,19 @@ The following table lists the APIs for cross-device data synchronization of RDB ...@@ -142,20 +147,19 @@ The following table lists the APIs for cross-device data synchronization of RDB
> **NOTE** > **NOTE**
> >
> **deviceIds** is obtained by using [devManager.getTrustedDeviceListSync](../reference/apis/js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are all system interfaces and available only to system applications. > The value of **deviceIds** can be obtained by [deviceManager.getAvailableDeviceListSync](../reference/apis/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
```js ```js
// Obtain device IDs. // Obtain device IDs.
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedDeviceManager';
let dmInstance = null;
let deviceId = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { try {
if (err) { dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
console.info(`Failed to create device manager. Code:${err.code},message:${err.message}`); let devices = dmInstance.getAvailableDeviceListSync();
return; deviceId = devices[0].networkId;
}
let devices = manager.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
// Construct a predicate object for querying the distributed table. // Construct a predicate object for querying the distributed table.
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
...@@ -169,5 +173,7 @@ The following table lists the APIs for cross-device data synchronization of RDB ...@@ -169,5 +173,7 @@ The following table lists the APIs for cross-device data synchronization of RDB
console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
} }
) )
}) } catch (err) {
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
}
``` ```
\ No newline at end of file
...@@ -57,13 +57,14 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt ...@@ -57,13 +57,14 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt
2. Right-click the **DataShareAbility** directory, and choose **New > TypeScript File** to create a file named **DataShareExtAbility.ts**. 2. Right-click the **DataShareAbility** directory, and choose **New > TypeScript File** to create a file named **DataShareExtAbility.ts**.
3. Import **@ohos.application.DataShareExtensionAbility** and other dependencies to the **DataShareExtAbility.ts** file, and 3. Import **@ohos.application.DataShareExtensionAbility** and other dependencies to the **DataShareExtAbility.ts** file, and override the service implementation as required. For example, if the data provider provides only the data insertion, deletion, and query services, you can override only these APIs.
override the service implementation as required. For example, if the data provider provides only the data insertion, deletion, and query services, you can override only these APIs.
```js ```js
import Extension from '@ohos.application.DataShareExtensionAbility'; import Extension from '@ohos.application.DataShareExtensionAbility';
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import dataSharePredicates from '@ohos.data.dataSharePredicates'; import dataSharePredicates from '@ohos.data.dataSharePredicates';
import relationalStore from '@ohos.data.relationalStore';
import Want from '@ohos.app.ability.Want';
``` ```
4. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network. 4. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network.
...@@ -75,20 +76,20 @@ override the service implementation as required. For example, if the data provid ...@@ -75,20 +76,20 @@ override the service implementation as required. For example, if the data provid
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
let result; let result: string;
export default class DataShareExtAbility extends Extension { export default class DataShareExtAbility extends Extension {
private rdbStore_; private rdbStore_: relationalStore.RdbStore;
// Override onCreate(). // Override onCreate().
onCreate(want, callback) { onCreate(want: Want, callback: Function) {
result = this.context.cacheDir + '/datashare.txt'; result = this.context.cacheDir + '/datashare.txt';
// Create an RDB store. // Create an RDB store.
rdb.getRdbStore(this.context, { rdb.getRdbStore(this.context, {
name: DB_NAME, name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1 securityLevel: rdb.SecurityLevel.S1
}, function (err, data) { }, (err, data) => {
rdbStore = data; rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => { rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => {
console.info(`DataShareExtAbility onCreate, executeSql done err:${err}`); console.info(`DataShareExtAbility onCreate, executeSql done err:${err}`);
...@@ -100,7 +101,7 @@ override the service implementation as required. For example, if the data provid ...@@ -100,7 +101,7 @@ override the service implementation as required. For example, if the data provid
} }
// Override query(). // Override query().
query(uri, predicates, columns, callback) { query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: Function) {
if (predicates === null || predicates === undefined) { if (predicates === null || predicates === undefined) {
console.info('invalid predicates'); console.info('invalid predicates');
} }
...@@ -188,6 +189,8 @@ override the service implementation as required. For example, if the data provid ...@@ -188,6 +189,8 @@ override the service implementation as required. For example, if the data provid
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import dataShare from '@ohos.data.dataShare'; import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates'; import dataSharePredicates from '@ohos.data.dataSharePredicates';
import { ValuesBucket } from '@ohos.data.ValuesBucket'
import window from '@ohos.window';
``` ```
2. Define the URI string for communicating with the data provider. 2. Define the URI string for communicating with the data provider.
...@@ -200,11 +203,11 @@ override the service implementation as required. For example, if the data provid ...@@ -200,11 +203,11 @@ override the service implementation as required. For example, if the data provid
3. Create a **DataShareHelper** instance. 3. Create a **DataShareHelper** instance.
```js ```js
let dsHelper; let dsHelper: dataShare.DataShareHelper;
let abilityContext; let abilityContext: Context;
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage: window.WindowStage) {
abilityContext = this.context; abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, (err, data) => { dataShare.createDataShareHelper(abilityContext, dseUri, (err, data) => {
dsHelper = data; dsHelper = data;
...@@ -217,8 +220,19 @@ override the service implementation as required. For example, if the data provid ...@@ -217,8 +220,19 @@ override the service implementation as required. For example, if the data provid
```js ```js
// Construct a piece of data. // Construct a piece of data.
let valuesBucket = { 'name': 'ZhangSan', 'age': 21, 'isStudent': false, 'Binary': new Uint8Array([1, 2, 3]) }; let key1 = 'name';
let updateBucket = { 'name': 'LiSi', 'age': 18, 'isStudent': true, 'Binary': new Uint8Array([1, 2, 3]) }; let key2 = 'age';
let key3 = 'isStudent';
let key4 = 'Binary';
let valueName1 = 'ZhangSan';
let valueName2 = 'LiSi';
let valueAge1 = 21;
let valueAge2 = 18;
let valueIsStudent1 = false;
let valueIsStudent2 = true;
let valueBinary = new Uint8Array([1, 2, 3]);
let valuesBucket: ValuesBucket = { key1: valueName1, key2: valueAge1, key3: valueIsStudent1, key4: valueBinary };
let updateBucket: ValuesBucket = { key1: valueName2, key2: valueAge2, key3: valueIsStudent2, key4: valueBinary };
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
let valArray = ['*']; let valArray = ['*'];
// Insert a piece of data. // Insert a piece of data.
...@@ -238,4 +252,3 @@ override the service implementation as required. For example, if the data provid ...@@ -238,4 +252,3 @@ override the service implementation as required. For example, if the data provid
console.info(`dsHelper delete result:${data}`); console.info(`dsHelper delete result:${data}`);
}); });
``` ```
\ No newline at end of file
...@@ -29,7 +29,7 @@ Currently, the UDMF provides the public data channel for cross-application data ...@@ -29,7 +29,7 @@ Currently, the UDMF provides the public data channel for cross-application data
## Available APIs ## Available APIs
The following table lists the UDMF APIs. All of them are executed asynchronously in callback or promise mode. In the following table, callback-based APIs are used as an example. For more information about the APIs, see [UDMF](../reference/apis/js-apis-data-udmf.md). The following table lists the UDMF APIs. All of them are executed asynchronously in callback or promise mode. In the following table, callback-based APIs are used as an example. For more information about the APIs, see [Unified Data Channel](../reference/apis/js-apis-data-unifiedDataChannel.md) and [Standard Data Definition and Description](../reference/apis/js-apis-data-uniformTypeDescriptor.md).
| API | Description | | API | Description |
|-----------------------------------------------------------------------------------------|---------------------------------------------| |-----------------------------------------------------------------------------------------|---------------------------------------------|
...@@ -45,75 +45,81 @@ The following example describes how to implement many-to-many data sharing. The ...@@ -45,75 +45,81 @@ The following example describes how to implement many-to-many data sharing. The
### Data Provider ### Data Provider
1. Import the **@ohos.data.UDMF** module. 1. Import the **@ohos.data.unifiedDataChannel** and **@ohos.data.uniformTypeDescriptor** modules.
```ts ```ts
import UDMF from '@ohos.data.UDMF'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
``` ```
2. Create a **UnifiedData** object and insert it into the UDMF public data channel. 2. Create a **UnifiedData** object and insert it into the UDMF public data channel.
```ts ```ts
let plainText = new UDMF.PlainText(); import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'hello world!'; plainText.textContent = 'hello world!';
let unifiedData = new UDMF.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
// Specify the type of the data channel to which the data is to be inserted. // Specify the type of the data channel to which the data is to be inserted.
let options = { let options: unifiedDataChannel.Options = {
intention: UDMF.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
} }
try { try {
UDMF.insertData(options, unifiedData, (err, data) => { unifiedDataChannel.insertData(options, unifiedData, (err, data) => {
if (err === undefined) { if (err === undefined) {
console.info(`Succeeded in inserting data. key = ${data}`); console.info(`Succeeded in inserting data. key = ${data}`);
} else { } else {
console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `); console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Insert data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
3. Update the **UnifiedData** object inserted. 3. Update the **UnifiedData** object inserted.
```ts ```ts
let plainText = new UDMF.PlainText(); import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'How are you!'; plainText.textContent = 'How are you!';
let unifiedData = new UDMF.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
// Specify the URI of the UnifiedData object to update. // Specify the URI of the UnifiedData object to update.
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
try { try {
UDMF.updateData(options, unifiedData, (err) => { unifiedDataChannel.updateData(options, unifiedData, (err) => {
if (err === undefined) { if (err === undefined) {
console.info('Succeeded in updating data.'); console.info('Succeeded in updating data.');
} else { } else {
console.error(`Failed to update data. code is ${err.code},message is ${err.message} `); console.error(`Failed to update data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Update data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
4. Delete the **UnifiedData** object from the UDMF public data channel. 4. Delete the **UnifiedData** object from the UDMF public data channel.
```ts ```ts
import { BusinessError } from '@ohos.base';
// Specify the type of the data channel whose data is to be deleted. // Specify the type of the data channel whose data is to be deleted.
let options = { let options: unifiedDataChannel.Options = {
intention: UDMF.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
try { try {
UDMF.deleteData(options, (err, data) => { unifiedDataChannel.deleteData(options, (err, data) => {
if (err === undefined) { if (err === undefined) {
console.info(`Succeeded in deleting data. size = ${data.length}`); console.info(`Succeeded in deleting data. size = ${data.length}`);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === UDMF.UnifiedDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
...@@ -122,35 +128,38 @@ The following example describes how to implement many-to-many data sharing. The ...@@ -122,35 +128,38 @@ The following example describes how to implement many-to-many data sharing. The
console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `); console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Delete data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Delete data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
### Data Consumer ### Data Consumer
1. Import the **@ohos.data.UDMF** module. 1. Import the **@ohos.data.unifiedDataChannel** and **@ohos.data.uniformTypeDescriptor** modules.
```ts ```ts
import UDMF from '@ohos.data.UDMF'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
``` ```
2. Query the **UnifiedData** object in the UDMF public data channel. 2. Query the **UnifiedData** object in the UDMF public data channel.
```ts ```ts
import { BusinessError } from '@ohos.base';
// Specify the type of the data channel whose data is to be queried. // Specify the type of the data channel whose data is to be queried.
let options = { let options: unifiedDataChannel.Options = {
intention: UDMF.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
try { try {
UDMF.queryData(options, (err, data) => { unifiedDataChannel.queryData(options, (err, data) => {
if (err === undefined) { if (err === undefined) {
console.info(`Succeeded in querying data. size = ${data.length}`); console.info(`Succeeded in querying data. size = ${data.length}`);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === UDMF.UnifiedDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <UDMF.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
...@@ -160,6 +169,7 @@ The following example describes how to implement many-to-many data sharing. The ...@@ -160,6 +169,7 @@ The following example describes how to implement many-to-many data sharing. The
} }
}); });
} catch(e) { } catch(e) {
console.error(`Query data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -5,28 +5,35 @@ ...@@ -5,28 +5,35 @@
To streamline cross-application data interaction of OpenHarmony and minimize the application/service data interaction costs, the Unified Data Management Framework (UDMF) provides standard data definitions to define common data types. Applications can use the APIs provided by the UDMF to create and use these data types. To streamline cross-application data interaction of OpenHarmony and minimize the application/service data interaction costs, the Unified Data Management Framework (UDMF) provides standard data definitions to define common data types. Applications can use the APIs provided by the UDMF to create and use these data types.
For example, in the cross-application drag scenario, the application of the drag source writes the data to be dragged to a [drag event](../reference/arkui-ts/ts-universal-events-drag-drop.md#dragevent) based on the standard data definitions. The application of the drop target reads the dragged data from the drag event and parses the data based on the standard data definitions. The data dragged between different applications complies with the same standard definitions, which avoids exhaustive data type adaptation and effectively reduces the development workload.
## Unified Data Types ## Unified Data Types
The UDMF provides the following unified data types: The UDMF provides the following unified data types:
**Basic data types**<br>Basic data types include File and Text, which can be used for cross-application and cross-platform data interaction. Figure 1 and Figure 2 illustrate the basic data types. **Basic data types**
Basic data types include File and Text, which can be used for cross-application and cross-platform data interaction. Figure 1 and Figure 2 illustrate the basic data types.
**Figure 1** UDMF File **Figure 1** UDMF File
![UDMF_FILE](figures/udmf_type_File.png) ![UDMF_FILE](figures/udmf_type_File.png)
Figure 2 UDMF Text **Figure 2** UDMF Text
![UDMF_TEXT](figures/udmf_type_Text.png) ![UDMF_TEXT](figures/udmf_type_Text.png)
**System Defined Types (SDTs)**<br>The SDTs are specific to the platform or operating system, such as Form (UI card information), AppItem (app description information), and PixelMap (thumbnail). This type of data can be used for cross-application data interaction in a system or platform. Figure 3 illustrates the SDT data. **System Defined Types (SDTs)**
The SDTs are specific to the platform or operating system, such as Form (UI card information), AppItem (app description information), and PixelMap (thumbnail). This type of data can be used for cross-application data interaction in a system or platform. Figure 3 illustrates the SDT data.
**Figure 3** UDMF SDT data **Figure 3** UDMF SDT data
![UDMF_SDT](figures/udmf_type_SDT.png) ![UDMF_SDT](figures/udmf_type_SDT.png)
**App Defined Type (ADT)**<br>The SDT data is application-specific. This type of data can be used for across-platform data interaction for an application. As shown in Figure 4, the MyFile file format can be defined for use in an application ecosystem. **App Defined Type (ADT)**
The SDT data is application-specific. This type of data can be used for across-platform data interaction for an application. As shown in Figure 4, the MyFile file format can be defined for use in an application ecosystem.
**Figure 4** UDMF ADT data **Figure 4** UDMF ADT data
...@@ -39,9 +46,9 @@ Figure 2 UDMF Text ...@@ -39,9 +46,9 @@ Figure 2 UDMF Text
## Available APIs ## Available APIs
The UDMF provides the unified data object **UnifiedData** to encapsulate a group of data records **UnifiedRecord**. **UnifiedRecord** is an abstract definition of data content supported by the UDMF, for example, a text record or an image record. The data content type in a data record corresponds to **UnifiedDataType**. The UDMF provides the unified data object **UnifiedData** to encapsulate a group of data records **UnifiedRecord**. **UnifiedRecord** is an abstract definition of data content supported by the UDMF, for example, a text record or an image record. The data content type in a data record corresponds to **UniformDataType**.
The following table describes common UDMF APIs. For more information, see [UDMF](../reference/apis/js-apis-data-udmf.md). The following table describes common UDMF APIs. For more information about the APIs, see [Unified Data Channel](../reference/apis/js-apis-data-unifiedDataChannel.md) and [Standard Data Definition and Description](../reference/apis/js-apis-data-uniformTypeDescriptor.md).
| Class | API | Description | | Class | API | Description |
|---------------|-------------------|-----------------------------------------------------------------------------------------------| |---------------|-------------------|-----------------------------------------------------------------------------------------------|
...@@ -55,17 +62,19 @@ The following table describes common UDMF APIs. For more information, see [UDMF] ...@@ -55,17 +62,19 @@ The following table describes common UDMF APIs. For more information, see [UDMF]
The following describes how to create a **UnifiedData** object containing two data records: image and plain text. The following describes how to create a **UnifiedData** object containing two data records: image and plain text.
1. Import the **@ohos.data.UDMF** module. 1. Import the **@ohos.data.unifiedDataChannel** and **@ohos.data.uniformTypeDescriptor** modules.
```ts ```ts
import UDMF from '@ohos.data.UDMF'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
``` ```
2. Create an image data record and initialize the **UnifiedData** object with the image data record. 2. Create an image data record and initialize the **UnifiedData** object with the image data record.
(1) Create an image data record. (1) Create an image data record.
```ts ```ts
let image = new UDMF.Image(); let image = new unifiedDataChannel.Image();
``` ```
(2) Modify object attributes. (2) Modify object attributes.
...@@ -84,12 +93,13 @@ The following describes how to create a **UnifiedData** object containing two da ...@@ -84,12 +93,13 @@ The following describes how to create a **UnifiedData** object containing two da
(4) Create a **UnifiedData** instance. (4) Create a **UnifiedData** instance.
```ts ```ts
let unifiedData = new UDMF.UnifiedData(image); let unifiedData = new unifiedDataChannel.UnifiedData(image);
``` ```
3. Create a plain text data record and add it to the **UnifiedData** instance created. 3. Create a plain text data record and add it to the **UnifiedData** instance created.
```ts ```ts
let plainText = new UDMF.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'this is textContent of plainText'; plainText.textContent = 'this is textContent of plainText';
plainText.abstract = 'abstract of plainText'; plainText.abstract = 'abstract of plainText';
plainText.details = { plainText.details = {
...@@ -98,11 +108,13 @@ The following describes how to create a **UnifiedData** object containing two da ...@@ -98,11 +108,13 @@ The following describes how to create a **UnifiedData** object containing two da
}; };
unifiedData.addRecord(plainText); unifiedData.addRecord(plainText);
``` ```
4. Obtain all data records in this **UnifiedData** instance. 4. Obtain all data records in this **UnifiedData** instance.
```ts ```ts
let records = unifiedData.getRecords(); let records = unifiedData.getRecords();
``` ```
5. Traverse each record, determine the data type of the record, and convert the record into a child class object to obtain the original data record. 5. Traverse each record, determine the data type of the record, and convert the record into a child class object to obtain the original data record.
```ts ```ts
...@@ -110,13 +122,13 @@ The following describes how to create a **UnifiedData** object containing two da ...@@ -110,13 +122,13 @@ The following describes how to create a **UnifiedData** object containing two da
// Read the type of the data record. // Read the type of the data record.
let type = records[i].getType(); let type = records[i].getType();
switch (type) { switch (type) {
case UDMF.UnifiedDataType.IMAGE: case uniformTypeDescriptor.UniformDataType.IMAGE:
// Convert the data to obtain the original image data record. // Convert the data to obtain the original image data record.
let image = <UDMF.Image>(records[i]); let image = records[i] as unifiedDataChannel.Image;
break; break;
case UDMF.UnifiedDataType.PLAIN_TEXT: case uniformTypeDescriptor.UniformDataType.PLAIN_TEXT:
// Convert the data to obtain the original text record. // Convert the data to obtain the original text record.
let plainText = <UDMF.PlainText>(records[i]); let plainText = records[i] as unifiedDataChannel.PlainText;
break; break;
default: default:
break; break;
......
...@@ -8,9 +8,11 @@ OpenHarmony provides multiple classes for you to develop audio playback applicat ...@@ -8,9 +8,11 @@ OpenHarmony provides multiple classes for you to develop audio playback applicat
- [AudioRenderer](using-audiorenderer-for-playback.md): provides ArkTS and JS API to implement audio output. It supports only the PCM format and requires applications to continuously write audio data. The applications can perform data preprocessing, for example, setting the sampling rate and bit width of audio files, before audio input. This class can be used to develop more professional and diverse playback applications. To use this class, you must have basic audio processing knowledge. - [AudioRenderer](using-audiorenderer-for-playback.md): provides ArkTS and JS API to implement audio output. It supports only the PCM format and requires applications to continuously write audio data. The applications can perform data preprocessing, for example, setting the sampling rate and bit width of audio files, before audio input. This class can be used to develop more professional and diverse playback applications. To use this class, you must have basic audio processing knowledge.
- [OpenSL ES](using-opensl-es-for-playback.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio output in PCM format and is applicable to playback applications that are ported from other embedded platforms or that implements audio output at the native layer. - [OpenSL ES](using-opensl-es-for-playback.md): provides a set of standard, cross-platform native audio APIs. It supports audio output in PCM format and is suitable for playback applications that are ported from other embedded platforms or that implement audio output at the native layer.
- [TonePlayer](using-toneplayer-for-playback.md): provides ArkTS and JS API to implement the playback of dialing tones and ringback tones. It can be used to play the content selected from a fixed type range, without requiring the input of media assets or audio data. This class is application to specific scenarios where dialing tones and ringback tones are played. is available only to system applications. - [Using OHAudio for Audio Playback](using-ohaudio-for-playback.md): provides a set of native APIs for audio output. These APIs are normalized in design and support both common and low-latency audio channels. They are suitable for playback applications that implement audio output at the native layer.
- [TonePlayer](using-toneplayer-for-playback.md): provides ArkTS and JS APIs to implement the playback of dialing tones and ringback tones. It can be used to play the content selected from a fixed type range, without requiring the input of media assets or audio data. This class is applicable to specific scenarios where dialing tones and ringback tones are played. It is available only to system applications.
- Applications often need to use short sound effects, such as camera shutter sound effect, key press sound effect, and game shooting sound effect. Currently, only the **AVPlayer** class can implement audio file playback. More APIs will be provided to support this scenario in later versions. - Applications often need to use short sound effects, such as camera shutter sound effect, key press sound effect, and game shooting sound effect. Currently, only the **AVPlayer** class can implement audio file playback. More APIs will be provided to support this scenario in later versions.
......
...@@ -8,7 +8,9 @@ OpenHarmony provides multiple classes for you to develop audio recording applica ...@@ -8,7 +8,9 @@ OpenHarmony provides multiple classes for you to develop audio recording applica
- [AudioCapturer](using-audiocapturer-for-recording.md): provides ArkTS and JS API to implement audio input. It supports only the PCM format and requires applications to continuously read audio data. The application can perform data processing after audio output. This class can be used to develop more professional and diverse recording applications. To use this class, you must have basic audio processing knowledge. - [AudioCapturer](using-audiocapturer-for-recording.md): provides ArkTS and JS API to implement audio input. It supports only the PCM format and requires applications to continuously read audio data. The application can perform data processing after audio output. This class can be used to develop more professional and diverse recording applications. To use this class, you must have basic audio processing knowledge.
- [OpenSL ES](using-opensl-es-for-recording.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio input in PCM format and is applicable to recording applications that are ported from other embedded platforms or that implements audio input at the native layer. - [OpenSL ES](using-opensl-es-for-recording.md): provides a set of standard, cross-platform native audio APIs. It supports audio input in PCM format and is suitable for recording applications that are ported from other embedded platforms or that implement audio input at the native layer.
- [Using OHAudio for Audio Recording](using-ohaudio-for-recording.md): provides a set of native APIs for audio input. These APIs are normalized in design and support both common and low-latency audio channels. They are suitable for playback applications that implement audio input at the native layer.
## Precautions for Developing Audio Recording Applications ## Precautions for Developing Audio Recording Applications
......
...@@ -241,7 +241,7 @@ The **abilities** tag represents the UIAbility configuration of the module, whic ...@@ -241,7 +241,7 @@ The **abilities** tag represents the UIAbility configuration of the module, whic
| label | Name of the UIAbility component displayed to users. The value is a string resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.| | label | Name of the UIAbility component displayed to users. The value is a string resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| permissions | Permissions required for another application to access the UIAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of predefined permission names.| String array| Yes (initial value: left empty)| | permissions | Permissions required for another application to access the UIAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of predefined permission names.| String array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications, not even by aa commands.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)| | continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)| | [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)| | backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
...@@ -382,7 +382,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie ...@@ -382,7 +382,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)| | uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)| |skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications, not even by aa commands.| Boolean| Yes (initial value: **false**)|
Example of the **extensionAbilities** structure: Example of the **extensionAbilities** structure:
......
...@@ -97,7 +97,7 @@ Example of the **module** tag structure: ...@@ -97,7 +97,7 @@ Example of the **module** tag structure:
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| moduleName | Name of the HAP file. The maximum length is 31 bytes. During application upgrade, this name can be changed. If it is changed, migration of module-related directories is required for the application. You can use the [file operation API](../reference/apis/js-apis-file-fs.md#fscopydir10) for migration.| String| No| | moduleName | Name of the HAP file. The maximum length is 31 bytes. This name can be changed during application update. However, if it is changed, you need to adapt the application to the migration of module-related directories. You can use the [file operation API](../reference/apis/js-apis-file-fs.md#fscopydir10) for this purpose.| String| No|
| moduleType | Type of the HAP file, which can **entry**, **feature**, or **har**.| String| No| | moduleType | Type of the HAP file, which can **entry**, **feature**, or **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. If this tag is set to **true** for an entry-type HAP file (**entry.hap**), it must also be set to **true** for feature-type HAP files (**feature.hap**) of the same application. If this tag is set to **false** for an entry-type HAP file, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| 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. If this tag is set to **true** for an entry-type HAP file (**entry.hap**), it must also be set to **true** for feature-type HAP files (**feature.hap**) of the same application. If this tag is set to **false** for an entry-type HAP file, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No|
| deliveryWithInstall | Whether the HAP file will be installed when the user installs the application. **true**: The HAP file will be installed when the user installs the application. **false**: The HAP file will not be installed when the user installs the application.| Boolean| No| | deliveryWithInstall | Whether the HAP file will be installed when the user installs the application. **true**: The HAP file will be installed when the user installs the application. **false**: The HAP file will not be installed when the user installs the application.| Boolean| No|
...@@ -203,7 +203,7 @@ Example of the metadata attribute: ...@@ -203,7 +203,7 @@ Example of the metadata attribute:
| label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. 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.<br>**NOTE**<br>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 bytes.| String| Yes (initial value: left empty)| | label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. 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.<br>**NOTE**<br>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 bytes.| String| Yes (initial value: left empty)|
| uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)| | uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)|
| launchType | Launch type of the ability. The value can be **standard** or **singleton**.<br>**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.<br>**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 launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)| | launchType | Launch type of the ability. The value can be **standard** or **singleton**.<br>**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.<br>**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 launch 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.<br>**true**: The ability can be called by other applications.<br>**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | visible | Whether the ability can be called by other applications.<br>**true**: The ability can be called by other applications.<br>**false**: The ability cannot be called by other applications, not even by aa commands.| Boolean| Yes (initial value: **false**)|
| permissions | Permissions required for abilities of another application to call the current ability. The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)| | permissions | Permissions required for abilities of another application to call the current ability. The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| 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)| |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. The value is an array of up to 512 elements, each of which contains a maximum of 64 bytes.| String array| Yes (initial value: left empty)| | deviceCapability | Device capabilities required to run the ability. The value is an array of up to 512 elements, each of which contains a maximum of 64 bytes.| String array| Yes (initial value: left empty)|
......
...@@ -57,7 +57,7 @@ You can debug HAP files using the methods: ...@@ -57,7 +57,7 @@ You can debug HAP files using the methods:
When your application package meets the release requirements, you can package and build it into an App Pack and release it to the application market on the cloud. The application market verifies the signature of the App Pack. If the signature verification is successful, the application market obtains the HAP files from the App Pack, signs them, and distributes the signed HAP files. When your application package meets the release requirements, you can package and build it into an App Pack and release it to the application market on the cloud. The application market verifies the signature of the App Pack. If the signature verification is successful, the application market obtains the HAP files from the App Pack, signs them, and distributes the signed HAP files.
## Deployment ## Deployment
The application market on the cloud distributes the applications to application market clients. These applications can contain one or more HAP files. After the user selects an application to download, the application market downloads all the HAP files contained in this application. The application market on the cloud distributes the applications to application market clients. These applications can contain one or more HAP files. After the user selects an application to download, the application market downloads all the HAP files contained in this application whose **deliveryWithInstall** field is set to **true**.
## Installation on a Device ## Installation on a Device
After the download is complete, the application market client calls the installation API of the bundle manager service in the system to install the downloaded HAP files. The bundle manager service deploys HAP files by application in the specified directory to complete the application installation. After the download is complete, the application market client calls the installation API of the bundle manager service in the system to install the downloaded HAP files. The bundle manager service deploys HAP files by application in the specified directory to complete the application installation.
...@@ -35,7 +35,7 @@ Along its evolution, OpenHarmony has provided two application models: ...@@ -35,7 +35,7 @@ Along its evolution, OpenHarmony has provided two application models:
For details about the differences between the FA model and stage model, see [Interpretation of the Application Model](../application-models/application-model-description.md). For details about the differences between the FA model and stage model, see [Interpretation of the Application Model](../application-models/application-model-description.md).
To help you better understand the preceding basic concepts and application development process, **Getting Started** provides a development example that contains two pages in different programming languages and application models. To help you better understand the preceding basic concepts and application development process, **Getting Started** walks you through an example of building the first ArkTS application with two pages in the stage model.
## Tool Preparation ## Tool Preparation
......
...@@ -280,7 +280,8 @@ ...@@ -280,7 +280,8 @@
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (User Preferences)](js-apis-data-preferences.md) - [@ohos.data.preferences (User Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md) - [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.UDMF (Unfied Data Management Framework)](js-apis-data-udmf.md) - [@ohos.data.unifiedDataChannel (Unified Data Channel)](js-apis-data-unifiedDataChannel.md)
- [@ohos.data.uniformTypeDescriptor (Standard Data Definition)](js-apis-data-uniformTypeDescriptor.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- File Management - File Management
......
...@@ -29,7 +29,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -29,7 +29,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
## UIAbility.onCreate ## UIAbility.onCreate
onCreate(want: Want, param: AbilityConstant.LaunchParam): void; onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;
Called to initialize the service logic when a UIAbility is created. Called to initialize the service logic when a UIAbility is created.
...@@ -46,7 +46,7 @@ Called to initialize the service logic when a UIAbility is created. ...@@ -46,7 +46,7 @@ Called to initialize the service logic when a UIAbility is created.
```ts ```ts
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onCreate(want, param) { onCreate(want, launchParam) {
console.log('onCreate, want: ${want.abilityName}'); console.log('onCreate, want: ${want.abilityName}');
} }
} }
...@@ -226,7 +226,7 @@ Called to save data during the ability migration preparation process. ...@@ -226,7 +226,7 @@ Called to save data during the ability migration preparation process.
## UIAbility.onNewWant ## UIAbility.onNewWant
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;
Called when a new Want is passed in and this UIAbility is started again. Called when a new Want is passed in and this UIAbility is started again.
...@@ -237,15 +237,15 @@ Called when a new Want is passed in and this UIAbility is started again. ...@@ -237,15 +237,15 @@ Called when a new Want is passed in and this UIAbility is started again.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.| | want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.| | launchParam | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.|
**Example** **Example**
```ts ```ts
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onNewWant(want, launchParams) { onNewWant(want, launchParam) {
console.log('onNewWant, want: ${want.abilityName}'); console.log('onNewWant, want: ${want.abilityName}');
console.log('onNewWant, launchParams: ${JSON.stringify(launchParams)}'); console.log('onNewWant, launchParam: ${JSON.stringify(launchParam)}');
} }
} }
``` ```
...@@ -315,7 +315,7 @@ class MyUIAbility extends UIAbility { ...@@ -315,7 +315,7 @@ class MyUIAbility extends UIAbility {
onShare(wantParam:{ [key: string]: Object }): void; onShare(wantParam:{ [key: string]: Object }): void;
Called by this UIAbility to set data to share. **ohos.extra.param.key.shareUrl** indicates the online address of the service. Called by this UIAbility to set data to share in the cross-device sharing scenario.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -323,7 +323,7 @@ Called by this UIAbility to set data to share. **ohos.extra.param.key.shareUrl** ...@@ -323,7 +323,7 @@ Called by this UIAbility to set data to share. **ohos.extra.param.key.shareUrl**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;Object} | Yes| **want** parameter.| | wantParam | {[key:&nbsp;string]:&nbsp;Object} | Yes| Data to share.|
**Example** **Example**
......
...@@ -4,11 +4,10 @@ The **DataShareExtensionAbility** module provides data share services based on t ...@@ -4,11 +4,10 @@ The **DataShareExtensionAbility** module provides data share services based on t
>**NOTE** >**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 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 provided by this module are system APIs. > - The APIs provided by this module are system APIs and can be used only in the stage model.
> >
> The APIs of this module can be used only in the stage model.
## Modules to Import ## Modules to Import
...@@ -50,17 +49,17 @@ let TBL_NAME = 'TBL00'; ...@@ -50,17 +49,17 @@ let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want, callback) { onCreate(want: Want, callback: Function) {
rdb.getRdbStore(this.context, { rdb.getRdbStore(this.context, {
name: DB_NAME, name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1 securityLevel: rdb.SecurityLevel.S1
}, function (err, data) { }, (err, data) => {
console.info(`getRdbStore done, data : ${data}`); console.info(`getRdbStore done, data : ${data}`);
rdbStore = data; rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => {
console.error(`executeSql done, error message : ${err}`); console.error(`executeSql done, error message : ${err}`);
}); });
if (callback) { if (callback) {
...@@ -91,21 +90,22 @@ Inserts data into the database. This API can be overridden as required. ...@@ -91,21 +90,22 @@ Inserts data into the database. This API can be overridden as required.
```ts ```ts
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import { ValuesBucket } from '@ohos.data.ValuesBucket'
let DB_NAME = 'DB00.db'; let DB_NAME = 'DB00.db';
let TBL_NAME = 'TBL00'; let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
insert(uri, valueBucket, callback) { insert(uri: string, valueBucket: ValuesBucket, callback: Function) {
if (valueBucket === null) { if (valueBucket === null) {
console.error('invalid valueBuckets'); console.error('invalid valueBuckets');
return; return;
} }
rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) { rdbStore.insert(TBL_NAME, valueBucket, (err, ret) => {
console.info(`callback ret: ${ret}`); console.info(`callback ret: ${ret}`);
if (callback !== undefined) { if (callback !== undefined) {
callback(err, ret); callback(err, ret);
...@@ -136,20 +136,22 @@ Updates data in the database. This API can be overridden as required. ...@@ -136,20 +136,22 @@ Updates data in the database. This API can be overridden as required.
```ts ```ts
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import { ValuesBucket } from '@ohos.data.ValuesBucket'
let DB_NAME = 'DB00.db'; let DB_NAME = 'DB00.db';
let TBL_NAME = 'TBL00'; let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
update(uri, predicates, valueBucket, callback) { update(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: Function) {
if (predicates === null || predicates === undefined) { if (predicates === null || predicates === undefined) {
return; return;
} }
rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { rdbStore.update(TBL_NAME, valueBucket, predicates, (err, ret) => {
if (callback !== undefined) { if (callback !== undefined) {
callback(err, ret); callback(err, ret);
} }
...@@ -178,20 +180,21 @@ Deletes data from the database. This API can be overridden as required. ...@@ -178,20 +180,21 @@ Deletes data from the database. This API can be overridden as required.
```ts ```ts
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
let DB_NAME = 'DB00.db'; let DB_NAME = 'DB00.db';
let TBL_NAME = 'TBL00'; let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
delete(uri, predicates, callback) { delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: Function) {
if (predicates === null || predicates === undefined) { if (predicates === null || predicates === undefined) {
return; return;
} }
rdbStore.delete(TBL_NAME, predicates, function (err, ret) { rdbStore.delete(TBL_NAME, predicates, (err, ret) => {
if (callback !== undefined) { if (callback !== undefined) {
callback(err, ret); callback(err, ret);
} }
...@@ -221,20 +224,21 @@ Queries data from the database. This API can be overridden as required. ...@@ -221,20 +224,21 @@ Queries data from the database. This API can be overridden as required.
```ts ```ts
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
let DB_NAME = 'DB00.db'; let DB_NAME = 'DB00.db';
let TBL_NAME = 'TBL00'; let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
query(uri, predicates, columns, callback) { query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: Function) {
if (predicates === null || predicates === undefined) { if (predicates === null || predicates === undefined) {
return; return;
} }
rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) { rdbStore.query(TBL_NAME, predicates, columns, (err, resultSet) => {
if (resultSet !== undefined) { if (resultSet !== undefined) {
console.info(`resultSet.rowCount: ${resultSet.rowCount}`); console.info(`resultSet.rowCount: ${resultSet.rowCount}`);
} }
...@@ -266,21 +270,22 @@ Batch inserts data into the database. This API is called by the server and can b ...@@ -266,21 +270,22 @@ Batch inserts data into the database. This API is called by the server and can b
```ts ```ts
import rdb from '@ohos.data.relationalStore'; import rdb from '@ohos.data.relationalStore';
import { ValuesBucket } from '@ohos.data.ValuesBucket'
let DB_NAME = 'DB00.db'; let DB_NAME = 'DB00.db';
let TBL_NAME = 'TBL00'; let TBL_NAME = 'TBL00';
let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME + TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore; let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
batchInsert(uri, valueBuckets, callback) { batchInsert(uri: string, valueBuckets: Array<ValuesBucket>, callback: Function) {
if (valueBuckets === null || valueBuckets.length === undefined) { if (valueBuckets === null || valueBuckets.length === undefined) {
console.error('invalid valueBuckets'); console.error('invalid valueBuckets');
return; return;
} }
rdbStore.batchInsert(TBL_NAME, valueBuckets, function (err, ret) { rdbStore.batchInsert(TBL_NAME, valueBuckets, (err, ret) => {
if (callback !== undefined) { if (callback !== undefined) {
callback(err, ret); callback(err, ret);
} }
...@@ -308,9 +313,15 @@ Normalizes a URI. This API can be overridden as required. ...@@ -308,9 +313,15 @@ Normalizes a URI. This API can be overridden as required.
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
normalizeUri(uri, callback) { normalizeUri(uri: string, callback: Function) {
let err = {'code':0}; let key = 'code';
let ret = `normalize: ${uri}`; let value = 0;
let err: BusinessError = {
code: value,
name: key,
message: key
};
let ret: string = `normalize: ${uri}`;
callback(err, ret); callback(err, ret);
} }
}; };
...@@ -335,8 +346,14 @@ Denormalizes a URI. This API can be overridden as required. ...@@ -335,8 +346,14 @@ Denormalizes a URI. This API can be overridden as required.
```ts ```ts
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
denormalizeUri(uri, callback) { denormalizeUri(uri: string, callback: Function) {
let err = {'code':0}; let key = 'code';
let value = 0;
let err: BusinessError = {
code: value,
name: key,
message: key
};
let ret = `denormalize ${uri}`; let ret = `denormalize ${uri}`;
callback(err, ret); callback(err, ret);
} }
......
...@@ -672,7 +672,7 @@ Describes audio renderer information. ...@@ -672,7 +672,7 @@ Describes audio renderer information.
| ------------- | --------------------------- | ---- | ---------------- | | ------------- | --------------------------- | ---- | ---------------- |
| content | [ContentType](#contenttype) | No | Audio content type.<br>This parameter is mandatory in API versions 8 and 9 and optional since API version 10.| | content | [ContentType](#contenttype) | No | Audio content type.<br>This parameter is mandatory in API versions 8 and 9 and optional since API version 10.|
| usage | [StreamUsage](#streamusage) | Yes | Audio stream usage.| | usage | [StreamUsage](#streamusage) | Yes | Audio stream usage.|
| rendererFlags | number | Yes | Audio renderer flags.| | rendererFlags | number | Yes | Audio renderer flags.<br>The value **0** means a common audio renderer, and **1** means a low-latency audio renderer. Currently, the JS APIs do not support the low-latency audio renderer.|
## InterruptResult<sup>9+</sup> ## InterruptResult<sup>9+</sup>
...@@ -4341,9 +4341,9 @@ async function selectOutputDeviceByFilter(){ ...@@ -4341,9 +4341,9 @@ async function selectOutputDeviceByFilter(){
} }
``` ```
### getPreferOutputDeviceForRendererInfo<sup>10+</sup> ### getPreferredOutputDeviceForRendererInfo<sup>10+</sup>
getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback&lt;AudioDeviceDescriptors&gt;): void getPreferredOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback&lt;AudioDeviceDescriptors&gt;): void
Obtains the output device with the highest priority based on the audio renderer information. This API uses an asynchronous callback to return the result. Obtains the output device with the highest priority based on the audio renderer information. This API uses an asynchronous callback to return the result.
...@@ -4356,6 +4356,15 @@ Obtains the output device with the highest priority based on the audio renderer ...@@ -4356,6 +4356,15 @@ Obtains the output device with the highest priority based on the audio renderer
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. | | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. |
| callback | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes | Callback used to return the information about the output device with the highest priority.| | callback | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes | Callback used to return the information about the output device with the highest priority.|
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error. Return by callback. |
| 6800301 | System error. Return by callback. |
**Example** **Example**
```js ```js
let rendererInfo = { let rendererInfo = {
...@@ -4363,8 +4372,8 @@ let rendererInfo = { ...@@ -4363,8 +4372,8 @@ let rendererInfo = {
usage : audio.StreamUsage.STREAM_USAGE_MEDIA, usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags : 0 } rendererFlags : 0 }
async function getPreferOutputDevice() { async function getPreferredOutputDevice() {
audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo, (err, desc) => { audioRoutingManager.getPreferredOutputDeviceForRendererInfo(rendererInfo, (err, desc) => {
if (err) { if (err) {
console.error(`Result ERROR: ${err}`); console.error(`Result ERROR: ${err}`);
} else { } else {
...@@ -4374,8 +4383,8 @@ async function getPreferOutputDevice() { ...@@ -4374,8 +4383,8 @@ async function getPreferOutputDevice() {
} }
``` ```
### getPreferOutputDeviceForRendererInfo<sup>10+</sup> ### getPreferredOutputDeviceForRendererInfo<sup>10+</sup>
getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise&lt;AudioDeviceDescriptors&gt; getPreferredOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise&lt;AudioDeviceDescriptors&gt;
Obtains the output device with the highest priority based on the audio renderer information. This API uses a promise to return the result. Obtains the output device with the highest priority based on the audio renderer information. This API uses a promise to return the result.
...@@ -4399,7 +4408,8 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco ...@@ -4399,7 +4408,8 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco
| ID| Error Message| | ID| Error Message|
| ------- | --------------------------------------------| | ------- | --------------------------------------------|
| 6800101 | if input parameter value error | | 6800101 | if input parameter value error. Return by promise. |
| 6800301 | System error. Return by promise. |
**Example** **Example**
...@@ -4409,8 +4419,8 @@ let rendererInfo = { ...@@ -4409,8 +4419,8 @@ let rendererInfo = {
usage : audio.StreamUsage.STREAM_USAGE_MEDIA, usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags : 0 } rendererFlags : 0 }
async function getPreferOutputDevice() { async function getPreferredOutputDevice() {
audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo).then((desc) => { audioRoutingManager.getPreferredOutputDeviceForRendererInfo(rendererInfo).then((desc) => {
console.info(`device descriptor: ${desc}`); console.info(`device descriptor: ${desc}`);
}).catch((err) => { }).catch((err) => {
console.error(`Result ERROR: ${err}`); console.error(`Result ERROR: ${err}`);
...@@ -4418,9 +4428,9 @@ async function getPreferOutputDevice() { ...@@ -4418,9 +4428,9 @@ async function getPreferOutputDevice() {
} }
``` ```
### on('preferOutputDeviceChangeForRendererInfo')<sup>10+</sup> ### on('preferredOutputDeviceChangeForRendererInfo')<sup>10+</sup>
on(type: 'preferOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback<AudioDeviceDescriptors\>): void on(type: 'preferredOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback<AudioDeviceDescriptors\>): void
Subscribes to the change of the output device with the highest priority. This API uses an asynchronous callback to return the result. Subscribes to the change of the output device with the highest priority. This API uses an asynchronous callback to return the result.
...@@ -4430,7 +4440,7 @@ Subscribes to the change of the output device with the highest priority. This AP ...@@ -4430,7 +4440,7 @@ Subscribes to the change of the output device with the highest priority. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | | :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
| type | string | Yes | Event type. The value **'preferOutputDeviceChangeForRendererInfo'** means the event triggered when the output device with the highest priority changes.| | type | string | Yes | Event type. The value **'preferredOutputDeviceChangeForRendererInfo'** means the output device change event, which is triggered when the output device with the highest priority is changed.|
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. | | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. |
| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)\> | Yes | Callback used to return the information about the output device with the highest priority. | | callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)\> | Yes | Callback used to return the information about the output device with the highest priority. |
...@@ -4450,14 +4460,14 @@ let rendererInfo = { ...@@ -4450,14 +4460,14 @@ let rendererInfo = {
usage : audio.StreamUsage.STREAM_USAGE_MEDIA, usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags : 0 } rendererFlags : 0 }
audioRoutingManager.on('preferOutputDeviceChangeForRendererInfo', rendererInfo, (desc) => { audioRoutingManager.on('preferredOutputDeviceChangeForRendererInfo', rendererInfo, (desc) => {
console.info(`device descriptor: ${desc}`); console.info(`device descriptor: ${desc}`);
}); });
``` ```
### off('preferOutputDeviceChangeForRendererInfo')<sup>10+</sup> ### off('preferredOutputDeviceChangeForRendererInfo')<sup>10+</sup>
off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback<AudioDeviceDescriptors\>): void off(type: 'preferredOutputDeviceChangeForRendererInfo', callback?: Callback<AudioDeviceDescriptors\>): void
Unsubscribes from the change of the output device with the highest priority. Unsubscribes from the change of the output device with the highest priority.
...@@ -4467,7 +4477,157 @@ Unsubscribes from the change of the output device with the highest priority. ...@@ -4467,7 +4477,157 @@ Unsubscribes from the change of the output device with the highest priority.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
| type | string | Yes | Event type. The value **'preferOutputDeviceChangeForRendererInfo'** means the event triggered when the output device with the highest priority changes.| | type | string | Yes | Event type. The value **'preferredOutputDeviceChangeForRendererInfo'** means the output device change event, which is triggered when the output device with the highest priority is changed.|
| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | No | Callback used for unsubscription. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error |
**Example**
```js
audioRoutingManager.off('preferredOutputDeviceChangeForRendererInfo');
```
### getPreferredInputDeviceForCapturerInfo<sup>10+</sup>
getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo, callback: AsyncCallback&lt;AudioDeviceDescriptors&gt;): void
Obtains the input device with the highest priority based on the audio renderer information. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
| Name | Type | Mandatory| Description |
| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Audio capturer information. |
| callback | AsyncCallback&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Yes | Callback used to return the information about the input device with the highest priority.|
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error |
| 6800301 | System error |
**Example**
```js
let capturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
}
audioRoutingManager.getPreferredInputDeviceForCapturerInfo(capturerInfo, (err, desc) => {
if (err) {
console.error(`Result ERROR: ${err}`);
} else {
console.info(`device descriptor: ${desc}`);
}
});
```
### getPreferredInputDeviceForCapturerInfo<sup>10+</sup>
getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo): Promise&lt;AudioDeviceDescriptors&gt;
Obtains the input device with the highest priority based on the audio renderer information. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Audio capturer information. |
**Return value**
| Type | Description |
| --------------------- | --------------------------- |
| Promise&lt;[AudioDeviceDescriptors](#audiodevicedescriptors)&gt; | Promise used to return the information about the input device with the highest priority.|
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error |
| 6800301 | System error |
**Example**
```js
let capturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
}
audioRoutingManager.getPreferredInputDeviceForCapturerInfo(capturerInfo).then((desc) => {
console.info(`device descriptor: ${desc}`);
}).catch((err) => {
console.error(`Result ERROR: ${err}`);
})
```
### on('preferredInputDeviceChangeForCapturerInfo')<sup>10+</sup>
on(type: 'preferredInputDeviceChangeForCapturerInfo', capturerInfo: AudioCapturerInfo, callback: Callback<AudioDeviceDescriptors\>): void
Subscribes to the change of the input device with the highest priority. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
| type | string | Yes | Event type. The value **'preferredInputDeviceChangeForCapturerInfo'** means the input device change event, which is triggered when the input device with the highest priority is changed.|
| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | Audio capturer information. |
| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)\> | Yes | Callback used to return the information about the input device with the highest priority. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 6800101 | if input parameter value error |
**Example**
```js
let capturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
}
audioRoutingManager.on('preferredInputDeviceChangeForCapturerInfo', capturerInfo, (desc) => {
console.info(`device descriptor: ${desc}`);
});
```
### off('preferredInputDeviceChangeForCapturerInfo')<sup>10+</sup>
off(type: 'preferredInputDeviceChangeForCapturerInfo', callback?: Callback<AudioDeviceDescriptors\>): void
Unsubscribes from the change of the input device with the highest priority.
**System capability**: SystemCapability.Multimedia.Audio.Device
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
| type | string | Yes | Event type. The value **'preferredInputDeviceChangeForCapturerInfo'** means the input device change event, which is triggered when the input device with the highest priority is changed.|
| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | No | Callback used for unsubscription. | | callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | No | Callback used for unsubscription. |
**Error codes** **Error codes**
...@@ -4481,7 +4641,7 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco ...@@ -4481,7 +4641,7 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco
**Example** **Example**
```js ```js
audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo'); audioRoutingManager.off('preferredInputDeviceChangeForCapturerInfo');
``` ```
## AudioRendererChangeInfoArray<sup>9+</sup> ## AudioRendererChangeInfoArray<sup>9+</sup>
...@@ -4861,6 +5021,14 @@ Sets an audio effect mode. This API uses an asynchronous callback to return the ...@@ -4861,6 +5021,14 @@ Sets an audio effect mode. This API uses an asynchronous callback to return the
| mode | [AudioEffectMode](#audioeffectmode10) | Yes | Audio effect mode to set. | | mode | [AudioEffectMode](#audioeffectmode10) | Yes | Audio effect mode to set. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | ----------------------------------------------|
| 6800101 | Invalid parameter error. Return by callback. |
**Example** **Example**
```js ```js
...@@ -4893,6 +5061,14 @@ Sets an audio effect mode. This API uses a promise to return the result. ...@@ -4893,6 +5061,14 @@ Sets an audio effect mode. This API uses a promise to return the result.
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | ---------------------------------------------|
| 6800101 | Invalid parameter error. Return by promise. |
**Example** **Example**
```js ```js
......
...@@ -4,9 +4,9 @@ The **DataShareResultSet** module provides APIs for accessing the result set obt ...@@ -4,9 +4,9 @@ The **DataShareResultSet** module provides APIs for accessing the result set obt
> **NOTE** > **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 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 provided by this module are system APIs. > - The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -22,8 +22,9 @@ You can call [query()](js-apis-data-dataShare.md#query) to obtain the **DataShar ...@@ -22,8 +22,9 @@ You can call [query()](js-apis-data-dataShare.md#query) to obtain the **DataShar
```ts ```ts
import dataShare from '@ohos.data.dataShare'; import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
import { BusinessError } from '@ohos.base'
let dataShareHelper; let dataShareHelper: dataShare.DataShareHelper;
let uri = ("datashare:///com.samples.datasharetest.DataShare"); let uri = ("datashare:///com.samples.datasharetest.DataShare");
await dataShare.createDataShareHelper(this.context, uri, (err, data) => { await dataShare.createDataShareHelper(this.context, uri, (err, data) => {
if (err != undefined) { if (err != undefined) {
...@@ -36,12 +37,12 @@ await dataShare.createDataShareHelper(this.context, uri, (err, data) => { ...@@ -36,12 +37,12 @@ await dataShare.createDataShareHelper(this.context, uri, (err, data) => {
let columns = ["*"]; let columns = ["*"];
let da = new dataSharePredicates.DataSharePredicates(); let da = new dataSharePredicates.DataSharePredicates();
let resultSet; let resultSet: DataShareResultSet;
da.equalTo("name", "ZhangSan"); da.equalTo("name", "ZhangSan");
dataShareHelper.query(uri, da, columns).then((data) => { dataShareHelper.query(uri, da, columns).then((data: DataShareResultSet) => {
console.info("query end, data : " + data); console.info("query end, data : " + data);
resultSet = data; resultSet = data;
}).catch((err) => { }).catch((err: BusinessError) => {
console.error("query fail, error message : " + err); console.error("query fail, error message : " + err);
}); });
``` ```
......
...@@ -43,11 +43,11 @@ FA model: ...@@ -43,11 +43,11 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db"} const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { data_rdb.getRdbStore(context, STORE_CONFIG, 1, (err, rdbStore) => {
if (err) { if (err) {
console.info("Failed to get RdbStore, err: " + err) console.info("Failed to get RdbStore, err: " + err)
return return
...@@ -61,23 +61,26 @@ Stage model: ...@@ -61,23 +61,26 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import { BusinessError } from "@ohos.base";
import window from '@ohos.window';
let context; let context: Context;
class EntryAbility extends UIAbility { interface storeConfig {
onWindowStageCreate(windowStage){ name: string
context = this.context
}
} }
// Call getRdbStore. class EntryAbility extends UIAbility {
const STORE_CONFIG = { name: "RdbTest.db"} onWindowStageCreate(windowStage: window.WindowStage){
data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { let STORE_CONFIG: storeConfig = { name: "RdbTest.db"};
data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, (err: BusinessError, rdbStore: data_rdb.RdbStore) => {
if (err) { if (err) {
console.info("Failed to get RdbStore, err: " + err) console.info("Failed to get RdbStore, err: " + err)
return return
} }
console.log("Got RdbStore successfully.") console.log("Got RdbStore successfully.")
}) })
}
}
``` ```
## data_rdb.getRdbStore ## data_rdb.getRdbStore
...@@ -109,7 +112,7 @@ FA model: ...@@ -109,7 +112,7 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" } const STORE_CONFIG = { name: "RdbTest.db" }
...@@ -126,20 +129,25 @@ Stage model: ...@@ -126,20 +129,25 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import { BusinessError } from "@ohos.base";
import window from '@ohos.window';
let context; let context: Context;
interface storeConfig {
name: string
}
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" } let STORE_CONFIG: storeConfig = { name: "RdbTest.db"};
let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1); let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1);
promise.then(async (rdbStore) => { promise.then(async (rdbStore: data_rdb.RdbStore) => {
console.log("Got RdbStore successfully.") console.log("Got RdbStore successfully.")
}).catch((err) => { }).catch((err: BusinessError) => {
console.log("Failed to get RdbStore, err: " + err) console.log("Failed to get RdbStore, err: " + err)
}) })
``` ```
...@@ -167,10 +175,10 @@ FA model: ...@@ -167,10 +175,10 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call deleteRdbStore. // Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) { data_rdb.deleteRdbStore(context, "RdbTest.db", (err) => {
if (err) { if (err) {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
return return
...@@ -184,16 +192,17 @@ Stage model: ...@@ -184,16 +192,17 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
let context; let context: Context;
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
// Call deleteRdbStore. // Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) { data_rdb.deleteRdbStore(context, "RdbTest.db", (err) => {
if (err) { if (err) {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
return return
...@@ -230,7 +239,7 @@ FA model: ...@@ -230,7 +239,7 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call deleteRdbStore. // Call deleteRdbStore.
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db") let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
...@@ -246,10 +255,12 @@ Stage model: ...@@ -246,10 +255,12 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import { BusinessError } from "@ohos.base";
import window from '@ohos.window';
let context; let context: Context;
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
...@@ -258,7 +269,7 @@ class EntryAbility extends UIAbility { ...@@ -258,7 +269,7 @@ class EntryAbility extends UIAbility {
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db") let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
promise.then(()=>{ promise.then(()=>{
console.log("Deleted RdbStore successfully.") console.log("Deleted RdbStore successfully.")
}).catch((err) => { }).catch((err: BusinessError) => {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
}) })
``` ```
...@@ -371,8 +382,8 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ ...@@ -371,8 +382,8 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null; let dmInstance: deviceManager.DeviceManager = null;
let deviceIds = []; let deviceIds: Array<string> = [];
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) { if (err) {
...@@ -381,7 +392,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) ...@@ -381,7 +392,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
} }
dmInstance = manager; dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync(); let devices = dmInstance.getTrustedDeviceListSync();
for (var i = 0; i < devices.length; i++) { for (let i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId; deviceIds[i] = devices[i].deviceId;
} }
}) })
......
# @ohos.data.uniformTypeDescriptor (Standard Data Definition)
The **uniformTypeDescriptor** module provides abstract definitions of OpenHarmony standardized data types.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
```
## UniformDataType
Enumerates the types of OpenHarmony standard data.
**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
| Name | Value | Description |
|----------------------------|------------------------------|-----------|
| TEXT | 'general.text' | Text. |
| PLAIN_TEXT | 'general.plain-text' | Plaintext. |
| HYPERLINK | 'general.hyperlink' | Hyperlink. |
| HTML | 'general.html' | HyperText Markup Language (HTML). |
| FILE | 'general.file' | File. |
| IMAGE | 'general.image' | Image. |
| VIDEO | 'general.video' | Video. |
| AUDIO | 'general.audio' | Audio. |
| FOLDER | 'general.folder' | Folder. |
| OPENHARMONY_FORM | 'openharmony.form' | Widget. |
| OPENHARMONY_APP_ITEM | 'openharmony.app-item' | Icon. |
| OPENHARMONY_PIXEL_MAP | 'openharmony.pixel-map' | Pixel map. |
...@@ -12,8 +12,7 @@ The **distributedKVStore** module provides the following functions: ...@@ -12,8 +12,7 @@ The **distributedKVStore** module provides the following functions:
> **NOTE** > **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 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.
> - All the APIs that need to obtain **deviceId** in this module are available only to system applications.
## Modules to Import ## Modules to Import
...@@ -2030,7 +2029,7 @@ deviceId(deviceId:string):Query ...@@ -2030,7 +2029,7 @@ deviceId(deviceId:string):Query
Creates a **Query** object with the device ID as the key prefix. Creates a **Query** object with the device ID as the key prefix.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2819,7 +2818,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -2819,7 +2818,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data of a device. This API uses an asynchronous callback to return the result. Deletes data of a device. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -2871,7 +2870,7 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt; ...@@ -2871,7 +2870,7 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt;
Deletes data of a device. This API uses a promise to return the result. Deletes data of a device. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -4550,7 +4549,7 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void ...@@ -4550,7 +4549,7 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md). Synchronizes the KV store manually. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE** > **NOTE**
> >
> **deviceIds** is the **networkId** in [DeviceInfo](js-apis-device-manager.md#deviceinfo), which is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceIds** is **networkId** in [DeviceBasicInfo](js-apis-distributedDeviceManager.md#devicebasicinfo), which can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4576,18 +4575,17 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4576,18 +4575,17 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedDeviceManager';
let devManager; let devManager;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
// create deviceManager // create deviceManager
deviceManager.createDeviceManager('bundleName', (err, value) => { try {
if (!err) { devManager = deviceManager.createDeviceManager(context.applicationInfo.name);
devManager = value;
let deviceIds = []; let deviceIds = [];
if (devManager != null) { if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync(); var devices = devManager.getAvailableDeviceListSync();
for (var i = 0; i < devices.length; i++) { for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].networkId; deviceIds[i] = devices[i].networkId;
} }
...@@ -4608,8 +4606,10 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { ...@@ -4608,8 +4606,10 @@ deviceManager.createDeviceManager('bundleName', (err, value) => {
} catch (e) { } catch (e) {
console.error(`Failed to sync.code is ${e.code},message is ${e.message}`); console.error(`Failed to sync.code is ${e.code},message is ${e.message}`);
} }
}
}); } catch (err) {
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
}
``` ```
### sync ### sync
...@@ -4619,7 +4619,7 @@ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void ...@@ -4619,7 +4619,7 @@ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md). Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE** > **NOTE**
> >
> **deviceIds** is the **networkId** in [DeviceInfo](js-apis-device-manager.md#deviceinfo), which is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceIds** is **networkId** in [DeviceBasicInfo](js-apis-distributedDeviceManager.md#devicebasicinfo), which can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4646,18 +4646,17 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4646,18 +4646,17 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedDeviceManager';
let devManager; let devManager;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
// create deviceManager // create deviceManager
deviceManager.createDeviceManager('bundleName', (err, value) => { try {
if (!err) { let devManager = deviceManager.createDeviceManager(context.applicationInfo.name);
devManager = value;
let deviceIds = []; let deviceIds = [];
if (devManager != null) { if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync(); var devices = devManager.getAvailableDeviceListSync();
for (var i = 0; i < devices.length; i++) { for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].networkId; deviceIds[i] = devices[i].networkId;
} }
...@@ -4675,14 +4674,16 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { ...@@ -4675,14 +4674,16 @@ deviceManager.createDeviceManager('bundleName', (err, value) => {
const mode = distributedKVStore.SyncMode.PULL_ONLY; const mode = distributedKVStore.SyncMode.PULL_ONLY;
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
query.deviceId('localDeviceId'); query.deviceId(devManager.getLocalDeviceNetworkId());
kvStore.sync(deviceIds, query, mode, 1000); kvStore.sync(deviceIds, query, mode, 1000);
}); });
} catch (e) { } catch (e) {
console.error(`Failed to sync.code is ${e.code},message is ${e.message}`); console.error(`Failed to sync.code is ${e.code},message is ${e.message}`);
} }
}
}); } catch (err) {
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
}
``` ```
### on('dataChange') ### on('dataChange')
...@@ -5046,7 +5047,7 @@ get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean | string | ...@@ -5046,7 +5047,7 @@ get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean | string |
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result. Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5101,7 +5102,7 @@ get(deviceId: string, key: string): Promise&lt;boolean | string | number | Uint8 ...@@ -5101,7 +5102,7 @@ get(deviceId: string, key: string): Promise&lt;boolean | string | number | Uint8
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result. Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5281,7 +5282,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry ...@@ -5281,7 +5282,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry
Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result. Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5348,7 +5349,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt; ...@@ -5348,7 +5349,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt;
Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result. Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5544,7 +5545,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt ...@@ -5544,7 +5545,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5616,7 +5617,7 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt; ...@@ -5616,7 +5617,7 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt;
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result. Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5824,7 +5825,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KVS ...@@ -5824,7 +5825,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KVS
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result. Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5879,7 +5880,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KVStoreResultSet&g ...@@ -5879,7 +5880,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KVStoreResultSet&g
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result. Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -5935,7 +5936,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KVStoreR ...@@ -5935,7 +5936,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KVStoreR
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -6011,7 +6012,7 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KVStoreResultSet&gt; ...@@ -6011,7 +6012,7 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KVStoreResultSet&gt;
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result. Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -6154,7 +6155,7 @@ getResultSet(query: Query, callback:AsyncCallback&lt;KVStoreResultSet&gt;): void ...@@ -6154,7 +6155,7 @@ getResultSet(query: Query, callback:AsyncCallback&lt;KVStoreResultSet&gt;): void
Obtains a **KVStoreResultSet** object that matches the specified **Query** object for this device. This API uses an asynchronous callback to return the result. Obtains a **KVStoreResultSet** object that matches the specified **Query** object for this device. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -6343,7 +6344,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat ...@@ -6343,7 +6344,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses an asynchronous callback to return the result. Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System API**: This is a system API. **System API**: This is a system API.
...@@ -6404,7 +6405,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat ...@@ -6404,7 +6405,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses a promise to return the result. Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System API**: This is a system API. **System API**: This is a system API.
...@@ -6585,7 +6586,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number& ...@@ -6585,7 +6586,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number&
Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -6651,7 +6652,7 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt; ...@@ -6651,7 +6652,7 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt;
Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result. Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. > **deviceId** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
> For details about how to obtain **deviceId**, see [sync()](#sync). > For details about how to obtain **deviceId**, see [sync()](#sync).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......
...@@ -20,6 +20,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal ...@@ -20,6 +20,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the stage model. This API can be used only in the stage model.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead. > This API is deprecated since API version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -44,7 +45,7 @@ const context = getContext(this); ...@@ -44,7 +45,7 @@ const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
``` ```
**Example (API version 8)** **Example (from API version 8)**
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -62,6 +63,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal ...@@ -62,6 +63,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the FA model. This API can be used only in the FA model.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. There is no substitute API. > This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -344,7 +346,7 @@ Creates a media asset. This API uses a promise to return the result. ...@@ -344,7 +346,7 @@ Creates a media asset. This API uses a promise to return the result.
| ------------ | ------------------------ | ---- | ------------------------------------------------------------ | | ------------ | ------------------------ | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype8) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | File name to display. | | displayName | string | Yes | File name to display. |
| relativePath | string | Yes | Relative path of the file, which can be obtained by [getPublicDirectory](#getpublicdirectory8).| | relativePath | string | Yes | Relative path of the file, which can be obtained by **getPublicDirectory**.|
**Return value** **Return value**
...@@ -557,7 +559,7 @@ Obtains albums. This API uses an asynchronous callback to return the result. ...@@ -557,7 +559,7 @@ Obtains albums. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead. > - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md). > - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA **Required permissions**: ohos.permission.READ_MEDIA
...@@ -597,7 +599,7 @@ Obtains albums. This API uses a promise to return the result. ...@@ -597,7 +599,7 @@ Obtains albums. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead. > - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md). > - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA **Required permissions**: ohos.permission.READ_MEDIA
...@@ -666,6 +668,7 @@ Releases this **MediaLibrary** instance. ...@@ -666,6 +668,7 @@ Releases this **MediaLibrary** instance.
Call this API when you no longer need to use the APIs in the **MediaLibrary** instance. Call this API when you no longer need to use the APIs in the **MediaLibrary** instance.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead. > This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......
...@@ -3226,6 +3226,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur ...@@ -3226,6 +3226,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur
```js ```js
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let localId: number = 100;
accountManager.isOsAccountVerified(localId).then((isVerified: boolean) => { accountManager.isOsAccountVerified(localId).then((isVerified: boolean) => {
console.log('isOsAccountVerified successfully, isVerified: ' + isVerified); console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
...@@ -3457,7 +3458,7 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -3457,7 +3458,7 @@ Obtains the OS account ID based on the domain account information. This API uses
```js ```js
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo: account_osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => {
if (err) { if (err) {
...@@ -3499,7 +3500,7 @@ Obtains the OS account ID based on the domain account information. This API uses ...@@ -3499,7 +3500,7 @@ Obtains the OS account ID based on the domain account information. This API uses
```js ```js
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
let accountManager = account_osAccount.getAccountManager(); let accountManager = account_osAccount.getAccountManager();
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; let domainInfo: account_osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => { accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => {
console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId); console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
......
...@@ -72,7 +72,7 @@ Creates a **FormComponent** instance to display the provided widget. ...@@ -72,7 +72,7 @@ Creates a **FormComponent** instance to display the provided widget.
| Name | Description | | Name | Description |
| ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| onAcquired(callback: (info: { id: number }) =&gt; void) | Triggered when a widget is obtained. This API returns the ID of the obtained widget. | | onAcquired(callback: (info: { id: number }) =&gt; void) | Triggered when a widget is obtained. This API returns the ID of the obtained widget. |
| onError(callback: (info: { errcode: number, msg: string }) =&gt; void) | Triggered when an error occurs during component loading.<br>**errcode**: error code.<br>**msg**: error information. | | onError(callback: (info: { errcode: number, msg: string }) =&gt; void) | Triggered when an error occurs during component loading.<br>**errcode**: error code.<br>**msg**: error information.<br>For details, see [Form Error Codes](../errorcodes/errorcode-form.md). |
| onRouter(callback: (info: any) =&gt; void) | Triggered when routing occurs for the widget. This API returns information in [routerEvent](../js-service-widget-ui/js-service-widget-syntax-hml.md#event-binding).| | onRouter(callback: (info: any) =&gt; void) | Triggered when routing occurs for the widget. This API returns information in [routerEvent](../js-service-widget-ui/js-service-widget-syntax-hml.md#event-binding).|
| onUninstall(callback: (info: { id: number }) =&gt; void) | Triggered when a widget is uninstalled. This API returns the ID of the uninstalled widget. | | onUninstall(callback: (info: { id: number }) =&gt; void) | Triggered when a widget is uninstalled. This API returns the ID of the uninstalled widget. |
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: launchWant: Want;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: launchWant: Want;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: lastRequestWant: Want;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: lastRequestWant: Want;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: callee: Callee;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: callee: Callee;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onCreate(want: Want, param: AbilityConstant.LaunchParam): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageCreate(windowStage: window.WindowStage): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageCreate(windowStage: window.WindowStage): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageDestroy(): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageDestroy(): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageRestore(windowStage: window.WindowStage): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onWindowStageRestore(windowStage: window.WindowStage): void;|@ohos.app.ability.UIAbility.d.ts|
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onForeground(): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onForeground(): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onBackground(): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onBackground(): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onDump(params: Array\<string>): Array\<string>;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onDump(params: Array\<string>): Array\<string>;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;|@ohos.app.ability.UIAbility.d.ts| |Added|NA|Module name: ohos.app.ability.UIAbility<br>Class name: UIAbility<br>Method or attribute name: onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;|@ohos.app.ability.UIAbility.d.ts|
|Added|NA|Module name: ohos.app.ability.Want<br>Class name: Want|@ohos.app.ability.Want.d.ts| |Added|NA|Module name: ohos.app.ability.Want<br>Class name: Want|@ohos.app.ability.Want.d.ts|
......
...@@ -73,5 +73,5 @@ The table below lists the APIs changes of the ability framework in OpenHarmony 3 ...@@ -73,5 +73,5 @@ The table below lists the APIs changes of the ability framework in OpenHarmony 3
| FormExtensionContext | FormExtensionContext | updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void;<br>updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>; | Deleted| | FormExtensionContext | FormExtensionContext | updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void;<br>updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>; | Deleted|
| ServiceExtensionContext | ServiceExtensionContext | extensionAbilityInfo: ExtensionAbilityInfo; | Deleted| | ServiceExtensionContext | ServiceExtensionContext | extensionAbilityInfo: ExtensionAbilityInfo; | Deleted|
| ohos.application.appManager | appManager | getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;<br>getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void; | Deprecated| | ohos.application.appManager | appManager | getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;<br>getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void; | Deprecated|
| ohos.application.Ability | Ability | old : onNewWant(want: Want): void;<br>new : onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; | Updated| | ohos.application.Ability | Ability | old : onNewWant(want: Want): void;<br>new : onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void; | Updated|
| ohos.application.Ability | Callee | old : on(method: string, callback: CaleeCallBack): void;<br>new : on(method: string, callback: CalleeCallBack): void; | Updated| | ohos.application.Ability | Callee | old : on(method: string, callback: CaleeCallBack): void;<br>new : on(method: string, callback: CalleeCallBack): void; | Updated|
\ No newline at end of file
| Change Type | Old Version | New Version | d.ts File | | Change Type | Old Version | New Version | .d.ts File |
| ---- | ------ | ------ | -------- | | ---- | ------ | ------ | -------- |
|Added|NA|Module name: ohos.app.ability.dataUriUtils<br>Class name: dataUriUtils|@ohos.app.ability.dataUriUtils.d.ts| |Added|NA|Module name: ohos.app.ability.dataUriUtils<br>Class name: dataUriUtils|@ohos.app.ability.dataUriUtils.d.ts|
|Added|NA|Module name: ohos.app.ability.dataUriUtils<br>Class name: dataUriUtils<br>Method or attribute name: function getId(uri: string): number|@ohos.app.ability.dataUriUtils.d.ts| |Added|NA|Module name: ohos.app.ability.dataUriUtils<br>Class name: dataUriUtils<br>Method or attribute name: function getId(uri: string): number|@ohos.app.ability.dataUriUtils.d.ts|
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: launchWant: Want;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: launchWant: Want;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: lastRequestWant: Want;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: lastRequestWant: Want;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: callee: Callee;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: callee: Callee;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onCreate(want: Want, param: AbilityConstant.LaunchParam): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageCreate(windowStage: window.WindowStage): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageCreate(windowStage: window.WindowStage): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageDestroy(): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageDestroy(): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageRestore(windowStage: window.WindowStage): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onWindowStageRestore(windowStage: window.WindowStage): void;|NA|@ohos.application.Ability.d.ts|
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onForeground(): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onForeground(): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onBackground(): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onBackground(): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onConfigurationUpdated(config: Configuration): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onConfigurationUpdated(config: Configuration): void;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: dump(params: Array<string>): Array<string>;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: dump(params: Array<string>): Array<string>;|NA|@ohos.application.Ability.d.ts|
|Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onMemoryLevel(level: AbilityConstant.MemoryLevel): void;|NA|@ohos.application.Ability.d.ts| |Deleted|Module name: ohos.application.Ability<br>Class name: Ability<br>Method or attribute name: onMemoryLevel(level: AbilityConstant.MemoryLevel): void;|NA|@ohos.application.Ability.d.ts|
......
# File Management Subsystem Changelog
## c1.filemanager.1 Change of the fileAccess Module
The **fileAccess** module will no longer support operations for obtaining thumbnails and media assets.
**Change Impact**
1. Deleted **getThumbnail()**.
2. Deleted the **FILEKEY** of image and audio options.
**Key API/Component Changes**
Deleted APIs:
| Class | API |
| -------------- | ------------------------------------------------------------ |
| fileAccessHelper | getThumbnail(uri: string, size: image.Size): Promise<image.PixelMap>;|
| fileAccessHelper | getThumbnail(uri: string, size: image.Size, callback: AsyncCallback<image.PixelMap>): void;|
Deleted options:
| Enum| Deleted Key Value|
| -------- | ---- |
| FileKey | DURATION = 'duration' |
| FileKey | WIDTH = 'width' |
| FileKey | HEIGHT = 'height' |
...@@ -156,7 +156,9 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关 ...@@ -156,7 +156,9 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关
进入对应路径后,查看toolchains->3.x.x.x(对应版本号命名文件夹)下是否存在idl工具的可执行文件。 进入对应路径后,查看toolchains->3.x.x.x(对应版本号命名文件夹)下是否存在idl工具的可执行文件。
> **注意**:请保证使用最新版的SDK,版本老旧可能导致部分语句报错。 > **注意**:
>
> 请保证使用最新版的SDK,版本老旧可能导致部分语句报错。
若不存在,可对应版本前往[docs仓版本目录](../../release-notes)下载SDK包,以[3.2Beta3版本](../../release-notes/OpenHarmony-v3.2-beta3.md)为例,可通过镜像站点获取。 若不存在,可对应版本前往[docs仓版本目录](../../release-notes)下载SDK包,以[3.2Beta3版本](../../release-notes/OpenHarmony-v3.2-beta3.md)为例,可通过镜像站点获取。
......
...@@ -20,7 +20,9 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式 ...@@ -20,7 +20,9 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式
**图1** 单实例模式演示效果 **图1** 单实例模式演示效果
![uiability-launch-type1](figures/uiability-launch-type1.gif) ![uiability-launch-type1](figures/uiability-launch-type1.gif)
> **说明**:应用的UIAbility实例已创建,该UIAbility配置为单实例模式,再次调用[`startAbility()`](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动该UIAbility实例。由于启动的还是原来的UIAbility实例,并未重新创建一个新的UIAbility实例,此时只会进入该UIAbility的[`onNewWant()`](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其[`onCreate()`](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)和[`onWindowStageCreate()`](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)生命周期回调。 > **说明**:
>
> 应用的UIAbility实例已创建,该UIAbility配置为单实例模式,再次调用[`startAbility()`](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动该UIAbility实例。由于启动的还是原来的UIAbility实例,并未重新创建一个新的UIAbility实例,此时只会进入该UIAbility的[`onNewWant()`](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonnewwant)回调,不会进入其[`onCreate()`](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)和[`onWindowStageCreate()`](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)生命周期回调。
如果需要使用singleton启动模式,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的`launchType`字段配置为`singleton`即可。 如果需要使用singleton启动模式,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的`launchType`字段配置为`singleton`即可。
......
...@@ -32,7 +32,9 @@ export default class EntryAbility extends UIAbility { ...@@ -32,7 +32,9 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
> **说明**:[Want](../reference/apis/js-apis-app-ability-want.md)是对象间信息传递的载体,可以用于应用组件间的信息传递。Want的详细介绍请参见[信息传递载体Want](want-overview.md)。 > **说明**:
>
> [Want](../reference/apis/js-apis-app-ability-want.md)是对象间信息传递的载体,可以用于应用组件间的信息传递。Want的详细介绍请参见[信息传递载体Want](want-overview.md)。
### WindowStageCreate和WindowStageDestory状态 ### WindowStageCreate和WindowStageDestory状态
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册