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

Commit 6902285a authored by Iliyan Malchev's avatar Iliyan Malchev Committed by Gerrit Code Review
Browse files

Merge changes from topic 'java_hidl_support'

* changes:
  Move Status to libhidl (DO NOT MERGE)
  Adds framework support for hidl-gen Java backend. (to support structs) (DO NOT MERGE)
  Add Bool* APIs to HwParcel (DO NOT MERGE)
  Link against libhidl for HidlSupport/svcmgr (DO NOT MERGE)
  Support one-way methods in java support for hardware binder (DO NOT MERGE)
  Initial commit of Java support for hardware binder (DO NOT MERGE)
parents 3f3ed243 aa2c32f9
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

import libcore.util.NativeAllocationRegistry;

/** @hide */
public abstract class HwBinder implements IHwBinder {
    private static final String TAG = "HwBinder";

    private static final NativeAllocationRegistry sNativeRegistry;

    public HwBinder() {
        native_setup();

        sNativeRegistry.registerNativeAllocation(
                this,
                mNativeContext);
    }

    public final native void transact(
            int code, HwParcel request, HwParcel reply, int flags);

    public abstract void onTransact(
            int code, HwParcel request, HwParcel reply, int flags);

    public native final void registerService(String serviceName);
    public static native final IHwBinder getService(String serviceName);

    // Returns address of the "freeFunction".
    private static native final long native_init();

    private native final void native_setup();

    static {
        long freeFunction = native_init();

        sNativeRegistry = new NativeAllocationRegistry(
                HwBinder.class.getClassLoader(),
                freeFunction,
                128 /* size */);
    }

    private long mNativeContext;
}
+74 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

import libcore.util.NativeAllocationRegistry;

/** @hide */
public class HwBlob {
    private static final String TAG = "HwBlob";

    private static final NativeAllocationRegistry sNativeRegistry;

    public HwBlob(int size) {
        native_setup(size);

        sNativeRegistry.registerNativeAllocation(
                this,
                mNativeContext);
    }

    public native final boolean getBool(long offset);
    public native final byte getInt8(long offset);
    public native final short getInt16(long offset);
    public native final int getInt32(long offset);
    public native final long getInt64(long offset);
    public native final float getFloat(long offset);
    public native final double getDouble(long offset);
    public native final String getString(long offset);

    public native final void putBool(long offset, boolean x);
    public native final void putInt8(long offset, byte x);
    public native final void putInt16(long offset, short x);
    public native final void putInt32(long offset, int x);
    public native final void putInt64(long offset, long x);
    public native final void putFloat(long offset, float x);
    public native final void putDouble(long offset, double x);
    public native final void putString(long offset, String x);

    public native final void putBlob(long offset, HwBlob blob);

    public native final long handle();

    // Returns address of the "freeFunction".
    private static native final long native_init();

    private native final void native_setup(int size);

    static {
        long freeFunction = native_init();

        sNativeRegistry = new NativeAllocationRegistry(
                HwBlob.class.getClassLoader(),
                freeFunction,
                128 /* size */);
    }

    private long mNativeContext;
}

+134 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

import libcore.util.NativeAllocationRegistry;

/** @hide */
public class HwParcel {
    private static final String TAG = "HwParcel";

    public static final int STATUS_SUCCESS      = 0;
    public static final int STATUS_ERROR        = -1;

    private static final NativeAllocationRegistry sNativeRegistry;

    private HwParcel(boolean allocate) {
        native_setup(allocate);

        sNativeRegistry.registerNativeAllocation(
                this,
                mNativeContext);
    }

    public HwParcel() {
        native_setup(true /* allocate */);

        sNativeRegistry.registerNativeAllocation(
                this,
                mNativeContext);
    }

    public native final void writeInterfaceToken(String interfaceName);
    public native final void writeBool(boolean val);
    public native final void writeInt8(byte val);
    public native final void writeInt16(short val);
    public native final void writeInt32(int val);
    public native final void writeInt64(long val);
    public native final void writeFloat(float val);
    public native final void writeDouble(double val);
    public native final void writeString(String val);

    public native final void writeBoolArray(int size, boolean[] val);
    public native final void writeBoolVector(boolean[] val);
    public native final void writeInt8Array(int size, byte[] val);
    public native final void writeInt8Vector(byte[] val);
    public native final void writeInt16Array(int size, short[] val);
    public native final void writeInt16Vector(short[] val);
    public native final void writeInt32Array(int size, int[] val);
    public native final void writeInt32Vector(int[] val);
    public native final void writeInt64Array(int size, long[] val);
    public native final void writeInt64Vector(long[] val);
    public native final void writeFloatArray(int size, float[] val);
    public native final void writeFloatVector(float[] val);
    public native final void writeDoubleArray(int size, double[] val);
    public native final void writeDoubleVector(double[] val);
    public native final void writeStringArray(int size, String[] val);
    public native final void writeStringVector(String[] val);

    public native final void writeStrongBinder(IHwBinder binder);

    public native final void enforceInterface(String interfaceName);
    public native final boolean readBool();
    public native final byte readInt8();
    public native final short readInt16();
    public native final int readInt32();
    public native final long readInt64();
    public native final float readFloat();
    public native final double readDouble();
    public native final String readString();

    public native final boolean[] readBoolArray(int size);
    public native final boolean[] readBoolVector();
    public native final byte[] readInt8Array(int size);
    public native final byte[] readInt8Vector();
    public native final short[] readInt16Array(int size);
    public native final short[] readInt16Vector();
    public native final int[] readInt32Array(int size);
    public native final int[] readInt32Vector();
    public native final long[] readInt64Array(int size);
    public native final long[] readInt64Vector();
    public native final float[] readFloatArray(int size);
    public native final float[] readFloatVector();
    public native final double[] readDoubleArray(int size);
    public native final double[] readDoubleVector();
    public native final String[] readStringArray(int size);
    public native final String[] readStringVector();

    public native final IHwBinder readStrongBinder();

    // Handle is stored as part of the blob.
    public native final HwBlob readBuffer();

    public native final HwBlob readEmbeddedBuffer(
            long parentHandle, long offset);

    public native final void writeBuffer(HwBlob blob);

    public native final void writeStatus(int status);
    public native final void verifySuccess();
    public native final void releaseTemporaryStorage();

    public native final void send();

    // Returns address of the "freeFunction".
    private static native final long native_init();

    private native final void native_setup(boolean allocate);

    static {
        long freeFunction = native_init();

        sNativeRegistry = new NativeAllocationRegistry(
                HwParcel.class.getClassLoader(),
                freeFunction,
                128 /* size */);
    }

    private long mNativeContext;
}
+56 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

import libcore.util.NativeAllocationRegistry;

/** @hide */
public class HwRemoteBinder implements IHwBinder {
    private static final String TAG = "HwRemoteBinder";

    private static final NativeAllocationRegistry sNativeRegistry;

    public HwRemoteBinder() {
        native_setup_empty();

        sNativeRegistry.registerNativeAllocation(
                this,
                mNativeContext);
    }

    public IHwInterface queryLocalInterface(String descriptor) {
        return null;
    }

    public native final void transact(
            int code, HwParcel request, HwParcel reply, int flags);

    private static native final long native_init();

    private native final void native_setup_empty();

    static {
        long freeFunction = native_init();

        sNativeRegistry = new NativeAllocationRegistry(
                HwRemoteBinder.class.getClassLoader(),
                freeFunction,
                128 /* size */);
    }

    private long mNativeContext;
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

/** @hide */
public interface IHwBinder {
    // These MUST match their corresponding libhwbinder/IBinder.h definition !!!
    public static final int FIRST_CALL_TRANSACTION = 1;
    public static final int FLAG_ONEWAY = 1;

    public void transact(
            int code, HwParcel request, HwParcel reply, int flags);

    public IHwInterface queryLocalInterface(String descriptor);
}
Loading