From 13cde9694d660c925480b1648955ac32f036a5bf Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Mon, 16 Dec 2019 11:47:59 -0800 Subject: Provide defaults and annotations for LocationListener Providing defaults allows lambdas to be used with LocationListener. Bug: 146355527 Test: presubmits Change-Id: Ic7b9575c2788b7fcfef91293aa2371a32621f761 --- .../java/android/location/LocationListener.java | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'location/java/android') diff --git a/location/java/android/location/LocationListener.java b/location/java/android/location/LocationListener.java index aa9dddc03515..8df08345c79b 100644 --- a/location/java/android/location/LocationListener.java +++ b/location/java/android/location/LocationListener.java @@ -16,6 +16,7 @@ package android.location; +import android.annotation.NonNull; import android.os.Bundle; /** @@ -37,36 +38,32 @@ public interface LocationListener { /** * Called when the location has changed. * - *

There are no restrictions on the use of the supplied Location object. - * - * @param location The new location, as a Location object. + * @param location the updated location */ - void onLocationChanged(Location location); + void onLocationChanged(@NonNull Location location); /** - * This callback will never be invoked and providers can be considers as always in the - * {@link LocationProvider#AVAILABLE} state. + * This callback will never be invoked on Android Q and above, and providers can be considered + * as always in the {@link LocationProvider#AVAILABLE} state. * - * @deprecated This callback will never be invoked. + * @deprecated This callback will never be invoked on Android Q and above. */ @Deprecated - void onStatusChanged(String provider, int status, Bundle extras); + default void onStatusChanged(String provider, int status, Bundle extras) {} /** * Called when the provider is enabled by the user. * - * @param provider the name of the location provider associated with this - * update. + * @param provider the name of the location provider that has become enabled */ - void onProviderEnabled(String provider); + default void onProviderEnabled(@NonNull String provider) {} /** * Called when the provider is disabled by the user. If requestLocationUpdates * is called on an already disabled provider, this method is called * immediately. * - * @param provider the name of the location provider associated with this - * update. + * @param provider the name of the location provider that has become disabled */ - void onProviderDisabled(String provider); + default void onProviderDisabled(@NonNull String provider) {} } -- cgit v1.2.3-59-g8ed1b