diff options
author | Yura <yura@google.com> | 2014-02-11 15:15:29 +0000 |
---|---|---|
committer | Yura <yura@google.com> | 2014-02-11 15:15:29 +0000 |
commit | 085c853a5702c45865e9b017d21fa15cf2b151b9 (patch) | |
tree | e9e367aea2ff7ca572bfd5dcc91975c506af7137 /src/com/android/launcher3/LauncherProvider.java | |
parent | ec0d61d79ef50010660b426b259a8ccb14656b31 (diff) | |
download | android_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/LauncherProvider.java')
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index cec9167f3..a69f4235d 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -22,11 +22,14 @@ import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.ContentProvider; +import android.content.ContentProviderOperation; +import android.content.ContentProviderResult; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.content.OperationApplicationException; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; @@ -194,6 +197,20 @@ public class LauncherProvider extends ContentProvider { } @Override + public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) + throws OperationApplicationException { + SQLiteDatabase db = mOpenHelper.getWritableDatabase(); + db.beginTransaction(); + try { + ContentProviderResult[] result = super.applyBatch(operations); + db.setTransactionSuccessful(); + return result; + } finally { + db.endTransaction(); + } + } + + @Override public int delete(Uri uri, String selection, String[] selectionArgs) { SqlArguments args = new SqlArguments(uri, selection, selectionArgs); |