Merge "Prevent mock location from leaking fudger offsets"
This commit is contained in:
committed by
Android (Google) Code Review
commit
817596d92b
@@ -213,11 +213,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
private PackageManager mPackageManager;
|
||||
private PowerManager mPowerManager;
|
||||
|
||||
// TODO: sharing a location fudger with mock providers can leak information as the mock provider
|
||||
// can be used to retrieve offset information. the fudger should likely be reset whenever mock
|
||||
// providers are added or removed
|
||||
private LocationFudger mLocationFudger;
|
||||
|
||||
private GeofenceManager mGeofenceManager;
|
||||
private GeocoderProxy mGeocodeProvider;
|
||||
|
||||
@@ -285,8 +280,6 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
mAppOps = mContext.getSystemService(AppOpsManager.class);
|
||||
mPowerManager = mContext.getSystemService(PowerManager.class);
|
||||
|
||||
mLocationFudger = new LocationFudger(mSettingsHelper.getCoarseLocationAccuracyM());
|
||||
mGeofenceManager = new GeofenceManager(mContext, mSettingsHelper);
|
||||
|
||||
PowerManagerInternal localPowerManager =
|
||||
@@ -663,6 +656,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
private final String mName;
|
||||
|
||||
private final LocationFudger mLocationFudger;
|
||||
|
||||
// if the provider is enabled for a given user id - null or not present means unknown
|
||||
@GuardedBy("mLock")
|
||||
private final SparseArray<Boolean> mEnabled;
|
||||
@@ -680,6 +675,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
private LocationProviderManager(String name) {
|
||||
mName = name;
|
||||
mLocationFudger = new LocationFudger(mSettingsHelper.getCoarseLocationAccuracyM());
|
||||
mEnabled = new SparseArray<>(2);
|
||||
mLastLocation = new SparseArray<>(2);
|
||||
mLastCoarseLocation = new SparseArray<>(2);
|
||||
@@ -704,7 +700,9 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
synchronized (mLock) {
|
||||
mProvider.setMockProvider(provider);
|
||||
|
||||
// when removing a mock provider, also clear any mock last locations
|
||||
// when removing a mock provider, also clear any mock last locations and reset the
|
||||
// location fudger. the mock provider could have been used to infer the current
|
||||
// location fudger offsets.
|
||||
if (provider == null) {
|
||||
for (int i = 0; i < mLastLocation.size(); i++) {
|
||||
Location lastLocation = mLastLocation.valueAt(i);
|
||||
@@ -719,6 +717,8 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
mLastCoarseLocation.setValueAt(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
mLocationFudger.resetOffsets();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,13 @@ public class LocationFudger {
|
||||
mRandom = random;
|
||||
mAccuracyM = Math.max(accuracyM, MIN_ACCURACY_M);
|
||||
|
||||
resetOffsets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the random offsets completely.
|
||||
*/
|
||||
public void resetOffsets() {
|
||||
mLatitudeOffsetM = nextRandomOffset();
|
||||
mLongitudeOffsetM = nextRandomOffset();
|
||||
mNextUpdateRealtimeMs = mClock.millis() + OFFSET_UPDATE_INTERVAL_MS;
|
||||
|
||||
Reference in New Issue
Block a user