Merge change 26103 into eclair

* changes:
  Handle restore of the original naive wallpaper backup schema
This commit is contained in:
Android (Google) Code Review
2009-09-20 22:49:44 -04:00

View File

@@ -32,23 +32,33 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
/** /**
* Backup agent for various system-managed data * Backup agent for various system-managed data, currently just the system wallpaper
*/ */
public class SystemBackupAgent extends BackupHelperAgent { public class SystemBackupAgent extends BackupHelperAgent {
private static final String TAG = "SystemBackupAgent"; private static final String TAG = "SystemBackupAgent";
// These paths must match what the WallpaperManagerService uses
private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper"; private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper";
private static final String WALLPAPER_INFO = "/data/system/wallpaper_info.xml"; private static final String WALLPAPER_INFO = "/data/system/wallpaper_info.xml";
@Override @Override
public void onCreate() { public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
// We only back up the data under the current "wallpaper" schema with metadata
addHelper("wallpaper", new AbsoluteFileBackupHelper(SystemBackupAgent.this, addHelper("wallpaper", new AbsoluteFileBackupHelper(SystemBackupAgent.this,
new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO })); new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }));
super.onBackup(oldState, data, newState);
} }
@Override @Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
throws IOException { throws IOException {
// On restore, we also support a previous data schema "system_files"
addHelper("wallpaper", new AbsoluteFileBackupHelper(SystemBackupAgent.this,
new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }));
addHelper("system_files", new AbsoluteFileBackupHelper(SystemBackupAgent.this,
new String[] { WALLPAPER_IMAGE }));
boolean success = false; boolean success = false;
try { try {
super.onRestore(data, appVersionCode, newState); super.onRestore(data, appVersionCode, newState);