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

Commit 4374b211 authored by Anil Admal's avatar Anil Admal
Browse files

Non-framework location management - remove roaming handling

Remove code that detects roaming and disables non-framework
location access for the entities represented by the configured
proxy apps. It was decided in the PWG meeting that detecting
and notifying the user for consent for a combination of cases
involving SIM change, multi-SIMs, roaming, different work
profiles is complex and instead have the proxy app include
text that any carrier the phone connects to can access the
device's location depending on the location permission settings
of the configured proxy app.

Bug: 122856189
Test: Verified that removal of this roaming code does not affect
      other non-framework location management features.

Change-Id: I4ec741bcf71ff0743fa4a026d6572d01a95eb03e
parent 2bfd202e
Loading
Loading
Loading
Loading
+1 −32
Original line number Original line Diff line number Diff line
@@ -24,10 +24,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.PowerManager;
import android.os.PowerManager;
@@ -75,7 +71,6 @@ class GnssVisibilityControl {
    private final Context mContext;
    private final Context mContext;


    private boolean mIsMasterLocationSettingsEnabled = true;
    private boolean mIsMasterLocationSettingsEnabled = true;
    private boolean mIsOnRoamingNetwork = false;


    // Number of non-framework location access proxy apps is expected to be small (< 5).
    // Number of non-framework location access proxy apps is expected to be small (< 5).
    private static final int HASH_MAP_INITIAL_CAPACITY_PROXY_APP_TO_LOCATION_PERMISSIONS = 7;
    private static final int HASH_MAP_INITIAL_CAPACITY_PROXY_APP_TO_LOCATION_PERMISSIONS = 7;
@@ -98,7 +93,6 @@ class GnssVisibilityControl {


        // Listen for proxy app package installation, removal events.
        // Listen for proxy app package installation, removal events.
        listenForProxyAppsPackageUpdates();
        listenForProxyAppsPackageUpdates();
        listenForRoamingNetworkUpdate();


        // TODO(b/122855984): Handle global location settings on/off.
        // TODO(b/122855984): Handle global location settings on/off.
    }
    }
@@ -348,8 +342,7 @@ class GnssVisibilityControl {
    }
    }


    private boolean shouldDisableNfwLocationAccess() {
    private boolean shouldDisableNfwLocationAccess() {
        // TODO(b/122856189): Add disableWhenRoaming configuration per proxy app.
        return !mIsMasterLocationSettingsEnabled;
        return mIsOnRoamingNetwork || !mIsMasterLocationSettingsEnabled;
    }
    }


    private String[] getLocationPermissionEnabledProxyApps() {
    private String[] getLocationPermissionEnabledProxyApps() {
@@ -459,30 +452,6 @@ class GnssVisibilityControl {
                isPermissionMismatched);
                isPermissionMismatched);
    }
    }


    private void listenForRoamingNetworkUpdate() {
        // Register for network capabilities changes to monitor roaming changes.
        ConnectivityManager mConnMgr = (ConnectivityManager) mContext.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        NetworkRequest.Builder networkRequestBuilder = new NetworkRequest.Builder();
        networkRequestBuilder.addCapability(NetworkCapabilities.TRANSPORT_CELLULAR);
        NetworkRequest networkRequest = networkRequestBuilder.build();
        mConnMgr.registerNetworkCallback(networkRequest,
                new ConnectivityManager.NetworkCallback() {
                    @Override
                    public void onCapabilitiesChanged(Network network,
                            NetworkCapabilities capabilities) {
                        boolean isRoaming = !capabilities.hasTransport(
                                NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING);
                        // No locking required for this test and set because the callback
                        // runs in mHandler thread.
                        if (mIsOnRoamingNetwork != isRoaming) {
                            mIsOnRoamingNetwork = isRoaming;
                            updateNfwLocationAccessProxyAppsInGnssHal();
                        }
                    }
                }, mHandler);
    }

    private void runOnHandler(Runnable event) {
    private void runOnHandler(Runnable event) {
        // Hold a wake lock until this message is delivered.
        // Hold a wake lock until this message is delivered.
        // Note that this assumes the message will not be removed from the queue before
        // Note that this assumes the message will not be removed from the queue before