Add auto-restore setting and Backup Manager awareness thereof

This setting, like BACKUP_ENABLE, should never be set directly in the secure
settings database.  Instead, it should be manipulated through the new IBackupManager
method setAutoRestore(boolean).

Change-Id: I5c3226ca85b6148bb756d753d7f9e4ea76e878c4
This commit is contained in:
Christopher Tate
2010-02-03 15:11:15 -08:00
parent 3c4a1ebc19
commit cce9da5dc3
3 changed files with 40 additions and 0 deletions

View File

@ -118,6 +118,7 @@ class BackupManagerService extends IBackupManager.Stub {
boolean mEnabled; // access to this is synchronized on 'this'
boolean mProvisioned;
boolean mAutoRestore;
PowerManager.WakeLock mWakelock;
HandlerThread mHandlerThread = new HandlerThread("backup", Process.THREAD_PRIORITY_BACKGROUND);
BackupHandler mBackupHandler;
@ -340,6 +341,8 @@ class BackupManagerService extends IBackupManager.Stub {
Settings.Secure.BACKUP_ENABLED, 0) != 0;
mProvisioned = Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.BACKUP_PROVISIONED, 0) != 0;
mAutoRestore = Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.BACKUP_AUTO_RESTORE, 0) != 0;
// If Encrypted file systems is enabled or disabled, this call will return the
// correct directory.
mBaseStateDir = new File(Environment.getSecureDataDirectory(), "backup");
@ -2019,6 +2022,20 @@ class BackupManagerService extends IBackupManager.Stub {
}
}
// Enable/disable automatic restore of app data at install time
public void setAutoRestore(boolean doAutoRestore) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
"setBackupEnabled");
Log.i(TAG, "Auto restore => " + doAutoRestore);
synchronized (this) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.BACKUP_AUTO_RESTORE, doAutoRestore ? 1 : 0);
mAutoRestore = doAutoRestore;
}
}
// Mark the backup service as having been provisioned
public void setBackupProvisioned(boolean available) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,