From 625f10eac8d1e3b0f1382c089445f917d4371f39 Mon Sep 17 00:00:00 2001 From: Vladimir Komsiyski Date: Tue, 6 Dec 2022 09:07:36 +0100 Subject: [PATCH] Minor API changes to VirtualSensor. Rename sendSensorEvent to sendEvent for consistency. Update the sensor type links to reference Sensor#getType Fix: 261498971 Test: builds Change-Id: I36ec3073ab68dcee6fb204ea915de3cf4fe38a40 --- core/api/system-current.txt | 2 +- .../companion/virtual/sensor/VirtualSensor.java | 9 ++++++--- .../companion/virtual/sensor/VirtualSensorConfig.java | 10 ++++++---- .../companion/virtual/sensor/VirtualSensorEvent.java | 11 ++++++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index dea8314c2467a..ca3302aaf93cf 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -3062,7 +3062,7 @@ package android.companion.virtual.sensor { public class VirtualSensor { method @NonNull public String getName(); method public int getType(); - method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendSensorEvent(@NonNull android.companion.virtual.sensor.VirtualSensorEvent); + method @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public void sendEvent(@NonNull android.companion.virtual.sensor.VirtualSensorEvent); } public static interface VirtualSensor.SensorStateChangeCallback { diff --git a/core/java/android/companion/virtual/sensor/VirtualSensor.java b/core/java/android/companion/virtual/sensor/VirtualSensor.java index a184481bdf99d..58a5387c56517 100644 --- a/core/java/android/companion/virtual/sensor/VirtualSensor.java +++ b/core/java/android/companion/virtual/sensor/VirtualSensor.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.companion.virtual.IVirtualDevice; +import android.hardware.Sensor; import android.os.IBinder; import android.os.RemoteException; @@ -68,8 +69,10 @@ public class VirtualSensor { } /** - * Returns the - * type of the sensor. + * Returns the type of the sensor. + * + * @see Sensor#getType() + * @see Sensor types */ public int getType() { return mType; @@ -87,7 +90,7 @@ public class VirtualSensor { * Send a sensor event to the system. */ @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) - public void sendSensorEvent(@NonNull VirtualSensorEvent event) { + public void sendEvent(@NonNull VirtualSensorEvent event) { try { mVirtualDevice.sendSensorEvent(mToken, event); } catch (RemoteException e) { diff --git a/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java b/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java index 7982fa59daf3e..eb2f9dde48dbf 100644 --- a/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java +++ b/core/java/android/companion/virtual/sensor/VirtualSensorConfig.java @@ -23,6 +23,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.SystemApi; +import android.hardware.Sensor; import android.os.Parcel; import android.os.Parcelable; @@ -77,8 +78,10 @@ public final class VirtualSensorConfig implements Parcelable { } /** - * Returns the - * type of the sensor. + * Returns the type of the sensor. + * + * @see Sensor#getType() + * @see Sensor types */ public int getType() { return mType; @@ -150,8 +153,7 @@ public final class VirtualSensorConfig implements Parcelable { /** * Creates a new builder. * - * @param type The - * type of the sensor. + * @param type The type of the sensor, matching {@link Sensor#getType}. * @param name The name of the sensor. Must be unique among all sensors with the same type * that belong to the same virtual device. */ diff --git a/core/java/android/companion/virtual/sensor/VirtualSensorEvent.java b/core/java/android/companion/virtual/sensor/VirtualSensorEvent.java index 8f8860ed5e6e0..01b49750572de 100644 --- a/core/java/android/companion/virtual/sensor/VirtualSensorEvent.java +++ b/core/java/android/companion/virtual/sensor/VirtualSensorEvent.java @@ -18,6 +18,7 @@ package android.companion.virtual.sensor; import android.annotation.NonNull; import android.annotation.SystemApi; +import android.hardware.Sensor; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; @@ -60,9 +61,11 @@ public final class VirtualSensorEvent implements Parcelable { } /** - * Returns the values of this sensor event. The length and contents depend on the - * sensor type. + * Returns the values of this sensor event. The length and contents depend on the sensor type. + * * @see android.hardware.SensorEvent#values + * @see Sensor#getType() + * @see Sensor types */ @NonNull public float[] getValues() { @@ -90,7 +93,9 @@ public final class VirtualSensorEvent implements Parcelable { /** * Creates a new builder. - * @param values the values of the sensor event. @see android.hardware.SensorEvent#values + * + * @param values the values of the sensor event. + * @see android.hardware.SensorEvent#values */ public Builder(@NonNull float[] values) { mValues = values;