提交 4c36c690 编写于 作者: S swx1239486

Merge branch 'monthly_20230815' of https://gitee.com/playing-song/docs into monthly_20230815

...@@ -200,9 +200,9 @@ zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShi ...@@ -200,9 +200,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
...@@ -322,7 +322,7 @@ zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yaf ...@@ -322,7 +322,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
...@@ -335,7 +335,7 @@ zh-cn/application-dev/reference/apis/js-apis-request.md @feng-aiwen @ningningW @ ...@@ -335,7 +335,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
...@@ -350,9 +350,9 @@ zh-cn/application-dev/reference/apis/js-apis-stack.md @gongjunsong @ge-yafang @f ...@@ -350,9 +350,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
...@@ -375,7 +375,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-timer.md @feng-aiwen @ningni ...@@ -375,7 +375,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
...@@ -426,7 +426,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-configuration.md @littl ...@@ -426,7 +426,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
......
...@@ -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<Preferences>): void | Obtain a **Preferences** instance. | | getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): 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<void>): void | Flushes the data of this **Preferences** instance to a file for data persistence. | | flush(callback: AsyncCallback<void>): void | Flushes the data of this **Preferences** instance to a file for data persistence. |
| on(type: 'change', callback: Callback<{ key : string }>): 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<{ key : string }>): 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<{ key : string }>): void | Unsubscribes from data changes. | | off(type: 'change', callback?: Callback<{ key : string }>): void | Unsubscribes from data changes. |
| deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): 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<void>): 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;
......
...@@ -279,7 +279,8 @@ ...@@ -279,7 +279,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
......
...@@ -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);
} }
......
...@@ -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
......
...@@ -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)为例,可通过镜像站点获取。
...@@ -185,7 +187,9 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关 ...@@ -185,7 +187,9 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关
-d后的dir为目标输出目录,以输出文件夹名为IIdlTestServiceTs为例,在idl可执行文件所在目录下执行`idl -gen-ts -d IIdlTestServiceTs -c IIdlTestServiceTs/IIdlTestService.idl`,将会在执行环境的dir目录(即IIdlTestServiceTs目录)中生成接口文件、Stub文件、Proxy文件。 -d后的dir为目标输出目录,以输出文件夹名为IIdlTestServiceTs为例,在idl可执行文件所在目录下执行`idl -gen-ts -d IIdlTestServiceTs -c IIdlTestServiceTs/IIdlTestService.idl`,将会在执行环境的dir目录(即IIdlTestServiceTs目录)中生成接口文件、Stub文件、Proxy文件。
> **注意**:生成的接口类文件名称和.idl文件名称保持一致,否则会生成代码时会出现错误。 > **注意**:
>
> 生成的接口类文件名称和.idl文件名称保持一致,否则会生成代码时会出现错误。
以名为`IIdlTestService.idl`的.idl文件、目标输出文件夹为IIdlTestServiceTs为例,其目录结构应类似于: 以名为`IIdlTestService.idl`的.idl文件、目标输出文件夹为IIdlTestServiceTs为例,其目录结构应类似于:
......
...@@ -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状态
......
...@@ -231,8 +231,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -231,8 +231,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
import Want from '@ohos.app.ability.Want'; import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
import { BusinessError } from '@ohos.base';
let proxy: rpc.RemoteProxy; let dmInstance: deviceManager.DeviceManager | undefined;
let proxy: rpc.IRemoteObject | undefined = undefined;
let connectId: number; let connectId: number;
// 单个设备绑定Ability // 单个设备绑定Ability
...@@ -242,7 +244,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -242,7 +244,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
abilityName: "ohos.rpc.test.server.ServiceAbility", abilityName: "ohos.rpc.test.server.ServiceAbility",
}; };
let connect: common.ConnectOptions = { let connect: common.ConnectOptions = {
onConnect: (elementName, remote: rpc.RemoteProxy) => { onConnect: (elementName, remote) => {
proxy = remote; proxy = remote;
}, },
onDisconnect: (elementName) => { onDisconnect: (elementName) => {
...@@ -263,11 +265,17 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -263,11 +265,17 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
return; return;
} }
console.info("createDeviceManager success"); console.info("createDeviceManager success");
let dmInstance = data; dmInstance = data;
} }
try{
deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback); deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback);
} catch(error) {
let e: BusinessError = error as BusinessError;
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
}
// 使用deviceManager获取目标设备NetworkId // 使用deviceManager获取目标设备NetworkId
if (dmInstance != undefined) {
let deviceList: Array<deviceManager.DeviceInfo> = dmInstance.getTrustedDeviceListSync(); let deviceList: Array<deviceManager.DeviceInfo> = dmInstance.getTrustedDeviceListSync();
let networkId: string = deviceList[0].networkId; let networkId: string = deviceList[0].networkId;
let want: Want = { let want: Want = {
...@@ -282,6 +290,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -282,6 +290,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
// 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数 // 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数
connectId = this.context.connectServiceExtensionAbility(want,connect); connectId = this.context.connectServiceExtensionAbility(want,connect);
}
``` ```
3. 服务端处理客户端请求 3. 服务端处理客户端请求
...@@ -289,10 +298,6 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -289,10 +298,6 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
服务端被绑定的Ability在onConnect方法里返回继承自rpc.RemoteObject的对象,该对象需要实现onRemoteMessageRequest方法,处理客户端的请求。 服务端被绑定的Ability在onConnect方法里返回继承自rpc.RemoteObject的对象,该对象需要实现onRemoteMessageRequest方法,处理客户端的请求。
```ts ```ts
onConnect(want: Want) {
const robj: rpc.RemoteObject = new Stub("rpcTestAbility");
return robj;
}
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
constructor(descriptor: string) { constructor(descriptor: string) {
super(descriptor); super(descriptor);
...@@ -302,6 +307,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -302,6 +307,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
return true; return true;
} }
} }
onConnect(want: Want) {
const robj: rpc.RemoteObject = new Stub("rpcTestAbility");
return robj;
}
``` ```
4. 客户端处理服务端响应 4. 客户端处理服务端响应
...@@ -359,6 +368,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -359,6 +368,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import featureAbility from "@ohos.ability.featureAbility"; // import featureAbility from "@ohos.ability.featureAbility";
function disconnectCallback() { function disconnectCallback() {
console.info("disconnect ability done"); console.info("disconnect ability done");
} }
......
...@@ -98,7 +98,6 @@ import Want from '@ohos.app.ability.Want'; ...@@ -98,7 +98,6 @@ import Want from '@ohos.app.ability.Want';
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import window from '@ohos.window'; import window from '@ohos.window';
export default class MainAbility extends UIAbility { export default class MainAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
console.log("[Demo] MainAbility onCreate"); console.log("[Demo] MainAbility onCreate");
...@@ -134,9 +133,9 @@ export default class MainAbility extends UIAbility { ...@@ -134,9 +133,9 @@ export default class MainAbility extends UIAbility {
import Want from '@ohos.app.ability.Want'; import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
let proxy: rpc.RemoteProxy; let proxy: rpc.IRemoteObject | undefined = undefined;
let connect: common.ConnectOptions = { let connect: common.ConnectOptions = {
onConnect: (elementName, remoteProxy: rpc.RemoteProxy) => { onConnect: (elementName, remoteProxy) => {
console.log("RpcClient: js onConnect called."); console.log("RpcClient: js onConnect called.");
proxy = remoteProxy; proxy = remoteProxy;
}, },
......
...@@ -30,6 +30,7 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务 ...@@ -30,6 +30,7 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
```ts ```ts
import hiTraceChain from '@ohos.hiTraceChain'; import hiTraceChain from '@ohos.hiTraceChain';
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
@Entry @Entry
@Component @Component
...@@ -50,26 +51,28 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务 ...@@ -50,26 +51,28 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
// 业务开始前,开启分布式跟踪。 // 业务开始前,开启分布式跟踪。
let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// 业务开始:完成一次系统事件打点。 // 业务开始:完成一次系统事件打点。
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 1,
'UID': 1,
'PACKAGE_NAME': "com.demo.hitracechain",
'PROCESS_NAME': "hitracechaindemo",
'MSG': "no msg."
}
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 1,
UID: 1,
PACKAGE_NAME: "com.demo.hitracechain",
PROCESS_NAME: "hitracechaindemo",
MSG: "no msg."
} }
}).then((val) => { hiSysEvent.write(eventInfo).then((val: number) => {
console.info(`write result is ${val}`); console.info(`write result is ${val}`);
// 业务结束,关闭分布式跟踪。 // 业务结束,关闭分布式跟踪。
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`error message is ${err.message}`); console.error(`error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
console.error(`error message is ${err.message}`); console.error(`error message is ${(err as BusinessError).message}`);
} }
}) })
} }
......
# 人像模式拍照实现方案 # 使用人像模式拍照
## 开发流程 ## 开发流程
......
...@@ -30,9 +30,10 @@ ...@@ -30,9 +30,10 @@
方法一:通过PixelMap进行编码。 方法一:通过PixelMap进行编码。
```ts ```ts
imagePackerApi.packing(pixelMap, packOpts).then( data => { import {BusinessError} from '@ohos.base'
imagePackerApi.packing(pixelMap, packOpts).then( (data : ArrayBuffer) => {
// data 为打包获取到的文件流,写入文件保存即可得到一张图片 // data 为打包获取到的文件流,写入文件保存即可得到一张图片
}).catch(error => { }).catch((error : BusinessError) => {
console.error('Failed to pack the image. And the error is: ' + error); console.error('Failed to pack the image. And the error is: ' + error);
}) })
``` ```
...@@ -40,9 +41,10 @@ ...@@ -40,9 +41,10 @@
方法二:通过imageSource进行编码。 方法二:通过imageSource进行编码。
```ts ```ts
imagePackerApi.packing(imageSource, packOpts).then( data => { import {BusinessError} from '@ohos.base'
imagePackerApi.packing(imageSource, packOpts).then( (data : ArrayBuffer) => {
// data 为打包获取到的文件流,写入文件保存即可得到一张图片 // data 为打包获取到的文件流,写入文件保存即可得到一张图片
}).catch(error => { }).catch((error : BusinessError) => {
console.error('Failed to pack the image. And the error is: ' + error); console.error('Failed to pack the image. And the error is: ' + error);
}) })
``` ```
...@@ -27,11 +27,12 @@ ...@@ -27,11 +27,12 @@
3. 读取并修改目标区域像素数据,写回原图。 3. 读取并修改目标区域像素数据,写回原图。
```ts ```ts
import {BusinessError} from '@ohos.base'
// 场景一:将读取的整张图像像素数据结果写入ArrayBuffer中 // 场景一:将读取的整张图像像素数据结果写入ArrayBuffer中
const readBuffer = new ArrayBuffer(pixelBytesNumber); const readBuffer = new ArrayBuffer(pixelBytesNumber);
pixelMap.readPixelsToBuffer(readBuffer).then(() => { pixelMap.readPixelsToBuffer(readBuffer).then(() => {
console.info('Succeeded in reading image pixel data.'); console.info('Succeeded in reading image pixel data.');
}).catch(error => { }).catch((error : BusinessError) => {
console.error('Failed to read image pixel data. And the error is: ' + error); console.error('Failed to read image pixel data. And the error is: ' + error);
}) })
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
} }
pixelMap.readPixels(area).then(() => { pixelMap.readPixels(area).then(() => {
console.info('Succeeded in reading the image data in the area.'); console.info('Succeeded in reading the image data in the area.');
}).catch(error => { }).catch((error : BusinessError) => {
console.error('Failed to read the image data in the area. And the error is: ' + error); console.error('Failed to read the image data in the area. And the error is: ' + error);
}) })
......
...@@ -621,7 +621,7 @@ struct Parent { ...@@ -621,7 +621,7 @@ struct Parent {
```ts ```ts
class Outer { class Outer {
innerArrayProp : ObservedArray<string>; innerArrayProp : ObservedArray<string> = [];
... ...
} }
``` ```
...@@ -689,7 +689,7 @@ struct ViewB { ...@@ -689,7 +689,7 @@ struct ViewB {
(item: ClassA) => { (item: ClassA) => {
ViewA({ label: `#${item.id}`, a: item }) ViewA({ label: `#${item.id}`, a: item })
}, },
(item: ClassA) => item.id.toString() (item: ClassA): string => { return item.id.toString(); }
) )
Divider().height(10) Divider().height(10)
...@@ -738,7 +738,7 @@ struct ViewB { ...@@ -738,7 +738,7 @@ struct ViewB {
@Component @Component
struct ViewA { struct ViewA {
@Prop a: ClassA; @Prop a: ClassA = new ClassA(0);
label : string = "ViewA1"; label : string = "ViewA1";
build() { build() {
...@@ -903,7 +903,7 @@ export class ObservedArray<T> extends Array<T> { ...@@ -903,7 +903,7 @@ export class ObservedArray<T> extends Array<T> {
@ObjectLink me : Person; @ObjectLink me : Person;
@ObjectLink contacts : ObservedArray<Person>; @ObjectLink contacts : ObservedArray<Person>;
@State selectedPerson: Person = undefined; @State selectedPerson: Person = new Person("", "", 0, "", []);
aboutToAppear() { aboutToAppear() {
this.selectedPerson = this.me; this.selectedPerson = this.me;
...@@ -919,7 +919,7 @@ export class ObservedArray<T> extends Array<T> { ...@@ -919,7 +919,7 @@ export class ObservedArray<T> extends Array<T> {
ForEach(this.contacts, (contact: Person) => { ForEach(this.contacts, (contact: Person) => {
PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson }) PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson })
}, },
(contact: Person) => contact.id_ (contact: Person): string => { return contact.id_; }
) )
Divider().height(8) Divider().height(8)
...@@ -1295,7 +1295,7 @@ export class ObservedArray<T> extends Array<T> { ...@@ -1295,7 +1295,7 @@ export class ObservedArray<T> extends Array<T> {
ForEach(this.contacts, (contact: Person) => { ForEach(this.contacts, (contact: Person) => {
PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson }) PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson })
}, },
(contact: Person) => contact.id_ (contact: Person): string => { return contact.id_; }
) )
Divider().height(8) Divider().height(8)
......
...@@ -507,8 +507,8 @@ incrSubCounter和setSubCounter都是同一个SubCounter的函数。在第一个 ...@@ -507,8 +507,8 @@ incrSubCounter和setSubCounter都是同一个SubCounter的函数。在第一个
```ts ```ts
@ObjectLink valueParentCounter; @ObjectLink valueParentCounter = new ParentCounter(0);
@ObjectLink subValueSubCounter; @ObjectLink subValueSubCounter = new SubCounter(0);
``` ```
该方法使得\@ObjectLink分别代理了ParentCounter和SubCounter的属性,这样对于这两个类的属性的变化都可以观察到,即都会对UI视图进行刷新。即使删除了上面所说的this.counter[0].incrCounter(),UI也会进行正确的刷新。 该方法使得\@ObjectLink分别代理了ParentCounter和SubCounter的属性,这样对于这两个类的属性的变化都可以观察到,即都会对UI视图进行刷新。即使删除了上面所说的this.counter[0].incrCounter(),UI也会进行正确的刷新。
...@@ -715,8 +715,8 @@ struct ParentComp { ...@@ -715,8 +715,8 @@ struct ParentComp {
```ts ```ts
@Component @Component
struct CounterComp { struct CounterComp {
@Prop value: ParentCounter; @Prop value: ParentCounter = new ParentCounter(0);
@Prop subValue: SubCounter; @Prop subValue: SubCounter = new SubCounter(0);
build() { build() {
Column({ space: 10 }) { Column({ space: 10 }) {
Text(`this.subValue.counter: ${this.subValue.counter}`) Text(`this.subValue.counter: ${this.subValue.counter}`)
...@@ -948,8 +948,8 @@ build函数中更改应用状态的行为可能会比上面的示例更加隐蔽 ...@@ -948,8 +948,8 @@ build函数中更改应用状态的行为可能会比上面的示例更加隐蔽
```ts ```ts
@State arr : Array<..> = [ ... ]; @State arr : Array<...> = [ ... ];
ForEach(this.arr.sort().filter(....), ForEach(this.arr.sort().filter(...),
item => { item => {
... ...
}) })
...@@ -959,7 +959,7 @@ ForEach(this.arr.sort().filter(....), ...@@ -959,7 +959,7 @@ ForEach(this.arr.sort().filter(....),
```ts ```ts
ForEach(this.arr.filter(....).sort(), ForEach(this.arr.filter(...).sort(),
item => { item => {
... ...
}) })
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
```ts ```ts
@Component @Component
struct TotalView { struct TotalView {
@Prop @Watch('onCountUpdated') count: number; @Prop @Watch('onCountUpdated') count: number = 0;
@State total: number = 0; @State total: number = 0;
// @Watch cb // @Watch cb
onCountUpdated(propName: string): void { onCountUpdated(propName: string): void {
......
...@@ -145,6 +145,7 @@ export { nativeMulti } from './utils/nativeTest' ...@@ -145,6 +145,7 @@ export { nativeMulti } from './utils/nativeTest'
```ts ```ts
// entry/src/main/ets/pages/index.ets // entry/src/main/ets/pages/index.ets
import { Log, add, MyTitleBar, ResManager, nativeMulti } from "library" import { Log, add, MyTitleBar, ResManager, nativeMulti } from "library"
import { BusinessError } from '@ohos.base';
@Entry @Entry
@Component @Component
...@@ -172,7 +173,7 @@ struct Index { ...@@ -172,7 +173,7 @@ struct Index {
.then(value => { .then(value => {
console.log("getStringValue is " + value); console.log("getStringValue is " + value);
}) })
.catch(error => { .catch((err: BusinessError) => {
console.log("getStringValue promise error is " + error); console.log("getStringValue promise error is " + error);
}); });
}) })
......
...@@ -275,6 +275,7 @@ ...@@ -275,6 +275,7 @@
// Index.ets // Index.ets
// 导入页面路由模块 // 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
import { BusinessError } from '@ohos.base';
@Entry @Entry
@Component @Component
...@@ -306,7 +307,7 @@ ...@@ -306,7 +307,7 @@
// 跳转到第二页 // 跳转到第二页
router.pushUrl({ url: 'pages/Second' }).then(() => { router.pushUrl({ url: 'pages/Second' }).then(() => {
console.info('Succeeded in jumping to the second page.') console.info('Succeeded in jumping to the second page.')
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`) console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)
}) })
}) })
...@@ -326,6 +327,7 @@ ...@@ -326,6 +327,7 @@
// Second.ets // Second.ets
// 导入页面路由模块 // 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
import { BusinessError } from '@ohos.base';
@Entry @Entry
@Component @Component
...@@ -358,7 +360,9 @@ ...@@ -358,7 +360,9 @@
router.back() router.back()
console.info('Succeeded in returning to the first page.') console.info('Succeeded in returning to the first page.')
} catch (err) { } catch (err) {
console.error(`Failed to return to the first page.Code is ${err.code}, message is ${err.message}`) let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.error(`Failed to return to the first page.Code is ${code}, message is ${message}`)
} }
}) })
} }
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
## 导入模块 ## 导入模块
```js ```ts
import animator from '@ohos.animator'; import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
import { BusinessError } from '@ohos.base';
``` ```
## create<sup>9+</sup> ## create<sup>9+</sup>
...@@ -39,10 +40,9 @@ create(options: AnimatorOptions): AnimatorResult ...@@ -39,10 +40,9 @@ create(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```ts
import animator, { AnimatorOptions } from '@ohos.animator'; import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = {
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -84,8 +84,10 @@ reset(options: AnimatorOptions): void ...@@ -84,8 +84,10 @@ reset(options: AnimatorOptions): void
**示例:** **示例:**
```js ```ts
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
import { BusinessError } from '@ohos.base';
let options: AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -98,7 +100,9 @@ let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型An ...@@ -98,7 +100,9 @@ let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型An
try { try {
animator.reset(options); animator.reset(options);
} catch(error) { } catch(error) {
console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); let message = (error as BusinessError).message
let code = (error as BusinessError).code
console.error(`Animator reset failed, error code: ${code}, message: ${message}.`);
} }
``` ```
...@@ -112,7 +116,7 @@ play(): void ...@@ -112,7 +116,7 @@ play(): void
**示例:** **示例:**
```js ```ts
animator.play(); animator.play();
``` ```
...@@ -126,7 +130,7 @@ finish(): void ...@@ -126,7 +130,7 @@ finish(): void
**示例:** **示例:**
```js ```ts
animator.finish(); animator.finish();
``` ```
...@@ -140,7 +144,7 @@ pause(): void ...@@ -140,7 +144,7 @@ pause(): void
**示例:** **示例:**
```js ```ts
animator.pause(); animator.pause();
``` ```
...@@ -154,7 +158,7 @@ cancel(): void ...@@ -154,7 +158,7 @@ cancel(): void
**示例:** **示例:**
```js ```ts
animator.cancel(); animator.cancel();
``` ```
...@@ -168,7 +172,7 @@ reverse(): void ...@@ -168,7 +172,7 @@ reverse(): void
**示例:** **示例:**
```js ```ts
animator.reverse(); animator.reverse();
``` ```
...@@ -188,9 +192,10 @@ onframe: (progress: number) => void ...@@ -188,9 +192,10 @@ onframe: (progress: number) => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onframe = function(value) { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onframe = (value)=> {
console.info("onframe callback") console.info("onframe callback")
} }
``` ```
...@@ -205,9 +210,10 @@ onfinish: () => void ...@@ -205,9 +210,10 @@ onfinish: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onfinish = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onfinish = ()=> {
console.info("onfinish callback") console.info("onfinish callback")
} }
``` ```
...@@ -222,9 +228,10 @@ oncancel: () => void ...@@ -222,9 +228,10 @@ oncancel: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.oncancel = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.oncancel = ()=> {
console.info("oncancel callback") console.info("oncancel callback")
} }
``` ```
...@@ -239,9 +246,10 @@ onrepeat: () => void ...@@ -239,9 +246,10 @@ onrepeat: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onrepeat = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onrepeat = ()=> {
console.info("onrepeat callback") console.info("onrepeat callback")
} }
``` ```
...@@ -277,15 +285,28 @@ animatorResult.onrepeat = function() { ...@@ -277,15 +285,28 @@ animatorResult.onrepeat = function() {
</div> </div>
``` ```
```js ```ts
export default { import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
data: { import { BusinessError } from '@ohos.base';
divWidth: 200, let DataTmp:Record<string,animator> = {
divHeight: 200, 'divWidth': 200,
animator: null 'divHeight': 200,
}, 'animator': animator
}
class Tmp{
data:animator = DataTmp
onInit:Function = ()=>{}
Show:Function = ()=>{}
}
class DateT{
divWidth:number = 0
divHeight:number = 0
animator:AnimatorResult | null = null
}
(Fn:(v:Tmp) => void) => {Fn({
data: DataTmp,
onInit() { onInit() {
let options = { let options:AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -295,10 +316,15 @@ export default { ...@@ -295,10 +316,15 @@ export default {
begin: 200.0, begin: 200.0,
end: 400.0 end: 400.0
}; };
this.animator = animator.create(options); let DataTmp:DateT = {
divWidth: 200,
divHeight: 200,
animator: null
}
DataTmp.animator = animator.create(options);
}, },
Show() { Show() {
let options1 = { let options1:AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -308,19 +334,29 @@ export default { ...@@ -308,19 +334,29 @@ export default {
begin: 0, begin: 0,
end: 400.0, end: 400.0,
}; };
let DataTmp:DateT = {
divWidth: 200,
divHeight: 200,
animator: null
}
try { try {
this.animator.reset(options1); DataTmp.animator = animator.create(options1);
DataTmp.animator.reset(options1);
} catch(error) { } catch(error) {
console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); let message = (error as BusinessError).message
let code = (error as BusinessError).code
console.error(`Animator reset failed, error code: ${code}, message: ${message}.`);
} }
let _this = this; let _this = DataTmp;
this.animator.onframe = function(value) { if(DataTmp.animator){
DataTmp.animator.onframe = (value:number)=> {
_this.divWidth = value; _this.divWidth = value;
_this.divHeight = value; _this.divHeight = value;
}; };
this.animator.play(); DataTmp.animator.play();
} }
} }
})}
``` ```
![zh-cn_image_00007](figures/zh-cn_image_00007.gif) ![zh-cn_image_00007](figures/zh-cn_image_00007.gif)
...@@ -328,7 +364,7 @@ export default { ...@@ -328,7 +364,7 @@ export default {
### 基于TS扩展的声明式开发范式 ### 基于TS扩展的声明式开发范式
```ts ```ts
import animator from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
@Entry @Entry
@Component @Component
...@@ -459,6 +495,7 @@ struct AnimatorTest { ...@@ -459,6 +495,7 @@ struct AnimatorTest {
.onClick(() => { .onClick(() => {
if (this.flag) { if (this.flag) {
this.flag = false this.flag = false
if(this.backAnimator){
this.backAnimator.reset({ this.backAnimator.reset({
duration: 5000, duration: 5000,
easing: "ease-in", easing: "ease-in",
...@@ -469,6 +506,7 @@ struct AnimatorTest { ...@@ -469,6 +506,7 @@ struct AnimatorTest {
begin: 100, begin: 100,
end: 300 end: 300
}) })
}
} else { } else {
console.info(this.TAG, 'Animation not ended') console.info(this.TAG, 'Animation not ended')
} }
...@@ -499,7 +537,7 @@ update(options: AnimatorOptions): void ...@@ -499,7 +537,7 @@ update(options: AnimatorOptions): void
**示例:** **示例:**
```js ```ts
animator.update(options); animator.update(options);
``` ```
...@@ -527,7 +565,8 @@ createAnimator(options: AnimatorOptions): AnimatorResult ...@@ -527,7 +565,8 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```ts
import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
......
...@@ -108,8 +108,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal ...@@ -108,8 +108,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 4400001 | 当调用键鼠穿越接口传入无效的设备描述符参数时,系统会产生此错误码。 | | 4400001 | Incorrect descriptor for the target device. |
| 4400002 | 当调用键鼠穿越接口时穿越状态异常,系统会产生此错误码。 | | 4400002 | Screen hop failed. |
**示例** **示例**
...@@ -158,8 +158,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\<void> ...@@ -158,8 +158,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\<void>
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 4400001 | 当调用键鼠穿越接口传入无效的设备描述符参数时,系统会产生此错误码。 | | 4400001 | Incorrect descriptor for the target device. |
| 4400002 | 当调用键鼠穿越接口时穿越状态异常,系统会产生此错误码。 | | 4400002 | Screen hop failed. |
**示例** **示例**
......
...@@ -156,7 +156,7 @@ activate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback ...@@ -156,7 +156,7 @@ activate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 20900001 | 当调用键鼠穿越接口时穿越状态异常,系统会产生此错误码。 | | 20900001 | Operation failed. |
**示例** **示例**
...@@ -205,7 +205,7 @@ activate(targetNetworkId: string, inputDeviceId: number): Promise&lt;void&gt;; ...@@ -205,7 +205,7 @@ activate(targetNetworkId: string, inputDeviceId: number): Promise&lt;void&gt;;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 20900001 | 当调用键鼠穿越接口时穿越状态异常,系统会产生此错误码。 | | 20900001 | Operation failed. |
**示例** **示例**
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册