diff options
Diffstat (limited to 'services/java/com/android/server/SystemBackupAgent.java')
-rw-r--r-- | services/java/com/android/server/SystemBackupAgent.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/SystemBackupAgent.java index 8cf273d..eeeec83 100644 --- a/services/java/com/android/server/SystemBackupAgent.java +++ b/services/java/com/android/server/SystemBackupAgent.java @@ -17,6 +17,7 @@ package com.android.server; +import android.app.backup.AbsoluteFileBackupHelper; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.BackupAgentHelper; @@ -46,6 +47,11 @@ public class SystemBackupAgent extends BackupAgentHelper { private static final String WALLPAPER_IMAGE_FILENAME = "wallpaper"; private static final String WALLPAPER_INFO_FILENAME = "wallpaper_info.xml"; + private static final String PROFILES_FILENAME = + ProfileManagerService.PROFILE_FILE.getName(); + private static final String PROFILES_FILE_DIRECTORY = + ProfileManagerService.PROFILE_FILE.getParentFile().getAbsolutePath(); + // TODO: Will need to change if backing up non-primary user's wallpaper private static final String WALLPAPER_IMAGE_DIR = Environment.getUserSystemDirectory(UserHandle.USER_OWNER).getAbsolutePath(); @@ -75,13 +81,16 @@ public class SystemBackupAgent extends BackupAgentHelper { keys = new String[] { WALLPAPER_INFO_KEY }; } addHelper("wallpaper", new WallpaperBackupHelper(SystemBackupAgent.this, files, keys)); + addHelper("profiles", new AbsoluteFileBackupHelper(SystemBackupAgent.this, + ProfileManagerService.PROFILE_FILE.getAbsolutePath())); super.onBackup(oldState, data, newState); } @Override public void onFullBackup(FullBackupDataOutput data) throws IOException { - // At present we back up only the wallpaper + // At present we back up only the wallpaper and profiles fullWallpaperBackup(data); + fullProfilesBackup(data); } private void fullWallpaperBackup(FullBackupDataOutput output) { @@ -95,6 +104,11 @@ public class SystemBackupAgent extends BackupAgentHelper { WALLPAPER_IMAGE_DIR, WALLPAPER_IMAGE, output.getData()); } + private void fullProfilesBackup(FullBackupDataOutput output) { + FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, + PROFILES_FILE_DIRECTORY, PROFILES_FILENAME, output.getData()); + } + @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { @@ -105,13 +119,19 @@ public class SystemBackupAgent extends BackupAgentHelper { addHelper("system_files", new WallpaperBackupHelper(SystemBackupAgent.this, new String[] { WALLPAPER_IMAGE }, new String[] { WALLPAPER_IMAGE_KEY} )); + addHelper("profiles", new AbsoluteFileBackupHelper(SystemBackupAgent.this, + ProfileManagerService.PROFILE_FILE.getAbsolutePath())); try { super.onRestore(data, appVersionCode, newState); WallpaperManagerService wallpaper = (WallpaperManagerService)ServiceManager.getService( Context.WALLPAPER_SERVICE); + ProfileManagerService profiles = (ProfileManagerService)ServiceManager.getService( + Context.PROFILE_SERVICE); + wallpaper.settingsRestored(); + profiles.settingsRestored(); } catch (IOException ex) { // If there was a failure, delete everything for the wallpaper, this is too aggressive, // but this is hopefully a rare failure. @@ -129,6 +149,7 @@ public class SystemBackupAgent extends BackupAgentHelper { // Bits to indicate postprocessing we may need to perform boolean restoredWallpaper = false; + boolean restoredProfiles = false; File outFile = null; // Various domain+files we understand a priori @@ -139,6 +160,9 @@ public class SystemBackupAgent extends BackupAgentHelper { } else if (path.equals(WALLPAPER_IMAGE_FILENAME)) { outFile = new File(WALLPAPER_IMAGE); restoredWallpaper = true; + } else if (path.equals(PROFILES_FILENAME)) { + outFile = ProfileManagerService.PROFILE_FILE; + restoredProfiles = true; } } @@ -154,6 +178,11 @@ public class SystemBackupAgent extends BackupAgentHelper { Context.WALLPAPER_SERVICE); wallpaper.settingsRestored(); } + if (restoredProfiles) { + ProfileManagerService profiles = (ProfileManagerService) + ServiceManager.getService(Context.PROFILE_SERVICE); + profiles.settingsRestored(); + } } catch (IOException e) { if (restoredWallpaper) { // Make sure we wind up in a good state |