From 6d6bd59958dcdbd2c8c0b5a25cc7b6b8d846dcf5 Mon Sep 17 00:00:00 2001 From: annie_wangli Date: Wed, 2 Mar 2022 14:52:52 +0800 Subject: [PATCH] update docs Signed-off-by: annie_wangli --- .../reference/apis/Readme-EN.md | 12 +- .../apis/js-apis-storage-statistics.md | 183 ++++++++++++++++++ .../reference/apis/js-apis-volumemanager.md | 167 ++++++++++++++++ 3 files changed, 360 insertions(+), 2 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-storage-statistics.md create mode 100644 en/application-dev/reference/apis/js-apis-volumemanager.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index d350833093..5e372b0913 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -19,7 +19,7 @@ - [Media](js-apis-media.md) - Security - [User Authentication](js-apis-useriam-userauth.md) - - [Access Control](js-apis-abilityAccessCtrl.md) + - [Access Control](js-apis-abilityAccessCtrl.md) - Data Management - [File Management](js-apis-fileio.md) - [Lightweight Storage](js-apis-data-storage.md) @@ -27,8 +27,16 @@ - [Relational Database](js-apis-data-rdb.md) - [Result Set](js-apis-data-resultset.md) - [DataAbilityPredicates](js-apis-data-ability.md) +- File Management + - [File Management](js-apis-fileio.md) + - [Statfs](js-apis-statfs.md) + - [Environment](js-apis-environment.md) + - [Public File Access and Management](js-apis-filemanager.md) + - [App Storage Statistics](js-apis-storage-statistics.md) + - [Volume Management](js-apis-volumemanager.md) - Account Management - [Distributed Account Management](js-apis-distributed-account.md) + - [App Account Management](js-apis-appAccount.md) - Telephony Service - [Call](js-apis-call.md) - [SMS](js-apis-sms.md) @@ -38,7 +46,7 @@ - [WLAN](js-apis-wifi.md) - Device Management - [Sensors](js-apis-sensor.md) - - [Vibration](js-apis-vibrator.md) + - [Vibrator](js-apis-vibrator.md) - [Brightness](js-apis-brightness.md) - [Battery Info](js-apis-battery-info.md) - [Power Management](js-apis-power.md) diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md new file mode 100644 index 0000000000..75a68449a7 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -0,0 +1,183 @@ +# App Storage Statistics + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import storagestatistics from "@ohos.storagestatistics"; +``` + +## System Capabilities + +SystemCapability.FileManagement.StorageService.SpatialStatistics + +## storagestatistics.getTotalSizeOfVolume + +getTotalSizeOfVolume(volumeUuid: string): Promise<number> + +Asynchronously obtains the total space of the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------ | ---- | ---- | + | volumeUuid | string | Yes| Universally unique identifier (UUID) of the volume.| + +- Return value + + | Type| Description| + | --------------------- | ---------------- | + | Promise<number> | Promise used to return the total space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){ + console.info("getTotalSizeOfVolume successfully:"+ number); + }).catch(function(err){ + console.info("getTotalSizeOfVolume failed with error:"+ err); + }); + ``` + +## storagestatistics.getTotalSizeOfVolume + +getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void + +Asynchronously obtains the total space of the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------------------ | ---- | -------------------------- | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the total space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ + // Do something + }); + ``` + + + +## storagestatistics.getFreeSizeOfVolume + +getFreeSizeOfVolume(volumeUuid: string): Promise<number> + +Asynchronously obtains the available space of the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------ | ---- | ---- | + | volumeUuid | string | Yes| UUID of the volume.| + +- Return value + + | Type| Description| + | --------------------- | ------------------ | + | Promise<number> | Promise used to return the available space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){ + console.info("getFreeSizeOfVolume successfully:"+ number); + }).catch(function(err){ + console.info("getFreeSizeOfVolume failed with error:"+ err); + }); + + ``` + +## storagestatistics.getFreeSizeOfVolume + +getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void + +Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------------------ | ---- | ---------------------------- | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the available space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ + // Do something + }); + ``` + +## storagestatistics.getBundleStats + +getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats> + +Asynchronously obtains the bundle status on the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------ | ---- | -------- | + | volumeUuid | string | Yes| UUID of the volume.| + | packageName | string | Yes| Bundle name of the app.| + +- Return value + + | Type| Description| + | ------------------------------------------ | -------------------------- | + | Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.| + +- Example + + ```js + let uuid = ""; + let packageName = ""; + storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){ + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); + }).catch(function(err){ + console.info("getBundleStats failed with error:"+ err); + }); + ``` + +## storagestatistics.getBundleStats + +getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void + +Asynchronously obtains the bundle status on the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes| Callback invoked to return the bundle status on the volume.| + +- Example + + ```js + let uuid = ""; + let packageName = ""; + storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){ + // Do something + }); + ``` + +## BundleStats + +### Attributes + +| Name| Type| Description| +| --------- | ------ | -------------- | +| appSize | number | Size of the app.| +| cacheSize | number | Size of the cached data.| +| dataSize | number | Total data size of the app.| diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md new file mode 100644 index 0000000000..71dd8f9201 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-volumemanager.md @@ -0,0 +1,167 @@ +# Volume Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import volumemanager from "@ohos.volumemanager"; +``` + +## System Capabilities + +SystemCapability.FileManagement.StorageService.Volume + +## volumemanager.getAllVolumes + +getAllVolumes(): Promise<Volume[]> + +Asynchronously obtains information about all available volumes. This method uses a promise to return the result. + +- Return value + + | Type| Description| + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | Promise used to return the execution result.| + +- Example + + ```js + volumemanager.getAllVolumes().then(function(volumes){ + // do something + }); + ``` + +## volumemanager.getAllVolumes + +getAllVolumes(callback:AsyncCallback<Volume[]>):void + +Asynchronously obtains information about all available volumes. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes| Callback invoked to return the volume information obtained.| + +- Example + + ```js + let uuid = ""; + volumemanager.getAllVolumes(uuid, function(error, volumes){ + // do something + }); + ``` + + +## volumemanager.mount + +mount(volumeId: string): Promise<boolean> + +Asynchronously mounts a volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes| Volume ID.| + +- Return value + + | Type| Description| + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.mount + +mount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously mounts a volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes| Volume ID.| + | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId, function(error, flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string): Promise<boolean> + +Asynchronously unmounts a volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes| Volume ID.| + +- Return value + + | Type| Description| + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously unmounts a volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes| Volume ID.| + | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId, function(error, flag){ + // do something + }); + ``` + +## Volume + +### Attributes + +| Name| Type| Description| +| ----------- | ------- | -------------------- | +| id | number | Volume ID.| +| uuid | string | Universally unique identifier (UUID) of the volume.| +| description | string | Description of the volume.| +| removeAble | boolean | Whether the volume is a removable storage device.| +| state | int | Current volume status.| +| path | string | Mount address of the volume.| -- GitLab