summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Bringert <bringert@google.com>2013-10-17 16:18:31 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-17 16:18:31 (GMT)
commit235a50e0d1a303e586c36bc5e70d560b8b924d58 (patch)
tree305a6cbbf1ddfc8b1b63bb914b4a79cfea7c9eae
parentb178a36244e4498b482978e1b49cf1a54467f55d (diff)
parent4e871a217b286775dc6c07feb6d9f1d7a7e914be (diff)
downloadandroid_packages_apps_Trebuchet-235a50e0d1a303e586c36bc5e70d560b8b924d58.zip
android_packages_apps_Trebuchet-235a50e0d1a303e586c36bc5e70d560b8b924d58.tar.gz
android_packages_apps_Trebuchet-235a50e0d1a303e586c36bc5e70d560b8b924d58.tar.bz2
Merge "Fix ConcurrentModificationException in InstallShortcutReceiver" into jb-ub-now-indigo-rose
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 821c15f..7df73b1 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -36,6 +36,9 @@ import java.util.Set;
import org.json.*;
public class InstallShortcutReceiver extends BroadcastReceiver {
+ private static final String TAG = "InstallShortcutReceiver";
+ private static final boolean DBG = false;
+
public static final String ACTION_INSTALL_SHORTCUT =
"com.android.launcher.action.INSTALL_SHORTCUT";
@@ -94,10 +97,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
json = json.endObject();
SharedPreferences.Editor editor = sharedPrefs.edit();
+ if (DBG) Log.d(TAG, "Adding to APPS_PENDING_INSTALL: " + json);
addToStringSet(sharedPrefs, editor, APPS_PENDING_INSTALL, json.toString());
editor.commit();
} catch (org.json.JSONException e) {
- Log.d("InstallShortcutReceiver", "Exception when adding shortcut: " + e);
+ Log.d(TAG, "Exception when adding shortcut: " + e);
}
}
}
@@ -106,9 +110,15 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
ArrayList<String> packageNames) {
synchronized(sLock) {
Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
+ if (DBG) {
+ Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
+ + ", removing packages: " + packageNames);
+ }
if (strings != null) {
Set<String> newStrings = new HashSet<String>(strings);
- for (String json : newStrings) {
+ Iterator<String> newStringsIter = newStrings.iterator();
+ while (newStringsIter.hasNext()) {
+ String json = newStringsIter.next();
try {
JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
@@ -117,12 +127,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
pn = launchIntent.getComponent().getPackageName();
}
if (packageNames.contains(pn)) {
- newStrings.remove(json);
+ newStringsIter.remove();
}
} catch (org.json.JSONException e) {
- Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+ Log.d(TAG, "Exception reading shortcut to remove: " + e);
} catch (java.net.URISyntaxException e) {
- Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+ Log.d(TAG, "Exception reading shortcut to remove: " + e);
}
}
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL,
@@ -135,6 +145,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
SharedPreferences sharedPrefs) {
synchronized(sLock) {
Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
+ if (DBG) Log.d(TAG, "Getting and clearing APPS_PENDING_INSTALL: " + strings);
if (strings == null) {
return new ArrayList<PendingInstallShortcutInfo>();
}
@@ -167,11 +178,9 @@ 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(TAG, "Exception reading shortcut to add: " + e);
} catch (java.net.URISyntaxException e) {
- Log.d("InstallShortcutReceiver",
- "Exception reading shortcut to add: " + e);
+ Log.d(TAG, "Exception reading shortcut to add: " + e);
}
}
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit();
@@ -203,6 +212,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return;
}
+ if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0));
+
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
if (intent == null) {
return;