Disable importing workspaces from Launcher2.
Bug: 9832552 Bug: 11761032 Change-Id: I4dfd16046e9d6d0d1d864dff4340b0ed13cc8b8f
This commit is contained in:
@@ -1636,7 +1636,9 @@ public class LauncherModel extends BroadcastReceiver {
|
||||
LauncherAppState.getLauncherProvider().loadDefaultFavoritesIfNecessary(0);
|
||||
|
||||
// Check if we need to do any upgrade-path logic
|
||||
// (Includes having just imported default favorites)
|
||||
boolean loadedOldDb = LauncherAppState.getLauncherProvider().justLoadedOldDb();
|
||||
|
||||
// Log to disk
|
||||
Launcher.addDumpLog(TAG, "11683562 - loadedOldDb: " + loadedOldDb, true);
|
||||
|
||||
|
||||
@@ -71,6 +71,9 @@ public class LauncherProvider extends ContentProvider {
|
||||
static final String OLD_AUTHORITY = "com.android.launcher2.settings";
|
||||
static final String AUTHORITY = ProviderConfig.AUTHORITY;
|
||||
|
||||
// Should we attempt to load anything from the com.android.launcher2 provider?
|
||||
static final boolean IMPORT_LAUNCHER2_DATABASE = false;
|
||||
|
||||
static final String TABLE_FAVORITES = "favorites";
|
||||
static final String TABLE_WORKSPACE_SCREENS = "workspaceScreens";
|
||||
static final String PARAMETER_NOTIFY = "notify";
|
||||
@@ -366,32 +369,38 @@ public class LauncherProvider extends ContentProvider {
|
||||
sendAppWidgetResetNotify();
|
||||
}
|
||||
|
||||
// Try converting the old database
|
||||
ContentValuesCallback permuteScreensCb = new ContentValuesCallback() {
|
||||
public void onRow(ContentValues values) {
|
||||
int container = values.getAsInteger(LauncherSettings.Favorites.CONTAINER);
|
||||
if (container == Favorites.CONTAINER_DESKTOP) {
|
||||
int screen = values.getAsInteger(LauncherSettings.Favorites.SCREEN);
|
||||
screen = (int) upgradeLauncherDb_permuteScreens(screen);
|
||||
values.put(LauncherSettings.Favorites.SCREEN, screen);
|
||||
if (IMPORT_LAUNCHER2_DATABASE) {
|
||||
// Try converting the old database
|
||||
ContentValuesCallback permuteScreensCb = new ContentValuesCallback() {
|
||||
public void onRow(ContentValues values) {
|
||||
int container = values.getAsInteger(LauncherSettings.Favorites.CONTAINER);
|
||||
if (container == Favorites.CONTAINER_DESKTOP) {
|
||||
int screen = values.getAsInteger(LauncherSettings.Favorites.SCREEN);
|
||||
screen = (int) upgradeLauncherDb_permuteScreens(screen);
|
||||
values.put(LauncherSettings.Favorites.SCREEN, screen);
|
||||
}
|
||||
}
|
||||
};
|
||||
Uri uri = Uri.parse("content://" + Settings.AUTHORITY +
|
||||
"/old_favorites?notify=true");
|
||||
if (!convertDatabase(db, uri, permuteScreensCb, true)) {
|
||||
// Try and upgrade from the Launcher2 db
|
||||
uri = LauncherSettings.Favorites.OLD_CONTENT_URI;
|
||||
if (!convertDatabase(db, uri, permuteScreensCb, false)) {
|
||||
// If we fail, then set a flag to load the default workspace
|
||||
setFlagEmptyDbCreated();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
Uri uri = Uri.parse("content://" + Settings.AUTHORITY +
|
||||
"/old_favorites?notify=true");
|
||||
if (!convertDatabase(db, uri, permuteScreensCb, true)) {
|
||||
// Try and upgrade from the Launcher2 db
|
||||
uri = LauncherSettings.Favorites.OLD_CONTENT_URI;
|
||||
if (!convertDatabase(db, uri, permuteScreensCb, false)) {
|
||||
// If we fail, then set a flag to load the default workspace
|
||||
setFlagEmptyDbCreated();
|
||||
return;
|
||||
}
|
||||
// Right now, in non-default workspace cases, we want to run the final
|
||||
// upgrade code (ie. to fix workspace screen indices -> ids, etc.), so
|
||||
// set that flag too.
|
||||
setFlagJustLoadedOldDb();
|
||||
} else {
|
||||
// Fresh and clean launcher DB.
|
||||
mMaxItemId = initializeMaxItemId(db);
|
||||
setFlagEmptyDbCreated();
|
||||
}
|
||||
// Right now, in non-default workspace cases, we want to run the final
|
||||
// upgrade code (ie. to fix workspace screen indices -> ids, etc.), so
|
||||
// set that flag too.
|
||||
setFlagJustLoadedOldDb();
|
||||
}
|
||||
|
||||
private void addWorkspacesTable(SQLiteDatabase db) {
|
||||
|
||||
Reference in New Issue
Block a user