summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-05-16 19:37:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-16 19:37:32 +0000
commitca853c4a351991c3be8b0939733990d88249a61e (patch)
tree87e70fed3f964881b4c23fbaecb957551f98648e /src/com
parente6203a4d300ac0bcc4ef6cbeba7b4560d71331b7 (diff)
parent71483f417bb19f524cda41081f5ccac6084dc103 (diff)
downloadandroid_packages_apps_Trebuchet-ca853c4a351991c3be8b0939733990d88249a61e.tar.gz
android_packages_apps_Trebuchet-ca853c4a351991c3be8b0939733990d88249a61e.tar.bz2
android_packages_apps_Trebuchet-ca853c4a351991c3be8b0939733990d88249a61e.zip
Merge "Removing antiquated migration path logic" into ub-now-nova
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/LauncherModel.java15
-rw-r--r--src/com/android/launcher3/LauncherProvider.java59
2 files changed, 57 insertions, 17 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 585c238c3..4b5e68b72 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -200,9 +200,19 @@ public class LauncherModel extends BroadcastReceiver
ContentResolver contentResolver = context.getContentResolver();
mAppsCanBeOnRemoveableStorage = Environment.isExternalStorageRemovable();
+ String oldProvider = context.getString(R.string.old_launcher_provider_uri);
ContentProviderClient client = contentResolver.acquireContentProviderClient(
Uri.parse(context.getString(R.string.old_launcher_provider_uri)));
+
+ Log.d(TAG, "Old launcher provider: " + oldProvider);
mOldContentProviderExists = (client != null);
+
+ if (mOldContentProviderExists) {
+ Log.d(TAG, "Old launcher provider exists.");
+ } else {
+ Log.d(TAG, "Old launcher provider does not exist.");
+ }
+
if (client != null) {
client.release();
}
@@ -1817,9 +1827,8 @@ 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();
+ // This code path is for our old migration code and should no longer be exercised
+ boolean loadedOldDb = false;
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - loadedOldDb: " + loadedOldDb, true);
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 437c2ad96..4a5096564 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -68,6 +68,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -157,7 +158,7 @@ public class LauncherProvider extends ContentProvider {
if (values == null) {
throw new RuntimeException("Error: attempting to insert null values");
}
- if (!values.containsKey(LauncherSettings.BaseLauncherColumns._ID)) {
+ if (!values.containsKey(LauncherSettings.ChangeLogColumns._ID)) {
throw new RuntimeException("Error: attempting to add item without specifying an id");
}
helper.checkId(table, values);
@@ -325,7 +326,6 @@ public class LauncherProvider extends ContentProvider {
}
mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), workspaceResId);
- mOpenHelper.setFlagJustLoadedOldDb();
editor.commit();
}
}
@@ -1231,18 +1231,47 @@ public class LauncherProvider extends ContentProvider {
return intent;
}
+ private int loadFavorites(SQLiteDatabase db, int workspaceResourceId) {
+ ArrayList<Long> screenIds = new ArrayList<Long>();
+ int count = loadFavoritesRecursive(db, workspaceResourceId, screenIds);
+
+ // Add the screens specified by the items above
+ Collections.sort(screenIds);
+ int rank = 0;
+ ContentValues values = new ContentValues();
+ for (Long id : screenIds) {
+ values.clear();
+ values.put(LauncherSettings.WorkspaceScreens._ID, id);
+ values.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, rank);
+ if (dbInsertAndCheck(this, db, TABLE_WORKSPACE_SCREENS, null, values) < 0) {
+ throw new RuntimeException("Failed initialize screen table"
+ + "from default layout");
+ }
+ rank++;
+ }
+
+ // Ensure that the max ids are initialized
+ mMaxItemId = initializeMaxItemId(db);
+ mMaxScreenId = initializeMaxScreenId(db);
+ return count;
+ }
+
/**
* Loads the default set of favorite packages from an xml file.
*
* @param db The database to write the values into
* @param filterContainerId The specific container id of items to load
+ * @param the set of screenIds which are used by the favorites
*/
- private int loadFavorites(SQLiteDatabase db, int workspaceResourceId) {
- ContentValues values = new ContentValues();
+ private int loadFavoritesRecursive(SQLiteDatabase db, int workspaceResourceId,
+ ArrayList<Long> screenIds) {
+
+
+ ContentValues values = new ContentValues();
if (LOGD) Log.v(TAG, String.format("Loading favorites from resid=0x%08x", workspaceResourceId));
- int i = 0;
+ int count = 0;
try {
XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);
AttributeSet attrs = Xml.asAttributeSet(parser);
@@ -1271,7 +1300,7 @@ public class LauncherProvider extends ContentProvider {
if (resId != 0 && resId != workspaceResourceId) {
// recursively load some more favorites, why not?
- i += loadFavorites(db, resId);
+ count += loadFavoritesRecursive(db, resId, screenIds);
added = false;
} else {
Log.w(TAG, String.format("Skipping <include workspace=0x%08x>", resId));
@@ -1367,7 +1396,15 @@ public class LauncherProvider extends ContentProvider {
}
}
}
- if (added) i++;
+ if (added) {
+ long screenId = Long.parseLong(screen);
+ // Keep track of the set of screens which need to be added to the db.
+ if (!screenIds.contains(screenId) &&
+ container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ screenIds.add(screenId);
+ }
+ count++;
+ }
a.recycle();
}
} catch (XmlPullParserException e) {
@@ -1377,13 +1414,7 @@ public class LauncherProvider extends ContentProvider {
} catch (RuntimeException e) {
Log.w(TAG, "Got exception parsing favorites.", e);
}
-
- // Update the max item id after we have loaded the database
- if (mMaxItemId == -1) {
- mMaxItemId = initializeMaxItemId(db);
- }
-
- return i;
+ return count;
}
/**