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

Commit b6c8769e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I93166347,Id09322c5,I878f80f0,I7a7b1b44,Iae2dbc23

* changes:
  Expose new ContextHubService APIs
  Adds ContextHubClient to callback parameters
  Renames RESULT_FAILED_PENDING to RESULT_FAILED_BUSY
  Changes transaction Listener to OnCompleteListener
  Adds Nullable/NonNull annotations to Context Hub APIs
parents c9f362bd f2b6f014
Loading
Loading
Loading
Loading
+114 −13
Original line number Diff line number Diff line
@@ -1340,9 +1340,30 @@ package android.hardware.hdmi {

package android.hardware.location {

  public class ContextHubClient implements java.io.Closeable {
    method public void close();
    method public android.hardware.location.ContextHubInfo getAttachedHub();
    method public int sendMessageToNanoApp(android.hardware.location.NanoAppMessage);
  }

  public class ContextHubClientCallback {
    ctor public ContextHubClientCallback();
    method public void onHubReset(android.hardware.location.ContextHubClient);
    method public void onMessageFromNanoApp(android.hardware.location.ContextHubClient, android.hardware.location.NanoAppMessage);
    method public void onNanoAppAborted(android.hardware.location.ContextHubClient, long, int);
    method public void onNanoAppDisabled(android.hardware.location.ContextHubClient, long);
    method public void onNanoAppEnabled(android.hardware.location.ContextHubClient, long);
    method public void onNanoAppLoaded(android.hardware.location.ContextHubClient, long);
    method public void onNanoAppUnloaded(android.hardware.location.ContextHubClient, long);
  }

  public class ContextHubInfo implements android.os.Parcelable {
    ctor public ContextHubInfo();
    method public int describeContents();
    method public byte getChreApiMajorVersion();
    method public byte getChreApiMinorVersion();
    method public short getChrePatchVersion();
    method public long getChrePlatformId();
    method public int getId();
    method public int getMaxPacketLengthBytes();
    method public android.hardware.location.MemoryRegion[] getMemoryRegions();
@@ -1362,19 +1383,27 @@ package android.hardware.location {
  }

  public final class ContextHubManager {
    method public int[] findNanoAppOnHub(int, android.hardware.location.NanoAppFilter);
    method public int[] getContextHubHandles();
    method public android.hardware.location.ContextHubInfo getContextHubInfo(int);
    method public android.hardware.location.NanoAppInstanceInfo getNanoAppInstanceInfo(int);
    method public int loadNanoApp(int, android.hardware.location.NanoApp);
    method public int registerCallback(android.hardware.location.ContextHubManager.Callback);
    method public int registerCallback(android.hardware.location.ContextHubManager.Callback, android.os.Handler);
    method public int sendMessage(int, int, android.hardware.location.ContextHubMessage);
    method public int unloadNanoApp(int);
    method public int unregisterCallback(android.hardware.location.ContextHubManager.Callback);
  }

  public static abstract class ContextHubManager.Callback {
    method public android.hardware.location.ContextHubClient createClient(android.hardware.location.ContextHubInfo, android.hardware.location.ContextHubClientCallback, java.util.concurrent.Executor);
    method public android.hardware.location.ContextHubClient createClient(android.hardware.location.ContextHubInfo, android.hardware.location.ContextHubClientCallback);
    method public android.hardware.location.ContextHubTransaction<java.lang.Void> disableNanoApp(android.hardware.location.ContextHubInfo, long);
    method public android.hardware.location.ContextHubTransaction<java.lang.Void> enableNanoApp(android.hardware.location.ContextHubInfo, long);
    method public deprecated int[] findNanoAppOnHub(int, android.hardware.location.NanoAppFilter);
    method public deprecated int[] getContextHubHandles();
    method public deprecated android.hardware.location.ContextHubInfo getContextHubInfo(int);
    method public java.util.List<android.hardware.location.ContextHubInfo> getContextHubs();
    method public deprecated android.hardware.location.NanoAppInstanceInfo getNanoAppInstanceInfo(int);
    method public deprecated int loadNanoApp(int, android.hardware.location.NanoApp);
    method public android.hardware.location.ContextHubTransaction<java.lang.Void> loadNanoApp(android.hardware.location.ContextHubInfo, android.hardware.location.NanoAppBinary);
    method public android.hardware.location.ContextHubTransaction<java.util.List<android.hardware.location.NanoAppState>> queryNanoApps(android.hardware.location.ContextHubInfo);
    method public deprecated int registerCallback(android.hardware.location.ContextHubManager.Callback);
    method public deprecated int registerCallback(android.hardware.location.ContextHubManager.Callback, android.os.Handler);
    method public deprecated int sendMessage(int, int, android.hardware.location.ContextHubMessage);
    method public deprecated int unloadNanoApp(int);
    method public android.hardware.location.ContextHubTransaction<java.lang.Void> unloadNanoApp(android.hardware.location.ContextHubInfo, long);
    method public deprecated int unregisterCallback(android.hardware.location.ContextHubManager.Callback);
  }

  public static abstract deprecated class ContextHubManager.Callback {
    ctor protected ContextHubManager.Callback();
    method public abstract void onMessageReceipt(int, int, android.hardware.location.ContextHubMessage);
  }
@@ -1392,6 +1421,37 @@ package android.hardware.location {
    field public static final android.os.Parcelable.Creator<android.hardware.location.ContextHubMessage> CREATOR;
  }

  public class ContextHubTransaction<T> {
    method public int getType();
    method public void setOnCompleteListener(android.hardware.location.ContextHubTransaction.OnCompleteListener<T>, java.util.concurrent.Executor);
    method public void setOnCompleteListener(android.hardware.location.ContextHubTransaction.OnCompleteListener<T>);
    method public static java.lang.String typeToString(int, boolean);
    method public android.hardware.location.ContextHubTransaction.Response<T> waitForResponse(long, java.util.concurrent.TimeUnit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException;
    field public static final int RESULT_FAILED_AT_HUB = 5; // 0x5
    field public static final int RESULT_FAILED_BAD_PARAMS = 2; // 0x2
    field public static final int RESULT_FAILED_BUSY = 4; // 0x4
    field public static final int RESULT_FAILED_HAL_UNAVAILABLE = 8; // 0x8
    field public static final int RESULT_FAILED_SERVICE_INTERNAL_FAILURE = 7; // 0x7
    field public static final int RESULT_FAILED_TIMEOUT = 6; // 0x6
    field public static final int RESULT_FAILED_UNINITIALIZED = 3; // 0x3
    field public static final int RESULT_FAILED_UNKNOWN = 1; // 0x1
    field public static final int RESULT_SUCCESS = 0; // 0x0
    field public static final int TYPE_DISABLE_NANOAPP = 3; // 0x3
    field public static final int TYPE_ENABLE_NANOAPP = 2; // 0x2
    field public static final int TYPE_LOAD_NANOAPP = 0; // 0x0
    field public static final int TYPE_QUERY_NANOAPPS = 4; // 0x4
    field public static final int TYPE_UNLOAD_NANOAPP = 1; // 0x1
  }

  public static abstract interface ContextHubTransaction.OnCompleteListener<L> {
    method public abstract void onComplete(android.hardware.location.ContextHubTransaction<L>, android.hardware.location.ContextHubTransaction.Response<L>);
  }

  public static class ContextHubTransaction.Response<R> {
    method public R getContents();
    method public int getResult();
  }

  public final class GeofenceHardware {
    method public boolean addGeofence(int, int, android.hardware.location.GeofenceHardwareRequest, android.hardware.location.GeofenceHardwareCallback);
    method public int[] getMonitoringTypes();
@@ -1508,6 +1568,25 @@ package android.hardware.location {
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoApp> CREATOR;
  }

  public final class NanoAppBinary implements android.os.Parcelable {
    ctor public NanoAppBinary(byte[]);
    method public int describeContents();
    method public byte[] getBinary();
    method public byte[] getBinaryNoHeader();
    method public int getFlags();
    method public int getHeaderVersion();
    method public long getHwHubType();
    method public long getNanoAppId();
    method public int getNanoAppVersion();
    method public byte getTargetChreApiMajorVersion();
    method public byte getTargetChreApiMinorVersion();
    method public boolean hasValidHeader();
    method public boolean isEncrypted();
    method public boolean isSigned();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppBinary> CREATOR;
  }

  public class NanoAppFilter {
    ctor public NanoAppFilter(long, int, int, long);
    method public int describeContents();
@@ -1541,6 +1620,28 @@ package android.hardware.location {
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppInstanceInfo> CREATOR;
  }

  public final class NanoAppMessage implements android.os.Parcelable {
    method public static android.hardware.location.NanoAppMessage createMessageFromNanoApp(long, int, byte[], boolean);
    method public static android.hardware.location.NanoAppMessage createMessageToNanoApp(long, int, byte[]);
    method public int describeContents();
    method public byte[] getMessageBody();
    method public int getMessageType();
    method public long getNanoAppId();
    method public boolean isBroadcastMessage();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppMessage> CREATOR;
  }

  public final class NanoAppState implements android.os.Parcelable {
    ctor public NanoAppState(long, int, boolean);
    method public int describeContents();
    method public long getNanoAppId();
    method public long getNanoAppVersion();
    method public boolean isEnabled();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.hardware.location.NanoAppState> CREATOR;
  }

}

package android.hardware.radio {
+29 −12
Original line number Diff line number Diff line
@@ -15,9 +15,13 @@
 */
package android.hardware.location;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.os.RemoteException;

import com.android.internal.util.Preconditions;

import dalvik.system.CloseGuard;

import java.io.Closeable;
@@ -31,16 +35,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 *
 * @hide
 */
@SystemApi
public class ContextHubClient implements Closeable {
    /*
     * The proxy to the client interface at the service.
     */
    private final IContextHubClient mClientProxy;

    /*
     * The callback interface associated with this client.
     */
    private final IContextHubClientCallback mCallbackInterface;
    private IContextHubClient mClientProxy = null;

    /*
     * The Context Hub that this client is attached to.
@@ -51,20 +51,33 @@ public class ContextHubClient implements Closeable {

    private final AtomicBoolean mIsClosed = new AtomicBoolean(false);

    /* package */ ContextHubClient(
            IContextHubClient clientProxy, IContextHubClientCallback callback,
            ContextHubInfo hubInfo) {
        mClientProxy = clientProxy;
        mCallbackInterface = callback;
    /* package */ ContextHubClient(ContextHubInfo hubInfo) {
        mAttachedHub = hubInfo;
        mCloseGuard.open("close");
    }

    /**
     * Sets the proxy interface of the client at the service. This method should always be called
     * by the ContextHubManager after the client is registered at the service, and should only be
     * called once.
     *
     * @param clientProxy the proxy of the client at the service
     */
    /* package */ void setClientProxy(IContextHubClient clientProxy) {
        Preconditions.checkNotNull(clientProxy, "IContextHubClient cannot be null");
        if (mClientProxy != null) {
            throw new IllegalStateException("Cannot change client proxy multiple times");
        }

        mClientProxy = clientProxy;
    }

    /**
     * Returns the hub that this client is attached to.
     *
     * @return the ContextHubInfo of the attached hub
     */
    @NonNull
    public ContextHubInfo getAttachedHub() {
        return mAttachedHub;
    }
@@ -96,12 +109,16 @@ public class ContextHubClient implements Closeable {
     *
     * @return the result of sending the message defined as in ContextHubTransaction.Result
     *
     * @throws NullPointerException if NanoAppMessage is null
     *
     * @see NanoAppMessage
     * @see ContextHubTransaction.Result
     */
    @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
    @ContextHubTransaction.Result
    public int sendMessageToNanoApp(NanoAppMessage message) {
    public int sendMessageToNanoApp(@NonNull NanoAppMessage message) {
        Preconditions.checkNotNull(message, "NanoAppMessage cannot be null");

        try {
            return mClientProxy.sendMessageToNanoApp(message);
        } catch (RemoteException e) {
+25 −11
Original line number Diff line number Diff line
@@ -15,15 +15,20 @@
 */
package android.hardware.location;

import android.annotation.SystemApi;

import java.util.concurrent.Executor;

/**
 * A class for {@link android.hardware.location.ContextHubClient ContextHubClient} to
 * receive messages and life-cycle events from nanoapps in the Context Hub at which the client is
 * attached to.
 *
 * This callback is registered through the
 * {@link android.hardware.location.ContextHubManager#createClient() creation} of
 * {@link android.hardware.location.ContextHubClient ContextHubClient}. Callbacks are
 * invoked in the following ways:
 * This callback is registered through the {@link
 * android.hardware.location.ContextHubManager#createClient(
 * ContextHubInfo, ContextHubClientCallback, Executor) creation} of
 * {@link android.hardware.location.ContextHubClient ContextHubClient}. Callbacks are invoked in
 * the following ways:
 * 1) Messages from nanoapps delivered through onMessageFromNanoApp may either be broadcasted
 *    or targeted to a specific client.
 * 2) Nanoapp or Context Hub events (the remaining callbacks) are broadcasted to all clients, and
@@ -31,6 +36,7 @@ package android.hardware.location;
 *
 * @hide
 */
@SystemApi
public class ContextHubClientCallback {
    /**
     * Callback invoked when receiving a message from a nanoapp.
@@ -38,48 +44,56 @@ public class ContextHubClientCallback {
     * The message contents of this callback may either be broadcasted or targeted to the
     * client receiving the invocation.
     *
     * @param client the client that is associated with this callback
     * @param message the message sent by the nanoapp
     */
    public void onMessageFromNanoApp(NanoAppMessage message) {}
    public void onMessageFromNanoApp(ContextHubClient client, NanoAppMessage message) {}

    /**
     * Callback invoked when the attached Context Hub has reset.
     *
     * @param client the client that is associated with this callback
     */
    public void onHubReset() {}
    public void onHubReset(ContextHubClient client) {}

    /**
     * Callback invoked when a nanoapp aborts at the attached Context Hub.
     *
     * @param client the client that is associated with this callback
     * @param nanoAppId the ID of the nanoapp that had aborted
     * @param abortCode the reason for nanoapp's abort, specific to each nanoapp
     */
    public void onNanoAppAborted(long nanoAppId, int abortCode) {}
    public void onNanoAppAborted(ContextHubClient client, long nanoAppId, int abortCode) {}

    /**
     * Callback invoked when a nanoapp is loaded at the attached Context Hub.
     *
     * @param client the client that is associated with this callback
     * @param nanoAppId the ID of the nanoapp that had been loaded
     */
    public void onNanoAppLoaded(long nanoAppId) {}
    public void onNanoAppLoaded(ContextHubClient client, long nanoAppId) {}

    /**
     * Callback invoked when a nanoapp is unloaded from the attached Context Hub.
     *
     * @param client the client that is associated with this callback
     * @param nanoAppId the ID of the nanoapp that had been unloaded
     */
    public void onNanoAppUnloaded(long nanoAppId) {}
    public void onNanoAppUnloaded(ContextHubClient client, long nanoAppId) {}

    /**
     * Callback invoked when a nanoapp is enabled at the attached Context Hub.
     *
     * @param client the client that is associated with this callback
     * @param nanoAppId the ID of the nanoapp that had been enabled
     */
    public void onNanoAppEnabled(long nanoAppId) {}
    public void onNanoAppEnabled(ContextHubClient client, long nanoAppId) {}

    /**
     * Callback invoked when a nanoapp is disabled at the attached Context Hub.
     *
     * @param client the client that is associated with this callback
     * @param nanoAppId the ID of the nanoapp that had been disabled
     */
    public void onNanoAppDisabled(long nanoAppId) {}
    public void onNanoAppDisabled(ContextHubClient client, long nanoAppId) {}
}
+0 −12
Original line number Diff line number Diff line
@@ -221,9 +221,6 @@ public class ContextHubInfo implements Parcelable {

    /**
     * @return the CHRE platform ID as defined in chre/version.h
     *
     * TODO(b/67734082): Expose as public API
     * @hide
     */
    public long getChrePlatformId() {
        return mChrePlatformId;
@@ -231,9 +228,6 @@ public class ContextHubInfo implements Parcelable {

    /**
     * @return the CHRE API's major version as defined in chre/version.h
     *
     * TODO(b/67734082): Expose as public API
     * @hide
     */
    public byte getChreApiMajorVersion() {
        return mChreApiMajorVersion;
@@ -241,9 +235,6 @@ public class ContextHubInfo implements Parcelable {

    /**
     * @return the CHRE API's minor version as defined in chre/version.h
     *
     * TODO(b/67734082): Expose as public API
     * @hide
     */
    public byte getChreApiMinorVersion() {
        return mChreApiMinorVersion;
@@ -251,9 +242,6 @@ public class ContextHubInfo implements Parcelable {

    /**
     * @return the CHRE patch version as defined in chre/version.h
     *
     * TODO(b/67734082): Expose as public API
     * @hide
     */
    public short getChrePatchVersion() {
        return mChrePatchVersion;
+110 −45

File changed.

Preview size limit exceeded, changes collapsed.

Loading