Merge "Adding additional synchronized blocks when committing changes to the new-apps list. (Bug 6621553)" into jb-dev

This commit is contained in:
Winson Chung
2012-06-11 14:13:51 -07:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 11 deletions

View File

@@ -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();

View File

@@ -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();
}