Merge "Add @Nullable to SensorManager.getDefaultSensor's return value" am: 29aa6b8a72 am: 64a8b8356f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2377608

Change-Id: I907a3bec80d7249b7d7ee452015872515cd7ae1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matthew Sedam
2023-01-10 18:27:42 +00:00
committed by Automerger Merge Worker
2 changed files with 5 additions and 4 deletions

View File

@@ -17088,8 +17088,8 @@ package android.hardware {
method public boolean flush(android.hardware.SensorEventListener); method public boolean flush(android.hardware.SensorEventListener);
method public static float getAltitude(float, float); method public static float getAltitude(float, float);
method public static void getAngleChange(float[], float[], float[]); method public static void getAngleChange(float[], float[], float[]);
method public android.hardware.Sensor getDefaultSensor(int); method @Nullable public android.hardware.Sensor getDefaultSensor(int);
method public android.hardware.Sensor getDefaultSensor(int, boolean); method @Nullable public android.hardware.Sensor getDefaultSensor(int, boolean);
method public java.util.List<android.hardware.Sensor> getDynamicSensorList(int); method public java.util.List<android.hardware.Sensor> getDynamicSensorList(int);
method public static float getInclination(float[]); method public static float getInclination(float[]);
method public static float[] getOrientation(float[], float[]); method public static float[] getOrientation(float[], float[]);

View File

@@ -16,6 +16,7 @@
package android.hardware; package android.hardware;
import android.annotation.Nullable;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.annotation.SystemService; import android.annotation.SystemService;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
@@ -496,7 +497,7 @@ public abstract class SensorManager {
* @see #getSensorList(int) * @see #getSensorList(int)
* @see Sensor * @see Sensor
*/ */
public Sensor getDefaultSensor(int type) { public @Nullable Sensor getDefaultSensor(int type) {
// TODO: need to be smarter, for now, just return the 1st sensor // TODO: need to be smarter, for now, just return the 1st sensor
List<Sensor> l = getSensorList(type); List<Sensor> l = getSensorList(type);
boolean wakeUpSensor = false; boolean wakeUpSensor = false;
@@ -544,7 +545,7 @@ public abstract class SensorManager {
* and the application has the necessary permissions, or null otherwise. * and the application has the necessary permissions, or null otherwise.
* @see Sensor#isWakeUpSensor() * @see Sensor#isWakeUpSensor()
*/ */
public Sensor getDefaultSensor(int type, boolean wakeUp) { public @Nullable Sensor getDefaultSensor(int type, boolean wakeUp) {
List<Sensor> l = getSensorList(type); List<Sensor> l = getSensorList(type);
for (Sensor sensor : l) { for (Sensor sensor : l) {
if (sensor.isWakeUpSensor() == wakeUp) { if (sensor.isWakeUpSensor() == wakeUp) {