Merge "Add @Nullable to SensorManager.getDefaultSensor's return value"
This commit is contained in:
@@ -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[]);
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user