Loading core/api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -16997,6 +16997,7 @@ package android.hardware { public class SensorEvent { field public int accuracy; field public boolean firstEventAfterDiscontinuity; field public android.hardware.Sensor sensor; field public long timestamp; field public final float[] values; Loading @@ -17008,7 +17009,6 @@ package android.hardware { method public void onFlushCompleted(android.hardware.Sensor); method public void onSensorAdditionalInfo(android.hardware.SensorAdditionalInfo); method public void onSensorChanged(android.hardware.SensorEvent); method public void onSensorDiscontinuity(@NonNull android.hardware.Sensor); } public interface SensorEventListener { core/java/android/hardware/SensorEvent.java +25 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.compat.annotation.UnsupportedAppUsage; /** Loading Loading @@ -664,16 +665,20 @@ public class SensorEvent { * The first three elements provide the transform from the (arbitrary, possibly slowly drifting) * reference frame to the head frame. The magnitude of this vector is in range [0, π] * radians, while the value of individual axes is in range [-π, π]. The next three * elements provide the estimated rotational velocity of the user's head relative to itself, in * radians per second. * elements optionally provide the estimated rotational velocity of the user's head relative to * itself, in radians per second. If a given sensor does not support determining velocity, these * elements are set to 0. * * <ul> * <li> values[0] : X component of Euler vector representing rotation</li> * <li> values[1] : Y component of Euler vector representing rotation</li> * <li> values[2] : Z component of Euler vector representing rotation</li> * <li> values[3] : X component of Euler vector representing angular velocity</li> * <li> values[4] : Y component of Euler vector representing angular velocity</li> * <li> values[5] : Z component of Euler vector representing angular velocity</li> * <li> values[3] : X component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * <li> values[4] : Y component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * <li> values[5] : Z component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * </ul> * * <h4>{@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES Loading Loading @@ -820,6 +825,21 @@ public class SensorEvent { */ public long timestamp; /** * Set to true when this is the first sensor event after a discontinuity. * * The exact meaning of discontinuity depends on the sensor type. For * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER}, this means that * the reference frame has suddenly and significantly changed, for example if the head tracking * device was removed then put back. * * Note that this concept is either not relevant to or not supported by most sensor types, * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER} being the notable * exception. */ @SuppressLint("MutableBareField") public boolean firstEventAfterDiscontinuity; @UnsupportedAppUsage SensorEvent(int valueSize) { values = new float[valueSize]; Loading core/java/android/hardware/SensorEventCallback.java +0 −19 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware; import android.annotation.NonNull; /** * Used for receiving sensor additional information frames. */ Loading Loading @@ -54,21 +52,4 @@ public abstract class SensorEventCallback implements SensorEventListener2 { * reported from sensor hardware. */ public void onSensorAdditionalInfo(SensorAdditionalInfo info) {} /** * Called when the next {@link android.hardware.SensorEvent SensorEvent} to be delivered via the * {@link #onSensorChanged(SensorEvent) onSensorChanged} method represents the first event after * a discontinuity. * * The exact meaning of discontinuity depends on the sensor type. For {@link * android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER}, this means that the * reference frame has suddenly and significantly changed. * * Note that this concept is either not relevant to or not supported by most sensor types, * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER} being the notable * exception. * * @param sensor The {@link android.hardware.Sensor Sensor} which experienced the discontinuity. */ public void onSensorDiscontinuity(@NonNull Sensor sensor) {} } core/java/android/hardware/SystemSensorManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -881,13 +881,13 @@ public class SystemSensorManager extends SensorManager { mListener.onAccuracyChanged(t.sensor, t.accuracy); } // call onSensorDiscontinuity() if the discontinuity counter changed if (t.sensor.getType() == Sensor.TYPE_HEAD_TRACKER && mListener instanceof SensorEventCallback) { // Indicate if the discontinuity count changed if (t.sensor.getType() == Sensor.TYPE_HEAD_TRACKER) { final int lastCount = mSensorDiscontinuityCounts.get(handle); final int curCount = Float.floatToIntBits(values[6]); if (lastCount >= 0 && lastCount != curCount) { ((SensorEventCallback) mListener).onSensorDiscontinuity(t.sensor); mSensorDiscontinuityCounts.put(handle, curCount); t.firstEventAfterDiscontinuity = true; } } Loading Loading
core/api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -16997,6 +16997,7 @@ package android.hardware { public class SensorEvent { field public int accuracy; field public boolean firstEventAfterDiscontinuity; field public android.hardware.Sensor sensor; field public long timestamp; field public final float[] values; Loading @@ -17008,7 +17009,6 @@ package android.hardware { method public void onFlushCompleted(android.hardware.Sensor); method public void onSensorAdditionalInfo(android.hardware.SensorAdditionalInfo); method public void onSensorChanged(android.hardware.SensorEvent); method public void onSensorDiscontinuity(@NonNull android.hardware.Sensor); } public interface SensorEventListener {
core/java/android/hardware/SensorEvent.java +25 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.compat.annotation.UnsupportedAppUsage; /** Loading Loading @@ -664,16 +665,20 @@ public class SensorEvent { * The first three elements provide the transform from the (arbitrary, possibly slowly drifting) * reference frame to the head frame. The magnitude of this vector is in range [0, π] * radians, while the value of individual axes is in range [-π, π]. The next three * elements provide the estimated rotational velocity of the user's head relative to itself, in * radians per second. * elements optionally provide the estimated rotational velocity of the user's head relative to * itself, in radians per second. If a given sensor does not support determining velocity, these * elements are set to 0. * * <ul> * <li> values[0] : X component of Euler vector representing rotation</li> * <li> values[1] : Y component of Euler vector representing rotation</li> * <li> values[2] : Z component of Euler vector representing rotation</li> * <li> values[3] : X component of Euler vector representing angular velocity</li> * <li> values[4] : Y component of Euler vector representing angular velocity</li> * <li> values[5] : Z component of Euler vector representing angular velocity</li> * <li> values[3] : X component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * <li> values[4] : Y component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * <li> values[5] : Z component of Euler vector representing angular velocity (if * supported, otherwise 0)</li> * </ul> * * <h4>{@link android.hardware.Sensor#TYPE_ACCELEROMETER_LIMITED_AXES Loading Loading @@ -820,6 +825,21 @@ public class SensorEvent { */ public long timestamp; /** * Set to true when this is the first sensor event after a discontinuity. * * The exact meaning of discontinuity depends on the sensor type. For * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER}, this means that * the reference frame has suddenly and significantly changed, for example if the head tracking * device was removed then put back. * * Note that this concept is either not relevant to or not supported by most sensor types, * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER} being the notable * exception. */ @SuppressLint("MutableBareField") public boolean firstEventAfterDiscontinuity; @UnsupportedAppUsage SensorEvent(int valueSize) { values = new float[valueSize]; Loading
core/java/android/hardware/SensorEventCallback.java +0 −19 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware; import android.annotation.NonNull; /** * Used for receiving sensor additional information frames. */ Loading Loading @@ -54,21 +52,4 @@ public abstract class SensorEventCallback implements SensorEventListener2 { * reported from sensor hardware. */ public void onSensorAdditionalInfo(SensorAdditionalInfo info) {} /** * Called when the next {@link android.hardware.SensorEvent SensorEvent} to be delivered via the * {@link #onSensorChanged(SensorEvent) onSensorChanged} method represents the first event after * a discontinuity. * * The exact meaning of discontinuity depends on the sensor type. For {@link * android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER}, this means that the * reference frame has suddenly and significantly changed. * * Note that this concept is either not relevant to or not supported by most sensor types, * {@link android.hardware.Sensor#TYPE_HEAD_TRACKER Sensor.TYPE_HEAD_TRACKER} being the notable * exception. * * @param sensor The {@link android.hardware.Sensor Sensor} which experienced the discontinuity. */ public void onSensorDiscontinuity(@NonNull Sensor sensor) {} }
core/java/android/hardware/SystemSensorManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -881,13 +881,13 @@ public class SystemSensorManager extends SensorManager { mListener.onAccuracyChanged(t.sensor, t.accuracy); } // call onSensorDiscontinuity() if the discontinuity counter changed if (t.sensor.getType() == Sensor.TYPE_HEAD_TRACKER && mListener instanceof SensorEventCallback) { // Indicate if the discontinuity count changed if (t.sensor.getType() == Sensor.TYPE_HEAD_TRACKER) { final int lastCount = mSensorDiscontinuityCounts.get(handle); final int curCount = Float.floatToIntBits(values[6]); if (lastCount >= 0 && lastCount != curCount) { ((SensorEventCallback) mListener).onSensorDiscontinuity(t.sensor); mSensorDiscontinuityCounts.put(handle, curCount); t.firstEventAfterDiscontinuity = true; } } Loading