Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10992,6 +10992,7 @@ package android.hardware { field public static final int SENSOR_STATUS_ACCURACY_HIGH = 3; // 0x3 field public static final int SENSOR_STATUS_ACCURACY_LOW = 1; // 0x1 field public static final int SENSOR_STATUS_ACCURACY_MEDIUM = 2; // 0x2 field public static final int SENSOR_STATUS_NO_CONTACT = -1; // 0xffffffff field public static final int SENSOR_STATUS_UNRELIABLE = 0; // 0x0 field public static final deprecated int SENSOR_TEMPERATURE = 4; // 0x4 field public static final deprecated int SENSOR_TRICORDER = 64; // 0x40 core/java/android/hardware/Sensor.java +10 −4 Original line number Diff line number Diff line Loading @@ -381,11 +381,17 @@ public final class Sensor { /** * A constant describing a heart rate monitor. * <p> * A sensor that measures the heart rate in beats per minute. * The reported value is the heart rate in beats per minute. * <p> * value[0] represents the beats per minute when the measurement was taken. * value[0] is 0 if the heart rate monitor could not measure the rate or the * rate is 0 beat per minute. * The reported accuracy represents the status of the monitor during the reading. See the * {@code SENSOR_STATUS_*} constants in {@link android.hardware.SensorManager SensorManager} * for more details on accuracy/status values. In particular, when the accuracy is * {@code SENSOR_STATUS_UNRELIABLE} or {@code SENSOR_STATUS_NO_CONTACT}, the heart rate * value should be discarded. * <p> * This sensor requires permission {@code android.permission.BODY_SENSORS}. * It will not be returned by {@code SensorManager.getSensorsList} nor * {@code SensorManager.getDefaultSensor} if the application doesn't have this permission. */ public static final int TYPE_HEART_RATE = 21; Loading core/java/android/hardware/SensorEventListener.java +7 −5 Original line number Diff line number Diff line Loading @@ -39,11 +39,13 @@ public interface SensorEventListener { public void onSensorChanged(SensorEvent event); /** * Called when the accuracy of a sensor has changed. * <p>See {@link android.hardware.SensorManager SensorManager} * for details. * Called when the accuracy of the registered sensor has changed. * * <p>See the SENSOR_STATUS_* constants in * {@link android.hardware.SensorManager SensorManager} for details. * * @param accuracy The new accuracy of this sensor * @param accuracy The new accuracy of this sensor, one of * {@code SensorManager.SENSOR_STATUS_*} */ public void onAccuracyChanged(Sensor sensor, int accuracy); } core/java/android/hardware/SensorManager.java +10 −2 Original line number Diff line number Diff line Loading @@ -320,6 +320,13 @@ public abstract class SensorManager { public static final int SENSOR_DELAY_NORMAL = 3; /** * The values returned by this sensor cannot be trusted because the sensor * had no contact with what it was measuring (for example, the heart rate * monitor is not in contact with the user). */ public static final int SENSOR_STATUS_NO_CONTACT = -1; /** * The values returned by this sensor cannot be trusted, calibration is * needed or the environment doesn't allow readings Loading Loading @@ -423,7 +430,8 @@ public abstract class SensorManager { * @param type * of sensors requested * * @return the default sensors matching the asked type. * @return the default sensor matching the requested type if one exists and the application * has the necessary permissions, or null otherwise. * * @see #getSensorList(int) * @see Sensor Loading core/java/android/hardware/SystemSensorManager.java +6 −19 Original line number Diff line number Diff line Loading @@ -395,26 +395,13 @@ public class SystemSensorManager extends SensorManager { t.timestamp = timestamp; t.accuracy = inAccuracy; t.sensor = sensor; switch (t.sensor.getType()) { // Only report accuracy for sensors that support it. case Sensor.TYPE_MAGNETIC_FIELD: case Sensor.TYPE_ORIENTATION: // call onAccuracyChanged() only if the value changes final int accuracy = mSensorAccuracies.get(handle); if ((t.accuracy >= 0) && (accuracy != t.accuracy)) { mSensorAccuracies.put(handle, t.accuracy); mListener.onAccuracyChanged(t.sensor, t.accuracy); } break; default: // For other sensors, just report the accuracy once if (mFirstEvent.get(handle) == false) { mFirstEvent.put(handle, true); mListener.onAccuracyChanged( t.sensor, SENSOR_STATUS_ACCURACY_HIGH); } break; } mListener.onSensorChanged(t); } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10992,6 +10992,7 @@ package android.hardware { field public static final int SENSOR_STATUS_ACCURACY_HIGH = 3; // 0x3 field public static final int SENSOR_STATUS_ACCURACY_LOW = 1; // 0x1 field public static final int SENSOR_STATUS_ACCURACY_MEDIUM = 2; // 0x2 field public static final int SENSOR_STATUS_NO_CONTACT = -1; // 0xffffffff field public static final int SENSOR_STATUS_UNRELIABLE = 0; // 0x0 field public static final deprecated int SENSOR_TEMPERATURE = 4; // 0x4 field public static final deprecated int SENSOR_TRICORDER = 64; // 0x40
core/java/android/hardware/Sensor.java +10 −4 Original line number Diff line number Diff line Loading @@ -381,11 +381,17 @@ public final class Sensor { /** * A constant describing a heart rate monitor. * <p> * A sensor that measures the heart rate in beats per minute. * The reported value is the heart rate in beats per minute. * <p> * value[0] represents the beats per minute when the measurement was taken. * value[0] is 0 if the heart rate monitor could not measure the rate or the * rate is 0 beat per minute. * The reported accuracy represents the status of the monitor during the reading. See the * {@code SENSOR_STATUS_*} constants in {@link android.hardware.SensorManager SensorManager} * for more details on accuracy/status values. In particular, when the accuracy is * {@code SENSOR_STATUS_UNRELIABLE} or {@code SENSOR_STATUS_NO_CONTACT}, the heart rate * value should be discarded. * <p> * This sensor requires permission {@code android.permission.BODY_SENSORS}. * It will not be returned by {@code SensorManager.getSensorsList} nor * {@code SensorManager.getDefaultSensor} if the application doesn't have this permission. */ public static final int TYPE_HEART_RATE = 21; Loading
core/java/android/hardware/SensorEventListener.java +7 −5 Original line number Diff line number Diff line Loading @@ -39,11 +39,13 @@ public interface SensorEventListener { public void onSensorChanged(SensorEvent event); /** * Called when the accuracy of a sensor has changed. * <p>See {@link android.hardware.SensorManager SensorManager} * for details. * Called when the accuracy of the registered sensor has changed. * * <p>See the SENSOR_STATUS_* constants in * {@link android.hardware.SensorManager SensorManager} for details. * * @param accuracy The new accuracy of this sensor * @param accuracy The new accuracy of this sensor, one of * {@code SensorManager.SENSOR_STATUS_*} */ public void onAccuracyChanged(Sensor sensor, int accuracy); }
core/java/android/hardware/SensorManager.java +10 −2 Original line number Diff line number Diff line Loading @@ -320,6 +320,13 @@ public abstract class SensorManager { public static final int SENSOR_DELAY_NORMAL = 3; /** * The values returned by this sensor cannot be trusted because the sensor * had no contact with what it was measuring (for example, the heart rate * monitor is not in contact with the user). */ public static final int SENSOR_STATUS_NO_CONTACT = -1; /** * The values returned by this sensor cannot be trusted, calibration is * needed or the environment doesn't allow readings Loading Loading @@ -423,7 +430,8 @@ public abstract class SensorManager { * @param type * of sensors requested * * @return the default sensors matching the asked type. * @return the default sensor matching the requested type if one exists and the application * has the necessary permissions, or null otherwise. * * @see #getSensorList(int) * @see Sensor Loading
core/java/android/hardware/SystemSensorManager.java +6 −19 Original line number Diff line number Diff line Loading @@ -395,26 +395,13 @@ public class SystemSensorManager extends SensorManager { t.timestamp = timestamp; t.accuracy = inAccuracy; t.sensor = sensor; switch (t.sensor.getType()) { // Only report accuracy for sensors that support it. case Sensor.TYPE_MAGNETIC_FIELD: case Sensor.TYPE_ORIENTATION: // call onAccuracyChanged() only if the value changes final int accuracy = mSensorAccuracies.get(handle); if ((t.accuracy >= 0) && (accuracy != t.accuracy)) { mSensorAccuracies.put(handle, t.accuracy); mListener.onAccuracyChanged(t.sensor, t.accuracy); } break; default: // For other sensors, just report the accuracy once if (mFirstEvent.get(handle) == false) { mFirstEvent.put(handle, true); mListener.onAccuracyChanged( t.sensor, SENSOR_STATUS_ACCURACY_HIGH); } break; } mListener.onSensorChanged(t); } Loading