summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-11-18 18:38:22 (GMT)
committerDanesh M <daneshm90@gmail.com>2015-09-28 04:06:03 (GMT)
commit28d42e88a7d6abdeb6f8da0fe291cd7fb7bc5679 (patch)
treefb3a6556f1802b022948223a17a5478cdc7186c5
parent2bf24b39f00df7fe9d0025ebb3c9a0017d886331 (diff)
downloadandroid_packages_apps_Trebuchet-28d42e88a7d6abdeb6f8da0fe291cd7fb7bc5679.zip
android_packages_apps_Trebuchet-28d42e88a7d6abdeb6f8da0fe291cd7fb7bc5679.tar.gz
android_packages_apps_Trebuchet-28d42e88a7d6abdeb6f8da0fe291cd7fb7bc5679.tar.bz2
Clearing DB before restore starts.
Bug: 18362052 Change-Id: Ic4faf04db2f76c0c434907f1c41c8b708283eeb7
-rw-r--r--src/com/android/launcher3/LauncherBackupAgentHelper.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/com/android/launcher3/LauncherBackupAgentHelper.java b/src/com/android/launcher3/LauncherBackupAgentHelper.java
index b03b13c..3868a57 100644
--- a/src/com/android/launcher3/LauncherBackupAgentHelper.java
+++ b/src/com/android/launcher3/LauncherBackupAgentHelper.java
@@ -69,13 +69,23 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
Log.d(TAG, "Restore is only supported on devices running Lollipop and above.");
return;
}
- super.onRestore(data, appVersionCode, newState);
- // If no favorite was migrated, clear the data and start fresh.
- final Cursor c = getContentResolver().query(
- LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, null, null, null, null);
- boolean hasData = c.moveToNext();
- c.close();
+ // Clear dB before restore
+ LauncherAppState.getLauncherProvider().createEmptyDB();
+
+ boolean hasData;
+ try {
+ super.onRestore(data, appVersionCode, newState);
+ // If no favorite was migrated, clear the data and start fresh.
+ final Cursor c = getContentResolver().query(
+ LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, null, null, null, null);
+ hasData = c.moveToNext();
+ c.close();
+ } catch (Exception e) {
+ // If the restore fails, we should do a fresh start.
+ Log.e(TAG, "Restore failed", e);
+ hasData = false;
+ }
if (hasData && mHelper.restoreSuccessful) {
LauncherAppState.getLauncherProvider().clearFlagEmptyDbCreated();