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

Commit 403aa268 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Jeff Davidson
Browse files

Make StatusBar display all default networks.

The basic principle is: if an app's traffic could possibly go
over a network without the app using the multinetwork APIs (hence
"by default"), then the status bar should show that network's
connectivity.

In the normal case, app traffic only goes over the system's default
network connection, so that's the only network returned.

With a VPN in force, some app traffic may go into the VPN, and thus over
whatever underlying networks the VPN specifies, while other app traffic
may go over the system default network (e.g.: a split-tunnel VPN, or an
app disallowed by the VPN), so the set of networks returned includes the
VPN's underlying networks and the system default.

Specifically:

1. Add a NETWORK_CAPABILITY_VALIDATED bit to NetworkCapabilities.
2. Add a hidden API to retrieve the NetworkCapabilities of
   all default networks for a given macro-user.
3. Modify the status bar code that used getActiveNetworkInfo to
   determine which network was active, and make it consider all
   validated networks instead.
4. Because the set of active networks depends on which VPN app
   the user is running, make the status bar re-evaluate the
   networking situation when the active user changes.

Bug: 17460017
Change-Id: Ie4965f35fb5936b088e6060ee06e362c22297ab2
parent dc1baa16
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -720,6 +720,19 @@ public class ConnectivityManager {
        }
    }

    /**
     * Returns an array of of {@link NetworkCapabilities} objects, representing
     * the Networks that applications run by the given user will use by default.
     * @hide
     */
    public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) {
        try {
            return mService.getDefaultNetworkCapabilitiesForUser(userId);
        } catch (RemoteException e) {
            return null;
        }
    }

    /**
     * Returns details about the Provisioning or currently active default data network. When
     * connected, this network is the default route for outgoing connections.
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ interface IConnectivityManager
    NetworkInfo[] getAllNetworkInfo();
    Network getNetworkForType(int networkType);
    Network[] getAllNetworks();
    NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId);

    NetworkInfo getProvisioningOrActiveNetworkInfo();

+8 −1
Original line number Diff line number Diff line
@@ -154,9 +154,16 @@ public final class NetworkCapabilities implements Parcelable {
     */
    public static final int NET_CAPABILITY_NOT_VPN        = 15;

    /**
     * Indicates that connectivity on this network was successfully validated. For example, for a
     * network with NET_CAPABILITY_INTERNET, it means that Internet connectivity was successfully
     * detected.
     * @hide
     */
    public static final int NET_CAPABILITY_VALIDATED      = 16;

    private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS;
    private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_NOT_VPN;
    private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_VALIDATED;

    /**
     * Adds the given capability to this {@code NetworkCapability} instance.
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public class QSTileHost implements QSTile.Host {
                    tile.userSwitch(newUserId);
                }
                mSecurity.onUserSwitched(newUserId);
                mNetwork.getAccessPointController().onUserSwitched(newUserId);
                mNetwork.onUserSwitched(newUserId);
                mObserver.register();
            }
        };
+1 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ public interface NetworkController {
    void addNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
    void removeNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
    void setWifiEnabled(boolean enabled);
    void onUserSwitched(int newUserId);
    AccessPointController getAccessPointController();
    MobileDataController getMobileDataController();

@@ -49,7 +50,6 @@ public interface NetworkController {
        void scanForAccessPoints();
        boolean connect(AccessPoint ap);
        boolean canConfigWifi();
        void onUserSwitched(int newUserId);

        public interface AccessPointCallback {
            void onAccessPointsChanged(AccessPoint[] accessPoints);
Loading