summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/ContentProvider.java24
-rw-r--r--core/java/android/content/ContentResolver.java33
2 files changed, 15 insertions, 42 deletions
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index 9cf6569a6220..60ecf64dd0a9 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -47,8 +47,8 @@ import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.IBinder;
import android.os.ICancellationSignal;
-import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.os.ParcelableException;
import android.os.Process;
import android.os.RemoteCallback;
import android.os.RemoteException;
@@ -307,7 +307,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
try {
result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getType(uri));
} catch (Exception e) {
- putExceptionInBundle(result, ContentResolver.REMOTE_CALLBACK_ERROR, e);
+ result.putParcelable(ContentResolver.REMOTE_CALLBACK_ERROR,
+ new ParcelableException(e));
}
callback.sendResult(result);
}
@@ -594,7 +595,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
result.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT,
canonicalize(callingPkg, attributionTag, uri));
} catch (Exception e) {
- putExceptionInBundle(result, ContentResolver.REMOTE_CALLBACK_ERROR, e);
+ result.putParcelable(ContentResolver.REMOTE_CALLBACK_ERROR,
+ new ParcelableException(e));
}
callback.sendResult(result);
}
@@ -709,22 +711,6 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
return AppOpsManager.MODE_ALLOWED;
}
-
- private void putExceptionInBundle(Bundle bundle, String key, Exception e) {
- Parcel parcel = Parcel.obtain();
- try {
- try {
- parcel.writeException(e);
- } catch (Exception ex) {
- // getType threw an unparcelable exception. Wrap the message into
- // a parcelable exception type
- parcel.writeException(new IllegalStateException(e.getMessage()));
- }
- bundle.putByteArray(key, parcel.marshall());
- } finally {
- parcel.recycle();
- }
- }
}
boolean checkUser(int pid, int uid, Context context) {
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 59862ae132a9..e446f4fa5eb4 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -55,8 +55,8 @@ import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.ICancellationSignal;
import android.os.OperationCanceledException;
-import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.os.ParcelableException;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -931,8 +931,15 @@ public abstract class ContentResolver implements ContentInterface {
@Override
public void onResult(Bundle result) {
synchronized (this) {
- this.exception = getExceptionFromBundle(result);
- if (this.exception == null) {
+ ParcelableException e = result.getParcelable(REMOTE_CALLBACK_ERROR);
+ if (e != null) {
+ Throwable t = e.getCause();
+ if (t instanceof RuntimeException) {
+ this.exception = (RuntimeException) t;
+ } else {
+ this.exception = new RuntimeException(t);
+ }
+ } else {
this.result = getResultFromBundle(result);
}
done = true;
@@ -940,26 +947,6 @@ public abstract class ContentResolver implements ContentInterface {
}
}
- private RuntimeException getExceptionFromBundle(Bundle result) {
- byte[] bytes = result.getByteArray(REMOTE_CALLBACK_ERROR);
- if (bytes == null) {
- return null;
- }
-
- Parcel parcel = Parcel.obtain();
- try {
- parcel.unmarshall(bytes, 0, bytes.length);
- parcel.setDataPosition(0);
- parcel.readException();
- } catch (RuntimeException ex) {
- return ex;
- } finally {
- parcel.recycle();
- }
-
- return null;
- }
-
protected abstract T getResultFromBundle(Bundle result);
public void waitForResult(long timeout) {