Start respecting the auto-restore-at-install setting

Change-Id: I420ff6b4ba72f87bee56f45d8906f086f7a2b114
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index d4b28e2..a1d8227 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2289,7 +2289,7 @@
         if (DEBUG) Log.v(TAG, "restoreAtInstall pkg=" + packageName
                 + " token=" + Integer.toHexString(token));
 
-        if (restoreSet != 0) {
+        if (mAutoRestore && mProvisioned && restoreSet != 0) {
             // 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
             // steps for 'token' will be issued from the restore handling code.
@@ -2306,8 +2306,8 @@
                     restoreSet, pkg, token);
             mBackupHandler.sendMessage(msg);
         } else {
-            // No way to attempt a restore; just tell the Package Manager to proceed
-            // with the post-install handling for this package.
+            // 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) Log.v(TAG, "No restore set -- skipping restore");
             try {
                 mPackageManagerBinder.finishPackageInstall(token);
@@ -2484,6 +2484,7 @@
             pw.println("Backup Manager is " + (mEnabled ? "enabled" : "disabled")
                     + " / " + (!mProvisioned ? "not " : "") + "provisioned / "
                     + (this.mPendingInits.size() == 0 ? "not " : "") + "pending init");
+            pw.println("Auto-restore is " + (mAutoRestore : "enabled" : "disabled"));
             pw.println("Last backup pass: " + mLastBackupPass
                     + " (now = " + System.currentTimeMillis() + ')');
             pw.println("  next scheduled: " + mNextBackupPass);