From 1f6d349e80d6cd98a29ed27835d64393489f2c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E8=BF=AA?= Date: Tue, 29 Aug 2023 11:27:04 +0800 Subject: [PATCH] fix volume and storage api docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文迪 --- .../apis/js-apis-file-storage-statistics.md | 127 ++++++++++++++---- .../apis/js-apis-file-volumemanager.md | 34 ++--- .../changelogs-file-management.md | 23 ++++ 3 files changed, 143 insertions(+), 41 deletions(-) create mode 100644 zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.5/changelogs-file-management.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-file-storage-statistics.md index 986ef521e9..228f6d6a2c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-storage-statistics.md @@ -47,7 +47,7 @@ getTotalSizeOfVolume(volumeUuid: string): Promise<number> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -90,7 +90,7 @@ getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -137,7 +137,7 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -181,7 +181,7 @@ getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -228,7 +228,7 @@ getBundleStats(packageName: string): Promise<BundleStats> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -271,7 +271,7 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>) | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -305,13 +305,16 @@ getCurrentBundleStats(): Promise<BundleStats> | -------- | -------- | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** ```js - let bundleStats = storageStatistics.getCurrentBundleStats(); - console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); + storageStatistics.getCurrentBundleStats().then(function(BundleStats){ + console.info("getCurrentBundleStats successfully:"+ JSON.stringify(BundleStats)); + }).catch(function(err){ + console.info("getCurrentBundleStats failed with error:"+ err); + }); ``` ## storageStatistics.getCurrentBundleStats9+ @@ -336,7 +339,7 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void | -------- | -------- | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -385,13 +388,16 @@ getTotalSize(): Promise<number> | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** ```js - let number = storageStatistics.getTotalSize(); - console.info("getTotalSize successfully:"+ JSON.stringify(number)); + storageStatistics.getTotalSize().then(function(number){ + console.info("getTotalSize successfully:"+ JSON.stringify(number)); + }).catch(function(err){ + console.info("getTotalSize failed with error:"+ err); + }); ``` ## storageStatistics.getTotalSize9+ @@ -422,7 +428,7 @@ getTotalSize(callback: AsyncCallback<number>): void | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -433,6 +439,41 @@ getTotalSize(callback: AsyncCallback<number>): void }); ``` +## storageStatistics.getTotalSizeSync10+ + +getTotalSizeSync(): number + +同步获取内置存储的总空间大小(单位为Byte)。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +**系统接口:** 该接口为系统接口。 + +**错误码:** + +以下错误码的详细介绍请参见[文件管理错误码](../errorcodes/errorcode-filemanagement.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13900042 | Unknown error. | + +**示例:** + + ```js + try { + let number = storageStatistics.getTotalSizeSync(); + console.info("getTotalSizeSync successfully:"+ JSON.stringify(number)); + } catch (err) { + console.info("getTotalSizeSync failed with error:"+ err); + } + ``` + ## storageStatistics.getFreeSize9+ getFreeSize(): Promise<number> @@ -461,13 +502,16 @@ getFreeSize(): Promise<number> | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** ```js - let number = storageStatistics.getFreeSize(); - console.info("getFreeSize successfully:"+ JSON.stringify(number)); + storageStatistics.getFreeSize().then(function(number){ + console.info("getFreeSize successfully:"+ JSON.stringify(number)); + }).catch(function(err){ + console.info("getFreeSize failed with error:"+ err); + }); ``` ## storageStatistics.getFreeSize9+ @@ -498,7 +542,7 @@ getFreeSize(callback: AsyncCallback<number>): void | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -509,6 +553,41 @@ getFreeSize(callback: AsyncCallback<number>): void }); ``` +## storageStatistics.getFreeSizeSync10+ + +getFreeSizeSync(): number + +同步获取内置存储的可用空间大小(单位为Byte)。 + +**需要权限**:ohos.permission.STORAGE_MANAGER + +**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics + +**系统接口:** 该接口为系统接口。 + +**错误码:** + +以下错误码的详细介绍请参见[文件管理错误码](../errorcodes/errorcode-filemanagement.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13900042 | Unknown error. | + +**示例:** + + ```js + try { + let number = storageStatistics.getFreeSizeSync(); + console.info("getFreeSizeSync successfully:"+ JSON.stringify(number)); + } catch (err) { + console.info("getFreeSizeSync failed with error:"+ err); + } + ``` + ## storageStatistics.getSystemSize9+ getSystemSize(): Promise<number> @@ -537,7 +616,7 @@ getSystemSize(): Promise<number> | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -577,7 +656,7 @@ getSystemSize(callback: AsyncCallback<number>): void | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -616,7 +695,7 @@ getUserStorageStats(): Promise<StorageStats> | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -656,7 +735,7 @@ getUserStorageStats(callback: AsyncCallback<StorageStats>): void | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -702,7 +781,7 @@ getUserStorageStats(userId: number): Promise<StorageStats> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600009 | User if out of range. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -745,7 +824,7 @@ getUserStorageStats(userId: number, callback: AsyncCallback<StorageStats>) | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600009 | User if out of range. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md index 2b8bd9a253..dc6116355b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md @@ -39,7 +39,7 @@ getAllVolumes(): Promise<Array<Volume>> | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -77,7 +77,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void | 202 | The caller is not a system application. | | 401 | The input parameter is invalid. | | 13600001 | IPC error. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -124,7 +124,7 @@ mount(volumeId: string): Promise<void> | 13600003 | Failed to mount. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -168,7 +168,7 @@ mount(volumeId: string, callback:AsyncCallback<void>):void | 13600003 | Failed to mount. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -215,7 +215,7 @@ unmount(volumeId: string): Promise<void> | 13600004 | Failed to unmount. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -259,7 +259,7 @@ unmount(volumeId: string, callback: AsyncCallback<void>): void | 13600004 | Failed to unmount. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -303,7 +303,7 @@ getVolumeByUuid(uuid: string): Promise<Volume> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -344,7 +344,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -388,7 +388,7 @@ getVolumeById(volumeId: string): Promise<Volume> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -429,7 +429,7 @@ getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -476,7 +476,7 @@ setVolumeDescription(uuid: string, description: string): Promise<void> | 13600002 | Not supported filesystem. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -521,7 +521,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& | 13600002 | Not supported filesystem. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -569,7 +569,7 @@ format(volumeId: string, fsType: string): Promise<void> | 13600002 | Not supported filesystem. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -614,7 +614,7 @@ format(volumeId: string, fsType: string, callback: AsyncCallback<void>): v | 13600002 | Not supported filesystem. | | 13600005 | Incorrect volume state. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -660,7 +660,7 @@ partition(diskId: string, type: number): Promise<void> | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -703,7 +703,7 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | 401 | The input parameter is invalid. | | 13600001 | IPC error. | | 13600008 | No such object. | -| 13900032 | Unknown error. | +| 13900042 | Unknown error. | **示例:** @@ -729,4 +729,4 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | description | string | 是 | 否 | 卷设备描述。 | | removable | boolean | 是 | 否 | 表示卷设备是否可移除,当前仅支持可移除存储设备。 | | state | number | 是 | 否 | 卷设备状态标识:
0:卸载状态 UNMOUNTED
1:检查状态 CHECKING
2:挂载状态 MOUNTED
3:正在弹出状态 EJECTING | -| path | string | 是 | 否 | 卷设备的挂载地址,一般为/mnt/external/{uuid} | \ No newline at end of file +| path | string | 是 | 否 | 卷设备的挂载地址,一般为/mnt/data/external/{uuid} | \ No newline at end of file diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.5/changelogs-file-management.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.5/changelogs-file-management.md new file mode 100644 index 0000000000..c143c753c3 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.5/changelogs-file-management.md @@ -0,0 +1,23 @@ +# 文件子系统ChangeLog + +## cl.file.1 @ohos.file.storageStatistics和@ohos.file.volumeManager 文档错误码变更 + +[@ohos.file.storageStatistics](../../../application-dev/reference/apis/js-apis-file-storage-statistics.md#)和[@ohos.file.volumeManager](../../../application-dev/reference/apis/js-apis-file-volumemanager.md#)两个模块中所有接口Unknown error错误码变更, d.ts中记录的错误码与实际功能代码中返回的不相符。 + +变更前每个接口Unknown error的错误码为13900032。 + +变更后每个接口Unknown error的错误码为13900042。 + +**变更影响** + +功能代码中,针对“Unknown error”从首版本开始一直返回13900042,仅接口定义d.ts文件与API文档记录错误。 + +对原来的“13900032 Unknown error”进行了特殊处理的应用,需要进行排查,并修改为139000342。 + +**关键接口/组件变更** + +涉及@ohos.file.storageStatistics模块和@ohos.file.volumemanager模块中的所有接口。 + +**适配指导** + +针对Unknown error进行特殊处理的应用需要将错误码更改为13900042。 -- GitLab