Call clearCallingIdentity in Provider Entry Points
Bug: 10777084
Change-Id: I7de6289e9b05b2ef51a9fe65c3a04f0d814c3362
diff --git a/src/com/android/providers/calendar/CalendarProvider2.java b/src/com/android/providers/calendar/CalendarProvider2.java
index d6c4839..344f6c1 100644
--- a/src/com/android/providers/calendar/CalendarProvider2.java
+++ b/src/com/android/providers/calendar/CalendarProvider2.java
@@ -823,6 +823,16 @@
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return queryInternal(uri, projection, selection, selectionArgs, sortOrder);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ private Cursor queryInternal(Uri uri, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "query uri - " + uri);
}
diff --git a/src/com/android/providers/calendar/SQLiteContentProvider.java b/src/com/android/providers/calendar/SQLiteContentProvider.java
index f492a05..3396c3d 100644
--- a/src/com/android/providers/calendar/SQLiteContentProvider.java
+++ b/src/com/android/providers/calendar/SQLiteContentProvider.java
@@ -26,6 +26,7 @@
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteTransactionListener;
import android.net.Uri;
+import android.os.Binder;
import android.provider.CalendarContract;
import java.util.ArrayList;
@@ -92,6 +93,7 @@
if (!applyingBatch) {
mDb = mOpenHelper.getWritableDatabase();
mDb.beginTransactionWithListener(this);
+ final long identity = Binder.clearCallingIdentity();
try {
result = insertInTransaction(uri, values, isCallerSyncAdapter);
if (result != null) {
@@ -99,6 +101,7 @@
}
mDb.setTransactionSuccessful();
} finally {
+ Binder.restoreCallingIdentity(identity);
mDb.endTransaction();
}
@@ -118,6 +121,7 @@
boolean isCallerSyncAdapter = getIsCallerSyncAdapter(uri);
mDb = mOpenHelper.getWritableDatabase();
mDb.beginTransactionWithListener(this);
+ final long identity = Binder.clearCallingIdentity();
try {
for (int i = 0; i < numValues; i++) {
Uri result = insertInTransaction(uri, values[i], isCallerSyncAdapter);
@@ -128,6 +132,7 @@
}
mDb.setTransactionSuccessful();
} finally {
+ Binder.restoreCallingIdentity(identity);
mDb.endTransaction();
}
@@ -143,6 +148,7 @@
if (!applyingBatch) {
mDb = mOpenHelper.getWritableDatabase();
mDb.beginTransactionWithListener(this);
+ final long identity = Binder.clearCallingIdentity();
try {
count = updateInTransaction(uri, values, selection, selectionArgs,
isCallerSyncAdapter);
@@ -151,6 +157,7 @@
}
mDb.setTransactionSuccessful();
} finally {
+ Binder.restoreCallingIdentity(identity);
mDb.endTransaction();
}
@@ -174,6 +181,7 @@
if (!applyingBatch) {
mDb = mOpenHelper.getWritableDatabase();
mDb.beginTransactionWithListener(this);
+ final long identity = Binder.clearCallingIdentity();
try {
count = deleteInTransaction(uri, selection, selectionArgs, isCallerSyncAdapter);
if (count > 0) {
@@ -181,6 +189,7 @@
}
mDb.setTransactionSuccessful();
} finally {
+ Binder.restoreCallingIdentity(identity);
mDb.endTransaction();
}
@@ -213,6 +222,7 @@
mDb = mOpenHelper.getWritableDatabase();
mDb.beginTransactionWithListener(this);
final boolean isCallerSyncAdapter = getIsCallerSyncAdapter(operations.get(0).getUri());
+ final long identity = Binder.clearCallingIdentity();
try {
mApplyingBatch.set(true);
final ContentProviderResult[] results = new ContentProviderResult[numOperations];
@@ -229,6 +239,7 @@
mApplyingBatch.set(false);
mDb.endTransaction();
onEndTransaction(isCallerSyncAdapter);
+ Binder.restoreCallingIdentity(identity);
}
}