diff options
author | Winson Chung <winsonc@google.com> | 2013-09-26 14:48:44 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2013-09-26 16:17:07 -0700 |
commit | 780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d (patch) | |
tree | a9181750afb09049eda9f69c205f8af1ceb10c24 /src/com/android/launcher3/InstallShortcutReceiver.java | |
parent | 88cc3f5aa2e9ac3ae0b24e563a44d320cc089cd8 (diff) | |
download | android_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.tar.gz android_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.tar.bz2 android_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.zip |
Integrating some aosp fixes, ensuring that we update the install queue before returning to Launcher.
- Fixing stuck page in All Apps (Bug 9347818)
- Fixing shortcuts to uninstalled apps from being installed (Bug 10726510)
- Consolidating vibration feedback
- Ensuring that we trim names during comparison in AllApps list
Change-Id: Ieaae4d85851ce771283b4684a8a60306da28cb3b
Diffstat (limited to 'src/com/android/launcher3/InstallShortcutReceiver.java')
-rw-r--r-- | src/com/android/launcher3/InstallShortcutReceiver.java | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java index fd580081b..b4d6ea551 100644 --- a/src/com/android/launcher3/InstallShortcutReceiver.java +++ b/src/com/android/launcher3/InstallShortcutReceiver.java @@ -102,6 +102,35 @@ public class InstallShortcutReceiver extends BroadcastReceiver { } } + public static void removeFromInstallQueue(SharedPreferences sharedPrefs, + ArrayList<String> packageNames) { + synchronized(sLock) { + Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); + if (strings != null) { + Set<String> newStrings = new HashSet<String>(strings); + for (String json : newStrings) { + try { + JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); + Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); + String pn = launchIntent.getPackage(); + if (pn == null) { + pn = launchIntent.getComponent().getPackageName(); + } + if (packageNames.contains(pn)) { + newStrings.remove(json); + } + } catch (org.json.JSONException e) { + Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e); + } catch (java.net.URISyntaxException e) { + Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e); + } + } + sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, + new HashSet<String>(newStrings)).commit(); + } + } + } + private static ArrayList<PendingInstallShortcutInfo> getAndClearInstallQueue( SharedPreferences sharedPrefs) { synchronized(sLock) { @@ -115,7 +144,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver { try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent data = Intent.parseUri(object.getString(DATA_INTENT_KEY), 0); - Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); + Intent launchIntent = + Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String name = object.getString(NAME_KEY); String iconBase64 = object.optString(ICON_KEY); String iconResourceName = object.optString(ICON_RESOURCE_NAME_KEY); @@ -137,9 +167,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver { new PendingInstallShortcutInfo(data, name, launchIntent); infos.add(info); } catch (org.json.JSONException e) { - Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e); + Log.d("InstallShortcutReceiver", + "Exception reading shortcut to add: " + e); } catch (java.net.URISyntaxException e) { - Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e); + Log.d("InstallShortcutReceiver", + "Exception reading shortcut to add: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit(); |