Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa5414b4 authored by Dante Russo's avatar Dante Russo Committed by Linux Build Service Account
Browse files

gps: LocationManager CTS proximity test fix

CTS proximity tests needs to use
GeoFenceManager for GeoFences to be
able to see mock locations

Change-Id: I7696ac4f0985fe526f1eb2dacd177b4db3c658ae
CRs-Fixed: 452172
(cherry picked from commit 43b1e745e0c05139419a0ba401ac39f2660eb82b)
(cherry picked from commit 1ee5f6effacd2e7eecd05829a81f5ad1614cae4f)
(cherry picked from commit d1c6929760149783e8c4927e8777fc7632ec1989)
parent 3d10bd61
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public class LocationManagerService extends ILocationManager.Stub {
    private GeofenceManager mGeofenceManager;
    private String mGeoFencerPackageName;
    private GeoFencerBase mGeoFencer;
    private boolean mGeoFencerEnabled;
    private PackageManager mPackageManager;
    private PowerManager mPowerManager;
    private GeocoderProxy mGeocodeProvider;
@@ -202,6 +203,7 @@ public class LocationManagerService extends ILocationManager.Stub {
        super();
        mContext = context;
        mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
        mGeoFencerEnabled = false;

        if (D) Log.d(TAG, "Constructed");

@@ -456,8 +458,10 @@ public class LocationManagerService extends ILocationManager.Stub {
        if (mGeoFencerPackageName != null &&
                mPackageManager.resolveService(new Intent(mGeoFencerPackageName), 0) != null) {
            mGeoFencer = GeoFencerProxy.getGeoFencerProxy(mContext, mGeoFencerPackageName);
            mGeoFencerEnabled = true;
        } else {
            mGeoFencer = null;
            mGeoFencerEnabled = false;
        }
    }

@@ -1667,7 +1671,7 @@ public class LocationManagerService extends ILocationManager.Stub {
        }
        long identity = Binder.clearCallingIdentity();
        try {
            if (mGeoFencer != null) {
            if (mGeoFencer != null && mGeoFencerEnabled) {
                long expiration;
                if (sanitizedRequest.getExpireAt() == Long.MAX_VALUE) {
                    expiration = -1; // -1 means forever
@@ -1697,7 +1701,7 @@ public class LocationManagerService extends ILocationManager.Stub {
        // geo-fence manager uses the public location API, need to clear identity
        long identity = Binder.clearCallingIdentity();
        try {
            if (mGeoFencer != null) {
            if (mGeoFencer != null && mGeoFencerEnabled) {
                mGeoFencer.remove(intent);
            } else {
                mGeofenceManager.removeFence(geofence, intent);
@@ -2237,6 +2241,9 @@ public class LocationManagerService extends ILocationManager.Stub {
            if (mProvidersByName.get(name) != null) {
                throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
            }

            mGeoFencerEnabled = false;

            addProviderLocked(provider);
            mMockProviders.put(name, provider);
            mLastLocation.put(name, null);
@@ -2257,6 +2264,10 @@ public class LocationManagerService extends ILocationManager.Stub {
            long identity = Binder.clearCallingIdentity();
            removeProviderLocked(mProvidersByName.get(provider));

            if (mGeoFencer != null) {
                mGeoFencerEnabled = true;
            }

            // reinstate real provider if available
            LocationProviderInterface realProvider = mRealProviders.get(provider);
            if (realProvider != null) {
@@ -2403,7 +2414,7 @@ public class LocationManagerService extends ILocationManager.Stub {
            }

            mGeofenceManager.dump(pw);
            if (mGeoFencer != null) {
            if (mGeoFencer != null && mGeoFencerEnabled) {
                mGeoFencer.dump(pw, "");
            }