Remove getTestProviderLocationRequests TestApi
This API is no longer necessary for testing, and inappropriately exposes internals. Also updates battery saver TEST_MAPPING to include location tests. Bug: 170224294 Test: presubmits Change-Id: I1322f21ced86d3622650ecf02dfa959a484660d0
This commit is contained in:
@@ -1720,7 +1720,6 @@ package android.location {
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void getCurrentLocation(@NonNull android.location.LocationRequest, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.location.Location>);
|
||||
method @NonNull public String[] getIgnoreSettingsWhitelist();
|
||||
method @Deprecated @Nullable @RequiresPermission("android.permission.READ_DEVICE_CONFIG") public java.util.List<java.lang.String> getProviderPackages(@NonNull String);
|
||||
method @NonNull public java.util.List<android.location.LocationRequest> getTestProviderCurrentRequests(String);
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}) public void requestLocationUpdates(@Nullable android.location.LocationRequest, @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(@Nullable android.location.LocationRequest, @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(@Nullable android.location.LocationRequest, @NonNull android.app.PendingIntent);
|
||||
|
||||
@@ -106,11 +106,12 @@ interface ILocationManager
|
||||
boolean isProviderEnabledForUser(String provider, int userId);
|
||||
boolean isLocationEnabledForUser(int userId);
|
||||
void setLocationEnabledForUser(boolean enabled, int userId);
|
||||
|
||||
void addTestProvider(String name, in ProviderProperties properties, String packageName, String attributionTag);
|
||||
void removeTestProvider(String provider, String packageName, String attributionTag);
|
||||
void setTestProviderLocation(String provider, in Location location, String packageName, String attributionTag);
|
||||
void setTestProviderEnabled(String provider, boolean enabled, String packageName, String attributionTag);
|
||||
List<LocationRequest> getTestProviderCurrentRequests(String provider);
|
||||
|
||||
LocationTime getGnssTimeMillis();
|
||||
|
||||
void sendExtraCommand(String provider, String command, inout Bundle extras);
|
||||
|
||||
@@ -1814,22 +1814,6 @@ public class LocationManager {
|
||||
@Deprecated
|
||||
public void clearTestProviderStatus(@NonNull String provider) {}
|
||||
|
||||
/**
|
||||
* Get the last list of {@link LocationRequest}s sent to the provider.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@NonNull
|
||||
public List<LocationRequest> getTestProviderCurrentRequests(String providerName) {
|
||||
Preconditions.checkArgument(providerName != null, "invalid null provider");
|
||||
try {
|
||||
return mService.getTestProviderCurrentRequests(providerName);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a proximity alert for the location given by the position (latitude, longitude) and the
|
||||
* given radius.
|
||||
|
||||
@@ -216,7 +216,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
private final LocalService mLocalService;
|
||||
|
||||
private final GeofenceManager mGeofenceManager;
|
||||
@Nullable private volatile GnssManagerService mGnssManagerService = null;
|
||||
private volatile @Nullable GnssManagerService mGnssManagerService = null;
|
||||
private GeocoderProxy mGeocodeProvider;
|
||||
|
||||
@GuardedBy("mLock")
|
||||
@@ -604,7 +604,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|| !request.getWorkSource().isEmpty();
|
||||
if (usesSystemApi
|
||||
&& isChangeEnabled(PREVENT_PENDING_INTENT_SYSTEM_API_USAGE, identity.getUid())) {
|
||||
throw new SecurityException("PendingIntent location requests may not use system APIs");
|
||||
throw new SecurityException(
|
||||
"PendingIntent location requests may not use system APIs: " + request);
|
||||
}
|
||||
|
||||
request = validateLocationRequest(request, identity);
|
||||
@@ -1090,19 +1091,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
manager.setMockProviderAllowed(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public List<LocationRequest> getTestProviderCurrentRequests(String provider) {
|
||||
mContext.enforceCallingOrSelfPermission(permission.READ_DEVICE_CONFIG, null);
|
||||
|
||||
LocationProviderManager manager = getLocationProviderManager(provider);
|
||||
if (manager == null) {
|
||||
throw new IllegalArgumentException("provider doesn't exist: " + provider);
|
||||
}
|
||||
|
||||
return manager.getMockProviderRequests();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleShellCommand(ParcelFileDescriptor in, ParcelFileDescriptor out,
|
||||
ParcelFileDescriptor err, String[] args) {
|
||||
|
||||
@@ -1391,16 +1391,6 @@ class LocationProviderManager extends
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocationRequest> getMockProviderRequests() {
|
||||
synchronized (mLock) {
|
||||
if (!mProvider.isMock()) {
|
||||
throw new IllegalArgumentException(mName + " provider is not a test provider");
|
||||
}
|
||||
|
||||
return mProvider.getCurrentRequest().getLocationRequests();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Location getLastLocation(CallerIdentity identity, @PermissionLevel int permissionLevel,
|
||||
boolean ignoreLocationSettings) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"presubmit": [
|
||||
{
|
||||
"name": "CtsLocationCoarseTestCases"
|
||||
},
|
||||
{
|
||||
"name": "CtsLocationFineTestCases"
|
||||
},
|
||||
{
|
||||
"name": "CtsLocationNoneTestCases"
|
||||
},
|
||||
{
|
||||
"name": "FrameworksMockingServicesTests",
|
||||
"options": [
|
||||
{"include-filter": "com.android.server.location"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user