Merge "Minor API changes to VirtualSensor."
This commit is contained in:
committed by
Android (Google) Code Review
commit
38590fb138
@@ -3097,7 +3097,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 {
|
||||
|
||||
@@ -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
|
||||
* <a href="https://source.android.com/devices/sensors/sensor-types">type</a> of the sensor.
|
||||
* Returns the type of the sensor.
|
||||
*
|
||||
* @see Sensor#getType()
|
||||
* @see <a href="https://source.android.com/devices/sensors/sensor-types">Sensor types</a>
|
||||
*/
|
||||
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) {
|
||||
|
||||
@@ -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
|
||||
* <a href="https://source.android.com/devices/sensors/sensor-types">type</a> of the sensor.
|
||||
* Returns the type of the sensor.
|
||||
*
|
||||
* @see Sensor#getType()
|
||||
* @see <a href="https://source.android.com/devices/sensors/sensor-types">Sensor types</a>
|
||||
*/
|
||||
public int getType() {
|
||||
return mType;
|
||||
@@ -150,8 +153,7 @@ public final class VirtualSensorConfig implements Parcelable {
|
||||
/**
|
||||
* Creates a new builder.
|
||||
*
|
||||
* @param type The
|
||||
* <a href="https://source.android.com/devices/sensors/sensor-types">type</a> 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.
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
* <a href="https://source.android.com/devices/sensors/sensor-types">sensor type</a>.
|
||||
* 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 <a href="https://source.android.com/devices/sensors/sensor-types">Sensor types</a>
|
||||
*/
|
||||
@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;
|
||||
|
||||
Reference in New Issue
Block a user