summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-23 21:21:02 (GMT)
committerDanesh M <daneshm90@gmail.com>2015-09-28 01:55:56 (GMT)
commit78e301e3cf00d6f57ec1d131979a47294d3b3668 (patch)
tree9021f83f10dab961c8b7972457dad862228143f4
parentcd9a2d8d22b68da7d7053ea9f3e4668ad6ce077d (diff)
downloadandroid_packages_apps_Trebuchet-78e301e3cf00d6f57ec1d131979a47294d3b3668.zip
android_packages_apps_Trebuchet-78e301e3cf00d6f57ec1d131979a47294d3b3668.tar.gz
android_packages_apps_Trebuchet-78e301e3cf00d6f57ec1d131979a47294d3b3668.tar.bz2
Loading internal default layout if partner layout fails to load
Bug: 18033885 Change-Id: I8399d0107cc3570c0e03d833601abf2cd194b3d3
-rw-r--r--src/com/android/launcher3/LauncherProvider.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index eda0fe2..12e2033 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -322,29 +322,34 @@ public class LauncherProvider extends ContentProvider {
}
}
+ final boolean usingExternallyProvidedLayout = loader != null;
if (loader == null) {
- loader = new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
- mOpenHelper, getContext().getResources(), getDefaultWorkspaceResourceId());
+ loader = getDefaultLayoutParser();
}
-
// Populate favorites table with initial favorites
- SharedPreferences.Editor editor = sp.edit().remove(EMPTY_DATABASE_CREATED);
- mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader);
- editor.commit();
+ if ((mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader) <= 0)
+ && usingExternallyProvidedLayout) {
+ // Unable to load external layout. Cleanup and load the internal layout.
+ createEmptyDB();
+ mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(),
+ getDefaultLayoutParser());
+ }
+ sp.edit().remove(EMPTY_DATABASE_CREATED).commit();
}
}
+ private DefaultLayoutParser getDefaultLayoutParser() {
+ int defaultLayout = LauncherAppState.getInstance()
+ .getDynamicGrid().getDeviceProfile().defaultLayoutId;
+ return new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
+ mOpenHelper, getContext().getResources(), defaultLayout);
+ }
+
public void migrateLauncher2Shortcuts() {
mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
}
- private static int getDefaultWorkspaceResourceId() {
- LauncherAppState app = LauncherAppState.getInstance();
- DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- return grid.defaultLayoutId;
- }
-
private static interface ContentValuesCallback {
public void onRow(ContentValues values);
}