diff options
author | Chris Wren <cwren@android.com> | 2013-10-04 07:55:36 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-04 07:55:36 -0700 |
commit | b485c9958754bf132e84e3c5019b484951c351e1 (patch) | |
tree | c03366b4452074f55879ec37623e07ef01ac69d6 | |
parent | a9a7b44b18e65f9d51b638c74d931376bfd8a240 (diff) | |
parent | 0c1eeac3360ee0f06a34701d9ae92ae1e88d1c4d (diff) | |
download | android_packages_apps_Trebuchet-b485c9958754bf132e84e3c5019b484951c351e1.tar.gz android_packages_apps_Trebuchet-b485c9958754bf132e84e3c5019b484951c351e1.tar.bz2 android_packages_apps_Trebuchet-b485c9958754bf132e84e3c5019b484951c351e1.zip |
am 0c1eeac3: am d8fe6de1: check the state of launcher before running a backup.
* commit '0c1eeac3360ee0f06a34701d9ae92ae1e88d1c4d':
check the state of launcher before running a backup.
-rw-r--r-- | src/com/android/launcher3/LauncherAppState.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherBackupAgent.java | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 7da1c2af7..8b34ffbe0 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -54,6 +54,10 @@ public class LauncherAppState { return INSTANCE; } + public static LauncherAppState getInstanceNoCreate() { + return INSTANCE; + } + public Context getContext() { return sContext; } diff --git a/src/com/android/launcher3/LauncherBackupAgent.java b/src/com/android/launcher3/LauncherBackupAgent.java index f29bb1fad..f40238cec 100644 --- a/src/com/android/launcher3/LauncherBackupAgent.java +++ b/src/com/android/launcher3/LauncherBackupAgent.java @@ -408,8 +408,13 @@ public class LauncherBackupAgent extends BackupAgent { private void backupIcons(Journal in, BackupDataOutput data, Journal out, ArrayList<Key> keys) throws IOException { // persist icons that haven't been persisted yet + final LauncherAppState app = LauncherAppState.getInstanceNoCreate(); + if (app == null) { + dataChanged(this); // try again later + if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying icon backup"); + return; + } final ContentResolver cr = getContentResolver(); - final LauncherAppState app = LauncherAppState.getInstance(); final IconCache iconCache = app.getIconCache(); final int dpi = getResources().getDisplayMetrics().densityDpi; @@ -520,10 +525,15 @@ public class LauncherBackupAgent extends BackupAgent { private void backupWidgets(Journal in, BackupDataOutput data, Journal out, ArrayList<Key> keys) throws IOException { // persist static widget info that hasn't been persisted yet + final LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); + if (appState == null) { + dataChanged(this); // try again later + if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying widget backup"); + return; + } final ContentResolver cr = getContentResolver(); - final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(this); final WidgetPreviewLoader previewLoader = new WidgetPreviewLoader(this); - final LauncherAppState appState = LauncherAppState.getInstance(); + final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(this); final IconCache iconCache = appState.getIconCache(); final int dpi = getResources().getDisplayMetrics().densityDpi; final DeviceProfile profile = appState.getDynamicGrid().getDeviceProfile(); |