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

Commit db64708d authored by Tushar Janefalkar's avatar Tushar Janefalkar Committed by Linux Build Service Account
Browse files

NLP Combo feature : screen network locations

If Combo Provider is listening for network
locations, it will want to screen these locations
before they are sent out to clients.

CRs-fixed: 483398

Change-Id: I3156e85307b40aee9fb06b433c83153c84b8ed42
parent 0fa31fb3
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -2316,6 +2316,53 @@ public class LocationManagerService extends ILocationManager.Stub {
        synchronized (mLock) {
            return mMockProviders.containsKey(provider);
        }

    }

    private Location screenLocationLocked(Location location, String provider) {

        if (false == provider.equals(LocationManager.NETWORK_PROVIDER)) {
            return location;
        }

        Bundle extras = location.getExtras();
        if (extras == null) {
            extras = new Bundle();
        }

        if (!extras.containsKey("com.qualcomm.location.nlp:ready")) {
            // see if com.qualcomm.location is a passive listener
            ArrayList<UpdateRecord> records =
                mRecordsByProvider.get(LocationManager.PASSIVE_PROVIDER);
            if (records != null) {
                for (UpdateRecord r : records) {
                    if (r.mReceiver.mPackageName.equals("com.qualcomm.location")) {
                        extras.putBoolean("com.qualcomm.location.nlp:screen", true);
                        // send location to com.qualcomm.location for screening
                        if (!r.mReceiver.callLocationChangedLocked(location)) {
                            Slog.w(TAG, "RemoteException calling onLocationChanged on "
                                   + r.mReceiver);
                        } else {
                            if (D) {
                                Log.d(TAG, "Sending location for screening");
                            }
                        }
                        return null;
                    }
                }
            }
            if (D) {
                Log.d(TAG, "Not screening locations");
            }
        } else {
            if (D) {
                Log.d(TAG, "This location is marked as ready for broadcast");
            }
            // clear the ready marker
            extras.remove("com.qualcomm.location.nlp:ready");
        }

        return location;
    }

    private void handleLocationChanged(Location location, boolean passive) {
@@ -2334,6 +2381,10 @@ public class LocationManagerService extends ILocationManager.Stub {
        synchronized (mLock) {
            if (isAllowedByCurrentUserSettingsLocked(provider)) {
                if (!passive) {
                    location = screenLocationLocked(location, provider);
                    if (location == null) {
                        return;
                    }
                    // notify passive provider of the new location
                    mPassiveProvider.updateLocation(myLocation);
                }