From e9284e22cdfb11db7e4854d58a8554dbff122074 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Mon, 6 May 2024 21:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=97=B6=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=89=A9=E5=B1=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- .../js-apis-file-backup-sys.md | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-backup-sys.md b/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-backup-sys.md index 45315af15a..d4d4876d3f 100644 --- a/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-backup-sys.md +++ b/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-backup-sys.md @@ -825,10 +825,12 @@ appendBundles(bundlesToBackup: string[], callback: AsyncCallback<void>): v ### appendBundles -appendBundles(bundlesToBackup: string[]): Promise<void> +appendBundles(bundlesToBackup: string[], infos?: string[]): Promise<void> 添加需要备份的应用。当前整个流程中,在获取SessionBackup类的实例后只能调用一次。使用Promise异步回调。 +从API version 12开始, 新增可选参数infos, 可携带备份所需要的信息 + **需要权限**:ohos.permission.BACKUP **系统能力**:SystemCapability.FileManagement.StorageService.Backup @@ -838,6 +840,7 @@ appendBundles(bundlesToBackup: string[]): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | --------------- | -------- | ---- | -------------------------- | | bundlesToBackup | string[] | 是 | 需要备份的应用名称的数组。 | +| infos | string[] | 否 | 备份所需信息的数组, 需与bundlesToBackup相同索引的内容对应, 从API version 12开始支持。| **返回值:** @@ -907,6 +910,30 @@ appendBundles(bundlesToBackup: string[]): Promise<void> ]; await sessionBackup.appendBundles(backupApps); console.info('appendBundles success'); + let infos: Array = [ + ` + { + "infos":[ + { + "details": [ + { + "detail": [ + { + "source": "com.example.hiworld", // 应用旧系统包名 + "target": "com.example.helloworld" // 应用新系统包名 + } + ], + "type": "app_mapping_relation" + } + ], + "type":"unitcast" + } + ] + } + ` + ] + await sessionBackup.appendBundles(backupApps, infos); + console.info('appendBundles success'); } catch (error) { let err: BusinessError = error as BusinessError; console.error('appendBundles failed with err: ' + JSON.stringify(err)); -- Gitee