diff options
| author | Ruslan Tkhakokhov <rthakohov@google.com> | 2020-08-05 00:41:20 +0100 |
|---|---|---|
| committer | Ruslan Tkhakokhov <rthakohov@google.com> | 2020-08-06 15:14:48 +0100 |
| commit | 9bdd2f67192def131adf015b6f5adcc3b112c847 (patch) | |
| tree | c50ed6efa9b9e510d470efc5ae1333642dd4982a /core/java/android | |
| parent | 1304c4aa57d78eb51d6bfa6a959560ecc55f1849 (diff) | |
[FSD2D] Add BackupManager API to start restore
Add an API to BackupManager to start restore in migration mode.
Bug: 160407842
Test: atest PerformUnifiedRestoreTaskTest BackupManagerServiceTest
UserBackupManagerServiceTest
Change-Id: I75fdb1c99edc3d11d1264d69e1f20c682d588479
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/backup/BackupManager.java | 31 | ||||
| -rw-r--r-- | core/java/android/app/backup/IBackupManager.aidl | 4 |
2 files changed, 33 insertions, 2 deletions
diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index b1a62bf42cc4..9b67587c4dcd 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -355,7 +355,36 @@ public class BackupManager { try { // All packages, current transport IRestoreSession binder = - sService.beginRestoreSessionForUser(mContext.getUserId(), null, null); + sService.beginRestoreSessionForUser(mContext.getUserId(), null, null, + OperationType.BACKUP); + if (binder != null) { + session = new RestoreSession(mContext, binder); + } + } catch (RemoteException e) { + Log.e(TAG, "beginRestoreSession() couldn't connect"); + } + } + return session; + } + + /** + * Begin the process of restoring data from backup. See the + * {@link android.app.backup.RestoreSession} class for documentation on that process. + * + * @param operationType Type of the operation, see {@link OperationType} + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.BACKUP) + public RestoreSession beginRestoreSession(@OperationType int operationType) { + RestoreSession session = null; + checkServiceBinder(); + if (sService != null) { + try { + // All packages, current transport + IRestoreSession binder = + sService.beginRestoreSessionForUser(mContext.getUserId(), null, null, + operationType); if (binder != null) { session = new RestoreSession(mContext, binder); } diff --git a/core/java/android/app/backup/IBackupManager.aidl b/core/java/android/app/backup/IBackupManager.aidl index 96b5dd593bbe..e177a74915ee 100644 --- a/core/java/android/app/backup/IBackupManager.aidl +++ b/core/java/android/app/backup/IBackupManager.aidl @@ -547,9 +547,11 @@ interface IBackupManager { * set can be restored. * @param transportID The name of the transport to use for the restore operation. * May be null, in which case the current active transport is used. + * @param operationType Type of the operation, see {@link BackupManager#OperationType} * @return An interface to the restore session, or null on error. */ - IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID); + IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID, + int operationType); /** * Notify the backup manager that a BackupAgent has completed the operation |
