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

Commit 88a2b682 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes from topic "hidl-system-api"

* changes:
  HIDL: add APIs used by subclasses to SystemApi
  Update HIDL-related documentation.
  Add remaining missing HIDL SystemApi methods.
  HIDL: reportSyspropMethod -> enableInstrumentation
  Allow HIDL to be used in priv-apps.
parents abb1562c 86d170c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -744,7 +744,9 @@ java_library {

    srcs: [
        "core/java/android/os/HidlSupport.java",
        "core/java/android/annotation/IntDef.java",
        "core/java/android/annotation/NonNull.java",
        "core/java/android/annotation/SystemApi.java",
        "core/java/android/os/HwBinder.java",
        "core/java/android/os/HwBlob.java",
        "core/java/android/os/HwParcel.java",
+129 −0
Original line number Diff line number Diff line
@@ -3161,6 +3161,135 @@ package android.os {
    field public static final java.lang.String ACTION_UPDATE_TZDATA = "android.intent.action.UPDATE_TZDATA";
  }

  public class HidlSupport {
    method public static boolean deepEquals(java.lang.Object, java.lang.Object);
    method public static int deepHashCode(java.lang.Object);
    method public static int getPidIfSharable();
    method public static boolean interfacesEqual(android.os.IHwInterface, java.lang.Object);
  }

  public abstract class HwBinder implements android.os.IHwBinder {
    ctor public HwBinder();
    method public static final void configureRpcThreadpool(long, boolean);
    method public static void enableInstrumentation();
    method public static final android.os.IHwBinder getService(java.lang.String, java.lang.String) throws java.util.NoSuchElementException, android.os.RemoteException;
    method public static final android.os.IHwBinder getService(java.lang.String, java.lang.String, boolean) throws java.util.NoSuchElementException, android.os.RemoteException;
    method public static final void joinRpcThreadpool();
    method public abstract void onTransact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
    method public final void registerService(java.lang.String) throws android.os.RemoteException;
    method public final void transact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
  }

  public class HwBlob {
    ctor public HwBlob(int);
    method public final void copyToBoolArray(long, boolean[], int);
    method public final void copyToDoubleArray(long, double[], int);
    method public final void copyToFloatArray(long, float[], int);
    method public final void copyToInt16Array(long, short[], int);
    method public final void copyToInt32Array(long, int[], int);
    method public final void copyToInt64Array(long, long[], int);
    method public final void copyToInt8Array(long, byte[], int);
    method public final boolean getBool(long);
    method public final double getDouble(long);
    method public final float getFloat(long);
    method public final short getInt16(long);
    method public final int getInt32(long);
    method public final long getInt64(long);
    method public final byte getInt8(long);
    method public final java.lang.String getString(long);
    method public final long handle();
    method public final void putBlob(long, android.os.HwBlob);
    method public final void putBool(long, boolean);
    method public final void putBoolArray(long, boolean[]);
    method public final void putDouble(long, double);
    method public final void putDoubleArray(long, double[]);
    method public final void putFloat(long, float);
    method public final void putFloatArray(long, float[]);
    method public final void putInt16(long, short);
    method public final void putInt16Array(long, short[]);
    method public final void putInt32(long, int);
    method public final void putInt32Array(long, int[]);
    method public final void putInt64(long, long);
    method public final void putInt64Array(long, long[]);
    method public final void putInt8(long, byte);
    method public final void putInt8Array(long, byte[]);
    method public final void putString(long, java.lang.String);
    method public static java.lang.Boolean[] wrapArray(boolean[]);
    method public static java.lang.Long[] wrapArray(long[]);
    method public static java.lang.Byte[] wrapArray(byte[]);
    method public static java.lang.Short[] wrapArray(short[]);
    method public static java.lang.Integer[] wrapArray(int[]);
    method public static java.lang.Float[] wrapArray(float[]);
    method public static java.lang.Double[] wrapArray(double[]);
  }

  public class HwParcel {
    ctor public HwParcel();
    method public final void enforceInterface(java.lang.String);
    method public final boolean readBool();
    method public final java.util.ArrayList<java.lang.Boolean> readBoolVector();
    method public final android.os.HwBlob readBuffer(long);
    method public final double readDouble();
    method public final java.util.ArrayList<java.lang.Double> readDoubleVector();
    method public final android.os.HwBlob readEmbeddedBuffer(long, long, long, boolean);
    method public final float readFloat();
    method public final java.util.ArrayList<java.lang.Float> readFloatVector();
    method public final short readInt16();
    method public final java.util.ArrayList<java.lang.Short> readInt16Vector();
    method public final int readInt32();
    method public final java.util.ArrayList<java.lang.Integer> readInt32Vector();
    method public final long readInt64();
    method public final java.util.ArrayList<java.lang.Long> readInt64Vector();
    method public final byte readInt8();
    method public final java.util.ArrayList<java.lang.Byte> readInt8Vector();
    method public final java.lang.String readString();
    method public final java.util.ArrayList<java.lang.String> readStringVector();
    method public final android.os.IHwBinder readStrongBinder();
    method public final void release();
    method public final void releaseTemporaryStorage();
    method public final void send();
    method public final void verifySuccess();
    method public final void writeBool(boolean);
    method public final void writeBoolVector(java.util.ArrayList<java.lang.Boolean>);
    method public final void writeBuffer(android.os.HwBlob);
    method public final void writeDouble(double);
    method public final void writeDoubleVector(java.util.ArrayList<java.lang.Double>);
    method public final void writeFloat(float);
    method public final void writeFloatVector(java.util.ArrayList<java.lang.Float>);
    method public final void writeInt16(short);
    method public final void writeInt16Vector(java.util.ArrayList<java.lang.Short>);
    method public final void writeInt32(int);
    method public final void writeInt32Vector(java.util.ArrayList<java.lang.Integer>);
    method public final void writeInt64(long);
    method public final void writeInt64Vector(java.util.ArrayList<java.lang.Long>);
    method public final void writeInt8(byte);
    method public final void writeInt8Vector(java.util.ArrayList<java.lang.Byte>);
    method public final void writeInterfaceToken(java.lang.String);
    method public final void writeStatus(int);
    method public final void writeString(java.lang.String);
    method public final void writeStringVector(java.util.ArrayList<java.lang.String>);
    method public final void writeStrongBinder(android.os.IHwBinder);
    field public static final int STATUS_SUCCESS = 0; // 0x0
  }

  public static abstract class HwParcel.Status implements java.lang.annotation.Annotation {
  }

  public abstract interface IHwBinder {
    method public abstract boolean linkToDeath(android.os.IHwBinder.DeathRecipient, long);
    method public abstract android.os.IHwInterface queryLocalInterface(java.lang.String);
    method public abstract void transact(int, android.os.HwParcel, android.os.HwParcel, int) throws android.os.RemoteException;
    method public abstract boolean unlinkToDeath(android.os.IHwBinder.DeathRecipient);
  }

  public static abstract interface IHwBinder.DeathRecipient {
    method public abstract void serviceDied(long);
  }

  public abstract interface IHwInterface {
    method public abstract android.os.IHwBinder asBinder();
  }

  public class IncidentManager {
    method public void reportIncident(android.os.IncidentReportArgs);
    method public void reportIncident(java.lang.String, byte[]);
+18 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.os;

import android.annotation.SystemApi;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
@@ -25,6 +27,7 @@ import java.util.Objects;
import java.util.stream.IntStream;

/** @hide */
@SystemApi
public class HidlSupport {
    /**
     * Similar to Objects.deepEquals, but also take care of lists.
@@ -36,7 +39,9 @@ public class HidlSupport {
     * 2.3 Both are Lists, elements are checked recursively
     * 2.4 (If both are collections other than lists or maps, throw an error)
     * 2.5 lft.equals(rgt) returns true
     * @hide
     */
    @SystemApi
    public static boolean deepEquals(Object lft, Object rgt) {
        if (lft == rgt) {
            return true;
@@ -91,6 +96,7 @@ public class HidlSupport {
     * and should be avoided).
     *
     * @param <E> Inner object type.
     * @hide
     */
    public static final class Mutable<E> {
        public E value;
@@ -106,7 +112,9 @@ public class HidlSupport {

    /**
     * Similar to Arrays.deepHashCode, but also take care of lists.
     * @hide
     */
    @SystemApi
    public static int deepHashCode(Object o) {
        if (o == null) {
            return 0;
@@ -133,6 +141,7 @@ public class HidlSupport {
        return o.hashCode();
    }

    /** @hide */
    private static void throwErrorIfUnsupportedType(Object o) {
        if (o instanceof Collection<?> && !(o instanceof List<?>)) {
            throw new UnsupportedOperationException(
@@ -146,6 +155,7 @@ public class HidlSupport {
        }
    }

    /** @hide */
    private static int primitiveArrayHashCode(Object o) {
        Class<?> elementType = o.getClass().getComponentType();
        if (elementType == boolean.class) {
@@ -185,7 +195,9 @@ public class HidlSupport {
     * - If both interfaces are stubs, asBinder() returns the object itself. By default,
     *   auto-generated IFoo.Stub does not override equals(), but an implementation can
     *   optionally override it, and {@code interfacesEqual} will use it here.
     * @hide
     */
    @SystemApi
    public static boolean interfacesEqual(IHwInterface lft, Object rgt) {
        if (lft == rgt) {
            return true;
@@ -200,7 +212,12 @@ public class HidlSupport {
    }

    /**
     * Return PID of process if sharable to clients.
     * Return PID of process only if on a non-user build. For debugging purposes.
     * @hide
     */
    @SystemApi
    public static native int getPidIfSharable();

    /** @hide */
    public HidlSupport() {}
}
+86 −0
Original line number Diff line number Diff line
@@ -16,16 +16,26 @@

package android.os;

import android.annotation.SystemApi;

import libcore.util.NativeAllocationRegistry;

import java.util.NoSuchElementException;

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

    private static final NativeAllocationRegistry sNativeRegistry;

    /**
     * Create and initialize a HwBinder object and the native objects
     * used to allow this to participate in hwbinder transactions.
     *
     * @hide
     */
    @SystemApi
    public HwBinder() {
        native_setup();

@@ -34,33 +44,90 @@ public abstract class HwBinder implements IHwBinder {
                mNativeContext);
    }

    /** @hide */
    @Override
    public final native void transact(
            int code, HwParcel request, HwParcel reply, int flags)
        throws RemoteException;

    /**
     * Process a hwbinder transaction.
     *
     * @param code interface specific code for interface.
     * @param request parceled transaction
     * @param reply object to parcel reply into
     * @param flags transaction flags to be chosen by wire protocol
     *
     * @hide
     */
    @SystemApi
    public abstract void onTransact(
            int code, HwParcel request, HwParcel reply, int flags)
        throws RemoteException;

    /**
     * Registers this service with the hwservicemanager.
     *
     * @param serviceName instance name of the service
     * @hide
     */
    @SystemApi
    public native final void registerService(String serviceName)
        throws RemoteException;

    /**
     * Returns the specified service from the hwservicemanager. Does not retry.
     *
     * @param iface fully-qualified interface name for example foo.bar@1.3::IBaz
     * @param serviceName the instance name of the service for example default.
     * @throws NoSuchElementException when the service is unavailable
     * @hide
     */
    @SystemApi
    public static final IHwBinder getService(
            String iface,
            String serviceName)
        throws RemoteException, NoSuchElementException {
        return getService(iface, serviceName, false /* retry */);
    }
    /**
     * Returns the specified service from the hwservicemanager.
     * @param iface fully-qualified interface name for example foo.bar@1.3::IBaz
     * @param serviceName the instance name of the service for example default.
     * @param retry whether to wait for the service to start if it's not already started
     * @throws NoSuchElementException when the service is unavailable
     * @hide
     */
    @SystemApi
    public static native final IHwBinder getService(
            String iface,
            String serviceName,
            boolean retry)
        throws RemoteException, NoSuchElementException;

    /**
     * Configures how many threads the process-wide hwbinder threadpool
     * has to process incoming requests.
     *
     * @param maxThreads total number of threads to create (includes this thread if
     *     callerWillJoin is true)
     * @param callerWillJoin whether joinRpcThreadpool will be called in advance
     * @hide
     */
    @SystemApi
    public static native final void configureRpcThreadpool(
            long maxThreads, boolean callerWillJoin);

    /**
     * Current thread will join hwbinder threadpool and process
     * commands in the pool. Should be called after configuring
     * a threadpool with callerWillJoin true and then registering
     * the provided service if this thread doesn't need to do
     * anything else.
     *
     * @hide
     */
    @SystemApi
    public static native final void joinRpcThreadpool();

    // Returns address of the "freeFunction".
@@ -81,8 +148,27 @@ public abstract class HwBinder implements IHwBinder {

    private static native void native_report_sysprop_change();

    /**
     * Enable instrumentation if available.
     *
     * On a non-user build, this method:
     * - tries to enable atracing (if enabled)
     * - tries to enable coverage dumps (if running in VTS)
     * - tries to enable record and replay (if running in VTS)
     *
     * @hide
     */
    @SystemApi
    public static void enableInstrumentation() {
        native_report_sysprop_change();
    }

    /**
     * Notifies listeners that a system property has changed
     *
     * TODO(b/72480743): remove this method
     *
     * @hide
     */
    public static void reportSyspropChanged() {
        native_report_sysprop_change();
+274 −3

File changed.

Preview size limit exceeded, changes collapsed.

Loading