summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-06-11 13:57:49 -0700
committerWinson Chung <winsonc@google.com>2012-06-11 13:58:30 -0700
commitd9e20bfba5b23c0da34dd628d9055ec3baad1ade (patch)
tree190e20ed935745d0e7d44eae43713d0266b9f7fd /src/com/android
parent478244409e15594ceaa7426a6a23cc805db0b1fc (diff)
downloadandroid_packages_apps_Trebuchet-d9e20bfba5b23c0da34dd628d9055ec3baad1ade.tar.gz
android_packages_apps_Trebuchet-d9e20bfba5b23c0da34dd628d9055ec3baad1ade.tar.bz2
android_packages_apps_Trebuchet-d9e20bfba5b23c0da34dd628d9055ec3baad1ade.zip
Adding additional synchronized blocks when committing changes to the new-apps list. (Bug 6621553)
Change-Id: Ia2553321230fec4202fa064cdc66ffd13d005281
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/InstallShortcutReceiver.java10
-rw-r--r--src/com/android/launcher2/UninstallShortcutReceiver.java16
2 files changed, 15 insertions, 11 deletions
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index b454afd7f..54ba7de18 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -191,10 +191,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
final Set<String> savedNewApps = newApps;
new Thread("setNewAppsThread") {
public void run() {
- sharedPrefs.edit()
- .putInt(NEW_APPS_PAGE_KEY, screen)
- .putStringSet(NEW_APPS_LIST_KEY, savedNewApps)
- .commit();
+ synchronized (savedNewApps) {
+ sharedPrefs.edit()
+ .putInt(NEW_APPS_PAGE_KEY, screen)
+ .putStringSet(NEW_APPS_LIST_KEY, savedNewApps)
+ .commit();
+ }
}
}.start();
diff --git a/src/com/android/launcher2/UninstallShortcutReceiver.java b/src/com/android/launcher2/UninstallShortcutReceiver.java
index e94a17ffd..02590c9f6 100644
--- a/src/com/android/launcher2/UninstallShortcutReceiver.java
+++ b/src/com/android/launcher2/UninstallShortcutReceiver.java
@@ -148,14 +148,16 @@ public class UninstallShortcutReceiver extends BroadcastReceiver {
final Set<String> savedNewApps = newApps;
new Thread("setNewAppsThread-remove") {
public void run() {
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
- savedNewApps);
- if (savedNewApps.isEmpty()) {
- // Reset the page index if there are no more items
- editor.putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1);
+ synchronized (savedNewApps) {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
+ savedNewApps);
+ if (savedNewApps.isEmpty()) {
+ // Reset the page index if there are no more items
+ editor.putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1);
+ }
+ editor.commit();
}
- editor.commit();
}
}.start();
}