Loading services/core/java/com/android/server/LocationManagerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading @@ -719,6 +717,8 @@ public class LocationManagerService extends ILocationManager.Stub { mLastCoarseLocation.setValueAt(i, null); } } mLocationFudger.resetOffsets(); } } } Loading services/core/java/com/android/server/location/LocationFudger.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
services/core/java/com/android/server/LocationManagerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading @@ -719,6 +717,8 @@ public class LocationManagerService extends ILocationManager.Stub { mLastCoarseLocation.setValueAt(i, null); } } mLocationFudger.resetOffsets(); } } } Loading
services/core/java/com/android/server/location/LocationFudger.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading