summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/InstallShortcutReceiver.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/InstallShortcutReceiver.java')
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index b31f45d57..821c15f52 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -37,7 +37,7 @@ import org.json.*;
public class InstallShortcutReceiver extends BroadcastReceiver {
public static final String ACTION_INSTALL_SHORTCUT =
- "com.android.launcher3.action.INSTALL_SHORTCUT";
+ "com.android.launcher.action.INSTALL_SHORTCUT";
public static final String DATA_INTENT_KEY = "intent.data";
public static final String LAUNCH_INTENT_KEY = "intent.launch";
@@ -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();
@@ -192,6 +224,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
// Queue the item up for adding if launcher has not loaded properly yet
+ LauncherAppState.setApplicationContext(context.getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
boolean launcherNotLoaded = (app.getDynamicGrid() == null);