diff options
| author | Christopher Tate <ctate@google.com> | 2014-08-15 21:41:06 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2014-08-15 21:41:06 +0000 |
| commit | 1db2391d9fb05dc20846731c41c76bb806327fb9 (patch) | |
| tree | 82f97a448f1d5c25cfd86b656ebfe9fe10f54de5 | |
| parent | d3077b95f8639fee553323bd4155862ad4db4596 (diff) | |
| parent | 6cbc07b7c08cad639870588d61e88d3c7a1191ed (diff) | |
| download | frameworks_base-1db2391d9fb05dc20846731c41c76bb806327fb9.zip frameworks_base-1db2391d9fb05dc20846731c41c76bb806327fb9.tar.gz frameworks_base-1db2391d9fb05dc20846731c41c76bb806327fb9.tar.bz2 | |
am 2c286400: Merge "Tighten restore-at-install behavior" into lmp-dev
* commit '2c286400bf4913c24dea7d0653314bdf162aaa16':
Tighten restore-at-install behavior
| -rw-r--r-- | core/java/android/app/backup/BackupManager.java | 22 | ||||
| -rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 12 |
2 files changed, 32 insertions, 2 deletions
diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index e9297b9..1bb4eba 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -229,6 +229,28 @@ public class BackupManager { } /** + * Enable/disable data restore at application install time. When enabled, app + * installation will include an attempt to fetch the app's historical data from + * the archival restore dataset (if any). When disabled, no such attempt will + * be made. + * + * <p>Callers must hold the android.permission.BACKUP permission to use this method. + * + * @hide + */ + @SystemApi + public void setAutoRestore(boolean isEnabled) { + checkServiceBinder(); + if (sService != null) { + try { + sService.setAutoRestore(isEnabled); + } catch (RemoteException e) { + Log.e(TAG, "setAutoRestore() couldn't connect"); + } + } + } + + /** * Identify the currently selected transport. Callers must hold the * android.permission.BACKUP permission to use this method. * @return The name of the currently active backup transport. In case of diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index b2d1b71..c44474d 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -8599,7 +8599,15 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF skip = true; } - if (!skip && mAutoRestore && mProvisioned) { + if (!mAutoRestore || !mProvisioned) { + if (DEBUG) { + Slog.w(TAG, "Non-restorable state: auto=" + mAutoRestore + + " prov=" + mProvisioned); + } + skip = true; + } + + if (!skip) { try { // okay, we're going to attempt a restore of this package from this restore set. // The eventual message back into the Package Manager to run the post-install @@ -8632,7 +8640,7 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF if (skip) { // Auto-restore disabled or no way to attempt a restore; just tell the Package // Manager to proceed with the post-install handling for this package. - if (DEBUG) Slog.v(TAG, "Skipping"); + if (DEBUG) Slog.v(TAG, "Finishing install immediately"); try { mPackageManagerBinder.finishPackageInstall(token); } catch (RemoteException e) { /* can't happen */ } |
