From 21b086984babbea1743ad63ef782fdfbfde5c0c0 Mon Sep 17 00:00:00 2001 From: Jeffrey Sharkey <> Date: Thu, 26 Mar 2009 21:35:10 -0700 Subject: [PATCH 1/2] AI 143057: Don't NPE when editing a folder name. Only happens when user changes orientation while editing, where getFolderById can return the wrong folder type for the given ID. BUG=1740367 Automated import of CL 143057 --- src/com/android/launcher/LauncherModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher/LauncherModel.java b/src/com/android/launcher/LauncherModel.java index e3020818b6..b6c90a285a 100644 --- a/src/com/android/launcher/LauncherModel.java +++ b/src/com/android/launcher/LauncherModel.java @@ -1243,7 +1243,7 @@ public class LauncherModel { FolderInfo getFolderById(Context context, long id) { final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, null, - "_id=? and itemType=? or itemType=?", + "_id=? and (itemType=? or itemType=?)", new String[] { String.valueOf(id), String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER), String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER) }, null); From bcc7c577d3394d91a1a4ced1afe95c21944f6ead Mon Sep 17 00:00:00 2001 From: Romain Guy <> Date: Fri, 27 Mar 2009 17:34:37 -0700 Subject: [PATCH 2/2] AI 143294: Fixes #1725672. For good this time. When Home starts for the first time, it spawns a loading thread for the workspace items. That loader is responsible for starting the drawer loader after it's done. Unfortunately, after a wipe data or a database upgrade, the worksapce loader could be interrupted by a ContentProvider notification change which would cause the loader to be cancelled and another workspace loader to be spawned. The new workspace loader, however, would not start the drawer loader because the appropriate flag was not set correctly. This change simply duplicates the flag from the old loader in the new one and all is well. BUG=1725672 Automated import of CL 143294 --- src/com/android/launcher/LauncherModel.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher/LauncherModel.java b/src/com/android/launcher/LauncherModel.java index b6c90a285a..da41f14996 100644 --- a/src/com/android/launcher/LauncherModel.java +++ b/src/com/android/launcher/LauncherModel.java @@ -584,6 +584,7 @@ public class LauncherModel { } if (mDesktopItemsLoader != null && mDesktopItemsLoader.isRunning()) { + if (DEBUG_LOADERS) d(LOG_TAG, " --> stopping workspace loader"); mDesktopItemsLoader.stop(); // Wait for the currently running thread to finish, this can take a little // time but it should be well below the timeout limit @@ -592,6 +593,13 @@ public class LauncherModel { } catch (InterruptedException e) { // Empty } + + // If the thread we are interrupting was tasked to load the list of + // applications make sure we keep that information in the new loader + // spawned below + // note: we don't apply this to localeChanged because the thread can + // only be stopped *after* the localeChanged handling has occured + loadApplications = mDesktopItemsLoader.mLoadApplications; } if (DEBUG_LOADERS) d(LOG_TAG, " --> starting workspace loader"); @@ -636,7 +644,8 @@ public class LauncherModel { final ContentValues values = new ContentValues(); values.put(LauncherSettings.Favorites.TITLE, label); - resolver.update(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, + resolver.update( + LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values, "_id=?", new String[] { String.valueOf(c.getLong(idIndex)) });