Merge "Make FUSED_PROVIDER public API"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d4c2928f8f
@@ -19297,10 +19297,10 @@ package android.location {
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, long, float, @NonNull android.location.LocationListener);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, long, float, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, long, float, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, long, float, @NonNull android.app.PendingIntent);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull android.app.PendingIntent);
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(long, float, @NonNull android.location.Criteria, @NonNull android.app.PendingIntent);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, @NonNull android.location.LocationRequest, @NonNull java.util.concurrent.Executor, @NonNull android.location.LocationListener);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@NonNull String, @NonNull android.location.LocationRequest, @NonNull android.app.PendingIntent);
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestSingleUpdate(@NonNull String, @NonNull android.location.LocationListener, @Nullable android.os.Looper);
|
||||
@@ -19318,6 +19318,7 @@ package android.location {
|
||||
field public static final String EXTRA_LOCATION_ENABLED = "android.location.extra.LOCATION_ENABLED";
|
||||
field public static final String EXTRA_PROVIDER_ENABLED = "android.location.extra.PROVIDER_ENABLED";
|
||||
field public static final String EXTRA_PROVIDER_NAME = "android.location.extra.PROVIDER_NAME";
|
||||
field public static final String FUSED_PROVIDER = "fused";
|
||||
field public static final String GPS_PROVIDER = "gps";
|
||||
field public static final String KEY_FLUSH_COMPLETE = "flushComplete";
|
||||
field public static final String KEY_LOCATION_CHANGED = "location";
|
||||
|
||||
@@ -4173,7 +4173,6 @@ package android.location {
|
||||
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setLocationEnabledForUser(boolean, @NonNull android.os.UserHandle);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean setProviderEnabledForUser(@NonNull String, boolean, @NonNull android.os.UserHandle);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE) public boolean unregisterGnssBatchedLocationCallback(@NonNull android.location.BatchedLocationCallback);
|
||||
field public static final String FUSED_PROVIDER = "fused";
|
||||
}
|
||||
|
||||
public final class LocationRequest implements android.os.Parcelable {
|
||||
|
||||
@@ -963,7 +963,6 @@ package android.location {
|
||||
method @NonNull public String[] getBackgroundThrottlingWhitelist();
|
||||
method @NonNull public String[] getIgnoreSettingsWhitelist();
|
||||
method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public java.util.List<java.lang.String> getProviderPackages(@NonNull String);
|
||||
field public static final String FUSED_PROVIDER = "fused";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -159,21 +159,21 @@ public class LocationManager {
|
||||
public static final long BLOCK_GPS_STATUS_USAGE = 144027538L;
|
||||
|
||||
/**
|
||||
* Name of the network location provider.
|
||||
* Standard name of the network location provider.
|
||||
*
|
||||
* <p>This provider determines location based on nearby of cell tower and WiFi access points.
|
||||
* Results are retrieved by means of a network lookup.
|
||||
* <p>If present, this provider determines location based on nearby of cell tower and WiFi
|
||||
* access points. Operation of this provider may require a data connection.
|
||||
*/
|
||||
public static final String NETWORK_PROVIDER = "network";
|
||||
|
||||
/**
|
||||
* Name of the GNSS location provider.
|
||||
* Standard name of the GNSS location provider.
|
||||
*
|
||||
* <p>This provider determines location using GNSS satellites. Depending on conditions, this
|
||||
* provider may take a while to return a location fix. Requires the
|
||||
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission.
|
||||
* <p>If present, this provider determines location using GNSS satellites. The responsiveness
|
||||
* and accuracy of location fixes may depend on GNSS signal conditions.
|
||||
*
|
||||
* <p>The extras Bundle for the GPS location provider can contain the following key/value pairs:
|
||||
* <p>The extras Bundle for locations derived by this location provider may contain the
|
||||
* following key/value pairs:
|
||||
* <ul>
|
||||
* <li> satellites - the number of satellites used to derive the fix
|
||||
* </ul>
|
||||
@@ -181,29 +181,22 @@ public class LocationManager {
|
||||
public static final String GPS_PROVIDER = "gps";
|
||||
|
||||
/**
|
||||
* A special location provider for receiving locations without actually initiating a location
|
||||
* fix.
|
||||
* A special location provider for receiving locations without actively initiating a location
|
||||
* fix. This location provider is always present.
|
||||
*
|
||||
* <p>This provider can be used to passively receive location updates when other applications or
|
||||
* services request them without actually requesting the locations yourself. This provider will
|
||||
* only return locations generated by other providers. You can query the
|
||||
* {@link Location#getProvider()} method to determine the actual provider that supplied the
|
||||
* location update. Requires the {@link android.Manifest.permission#ACCESS_FINE_LOCATION}
|
||||
* permission, although there is no guarantee of fine locations.
|
||||
* only return locations generated by other providers.
|
||||
*/
|
||||
public static final String PASSIVE_PROVIDER = "passive";
|
||||
|
||||
/**
|
||||
* The fused location provider.
|
||||
* Standard name of the fused location provider.
|
||||
*
|
||||
* <p>This provider may combine inputs from several location sources to provide the
|
||||
* best possible location fix. It is implicitly used for all API's that involve the
|
||||
* {@link LocationRequest} object.
|
||||
*
|
||||
* @hide
|
||||
* <p>If present, this provider may combine inputs from several other location providers to
|
||||
* provide the best possible location fix. It is implicitly used for all requestLocationUpdates
|
||||
* APIs that involve a {@link Criteria}.
|
||||
*/
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public static final String FUSED_PROVIDER = "fused";
|
||||
|
||||
/**
|
||||
@@ -918,6 +911,9 @@ public class LocationManager {
|
||||
/**
|
||||
* Register for a single location update using a Criteria and a callback.
|
||||
*
|
||||
* <p>Note: Since Android KitKat, Criteria requests will always result in using the
|
||||
* {@link #FUSED_PROVIDER}.
|
||||
*
|
||||
* <p>See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} for more detail
|
||||
* on how to use this method.
|
||||
*
|
||||
@@ -985,6 +981,9 @@ public class LocationManager {
|
||||
/**
|
||||
* Register for a single location update using a Criteria and pending intent.
|
||||
*
|
||||
* <p>Note: Since Android KitKat, Criteria requests will always result in using the
|
||||
* {@link #FUSED_PROVIDER}.
|
||||
*
|
||||
* <p>See {@link #requestLocationUpdates(long, float, Criteria, PendingIntent)} for more detail
|
||||
* on how to use this method.
|
||||
*
|
||||
@@ -1113,6 +1112,9 @@ public class LocationManager {
|
||||
* Register for location updates using a provider selected through the given Criteria, and a
|
||||
* callback on the specified {@link Looper}.
|
||||
*
|
||||
* <p>Note: Since Android KitKat, Criteria requests will always result in using the
|
||||
* {@link #FUSED_PROVIDER}.
|
||||
*
|
||||
* <p>See {@link #requestLocationUpdates(String, LocationRequest, Executor, LocationListener)}
|
||||
* for more detail on how this method works.
|
||||
*
|
||||
@@ -1124,7 +1126,12 @@ public class LocationManager {
|
||||
* @throws IllegalArgumentException if criteria is null
|
||||
* @throws IllegalArgumentException if listener is null
|
||||
* @throws SecurityException if no suitable permission is present
|
||||
*
|
||||
* @deprecated Use
|
||||
* {@link #requestLocationUpdates(String, long, float, LocationListener, Looper)} instead to
|
||||
* explicitly select a provider.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(anyOf = {ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION})
|
||||
public void requestLocationUpdates(long minTimeMs, float minDistanceM,
|
||||
@NonNull Criteria criteria, @NonNull LocationListener listener,
|
||||
@@ -1138,6 +1145,9 @@ public class LocationManager {
|
||||
* Register for location updates using a provider selected through the given Criteria, and a
|
||||
* callback on the specified {@link Executor}.
|
||||
*
|
||||
* <p>Note: Since Android KitKat, Criteria requests will always result in using the
|
||||
* {@link #FUSED_PROVIDER}.
|
||||
*
|
||||
* <p>See {@link #requestLocationUpdates(String, LocationRequest, Executor, LocationListener)}
|
||||
* for more detail on how this method works.
|
||||
*
|
||||
@@ -1151,7 +1161,12 @@ public class LocationManager {
|
||||
* @throws IllegalArgumentException if executor is null
|
||||
* @throws IllegalArgumentException if listener is null
|
||||
* @throws SecurityException if no suitable permission is present
|
||||
*
|
||||
* @deprecated Use
|
||||
* {@link #requestLocationUpdates(String, long, float, Executor, LocationListener)} instead to
|
||||
* explicitly select a provider.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(anyOf = {ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION})
|
||||
public void requestLocationUpdates(
|
||||
long minTimeMs,
|
||||
@@ -1199,6 +1214,9 @@ public class LocationManager {
|
||||
* Register for location updates using a provider selected through the given Criteria, and
|
||||
* callbacks delivered via the provided {@link PendingIntent}.
|
||||
*
|
||||
* <p>Note: Since Android KitKat, Criteria requests will always result in using the
|
||||
* {@link #FUSED_PROVIDER}.
|
||||
*
|
||||
* <p>See {@link #requestLocationUpdates(String, long, float, PendingIntent)} for more detail on
|
||||
* how this method works.
|
||||
*
|
||||
@@ -1210,7 +1228,11 @@ public class LocationManager {
|
||||
* @throws IllegalArgumentException if provider is null or doesn't exist
|
||||
* @throws IllegalArgumentException if pendingIntent is null
|
||||
* @throws SecurityException if no suitable permission is present
|
||||
*
|
||||
* @deprecated Use {@link #requestLocationUpdates(String, long, float, PendingIntent)} instead
|
||||
* to explicitly select a provider.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(anyOf = {ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION})
|
||||
public void requestLocationUpdates(long minTimeMs, float minDistanceM,
|
||||
@NonNull Criteria criteria, @NonNull PendingIntent pendingIntent) {
|
||||
@@ -1594,9 +1616,8 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the names of all known location providers. All providers are returned,
|
||||
* including ones that are not permitted to be accessed by the calling activity or are currently
|
||||
* disabled.
|
||||
* Returns a list of the names of all available location providers. All providers are returned,
|
||||
* including those that are currently disabled.
|
||||
*
|
||||
* @return list of provider names
|
||||
*/
|
||||
@@ -1609,8 +1630,8 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the names of location providers. Only providers that the caller has
|
||||
* permission to access will be returned.
|
||||
* Returns a list of the names of available location providers. If {@code enabledOnly} is false,
|
||||
* this is functionally the same as {@link #getAllProviders()}.
|
||||
*
|
||||
* @param enabledOnly if true then only enabled providers are included
|
||||
* @return list of provider names
|
||||
@@ -1624,8 +1645,7 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the names of providers that satisfy the given criteria. Only providers that
|
||||
* the caller has permission to access will be returned.
|
||||
* Returns a list of the names of available location providers that satisfy the given criteria.
|
||||
*
|
||||
* @param criteria the criteria that providers must match
|
||||
* @param enabledOnly if true then only enabled providers are included
|
||||
|
||||
@@ -519,9 +519,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
public List<String> getAllProviders() {
|
||||
ArrayList<String> providers = new ArrayList<>(mProviderManagers.size());
|
||||
for (LocationProviderManager manager : mProviderManagers) {
|
||||
if (FUSED_PROVIDER.equals(manager.getName())) {
|
||||
continue;
|
||||
}
|
||||
providers.add(manager.getName());
|
||||
}
|
||||
return providers;
|
||||
@@ -538,9 +535,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
ArrayList<String> providers = new ArrayList<>(mProviderManagers.size());
|
||||
for (LocationProviderManager manager : mProviderManagers) {
|
||||
String name = manager.getName();
|
||||
if (FUSED_PROVIDER.equals(name)) {
|
||||
continue;
|
||||
}
|
||||
if (enabledOnly && !manager.isEnabled(UserHandle.getCallingUserId())) {
|
||||
continue;
|
||||
}
|
||||
@@ -565,7 +559,9 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
|
||||
if (!providers.isEmpty()) {
|
||||
if (providers.contains(GPS_PROVIDER)) {
|
||||
if (providers.contains(FUSED_PROVIDER)) {
|
||||
return FUSED_PROVIDER;
|
||||
} else if (providers.contains(GPS_PROVIDER)) {
|
||||
return GPS_PROVIDER;
|
||||
} else if (providers.contains(NETWORK_PROVIDER)) {
|
||||
return NETWORK_PROVIDER;
|
||||
@@ -1046,10 +1042,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@Override
|
||||
public boolean isProviderEnabledForUser(String provider, int userId) {
|
||||
// fused provider is accessed indirectly via criteria rather than the provider-based APIs,
|
||||
// so we discourage its use
|
||||
if (FUSED_PROVIDER.equals(provider)) return false;
|
||||
|
||||
return mLocalService.isProviderEnabledForUser(provider, userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user