diff --git a/core/java/android/os/BinderProxy.java b/core/java/android/os/BinderProxy.java index 2a9b703583a6e..d44b016cb5d00 100644 --- a/core/java/android/os/BinderProxy.java +++ b/core/java/android/os/BinderProxy.java @@ -565,8 +565,7 @@ public final class BinderProxy implements IBinder { } try { - boolean replyOwnsNative = (reply == null) ? false : reply.ownsNativeParcelObject(); - return transactNative(code, data, reply, replyOwnsNative, flags); + return transactNative(code, data, reply, flags); } finally { if (transactListener != null) { transactListener.onTransactEnded(session); @@ -589,7 +588,7 @@ public final class BinderProxy implements IBinder { * Native implementation of transact() for proxies */ public native boolean transactNative(int code, Parcel data, Parcel reply, - boolean replyOwnsNativeParcelObject, int flags) throws RemoteException; + int flags) throws RemoteException; /** * See {@link IBinder#linkToDeath(DeathRecipient, int)} */ diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 50f390bce890f..e06e7b6be90a9 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -3736,9 +3736,4 @@ public final class Parcel { public long getBlobAshmemSize() { return nativeGetBlobAshmemSize(mNativePtr); } - - /** @hide */ - /*package*/ boolean ownsNativeParcelObject() { - return mOwnsNativeParcelObject; - } } diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index 3acbd1ecd16ec..787d34822ef7a 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -516,9 +515,8 @@ static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jclass clazz, j static jlong android_os_Parcel_create(JNIEnv* env, jclass clazz) { - sp parcelRef = ParcelRef::create(); - parcelRef->incStrong(reinterpret_cast(android_os_Parcel_create)); - return reinterpret_cast(static_cast(parcelRef.get())); + Parcel* parcel = new Parcel(); + return reinterpret_cast(parcel); } static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr) @@ -531,8 +529,8 @@ static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong native static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jlong nativePtr) { - ParcelRef* derivative = static_cast(reinterpret_cast(nativePtr)); - derivative->decStrong(reinterpret_cast(android_os_Parcel_create)); + Parcel* parcel = reinterpret_cast(nativePtr); + delete parcel; } static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong nativePtr) diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 29f8ccf376548..793b4eba788ca 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -1381,8 +1380,7 @@ static bool should_time_binder_calls() { } static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, - jint code, jobject dataObj, jobject replyObj, jboolean replyObjOwnsNativeParcel, - jint flags) // throws RemoteException + jint code, jobject dataObj, jobject replyObj, jint flags) // throws RemoteException { if (dataObj == NULL) { jniThrowNullPointerException(env, NULL); @@ -1424,21 +1422,6 @@ static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, status_t err = target->transact(code, *data, reply, flags); //if (reply) printf("Transact from Java code to %p received: ", target); reply->print(); - if (reply) { - if (replyObjOwnsNativeParcel) { - // as per Parcel java class constructor, here, "reply" MUST be a "ParcelRef" - // only for Parcel that contained Binder objects - if (reply->objectsCount() > 0) { - IPCThreadState::self()->createTransactionReference(static_cast(reply)); - } - } else { - // as per Parcel.java, if Parcel java object NOT owning native Parcel object, it will - // NOT destroy the native Parcel object upon GC(finalize()), so, there will be no race - // condtion in this case. Please refer to the java class methods: Parcel.finalize(), - // Parcel.destroy(). - } - } - if (kEnableBinderSample) { if (time_binder_calls) { conditionally_log_binder_call(start_millis, target, code); @@ -1567,7 +1550,7 @@ static const JNINativeMethod gBinderProxyMethods[] = { {"pingBinder", "()Z", (void*)android_os_BinderProxy_pingBinder}, {"isBinderAlive", "()Z", (void*)android_os_BinderProxy_isBinderAlive}, {"getInterfaceDescriptor", "()Ljava/lang/String;", (void*)android_os_BinderProxy_getInterfaceDescriptor}, - {"transactNative", "(ILandroid/os/Parcel;Landroid/os/Parcel;ZI)Z", (void*)android_os_BinderProxy_transact}, + {"transactNative", "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void*)android_os_BinderProxy_transact}, {"linkToDeath", "(Landroid/os/IBinder$DeathRecipient;I)V", (void*)android_os_BinderProxy_linkToDeath}, {"unlinkToDeath", "(Landroid/os/IBinder$DeathRecipient;I)Z", (void*)android_os_BinderProxy_unlinkToDeath}, {"getNativeFinalizer", "()J", (void*)android_os_BinderProxy_getNativeFinalizer},