Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ab665dd authored by Ashok Bhat's avatar Ashok Bhat Committed by David Butcher
Browse files

AArch64: Make Binder and Parcel 64-bit compatible



Changes include
[x] Long is used to store native pointers

[x] Added new method obtain(long obj) to Parcel. Binder
    uses this method instead of obtain(int obj).

[x] obtain(int) has been changed to throw unsupported
    operation exception.

Change-Id: I408e0f2a24deb28c9277d86670653a51eb314266
Signed-off-by: default avatarAshok Bhat <ashok.bhat@arm.com>
Signed-off-by: default avatarCraig Barber <craig.barber@arm.com>
Signed-off-by: default avatarKévin PETIT <kevin.petit@arm.com>
parent 407f74f4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class Binder implements IBinder {
    private static String sDumpDisabled = null;

    /* mObject is used by native code, do not remove or rename */
    private int mObject;
    private long mObject;
    private IInterface mOwner;
    private String mDescriptor;
    
@@ -390,7 +390,7 @@ public class Binder implements IBinder {
    private native final void destroy();

    // Entry point from android_util_Binder.cpp's onTransact
    private boolean execTransact(int code, int dataObj, int replyObj,
    private boolean execTransact(int code, long dataObj, long replyObj,
            int flags) {
        Parcel data = Parcel.obtain(dataObj);
        Parcel reply = Parcel.obtain(replyObj);
@@ -499,6 +499,6 @@ final class BinderProxy implements IBinder {
    }
    
    final private WeakReference mSelf;
    private int mObject;
    private int mOrgue;
    private long mObject;
    private long mOrgue;
}
+47 −42
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ public final class Parcel {
    private static final String TAG = "Parcel";

    @SuppressWarnings({"UnusedDeclaration"})
    private int mNativePtr; // used by native code
    private long mNativePtr; // used by native code

    /**
     * Flag indicating if {@link #mNativePtr} was allocated by this object,
@@ -232,47 +232,47 @@ public final class Parcel {
    private static final int EX_NETWORK_MAIN_THREAD = -6;
    private static final int EX_HAS_REPLY_HEADER = -128;  // special; see below

    private static native int nativeDataSize(int nativePtr);
    private static native int nativeDataAvail(int nativePtr);
    private static native int nativeDataPosition(int nativePtr);
    private static native int nativeDataCapacity(int nativePtr);
    private static native void nativeSetDataSize(int nativePtr, int size);
    private static native void nativeSetDataPosition(int nativePtr, int pos);
    private static native void nativeSetDataCapacity(int nativePtr, int size);

    private static native boolean nativePushAllowFds(int nativePtr, boolean allowFds);
    private static native void nativeRestoreAllowFds(int nativePtr, boolean lastValue);

    private static native void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len);
    private static native void nativeWriteInt(int nativePtr, int val);
    private static native void nativeWriteLong(int nativePtr, long val);
    private static native void nativeWriteFloat(int nativePtr, float val);
    private static native void nativeWriteDouble(int nativePtr, double val);
    private static native void nativeWriteString(int nativePtr, String val);
    private static native void nativeWriteStrongBinder(int nativePtr, IBinder val);
    private static native void nativeWriteFileDescriptor(int nativePtr, FileDescriptor val);

    private static native byte[] nativeCreateByteArray(int nativePtr);
    private static native int nativeReadInt(int nativePtr);
    private static native long nativeReadLong(int nativePtr);
    private static native float nativeReadFloat(int nativePtr);
    private static native double nativeReadDouble(int nativePtr);
    private static native String nativeReadString(int nativePtr);
    private static native IBinder nativeReadStrongBinder(int nativePtr);
    private static native FileDescriptor nativeReadFileDescriptor(int nativePtr);

    private static native int nativeCreate();
    private static native void nativeFreeBuffer(int nativePtr);
    private static native void nativeDestroy(int nativePtr);

    private static native byte[] nativeMarshall(int nativePtr);
    private static native int nativeDataSize(long nativePtr);
    private static native int nativeDataAvail(long nativePtr);
    private static native int nativeDataPosition(long nativePtr);
    private static native int nativeDataCapacity(long nativePtr);
    private static native void nativeSetDataSize(long nativePtr, int size);
    private static native void nativeSetDataPosition(long nativePtr, int pos);
    private static native void nativeSetDataCapacity(long nativePtr, int size);

    private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds);
    private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue);

    private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len);
    private static native void nativeWriteInt(long nativePtr, int val);
    private static native void nativeWriteLong(long nativePtr, long val);
    private static native void nativeWriteFloat(long nativePtr, float val);
    private static native void nativeWriteDouble(long nativePtr, double val);
    private static native void nativeWriteString(long nativePtr, String val);
    private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
    private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);

    private static native byte[] nativeCreateByteArray(long nativePtr);
    private static native int nativeReadInt(long nativePtr);
    private static native long nativeReadLong(long nativePtr);
    private static native float nativeReadFloat(long nativePtr);
    private static native double nativeReadDouble(long nativePtr);
    private static native String nativeReadString(long nativePtr);
    private static native IBinder nativeReadStrongBinder(long nativePtr);
    private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);

    private static native long nativeCreate();
    private static native void nativeFreeBuffer(long nativePtr);
    private static native void nativeDestroy(long nativePtr);

    private static native byte[] nativeMarshall(long nativePtr);
    private static native void nativeUnmarshall(
            int nativePtr, byte[] data, int offest, int length);
            long nativePtr, byte[] data, int offest, int length);
    private static native void nativeAppendFrom(
            int thisNativePtr, int otherNativePtr, int offset, int length);
    private static native boolean nativeHasFileDescriptors(int nativePtr);
    private static native void nativeWriteInterfaceToken(int nativePtr, String interfaceName);
    private static native void nativeEnforceInterface(int nativePtr, String interfaceName);
            long thisNativePtr, long otherNativePtr, int offset, int length);
    private static native boolean nativeHasFileDescriptors(long nativePtr);
    private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
    private static native void nativeEnforceInterface(long nativePtr, String interfaceName);

    public final static Parcelable.Creator<String> STRING_CREATOR
             = new Parcelable.Creator<String>() {
@@ -2229,6 +2229,11 @@ public final class Parcel {
        mCreators = new HashMap<ClassLoader,HashMap<String,Parcelable.Creator>>();

    static protected final Parcel obtain(int obj) {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    static protected final Parcel obtain(long obj) {
        final Parcel[] pool = sHolderPool;
        synchronized (pool) {
            Parcel p;
@@ -2247,7 +2252,7 @@ public final class Parcel {
        return new Parcel(obj);
    }

    private Parcel(int nativePtr) {
    private Parcel(long nativePtr) {
        if (DEBUG_RECYCLE) {
            mStack = new RuntimeException();
        }
@@ -2255,7 +2260,7 @@ public final class Parcel {
        init(nativePtr);
    }

    private void init(int nativePtr) {
    private void init(long nativePtr) {
        if (nativePtr != 0) {
            mNativePtr = nativePtr;
            mOwnsNativeParcelObject = false;
+75 −75

File changed.

Preview size limit exceeded, changes collapsed.

+24 −24

File changed.

Preview size limit exceeded, changes collapsed.