From 3534e8e8f92163197e44a508f736413290f10657 Mon Sep 17 00:00:00 2001 From: yaoruozi Date: Sat, 6 Sep 2025 15:56:13 +0800 Subject: [PATCH] add clouddisk inerface Signed-off-by: yaoruozi --- api/@ohos.commonEventManager.d.ts | 23 ++-- api/@ohos.file.cloudDiskManager.d.ts | 154 +++++++++++++++++++++++++++ kits/@kit.CoreFileKit.d.ts | 3 +- 3 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 api/@ohos.file.cloudDiskManager.d.ts diff --git a/api/@ohos.commonEventManager.d.ts b/api/@ohos.commonEventManager.d.ts index 472432ef21..1f3c57447e 100644 --- a/api/@ohos.commonEventManager.d.ts +++ b/api/@ohos.commonEventManager.d.ts @@ -2573,13 +2573,13 @@ declare namespace commonEventManager { * To subscribe to this common event, your application must have the ohos.permission.GET_BUNDLE_RESOURCES * permission. * This is a protected common event, which can be sent only by the system. - * + * * @syscap SystemCapability.Notification.CommonEvent * @systemapi * @since arkts {'1.1':'15', '1.2':'20'} * @arkts 1.1&1.2 */ - COMMON_EVENT_BUNDLE_RESOURCES_CHANGED = 'usual.event.BUNDLE_RESOURCES_CHANGED', + COMMON_EVENT_BUNDLE_RESOURCES_CHANGED = 'usual.event.BUNDLE_RESOURCES_CHANGED', /** * This common event means that datashare is ready. @@ -2608,7 +2608,7 @@ declare namespace commonEventManager { * To subscribe to this common event, your application must have the ohos.permission.START_RESTORE_NOTIFICATION * permission. * This is a protected common event that can only be sent by system. - * + * * @syscap SystemCapability.Notification.CommonEvent * @systemapi * @since arkts {'1.1':'13', '1.2':'20'} @@ -2657,7 +2657,7 @@ declare namespace commonEventManager { * @since 20 * @arkts 1.1&1.2 */ - COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_STATE_CHANGE = + COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_STATE_CHANGE = 'usual.event.bluetooth.remotedevice.ACL_STATE_CHANGE', /** @@ -2698,7 +2698,7 @@ declare namespace commonEventManager { * This common event means that shortcut has been changed. * To subscribe to this common event, your application must have the ohos.permission.MANAGE_SHORTCUTS permission. * This is a protected common event that can only be sent by system. - * + * * @syscap SystemCapability.Notification.CommonEvent * @systemapi * @since 20 @@ -2750,11 +2750,22 @@ declare namespace commonEventManager { * This common event means that screen capture. * This is a protected common event that can only be sent by system. * @syscap SystemCapability.Notification.CommonEvent - * @systemapi + * @systemapi * @since 20 * @arkts 1.1&1.2 */ COMMON_EVENT_SCREEN_SHARE = 'usual.event.SCREEN_SHARE', + + /** + * This common event means that the sync folder of cloud disk has been updated. + * This is a protected common event that can only be sent by system. + * + * @syscap SystemCapability.Notification.CommonEvent + * @systemapi + * @since 21 + * @arkts 1.1&1.2 + */ + COMMON_EVENT_CLOUD_DISK_STATE_CHANGED = 'usual.event.CLOUD_DISK_STATE_CHANGED', } /** diff --git a/api/@ohos.file.cloudDiskManager.d.ts b/api/@ohos.file.cloudDiskManager.d.ts new file mode 100644 index 0000000000..759769d93c --- /dev/null +++ b/api/@ohos.file.cloudDiskManager.d.ts @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit CoreFileKit + */ + +/** + * Provides cloud disk manager APIs. + * + * @namespace cloudDiskManager + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @since 21 + */ +declare namespace cloudDiskManager { + /** + * Enumerates the state of the cloud disk. + * + * @enum {number} + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + enum State { + /** + * Indicates the inactive state. + * + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + INACTIVE = 0, + + /** + * Indicates the active state. + * + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + ACTIVE = 1 + } + + /** + * Defines the syncFolder of the cloudDisk for all bundles. + * + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + interface SyncFolder { + /** + * The path of the syncFolder. + * + * @type { string } + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + path: string; + + /** + * The bundleName of the syncFolder. + * + * @type { string } + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + bundleName: string; + + /** + * The state of the syncFolder. + * + * @type { State } + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + state: State; + + /** + * The displayNameResId of the syncFolder. + * + * @type { number } + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + displayNameResId?: number; + + /** + * The displayName of the syncFolder. + * + * @type { string } + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + displayName?: string; + } + + /** + * Provides the capability to access all cloud disk syncFolders. + * + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + class SyncFolderAccess { + /** + * A constructor used to create a SyncFolderAccess object. + * + * @permssion ohos.permission.ACCESS_CLOUD_DISK_INFO + * @throws { BusinessError } 201 - Permission verification failed. + * @throws { BusinessError } 202 - Permission verification failed, application is not a system application use system api + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + constructor(); + + /** + * Get all sync folders for all bundles. + * + * @permission ohos.permission.ACCESS_CLOUD_DISK_INFO + * @return { Primise> } Returns the syncFolder list for all bundles. + * @throws { BusinessError } 201 - Permission verification failed. + * @throws { BusinessError } 202 - Permission verification failed, application is not a system application use system api + * @throws { BusinessError } 34400003 - IPC communication failed. + * @throws { BusinessError } 34400015 - Internal error. + * @throws { BusinessError } 34400016 - Cloud disk not support. + * @syscap SystemCapability.FileManagement.CloudDiskManager + * @systemapi + * @since 21 + */ + getAllSyncFolders(): Promise>; + } +} + +export default cloudDiskManager; diff --git a/kits/@kit.CoreFileKit.d.ts b/kits/@kit.CoreFileKit.d.ts index 4308ed3a7e..e776b62c26 100644 --- a/kits/@kit.CoreFileKit.d.ts +++ b/kits/@kit.CoreFileKit.d.ts @@ -23,6 +23,7 @@ import BackupExtensionContext from '@ohos.file.BackupExtensionContext'; import backup from '@ohos.file.backup'; import cloudSync from '@ohos.file.cloudSync'; import cloudSyncManager from '@ohos.file.cloudSyncManager'; +import cloudDiskManager from '@ohos.file.cloudDiskManager'; import Environment from '@ohos.file.environment'; import fileAccess from '@ohos.file.fileAccess'; import fileExtensionInfo from '@ohos.file.fileExtensionInfo'; @@ -46,7 +47,7 @@ import fileShare from '@ohos.fileshare'; export { BackupExtensionAbility, BackupExtensionContext, BundleVersion, ConflictFiles, Environment, Filter, Options, ReaderIteratorResult, WatchEvent, WatchEventListener, Watcher, ReadOptions, ReadTextOptions, WriteOptions, ListFileOptions, - backup, cloudSync, cloudSyncManager, fileAccess, fileExtensionInfo, + backup, cloudSync, cloudSyncManager, cloudDiskManager, fileAccess, fileExtensionInfo, fileIo, fileShare, fileUri, hash, picker, recent, securityLabel, statfs, storageStatistics, trash, userFileManager, volumeManager, keyManager, DfsListeners, TaskSignal }; -- Gitee