提交 cb2781b4 编写于 作者: A Annie_wang

Merge branch 'master' of gitee.com:Annie_wang/docs_2

......@@ -135,7 +135,7 @@ zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingz
zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua
zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/webgl/ @zengyawen @zhangqiang183 @wind_zj @zxg-gitee
zh-cn/application-dev/media/audio-overview.md @zengyawen @liuyuehua1 @saga2020 @currydavids
zh-cn/application-dev/media/audio-playback.md @zengyawen @liuyuehua1 @saga2020 @currydavids
......@@ -186,8 +186,9 @@ zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chen
zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chengxingzhen @RayShih
zh-cn/application-dev/key-features/multi-device-app-dev/ @lingminghw @crazyracing0726
zh-cn/application-dev/database/ @ge-yafang @feng-aiwen @gong-a-shi @logic42
zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee
zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/mindspore-lite-offline-model-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/rawfile_guidelines.md @ningningW
zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih
zh-cn/application-dev/background-task-management/ @ningningW @wangwenli_wolf @tangtiantian2021 @nan-xiansen
......@@ -274,9 +275,9 @@ zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @litt
zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
......@@ -321,6 +322,8 @@ zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @feng-ai
zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-udmf.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-relationStore.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-data-storage.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
......@@ -331,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-deque.md @gongjunsong @ge-yafang @f
zh-cn/application-dev/reference/apis/js-apis-device-info.md @mupceet @zengyawen @handyohos @nan-xiansen
zh-cn/application-dev/reference/apis/js-apis-device-manager.md @intermilano @RayShih @william-ligang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
......@@ -415,9 +418,8 @@ zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ning
zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @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-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
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-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
......@@ -458,6 +460,8 @@ zh-cn/application-dev/reference/apis/js-apis-testRunner.md @inter515 @littlejerr
zh-cn/application-dev/reference/apis/js-apis-thermal.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-timer.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
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-devicestatus-cooperate.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-treemap.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-treeset.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-uitest.md @inter515 @ningningW @inter515 @jiyong
......@@ -473,17 +477,19 @@ zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @
zh-cn/application-dev/reference/apis/js-apis-vibrator.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @feng-aiwen @ningningW @wangzhangjun @murphy1984
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @feng-aiwen @ningningW @wangzhangjun @murphy1984
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-webgl.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-wifi.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-taskpool.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-inner-application-WorkSchedulerExtensionContext.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-xml.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-zlib.md @shuaytao @RayShih @wangzhen107 @inter515
......@@ -529,6 +535,7 @@ zh-cn/application-dev/reference/apis/js-apis-curve.md @huaweimaxuchu @HelloCreas
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-enterprise-applicationManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md @liuzuming @ningningW @yangqing3
......@@ -551,8 +558,10 @@ zh-cn/application-dev/reference/apis/js-apis-net-sharing.md @zhang-hai-feng @zen
zh-cn/application-dev/reference/apis/js-apis-nfctech.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-promptAction.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @chenmingJay @ningningW @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-stationary.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-system-capability.md taiyipei taiyipei BlackStone
......@@ -607,6 +616,7 @@ zh-cn/application-dev/reference/errorcodes/errorcode-request.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-router.md @HelloCrease
zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @RayShih
zh-cn/application-dev/reference/errorcodes/errorcode-screenlock.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md @zengyawen
zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md @ningningW
zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md @zengyawen
......
# Device Usage Statistics Development (API Version 9)
# Device Usage Statistics Development
## When to Use
......
# Native APIs
- [Introduction to Native APIs](introduction.md)
- [Using N-APIs in Application Projects](napi-guidelines.md)
- [Using Native APIs in Application Projects](napi-guidelines.md)
- [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
......
......@@ -128,10 +128,7 @@ The following steps describe how to use the canvas and brush of the Native Drawi
```c++
// Obtain the pixel address after drawing. The memory to which the address points contains the pixel data of the drawing on the canvas.
void* bitmapAddr = OH_Drawing_BitmapGetPixels(cBitmap);
auto ret = memcpy_s(addr, addrSize, bitmapAddr, addrSize);
if (ret != EOK) {
LOGI("memcpy_s failed");
}
std::copy(addr, addr + addrSize, static_cast<uint8_t*>(bitmapAddr));
// Destroy the canvas object.
OH_Drawing_CanvasDestroy(cCanvas);
// Destroy the bitmap object.
......
# Using N-APIs in Application Projects
# Using Native APIs in Application Projects
In OpenHarmony, you can use the N-APIs in C APIs to implement interaction between ArkTS/TS/JS and C/C++. The N-API names are the same as those in the third-party **Node.js**. Currently, OpenHarmony supports some N-APIs. For details about the APIs supported, see [arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/libnapi.ndk.json).
......
# Creating a Custom Component
In ArkUI, components are what's displayed on the UI. They can be classified as built-in components – those directly provided by ArkUI framework, and custom components – those defined by developers. Defining the entire application UI with just built-in components would lead to a monolithic design, low code maintainability, and poor execution performance. A good UI is the result of a well-thought-out development process, with such factors as code reusability, separation of service logic from the UI, and version evolution carefully considered. Creating custom components that encapsulate the UI and some business logic is a critical step in this process.
In ArkUI, components are what's displayed on the UI. They can be classified as built-in components – those directly provided by the ArkUI framework, and custom components – those defined by developers. Defining the entire application UI with just built-in components would lead to a monolithic design, low code maintainability, and poor execution performance. A good UI is the result of a well-thought-out development process, with such factors as code reusability, separation of service logic from the UI, and version evolution carefully considered. Creating custom components that encapsulate the UI and some business logic is a critical step in this process.
The custom component has the following features:
......
......@@ -29,7 +29,9 @@ liba
│ └── module.json5
└── oh-package.json5
```
Below is an example of the **index.ets** file content:
In the entry file **index.ets**, declare the APIs to be exposed.
Below is an example:
```ts
// liba/src/main/ets/index.ets
......@@ -168,7 +170,7 @@ struct Index {
}
```
## Inter-Application HSP Distribution
## Inter-Application HSP Distribution (for System Applications Only)
Inter-application HSPs are not completely integrated into an application. They are distributed by being preset in the system version or installed with an application on the device. To be specific:
1. Some frequently-used inter-application HSPs are preset in the system version.
2. When a user downloads an application from the application market, if the application market detects that the application depends on one or more inter-application HSPs and any of these HSPs are not installed on the target device, it will download the application as well as the missing HSPs for the user. In this way, the application can use the features shared through the HSPs properly.
......
......@@ -210,6 +210,9 @@
- [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](js-apis-image.md)
- [@ohos.multimedia.media (Media)](js-apis-media.md)
- [@ohos.multimedia.systemSoundManager (System Sound Management)](js-apis-systemSoundManager.md)
- multimedia
- [ringtonePlayer (Ringtone Player)](js-apis-inner-multimedia-ringtonePlayer.md)
- Resource Manager
- [@ohos.i18n (Internationalization)](js-apis-i18n.md)
......@@ -238,6 +241,7 @@
- [PermissionRequestResult](js-apis-permissionrequestresult.md)
- Data Management
- [@ohos.data.cloudData (Device-Cloud Synergy)](js-apis-data-cloudData.md)
- [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
- [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates (DataShare Predicates)](js-apis-data-dataSharePredicates.md)
......@@ -319,6 +323,7 @@
- [@ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)](js-apis-inputmethod-extension-ability.md)
- [@ohos.InputMethodExtensionContext (InputMethodExtensionContext)](js-apis-inputmethod-extension-context.md)
- [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md)
- [@ohos.logLibrary (Log Library)](js-apis-loglibrary.md)
- [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md)
- [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md)
......
......@@ -5,13 +5,11 @@ For details about the definition of a system common event, see [Support in @ohos
**System capability**: SystemCapability.Notification.CommonEvent
## COMMON_EVENT_BOOT_COMPLETED
Indicates that the user has finished booting and the system has been loaded.
- Value: **usual.event.BOOT_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVER_STARTUP_COMPLETED
## [COMMON_EVENT_BOOT_COMPLETED](./common_event/commonEvent-ability.md)
Indicates that the user has finished the boot process.
## COMMON_EVENT_LOCKED_BOOT_COMPLETED
(Reserved, not supported yet) Indicates that the user has finished booting and the system has been loaded but the screen is still locked.
(Reserved, not supported yet) Indicates that the user has finished the boot process but the screen is still locked.
- Value: **usual.event.LOCKED_BOOT_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVER_STARTUP_COMPLETED
......@@ -40,31 +38,26 @@ Indicates that the device is connected to an external power supply.
- Value: **usual.event.POWER_CONNECTED**
- Required subscriber permissions: none
## COMMON_EVENT_POWER_DISCONNECTED
Indicates that the device is disconnected from the external power supply.
- Value: **usual.event.POWER_DISCONNECTED**
- Required subscriber permissions: none
## COMMON_EVENT_SCREEN_OFF
Indicates that the device screen is off and the device is in sleep mode.
- Value: **usual.event.SCREEN_OFF**
- Required subscriber permissions: none
## COMMON_EVENT_SCREEN_ON
Indicates that the device screen is on and the device is in interactive state.
- Value: **usual.event.SCREEN_ON**
- Required subscriber permissions: none
## COMMON_EVENT_THERMAL_LEVEL_CHANGED<sup>8+</sup>
Indicates that the device's thermal level has changed.
- Value: **usual.event.THERMAL_LEVEL_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_USER_PRESENT<sup>(deprecated)</sup>
(Reserved, not supported yet) Indicates that the user unlocks the device.
- Value: **usual.event.USER_PRESENT**
......@@ -78,43 +71,36 @@ Indicates that the system time has changed as time ticks by.
- Value: **usual.event.TIME_TICK**
- Required subscriber permissions: none
## COMMON_EVENT_TIME_CHANGED
Indicates that the system time is set.
- Value: **usual.event.TIME_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_DATE_CHANGED
(Reserved, not supported yet) Indicates that the system date has changed.
- Value: **usual.event.DATE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_TIMEZONE_CHANGED
Indicates that the system time zone has changed.
- Value: **usual.event.TIMEZONE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_CLOSE_SYSTEM_DIALOGS
(Reserved, not supported yet) Indicates that the user closes a temporary system dialog box.
- Value: **usual.event.CLOSE_SYSTEM_DIALOGS**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_ADDED
Indicates that a new application package has been installed on the device.
- Value: **usual.event.PACKAGE_ADDED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_REPLACED
(Reserved, not supported yet) Indicates that a later version of an installed application package has replaced the previous one on the device.
- Value: **usual.event.PACKAGE_REPLACED**
- Required subscriber permissions: none
## COMMON_EVENT_MY_PACKAGE_REPLACED
(Reserved, not supported yet) Indicates that a later version of your application package has replaced the previous one.
- Value: **usual.event.MY_PACKAGE_REPLACED**
......@@ -125,85 +111,67 @@ Indicates that an installed application has been uninstalled from the device wit
- Value: **usual.event.PACKAGE_REMOVED**
- Required subscriber permissions: none
## COMMON_EVENT_BUNDLE_REMOVED
(Reserved, not supported yet) Indicates that an installed bundle has been uninstalled from the device with the application data retained.
- Value: **usual.event.BUNDLE_REMOVED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_FULLY_REMOVED
(Reserved, not supported yet) Indicates that an installed application, including both the application data and code, has been completely uninstalled from the device.
- Value: **usual.event.PACKAGE_FULLY_REMOVED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_CHANGED
Indicates that an application package has been changed (for example, an ability in the package has been enabled or disabled).
- Value: **usual.event.PACKAGE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_RESTARTED
## [COMMON_EVENT_PACKAGE_RESTARTED](./common_event/commonEvent-ability.md)
Indicates that the user closed all processes of the application and restarted the application.
- Value: **usual.event.PACKAGE_RESTARTED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_DATA_CLEARED
## [COMMON_EVENT_PACKAGE_DATA_CLEARED](./common_event/commonEvent-ability.md)
Indicates that the user cleared the application package data.
- Value: **usual.event.PACKAGE_DATA_CLEARED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_CACHE_CLEARED<sup>9+</sup>
Indicates that the user cleared the application package cache.
- Value: **usual.event.PACKAGE_CACHE_CLEARED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGES_SUSPENDED
(Reserved, not supported yet) Indicates that application HAP files are suspended.
- Value: **usual.event.PACKAGES_SUSPENDED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGES_UNSUSPENDED
(Reserved, not supported yet) Indicates that application HAP files are not suspended (restored from the suspended state).
- Value: **usual.event.PACKAGES_UNSUSPENDED**
- Required subscriber permissions: none
## COMMON_EVENT_MY_PACKAGE_SUSPENDED
Indicates that an application HAP file is suspended.
- Value: **usual.event.MY_PACKAGE_SUSPENDED**
- Required subscriber permissions: none
## COMMON_EVENT_MY_PACKAGE_UNSUSPENDED
Indicates that an application HAP file is not suspended.
- Value: **usual.event.MY_PACKAGE_UNSUSPENDED**
- Required subscriber permissions: none
## COMMON_EVENT_UID_REMOVED
(Reserved, not supported yet) Indicates that a user ID has been removed from the system.
- Value: **usual.event.UID_REMOVED**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_FIRST_LAUNCH
(Reserved, not supported yet) Indicates that an installed application is started for the first time.
- Value: **usual.event.PACKAGE_FIRST_LAUNCH**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION
(Reserved, not supported yet) Indicates that an application requires system verification.
- Value: **usual.event.PACKAGE_NEEDS_VERIFICATION**
- Required subscriber permissions: none
## COMMON_EVENT_PACKAGE_VERIFIED
(Reserved, not supported yet) Indicates that an application has been verified by the system.
- Value: **usual.event.PACKAGE_VERIFIED**
......@@ -215,91 +183,76 @@ Indicates that an application HAP file is not suspended.
- Value: **usual.event.EXTERNAL_APPLICATIONS_AVAILABLE**
- Required subscriber permissions: none
## COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE
(Reserved, not supported yet) Indicates that applications installed on the external storage are not available for the system.
- Value: **usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE**
- Required subscriber permissions: none
## COMMON_EVENT_CONFIGURATION_CHANGED
(Reserved, not supported yet) Indicates that the device state (for example, orientation and locale) has changed.
- Value: **usual.event.CONFIGURATION_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_LOCALE_CHANGED
(Reserved, not supported yet) Indicates that the device locale has changed.
- Value: **usual.event.LOCALE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_MANAGE_PACKAGE_STORAGE
(Reserved, not supported yet) Indicates that the device storage is insufficient.
- Value: **usual.event.MANAGE_PACKAGE_STORAGE**
- Required subscriber permissions: none
## COMMON_EVENT_DRIVE_MODE
(Reserved, not supported yet) Indicates that the system is in driving mode.
- Value: **common.event.DRIVE_MODE**
- Required subscriber permissions: none
## COMMON_EVENT_HOME_MODE
(Reserved, not supported yet) Indicates that the system is in home mode.
- Value: **common.event.HOME_MODE**
- Required subscriber permissions: none
## COMMON_EVENT_OFFICE_MODE
(Reserved, not supported yet) Indicates that the system is in office mode.
- Value: **common.event.OFFICE_MODE**
- Required subscriber permissions: none
## COMMON_EVENT_USER_STARTED
(Reserved, not supported yet) Indicates that the user has been started.
- Value: **usual.event.USER_STARTED**
- Required subscriber permissions: none
## COMMON_EVENT_USER_BACKGROUND
(Reserved, not supported yet) Indicates that the user has been brought to the background.
- Value: **usual.event.USER_BACKGROUND**
- Required subscriber permissions: none
## COMMON_EVENT_USER_FOREGROUND
(Reserved, not supported yet) Indicates that the user has been brought to the foreground.
- Value: **usual.event.USER_FOREGROUND**
- Required subscriber permissions: none
## COMMON_EVENT_USER_SWITCHED
Indicates that user switching is in progress.
- Value: **usual.event.USER_SWITCHED**
- Required subscriber permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS
## COMMON_EVENT_USER_STARTING
(Reserved, not supported yet) Indicates that the user is being started.
- Value: **usual.event.USER_STARTING**
- Required subscriber permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
## COMMON_EVENT_USER_UNLOCKED
(Reserved, not supported yet) Indicates that the credential-encrypted storage has been unlocked for the current user after the device is restarted.
- Value: **usual.event.USER_UNLOCKED**
- Required subscriber permissions: none
## COMMON_EVENT_USER_STOPPING
(Reserved, not supported yet) Indicates that the user is going to be stopped.
- Value: **usual.event.USER_STOPPING**
- Required subscriber permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
## COMMON_EVENT_USER_STOPPED
(Reserved, not supported yet) Indicates that the user has been stopped.
- Value: **usual.event.USER_STOPPED**
......@@ -665,11 +618,15 @@ Indicates that the system charging type has changed. This event is available onl
- Value: **usual.event.CHARGE_TYPE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED
## [COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED](./common_event/commonEvent-resourceschedule.md)
(Reserved, not supported yet) Indicates that the system idle mode has changed.
- Value: **usual.event.DEVICE_IDLE_MODE_CHANGED**
- Required subscriber permissions: none
## [COMMON_EVENT_DEVICE_IDLE_EXEMPTION_LIST_UPDATED<sup>10+<sup>](./common_event/commonEvent-resourceschedule.md)
Indicates that the exemption list for resource usage restrictions has been updated in idle mode. This event is for system applications only.
- Value: **usual.event.DEVICE_IDLE_EXEMPTION_LIST_UPDATED**
- Required subscriber permissions: none
## COMMON_EVENT_POWER_SAVE_MODE_CHANGED
Indicates that the system power saving mode has changed.
......@@ -766,61 +723,51 @@ Indicates that a user has been removed from the system.
- Value: **common.event.IVI_VOLTAGE_RECOVERY**
- Required subscriber permissions: none
## COMMON_EVENT_IVI_TEMPERATURE_RECOVERY
(Reserved, not supported yet) Indicates that the temperature of the IVI system is restored to normal.
- Value: **common.event.IVI_TEMPERATURE_RECOVERY**
- Required subscriber permissions: none
## COMMON_EVENT_IVI_ACTIVE
(Reserved, not supported yet) Indicates that the battery service of the IVI system is active.
- Value: **common.event.IVI_ACTIVE**
- Required subscriber permissions: none
## COMMON_EVENT_USB_STATE<sup>9+</sup>
Indicates that the USB device state has changed.
- Value: **usual.event.hardware.usb.action.USB_STATE**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_USB_PORT_CHANGED<sup>9+</sup>
Indicates that the USB port state of the device has changed.
- Value: **usual.event.hardware.usb.action.USB_PORT_CHANGED**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_USB_DEVICE_ATTACHED
Indicates that a USB device has been attached to the device functioning as a USB host.
- Value: **usual.event.hardware.usb.action.USB_DEVICE_ATTACHED**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_USB_DEVICE_DETACHED
Indicates that a USB device has been detached from the device functioning as a USB host.
- Value: **usual.event.hardware.usb.action.USB_DEVICE_DETACHED**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_USB_ACCESSORY_ATTACHED
(Reserved, not supported yet) Indicates that a USB accessory was attached.
- Value: **usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_USB_ACCESSORY_DETACHED
(Reserved, not supported yet) Indicates that a USB accessory was detached.
- Value: **usual.event.data.DISK_MOUNTED**
- Required subscriber permissions: none
For details, see [Common Events of the USB Subsystem](common_event/commonEvent-usb.md).
## COMMON_EVENT_DISK_REMOVED
(Reserved, not supported yet) Indicates that an external storage device was removed.
- Value: **usual.event.data.DISK_BAD_REMOVAL**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_DISK_UNMOUNTED
(Reserved, not supported yet) Indicates that an external storage device was unmounted.
- Value: **usual.event.data.DISK_UNMOUNTABLE**
......@@ -838,92 +785,77 @@ Indicates that a USB device has been detached from the device functioning as a U
- Value: usual.event.data.DISK_REMOVED
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_DISK_UNMOUNTABLE
(Reserved, not supported yet) Indicates that an external storage device is unmountable when the card is inserted.
- Value: **usual.event.data.DISK_UNMOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_DISK_EJECT
(Reserved, not supported yet) Indicates that an external storage device was ejected (at the software level).
- Value: **usual.event.data.DISK_EJECT**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VOLUME_REMOVED<sup>9+</sup>
Indicates that an external storage device was removed.
- Value: **usual.event.data.VOLUME_REMOVED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VOLUME_UNMOUNTED<sup>9+</sup>
Indicates that an external storage device was unmounted.
- Value: **usual.event.data.VOLUME_UNMOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VOLUME_MOUNTED<sup>9+</sup>
Indicates that an external storage device was mounted.
- Value: **usual.event.data.VOLUME_MOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VOLUME_BAD_REMOVAL<sup>9+</sup>
Indicates that an external storage device was removed without being unmounted.
- Value: **usual.event.data.VOLUME_BAD_REMOVAL**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VOLUME_EJECT<sup>9+</sup>
Indicates that an external storage device was ejected (at the software level).
- Value: usual.event.data.VOLUME_EJECT
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
## COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED
(Reserved, not supported yet) Indicates that the account visibility changed.
- Value: **usual.event.data.VISIBLE_ACCOUNTS_UPDATED**
- Required subscriber permissions: ohos.permission.GET_APP_ACCOUNTS
## COMMON_EVENT_ACCOUNT_DELETED
(Reserved, not supported yet) Indicates that an account was deleted.
- Value: **usual.event.data.ACCOUNT_DELETED**
- Required subscriber permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
## COMMON_EVENT_FOUNDATION_READY
(Reserved, not supported yet) Indicates that the foundation is ready.
- Value: **usual.event.data.FOUNDATION_READY**
- Required subscriber permissions: ohos.permission.RECEIVER_STARTUP_COMPLETED
## COMMON_EVENT_AIRPLANE_MODE_CHANGED
Indicates that the airplane mode of the device has changed.
- Value: **usual.event.AIRPLANE_MODE**
- Required subscriber permissions: none
## COMMON_EVENT_SPLIT_SCREEN
Indicates that the screen has been split.
- Value: **usual.event.SPLIT_SCREEN**
- Required subscriber permissions: ohos.permission.RECEIVER_SPLIT_SCREEN
## COMMON_EVENT_SLOT_CHANGE<sup>9+</sup>
Indicates that the notification slot has been updated.
- Value: **usual.event.SLOT_CHANGE**
- Required subscriber permissions: ohos.permission.NOTIFICATION_CONTROLLER
## COMMON_EVENT_SPN_INFO_CHANGED<sup>9+</sup>
Indicates that the SPN displayed has been updated.
- Value: **usual.event.SPN_INFO_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_QUICK_FIX_APPLY_RESULT<sup>9+</sup>
## [COMMON_EVENT_QUICK_FIX_APPLY_RESULT<sup>9+<sup>](./common_event/commonEvent-ability.md)
Indicates the result of applying a quick fix to the application.
- Value: **usual.event.QUICK_FIX_APPLY_RESULT**
- Required subscriber permissions: none
......@@ -1049,3 +981,6 @@ Indicates that the screen is unlocked.
- Value: **usual.event.SCREEN_UNLOCKED**
- Required subscriber permissions: none
## [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT<sup>10+<sup>](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10)
ָIndicates the result of revoking a quick fix to the application.
\ No newline at end of file
# Common Events
- [Common Events of the Ability Subsystem](commonEvent-ability.md)
- [Common Events of the Bundle Management Subsystem](commonEvent-bundleManager.md)
- [Common Events of the Notification Service](commonEvent-ans.md)
- [Common Events of the Resource Scheduling Subsystem](commonEvent-resourceschedule.md)
- [Common Events of the Telephony Subsystem](commonEvent-telephony.md)
- [Common Events of the USB Subsystem](commonEvent-usb.md)
# Common Events of the Ability Subsystem
This document lists the common system events provided by the Ability subsystem to applications.
## COMMON_EVENT_BOOT_COMPLETED
Indicates that the user has finished the boot process.
- Constant value: "usual.event.BOOT_COMPLETED"
- Required subscriber permissions: ohos.permission.RECEIVER_STARTUP_COMPLETED
When the specified user finishes the boot process on the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_PACKAGE_RESTARTED
Indicates that the user has restarted the application package and killed all its processes.
- Constant value: "usual.event.PACKAGE_RESTARTED"
- Required subscriber permissions: none
When the specified user restarts the application and kills all its processes, the event notification service is triggered to publish this event.
## COMMON_EVENT_PACKAGE_DATA_CLEARED
Indicates that the user cleared the application package data.
- Constant value: "usual.event.PACKAGE_DATA_CLEARED"
- Required subscriber permissions: none
When the specified user clears the application package data on the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_QUICK_FIX_APPLY_RESULT<sup>9+</sup>
Indicates the result of applying a quick fix to the application.
- Constant value: "usual.event.QUICK_FIX_APPLY_RESULT"
- Required subscriber permissions: none
When the specified user applies a quick fix to the application on the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_QUICK_FIX_REVOKE_RESULT<sup>10+</sup>
Indicates the result of revoking a quick fix to the application.
- Constant value: "usual.event.QUICK_FIX_REVOKE_RESULT"
- Required subscriber permissions: none
When a quick fix to the application is revoked on the device, the event notification service is triggered to publish this event.
# Common Events of the Resource Scheduling Subsystem
This document lists the common system events provided by the resource scheduling subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED
Indicates that the system idle mode has changed.
- Constant value: "usual.event.DEVICE_IDLE_MODE_CHANGED"
- Required subscriber permissions: none
When the user does not use the device for the specified period of time and the screen is turned off, the system delays the CPU and network access by background applications, and the event notification service is triggered to publish this event.
APIs related to this event: **deviceStandby**.
## COMMON_EVENT_DEVICE_IDLE_EXEMPTION_LIST_UPDATED
Indicates that the exemption list for resource usage restrictions has been updated in idle mode.
- Constant value: "usual.event.DEVICE_IDLE_EXEMPTION_LIST_UPDATED"
- Required subscriber permissions: none
When the exemption list for resource usage restrictions is updated, the event notification service is triggered to publish this event.
Resources include application network access, Timer usage, and WorkScheduler task usage.
System applications can call JavaScript APIs to apply for removing resource usage restrictions.
APIs related to this event: **deviceStandby**.
# Common Events of the USB Subsystem
This document lists the common system events provided by the USB subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_USB_STATE
Indicates that the USB device state has changed.
- Constant value: "usual.event.hardware.usb.action.USB_STATE"
- Required subscriber permissions: none
When a USB device is connected to or disconnected from the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_USB_PORT_CHANGED
Indicates that the USB port state of the device has changed.
- Constant value: "usual.event.hardware.usb.action.USB_PORT_CHANGED"
- Required subscriber permissions: none
When the USB port status changes, the event notification service is triggered to publish this event.
APIs related to this event: **dataRole** parameter in [setPortRoles](../js-apis-usbManager.md#usbsetportroles).
## COMMON_EVENT_USB_DEVICE_ATTACHED
Indicates that a USB device has been attached to the device functioning as a USB host.
- Constant value: "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED"
- Required subscriber permissions: none
When a USB device is attached, the event notification service is triggered to publish this event.
APIs related to this event: [USBDevice](../js-apis-usbManager.md#usbdevice).
## COMMON_EVENT_USB_DEVICE_DETACHED
Indicates that a USB device has been detached from the device functioning as a USB host.
- Constant value: "usual.event.hardware.usb.action.USB_DEVICE_DETACHED"
- Required subscriber permissions: none
When a USB device is deattached, the event notification service is triggered to publish this event.
APIs related to this event: [USBDevice](../js-apis-usbManager.md#usbdevice).
## COMMON_EVENT_USB_ACCESSORY_ATTACHED
(Reserved, not supported yet) Indicates that a USB accessory was attached.
- Constant value: "usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED"
- Required subscriber permissions: none
## COMMON_EVENT_USB_ACCESSORY_DETACHED
(Reserved, not supported yet) Indicates that a USB accessory was detached.
- Constant value: "usual.event.data.DISK_MOUNTED"
- Required subscriber permissions: none
......@@ -64,7 +64,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example**
......@@ -74,7 +74,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try {
atManager.checkAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
atManager.checkAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`checkAccessToken success, data->${JSON.stringify(data)}`);
}).catch((err) => {
console.log(`checkAccessToken fail, err->${JSON.stringify(err)}`);
......@@ -111,14 +111,14 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example**
```js
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let data = atManager.verifyAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`);
```
......@@ -154,7 +154,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName exceeds 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
......@@ -169,7 +169,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1;
try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('grantUserGrantedPermission success');
}).catch((err) => {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
......@@ -221,7 +221,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1;
try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
......@@ -280,7 +280,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1;
try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('revokeUserGrantedPermission success');
}).catch((err) => {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
......@@ -332,7 +332,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1;
try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
......@@ -375,7 +375,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
......@@ -389,7 +389,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try {
atManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
atManager.getPermissionFlags(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`);
}).catch((err) => {
console.log(`getPermissionFlags fail, err->${JSON.stringify(err)}`);
......@@ -443,7 +443,7 @@ Subscribes to permission state changes of the specified applications and permiss
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type to subscribe to. The value is **'permissionStateChange'**, which indicates the permission grant state change. |
| tokenIDList | Array&lt;number&gt; | Yes | Token IDs of the applications to observe. If this parameter is left empty, the permission grant state changes of all applications are observed. |
| permissionList | Array&lt;Permissions&gt; | Yes | Permissions to observe. If this parameter is left empty, the grant state changes of all permissions are observed. |
| permissionList | Array&lt;Permissions&gt; | Yes | List of permission names. If this parameter is left empty, the grant state changes of all permissions are subscribed to. |
| callback | Callback&lt;[PermissionStateChangeInfo](#permissionstatechangeinfo9)&gt; | Yes| Callback invoked to return the permission grant state change.|
**Error codes**
......@@ -452,7 +452,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
| 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. |
......@@ -461,16 +461,16 @@ For details about the error codes, see [Application Access Control Error Codes](
**Example**
```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
import {Permissions} from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"];
let permissionList: Array<Permissions> = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try {
atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => {
console.debug("receive permission state change, data:" + JSON.stringify(data));
console.debug('receive permission state change, data:' + JSON.stringify(data));
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
......@@ -505,20 +505,20 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. |
| 12100004 | The interface is not used together with "on". |
| 12100004 | The interface is not used together with 'on'. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example**
```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
import {Permissions} from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"];
let permissionList: Array<Permissions> = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try {
atManager.off('permissionStateChange', tokenIDList, permissionList);
} catch(err) {
......@@ -558,7 +558,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
......@@ -599,10 +599,10 @@ For details about the error codes, see [Application Access Control Error Codes](
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"], (err, data)=>{
console.info("data:" + JSON.stringify(data));
console.info("data permissions:" + data.permissions);
console.info("data authResults:" + data.authResults);
atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
console.info('data:' + JSON.stringify(data));
console.info('data permissions:' + data.permissions);
console.info('data authResults:' + data.authResults);
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
......@@ -650,12 +650,12 @@ For details about the error codes, see [Application Access Control Error Codes](
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => {
console.info("data:" + JSON.stringify(data));
console.info("data permissions:" + data.permissions);
console.info("data authResults:" + data.authResults);
atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA']).then((data) => {
console.info('data:' + JSON.stringify(data));
console.info('data permissions:' + data.permissions);
console.info('data authResults:' + data.authResults);
}).catch((err) => {
console.info("data:" + JSON.stringify(err));
console.info('data:' + JSON.stringify(err));
})
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
......@@ -694,7 +694,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
......@@ -727,14 +727,14 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. |
| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example**
```js
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.checkAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let data = atManager.checkAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`);
```
......
......@@ -247,7 +247,7 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback&lt;void&gt; | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback&lt;void&gt; | No| Callback for the event.|
**Example**
......@@ -425,7 +425,7 @@ Cancels the listener for attribute changes. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback&lt;T&gt; | No| Callback for the event.|
**Example**
......
......@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Type| Description|
| -------- | -------- |
|AsyncCallback&lt;boolean&gt; |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
|AsyncCallback&lt;boolean&gt; |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes**
......@@ -59,9 +59,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes**
......@@ -94,9 +94,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes**
......@@ -128,9 +128,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Type| Description|
| -------- | -------- |
| AsyncCallback&lt;boolean&gt; |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| AsyncCallback&lt;boolean&gt; |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes**
......@@ -164,9 +164,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes**
......@@ -198,9 +198,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Type| Description|
| -------- | -------- |
|AsyncCallback&lt;number&gt; |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
| Type| Description|
| -------- | -------- |
|AsyncCallback&lt;number&gt; |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes**
......@@ -298,6 +298,82 @@ appManager.getRunningProcessInformation((err, data) => {
});
```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number): Promise\<boolean>;
Checks whether the shared library is in use. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode).then((data) => {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}).catch((error) => {
console.error('error: ${JSON.stringify(error)}');
});
```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number, callback: AsyncCallback\<boolean>): void;
Checks whether the shared library is in use. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
|AsyncCallback\<boolean>> | Callback used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode, (err, data) => {
if (err) {
console.error('err: ${JSON.stringify(err)}');
} else {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}
});
```
## appManager.on
on(type: 'applicationState', observer: ApplicationStateObserver): number;
......@@ -641,7 +717,7 @@ Obtains applications that are running in the foreground. This API uses a promise
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data. |
| Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data.|
**Error codes**
......@@ -731,11 +807,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
**Error codes**
......
......@@ -116,8 +116,8 @@ struct SnapshotExample {
Image(this.pixmap)
.width(300).height(300)
// ...Component
// ...Components
// ...Components
// ...Component
// ...Component
Button("click to generate UI snapshot")
.onClick(() => {
componentSnapshot.get("root")
......
......@@ -2,8 +2,7 @@
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
> 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
......@@ -118,8 +117,9 @@ Enumerates the camera error codes, which are returned when an API call is incorr
| SESSION_NOT_RUNNING | 7400104 | The session is not running. |
| SESSION_CONFIG_LOCKED | 7400105 | The session configuration is locked. |
| DEVICE_SETTING_LOCKED | 7400106 | The device setting is locked. |
| CONFILICT_CAMERA | 7400107 | The device is already started. |
| CONFLICT_CAMERA | 7400107 | The device is already started. |
| DEVICE_DISABLED | 7400108 | The camera is disabled for security reasons. |
| DEVICE_PREEMPTED | 7400109 | The camera is preempted. |
| SERVICE_FATAL_ERROR | 7400201 | An error occurs in the camera service. |
## CameraManager
......@@ -203,7 +203,7 @@ isCameraMuteSupported(): boolean
Checks whether the camera can be muted.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -225,7 +225,7 @@ muteCamera(mute: boolean): void
Mutes or unmutes the camera.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -562,7 +562,7 @@ on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void
Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -630,6 +630,20 @@ Enumerates the camera connection types.
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.|
## HostDeviceType
Enumerates the remote camera types.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ---------------------------- | ---- | ------------- |
| UNKNOWN_TYPE | 0 | Unknown type. |
| PHONE | 0x0E | Camera of a smartphone.|
| TABLET | 0x11 | Camera of a tablet.|
## CameraDevice
Defines the camera device information.
......@@ -642,6 +656,8 @@ Defines the camera device information.
| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
| hostDeviceName | string | Yes | Name of the remote device.<br>**System API**: This is a system API.|
| hostDeviceType | [hostDeviceType](#hostdevicetype) | Yes | Type of the remote device.<br>**System API**: This is a system API.|
## Size
......@@ -1754,7 +1770,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.|
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes**
......@@ -1788,7 +1804,7 @@ Obtains the exposure value in use.
| Type | Description |
| ---------- | ----------------------------- |
| number | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
| number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes**
......
# @ohos.data.cloudData (Device-Cloud Synergy)
The **cloudData** module provides the capability of synchronizing the structured data (in RDB stores) between the device and cloud. The cloud serves as the central node of data. The devices synchronize data with the data in the cloud to implement cloud data backup and data consistency between the devices with the same account.
This module provides the following common functions:
- [Config](#config): provides methods for configuring device-cloud synergy, including enabling and disabling cloud synchronization, clearing data, and notifying data changes.
> **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 cloudData from '@ohos.data.cloudData';
```
## Action
Enumerates the actions for clearing the cloud information about the local data.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
| Name | Description |
| --------- | ---------------------------- |
| CLEAR_CLOUD_INFO | Clear the cloud ID information.|
| CLEAR_CLOUD_DATA_AND_INFO |Clear all cloud data, including cloud ID information and data downloaded from the cloud (excluding the data modified or generated locally). |
## Config
Provides methods for configuring device-cloud synergy, including enabling and disabling cloud synchronization, clearing data, and notifying data changes.
### enableCloud
static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, callback: AsyncCallback&lt;void&gt;):void
Enables device-cloud synergy. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | Yes | ID of the target cloud. |
| switches | {[bundleName: string]: boolean} | Yes | Device-cloud synergy switches for applications. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let switches = { 'test_bundleName1': true, 'test_bundleName2': false };
try {
cloudData.Config.enableCloud(account, switches, function (err) {
if (err === undefined) {
console.info('Succeeded in enabling cloud');
} else {
console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### enableCloud
static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}): Promise&lt;void&gt;
Enables device-cloud synergy. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | Yes | ID of the target cloud. |
| switches | {[bundleName: string]: boolean} | Yes | Device-cloud synergy switches for applications. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let switches = { 'test_bundleName1': true, 'test_bundleName2': false };
try {
cloudData.Config.enableCloud(account, switches).then(() => {
console.info('Succeeded in enabling cloud');
}).catch((err) => {
console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### disableCloud
static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;):void
Disables device-cloud synergy. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
try {
cloudData.Config.disableCloud(account, function (err) {
if (err === undefined) {
console.info('Succeeded in disabling cloud');
} else {
console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### disableCloud
static disableCloud(accountId: string): Promise&lt;void&gt;
Disables device-cloud synergy. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
try {
cloudData.Config.disableCloud(account).then(() => {
console.info('Succeeded in disabling cloud');
}).catch((err) => {
console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### changeAppCloudSwitch
static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, callback: AsyncCallback&lt;void&gt;):void
Changes the device-cloud synergy switch for an application. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName| string | Yes | Name of the target application.|
| status | boolean | Yes | Setting of the device-cloud synergy switch for the application. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.changeAppCloudSwitch(account, bundleName, true, function (err) {
if (err === undefined) {
console.info('Succeeded in changing App cloud switch');
} else {
console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### changeAppCloudSwitch
static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): Promise&lt;void&gt;
Changes the device-cloud synergy switch for an application. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName| string | Yes | Name of the target application.|
| status | boolean | Yes | Setting of the device-cloud synergy switch for the application. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
console.info('Succeeded in changing App cloud switch');
}).catch((err) => {
console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### notifyDataChange
static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCallback&lt;void&gt;):void
Notifies the data changes in the cloud. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName | string | Yes | Name of the target application. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.notifyDataChange(account, bundleName, function (err) {
if (err === undefined) {
console.info('Succeeded in notifying the change of data');
} else {
console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### notifyDataChange
static notifyDataChange(accountId: string,bundleName:string): Promise&lt;void&gt;
Notifies the data changes in the cloud. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName | string | Yes | Name of the target application. |
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.notifyDataChange(account, bundleName).then(() => {
console.info('Succeeded in notifying the change of data');
}).catch((err) => {
console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
# @ohos.data.dataSharePredicates (DataShare Predicates)
# @ohos.data.dataSharePredicates (Data Share Predicates)
You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data.
......@@ -18,13 +18,13 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
## DataSharePredicates
Provides methods for setting different **DataSharePredicates** objects.
Provides methods for setting different **DataSharePredicates** objects. This type is not multi-thread safe. If a **DataSharePredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
### equalTo
equalTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is equal to the specified value.
Sets a **DataSharePredicates** object to match the data that is equal to the specified value.
Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object.
......@@ -54,10 +54,11 @@ predicates.equalTo("NAME", "Rose")
notEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is not equal to the specified value.
Sets a **DataSharePredicates** object to match the data that is not equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -88,6 +89,7 @@ Adds a left parenthesis to this **DataSharePredicates**.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -116,6 +118,7 @@ Adds a right parenthesis to this **DataSharePredicates** object.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -144,6 +147,7 @@ Adds the OR condition to this **DataSharePredicates** object.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -190,10 +194,11 @@ predicates.equalTo("NAME", "lisi")
contains(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that contains the specified value.
Sets a **DataSharePredicates** object to match the data that contains the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -220,10 +225,11 @@ predicates.contains("NAME", "os")
beginsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that begins with the specified value.
Sets a **DataSharePredicates** object to match the data that begins with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -250,10 +256,11 @@ predicates.beginsWith("NAME", "os")
endsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that ends with the specified value.
Sets a **DataSharePredicates** object to match the data that ends with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -280,10 +287,11 @@ predicates.endsWith("NAME", "os")
isNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose value is null.
Sets a **DataSharePredicates** object to match the data whose value is null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -309,10 +317,11 @@ predicates.isNull("NAME")
isNotNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose value is not null.
Sets a **DataSharePredicates** object to match the data whose value is not null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -338,10 +347,11 @@ predicates.isNotNull("NAME")
like(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression.
Sets a **DataSharePredicates** object to match the data that matches the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -368,10 +378,11 @@ predicates.like("NAME", "%os%")
unlike(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that does not match the specified wildcard expression.
Sets a **DataSharePredicates** object to match the data that does not match the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -398,10 +409,11 @@ predicates.unlike("NAME", "%os%")
glob(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression.
Sets a **DataSharePredicates** object to match the data that matches the specified wildcard expression.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -428,10 +440,11 @@ predicates.glob("NAME", "?h*g")
between(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is within the specified range, including the start and end values.
Sets a **DataSharePredicates** object to match the data that is within the specified range, including the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -459,10 +472,11 @@ predicates.between("AGE", 10, 50)
notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is out of the specified range, excluding the start and end values.
Sets a **DataSharePredicates** object to match the data that is out of the specified range, excluding the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -490,10 +504,11 @@ predicates.notBetween("AGE", 10, 50)
greaterThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is greater than the specified value.
Sets a **DataSharePredicates** object to match the data that is greater than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -520,10 +535,11 @@ predicates.greaterThan("AGE", 10)
lessThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is less than the specified value.
Sets a **DataSharePredicates** object to match the data that is less than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -550,10 +566,11 @@ predicates.lessThan("AGE", 50)
greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is greater than or equal to the specified value.
Sets a **DataSharePredicates** object to match the data that is greater than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -580,10 +597,11 @@ predicates.greaterThanOrEqualTo("AGE", 10)
lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is less than or equal to the specified value.
Sets a **DataSharePredicates** object to match the data that is less than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -672,6 +690,7 @@ Sets a **DataSharePredicates** object to filter out duplicate data records.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -725,6 +744,7 @@ Sets a **DataSharePredicates** object group the records according to the specifi
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -754,6 +774,7 @@ Sets a **DataSharePredicates** object to list data by the specified index.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -779,7 +800,7 @@ predicates.indexedBy("SALARY_INDEX")
in(field: string, value: Array&lt;ValueType&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is within the specified value.
Sets a **DataSharePredicates** object to match the data that is within the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
......@@ -809,10 +830,11 @@ predicates.in("AGE", [18, 20])
notIn(field: string, value: Array&lt;ValueType&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is not in the specified value.
Sets a **DataSharePredicates** object to match the data that is not in the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -839,10 +861,11 @@ predicates.notIn("NAME", ["Lisa", "Rose"])
prefixKey(prefix: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data with the specified key prefix.
Sets a **DataSharePredicates** object to match the data with the specified key prefix.
Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -868,10 +891,11 @@ predicates.prefixKey("NAME")
inKeys(keys: Array&lt;string&gt;): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose keys are within the given range.
Sets a **DataSharePredicates** object to match the data whose keys are within the given range.
Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......
......@@ -23,10 +23,10 @@ Creates a distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| source | object | Yes| Attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| source | object | Yes| Attributes of the distributed data object.|
**Return value**
......@@ -75,9 +75,9 @@ Creates a random session ID.
**Return value**
| Type| Description|
| -------- | -------- |
| string | Session ID created.|
| Type| Description|
| -------- | -------- |
| string | Session ID created.|
**Example**
......@@ -124,18 +124,18 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | Yes| ID of a distributed data object on a trusted network.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the session ID is successfully set.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | Yes| ID of a distributed data object on a trusted network.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the session ID is successfully set.|
**Error codes**
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message|
| -------- | -------- |
| 15400001 | Failed to create the in-memory database.|
| ID| Error Message|
| -------- | -------- |
| 15400001 | Create table failed.|
**Example**
......@@ -158,17 +158,17 @@ Exits all joined sessions.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.|
**Error codes**
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message|
| -------- | -------- |
| 15400001 | Failed to create the in-memory database.|
| ID| Error Message|
| -------- | -------- |
| 15400001 | Create table failed.|
**Example**
......@@ -195,9 +195,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value**
......@@ -209,9 +209,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message|
| -------- | -------- |
| 15400001 | Failed to create the in-memory database.|
| ID| Error Message|
| -------- | -------- |
| 15400001 | Create table failed.|
**Example**
......@@ -240,10 +240,10 @@ Subscribes to data changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
......@@ -269,10 +269,10 @@ Unsubscribes from the data changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
......@@ -294,10 +294,10 @@ Subscribes to status changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
**Example**
......@@ -318,10 +318,10 @@ Unsubscribes from the status change of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
**Example**
......@@ -354,10 +354,10 @@ The saved data will be released in the following cases:
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
| callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
| callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example**
......@@ -394,15 +394,15 @@ The saved data will be released in the following cases:
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example**
......@@ -423,7 +423,7 @@ g_object.save("local").then((result) => {
revokeSave(callback: AsyncCallback&lt;RevokeSaveSuccessResponse&gt;): void
Revokes the saving operation of this distributed data object. This API uses an asynchronous callback to return the result.
Revokes the data of this distributed data object saved. This API uses an asynchronous callback to return the result.
If the object is saved on the local device, the data saved on all trusted devices will be deleted.
If the object is stored on another device, the data on the local device will be deleted.
......@@ -432,9 +432,9 @@ If the object is stored on another device, the data on the local device will be
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example**
......@@ -468,7 +468,7 @@ g_object.revokeSave((err, result) => {
revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt;
Revokes the saving operation of this distributed data object. This API uses a promise to return the result.
Revokes the data of this distributed data object saved. This API uses a promise to return the result.
If the object is saved on the local device, the data saved on all trusted devices will be deleted.
If the object is stored on another device, the data on the local device will be deleted.
......@@ -477,9 +477,9 @@ If the object is stored on another device, the data on the local device will be
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example**
......@@ -520,9 +520,9 @@ Creates a distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| source | object | Yes| Attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| source | object | Yes| Attributes of the distributed data object.|
**Return value**
......@@ -558,15 +558,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
**Example**
......@@ -593,10 +593,10 @@ Subscribes to data changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
......@@ -628,10 +628,10 @@ Unsubscribes from the data changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
......@@ -659,10 +659,10 @@ Subscribes to status changes of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
**Example**
......@@ -689,8 +689,8 @@ Unsubscribes from the status change of this distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
......
......@@ -185,7 +185,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod
| ID| Error Message |
| -------- | ------------------------------|
| 15500010 | Failed to delete the preferences. |
| 15500010 | Failed to delete preferences file. |
**Example**
......@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
try {
data_preferences.deletePreferences(context, 'mystore', function (err, val) {
data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message);
return;
......@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
try {
data_preferences.deletePreferences(this.context, 'mystore', function (err, val) {
data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message);
return;
......@@ -262,7 +262,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod
| ID| Error Message |
| -------- | ------------------------------|
| 15500010 | Failed to delete the preferences. |
| 15500010 | Failed to delete preferences file. |
**Example**
......@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
try {
data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) {
data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message);
return;
......@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
try {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err, val) {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message);
return;
......
# @ohos.data.ValuesBucket (Value Bucket)
# @ohos.data.ValuesBucket (Data Set)
The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
......@@ -6,7 +6,6 @@ The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to
>
> 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.
## Modules to Import
......@@ -30,7 +29,7 @@ Enumerates the value types allowed by the database.
## ValuesBucket
Defines the types of the key and value in a KV pair.
Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册