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

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

Merge "Minor API changes to VirtualSensor."

parents b29e4dc3 625f10ea
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+6 −3
Original line number Diff line number Diff line
@@ -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) {
+6 −4
Original line number Diff line number Diff line
@@ -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.
         */
+8 −3
Original line number Diff line number Diff line
@@ -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;