1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"), 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import type { AsyncCallback } from './@ohos.base'; 17 18/** 19 * Provides the capabilities to manage the state and data of cloud file synchronization. 20 * 21 * @namespace cloudSyncManager 22 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 23 * @since 10 24 */ 25declare namespace cloudSyncManager { 26 /** 27 * Modify switch state of the application's cloud synchronization capability. 28 * 29 * @param { string } accountId - Current account id 30 * @param { string } bundleName - Name of bundle whose switchStatus is changing 31 * @param { boolean } status - New switch status 32 * @returns { Promise<void> } - Return Promise 33 * @throws { BusinessError } 201 - Permission verification failed. 34 * @throws { BusinessError } 202 - The caller is not a system application. 35 * @throws { BusinessError } 401 - The input parameter is invalid. 36 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 37 * @systemapi 38 * @since 10 39 */ 40 function changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise<void>; 41 42 /** 43 * Modify switch state of the application's cloud synchronization capability. 44 * 45 * @param { string } accountId - Current account id 46 * @param { string } bundleName - Name of bundle whose switchStatus is changing 47 * @param { boolean } status - New switch status 48 * @param { AsyncCallback<void> } [callback] - Callback function 49 * @throws { BusinessError } 201 - Permission verification failed. 50 * @throws { BusinessError } 202 - The caller is not a system application. 51 * @throws { BusinessError } 401 - The input parameter is invalid. 52 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 53 * @systemapi 54 * @since 10 55 */ 56 function changeAppCloudSwitch( 57 accountId: string, 58 bundleName: string, 59 status: boolean, 60 callback: AsyncCallback<void> 61 ): void; 62 63 /** 64 * Notify the change of data in cloud. 65 * 66 * @param { string } accountId - Current account id 67 * @param { string } bundleName - Name of bundle whose switchStatus is changing 68 * @returns { Promise<void> } Return Promise 69 * @throws { BusinessError } 201 - Permission verification failed. 70 * @throws { BusinessError } 202 - The caller is not a system application. 71 * @throws { BusinessError } 401 - The input parameter is invalid. 72 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 73 * @systemapi 74 * @since 10 75 */ 76 function notifyDataChange(accountId: string, bundleName: string): Promise<void>; 77 78 /** 79 * Notify the change of data in cloud. 80 * 81 * @param { string } accountId - Current account id 82 * @param { string } bundleName - Name of bundle whose switchStatus is changing 83 * @param { AsyncCallback<void> } [callback] - Callback function 84 * @throws { BusinessError } 201 - Permission verification failed. 85 * @throws { BusinessError } 202 - The caller is not a system application. 86 * @throws { BusinessError } 401 - The input parameter is invalid. 87 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 88 * @systemapi 89 * @since 10 90 */ 91 function notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback<void>): void; 92 93 /** 94 * Enable the cloud file synchronization function. 95 * 96 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 97 * @param { string } accountId - Current account id. 98 * @param { object } switches - Indicates switches information of all applications. 99 * @returns { Promise<void> } Return Promise 100 * @throws { BusinessError } 201 - Permission verification failed. 101 * @throws { BusinessError } 202 - The caller is not a system application. 102 * @throws { BusinessError } 401 - The input parameter is invalid. 103 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 104 * @systemapi 105 * @since 10 106 */ 107 function enableCloud(accountId: string, switches: { [bundleName: string]: boolean }): Promise<void>; 108 109 /** 110 * Enable the cloud file synchronization function. 111 * 112 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 113 * @param { string } accountId - Current account id 114 * @param { object } switches - Indicates switches information of all applications. 115 * @param { AsyncCallback<void> } [callback] - Callback function 116 * @throws { BusinessError } 201 - Permission verification failed. 117 * @throws { BusinessError } 202 - The caller is not a system application. 118 * @throws { BusinessError } 401 - The input parameter is invalid. 119 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 120 * @systemapi 121 * @since 10 122 */ 123 function enableCloud( 124 accountId: string, 125 switches: { [bundleName: string]: boolean }, 126 callback: AsyncCallback<void> 127 ): void; 128 129 /** 130 * Disable the cloud file synchronization function. 131 * 132 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 133 * @param { string } accountId - Current account id. 134 * @returns { Promise<void> } Return Promise. 135 * @throws { BusinessError } 201 - Permission verification failed. 136 * @throws { BusinessError } 202 - The caller is not a system application. 137 * @throws { BusinessError } 401 - The input parameter is invalid. 138 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 139 * @systemapi 140 * @since 10 141 */ 142 function disableCloud(accountId: string): Promise<void>; 143 144 /** 145 * Disable the cloud file synchronization function. 146 * 147 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 148 * @param { string } accountId - Current account id. 149 * @param { AsyncCallback<void> } callback - Callback function 150 * @throws { BusinessError } 201 - Permission verification failed. 151 * @throws { BusinessError } 202 - The caller is not a system application. 152 * @throws { BusinessError } 401 - The input parameter is invalid. 153 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 154 * @systemapi 155 * @since 10 156 */ 157 function disableCloud(accountId: string, callback: AsyncCallback<void>): void; 158 159 /** 160 * Describes the clear action type. 161 * 162 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 163 * @enum { number } 164 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 165 * @systemapi 166 * @since 10 167 */ 168 enum Action { 169 /** 170 * Indicates clearing cloud identification only, retaining local cached data. 171 * 172 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 173 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 174 * @systemapi 175 * @since 10 176 */ 177 RETAIN_DATA, 178 179 /** 180 * Indicates clearing all cloud-related file data, which synchronized with the cloud. 181 * 182 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 183 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 184 * @systemapi 185 * @since 10 186 */ 187 CLEAR_DATA 188 } 189 190 /** 191 * Clean up cloud-related file data based on specific action. 192 * 193 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 194 * @param { string } accountId - Current account id. 195 * @param { object } appActions - Indicates information about cloud file need to clear in which way. 196 * @returns { Promise<void> } Return Promise. 197 * @throws { BusinessError } 201 - Permission verification failed. 198 * @throws { BusinessError } 202 - The caller is not a system application. 199 * @throws { BusinessError } 401 - The input parameter is invalid. 200 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 201 * @systemapi 202 * @since 10 203 */ 204 function clean(accountId: string, appActions: { [bundleName: string]: Action }): Promise<void>; 205 206 /** 207 * Clean up cloud-related file data based on specific action. 208 * 209 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 210 * @param { string } accountId - Current account id. 211 * @param { object } appActions - Indicates information about cloud file need to clear in which way. 212 * @param { AsyncCallback<void> } callback - Callback function 213 * @throws { BusinessError } 201 - Permission verification failed. 214 * @throws { BusinessError } 202 - The caller is not a system application. 215 * @throws { BusinessError } 401 - The input parameter is invalid. 216 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 217 * @systemapi 218 * @since 10 219 */ 220 function clean(accountId: string, appActions: { [bundleName: string]: Action }, callback: AsyncCallback<void>): void; 221} 222 223export default cloudSyncManager; 224