summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorYura <yura@google.com>2014-02-11 15:15:29 +0000
committerYura <yura@google.com>2014-02-11 15:15:29 +0000
commit085c853a5702c45865e9b017d21fa15cf2b151b9 (patch)
treee9e367aea2ff7ca572bfd5dcc91975c506af7137 /src/com/android/launcher3/LauncherModel.java
parentec0d61d79ef50010660b426b259a8ccb14656b31 (diff)
downloadandroid_packages_apps_Trebuchet-085c853a5702c45865e9b017d21fa15cf2b151b9.tar.gz
android_packages_apps_Trebuchet-085c853a5702c45865e9b017d21fa15cf2b151b9.tar.bz2
android_packages_apps_Trebuchet-085c853a5702c45865e9b017d21fa15cf2b151b9.zip
Do updateWorkspaceScreenOrder inside a single transaction.
The workspacescreens table is updated in LauncherModel.updateWorkspaceScreenOrder and that the operation to remove all screens, then reinsert the new list of screens in not inside a single transaction, so if the app is updating or crashes between ContentResolver.delete and ContentResolver.bulkInsert then the data will be lost. This CL makes it all happen inside 1 transaction. Bug: 12523285 Change-Id: I409dbc9f48fa9c8bd4bf3b1453204a4daac1689a
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index ff8a35647..f4fa10ffa 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1063,18 +1063,23 @@ public class LauncherModel extends BroadcastReceiver {
Runnable r = new Runnable() {
@Override
public void run() {
+ ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
// Clear the table
- cr.delete(uri, null, null);
+ ops.add(ContentProviderOperation.newDelete(uri).build());
int count = screensCopy.size();
- ContentValues[] values = new ContentValues[count];
for (int i = 0; i < count; i++) {
ContentValues v = new ContentValues();
long screenId = screensCopy.get(i);
v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
- values[i] = v;
+ ops.add(ContentProviderOperation.newInsert(uri).withValues(v).build());
+ }
+
+ try {
+ cr.applyBatch(LauncherProvider.AUTHORITY, ops);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
}
- cr.bulkInsert(uri, values);
synchronized (sBgLock) {
sBgWorkspaceScreens.clear();