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

Commit 4e486871 authored by Robin Lee's avatar Robin Lee Committed by The Android Automerger
Browse files

Start VPN as early as possible during startup

- Switch from USER_STARTING to USER_STARTED which is the foreground
  version of the broadcast

- Set the new VPN network as CONNECTING initially to avoid spamming
  apps with useless notifications ahead of the network being fully
  available

Bug: 26694104
Fix: 28335277
Change-Id: I31d5260dda62ff440c31c44eb0aa5c891e2717e5
parent b0182e9f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -741,7 +741,7 @@ public class ConnectivityService extends IConnectivityManager.Stub

        //set up the listener for user state for creating user VPNs
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_USER_STARTING);
        intentFilter.addAction(Intent.ACTION_USER_STARTED);
        intentFilter.addAction(Intent.ACTION_USER_STOPPED);
        intentFilter.addAction(Intent.ACTION_USER_ADDED);
        intentFilter.addAction(Intent.ACTION_USER_REMOVED);
@@ -3699,7 +3699,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
            final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
            if (userId == UserHandle.USER_NULL) return;

            if (Intent.ACTION_USER_STARTING.equals(action)) {
            if (Intent.ACTION_USER_STARTED.equals(action)) {
                onUserStart(userId);
            } else if (Intent.ACTION_USER_STOPPED.equals(action)) {
                onUserStop(userId);
+4 −2
Original line number Diff line number Diff line
@@ -449,8 +449,7 @@ public class Vpn {
            mNetworkCapabilities.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
        }

        mNetworkInfo.setIsAvailable(true);
        mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, null);
        mNetworkInfo.setDetailedState(DetailedState.CONNECTING, null, null);

        NetworkMisc networkMisc = new NetworkMisc();
        networkMisc.allowBypass = mConfig.allowBypass;
@@ -485,6 +484,9 @@ public class Vpn {
            }
        }
        mNetworkAgent.addUidRanges(mVpnUsers.toArray(new UidRange[mVpnUsers.size()]));

        mNetworkInfo.setIsAvailable(true);
        updateState(DetailedState.CONNECTED, "agentConnect");
    }

    private boolean canHaveRestrictedProfile(int userId) {