am 06a0ac2f: Merge "backup launcher preferences" into jb-ub-now-kermit

* commit '06a0ac2fea10bde7f5a45e72dea83308773a220d':
  backup launcher preferences
This commit is contained in:
Chris Wren
2014-02-14 20:38:30 +00:00
committed by Android Git Automerger
2 changed files with 18 additions and 0 deletions
@@ -18,10 +18,14 @@ package com.android.launcher3;
import android.app.backup.BackupAgentHelper;
import android.app.backup.BackupManager;
import android.app.backup.SharedPreferencesBackupHelper;
import android.content.Context;
import android.content.SharedPreferences;
public class LauncherBackupAgentHelper extends BackupAgentHelper {
private static final String TAG = "LauncherBackupAgentHelper";
private static BackupManager sBackupManager;
/**
@@ -38,9 +42,21 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
sBackupManager.dataChanged();
}
@Override
public void onDestroy() {
// There is only one process accessing this preference file, but the restore
// modifies the file outside the normal codepaths, so it looks like another
// process. This forces a reload of the file, in case this process persists.
String spKey = LauncherAppState.getSharedPreferencesKey();
SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
super.onDestroy();
}
@Override
public void onCreate() {
addHelper(LauncherBackupHelper.LAUNCHER_PREFS_PREFIX,
new SharedPreferencesBackupHelper(this,
LauncherAppState.getSharedPreferencesKey()));
addHelper(LauncherBackupHelper.LAUNCHER_PREFIX, new LauncherBackupHelper(this));
}
}
@@ -82,6 +82,8 @@ public class LauncherBackupHelper implements BackupHelper {
public static final String LAUNCHER_PREFIX = "L";
public static final String LAUNCHER_PREFS_PREFIX = "LP";
private static final Bitmap.CompressFormat IMAGE_FORMAT =
android.graphics.Bitmap.CompressFormat.PNG;