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

Commit 1d5285fb authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Remove the unused parameters" into main am: 3f7cafba am: 5342b256 am: 79840c11

parents d90c2784 79840c11
Loading
Loading
Loading
Loading
+1 −9
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import android.content.pm.UserInfo;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager;
import android.net.INetd;
import android.net.INetd;
import android.net.IVpnManager;
import android.net.IVpnManager;
import android.net.LinkProperties;
import android.net.Network;
import android.net.Network;
import android.net.NetworkStack;
import android.net.NetworkStack;
import android.net.UnderlyingNetworkInfo;
import android.net.UnderlyingNetworkInfo;
@@ -437,16 +436,9 @@ public class VpnManagerService extends IVpnManager.Stub {
            throw new UnsupportedOperationException("Legacy VPN is deprecated");
            throw new UnsupportedOperationException("Legacy VPN is deprecated");
        }
        }
        int user = UserHandle.getUserId(mDeps.getCallingUid());
        int user = UserHandle.getUserId(mDeps.getCallingUid());
        // Note that if the caller is not system (uid >= Process.FIRST_APPLICATION_UID),
        // the code might not work well since getActiveNetwork might return null if the uid is
        // blocked by NetworkPolicyManagerService.
        final LinkProperties egress = mCm.getLinkProperties(mCm.getActiveNetwork());
        if (egress == null) {
            throw new IllegalStateException("Missing active network connection");
        }
        synchronized (mVpns) {
        synchronized (mVpns) {
            throwIfLockdownEnabled();
            throwIfLockdownEnabled();
            mVpns.get(user).startLegacyVpn(profile, null /* underlying */, egress);
            mVpns.get(user).startLegacyVpn(profile);
        }
        }
    }
    }


+6 −8
Original line number Original line Diff line number Diff line
@@ -2549,15 +2549,14 @@ public class Vpn {
     * secondary thread to perform connection work, returning quickly.
     * secondary thread to perform connection work, returning quickly.
     *
     *
     * Should only be called to respond to Binder requests as this enforces caller permission. Use
     * Should only be called to respond to Binder requests as this enforces caller permission. Use
     * {@link #startLegacyVpnPrivileged(VpnProfile, Network, LinkProperties)} to skip the
     * {@link #startLegacyVpnPrivileged(VpnProfile)} to skip the
     * permission check only when the caller is trusted (or the call is initiated by the system).
     * permission check only when the caller is trusted (or the call is initiated by the system).
     */
     */
    public void startLegacyVpn(VpnProfile profile, @Nullable Network underlying,
    public void startLegacyVpn(VpnProfile profile) {
            LinkProperties egress) {
        enforceControlPermission();
        enforceControlPermission();
        final long token = Binder.clearCallingIdentity();
        final long token = Binder.clearCallingIdentity();
        try {
        try {
            startLegacyVpnPrivileged(profile, underlying, egress);
            startLegacyVpnPrivileged(profile);
        } finally {
        } finally {
            Binder.restoreCallingIdentity(token);
            Binder.restoreCallingIdentity(token);
        }
        }
@@ -2616,13 +2615,12 @@ public class Vpn {
    }
    }


    /**
    /**
     * Like {@link #startLegacyVpn(VpnProfile, Network, LinkProperties)}, but does not
     * Like {@link #startLegacyVpn(VpnProfile)}, but does not check permissions under
     * check permissions under the assumption that the caller is the system.
     * the assumption that the caller is the system.
     *
     *
     * Callers are responsible for checking permissions if needed.
     * Callers are responsible for checking permissions if needed.
     */
     */
    public void startLegacyVpnPrivileged(VpnProfile profileToStart,
    public void startLegacyVpnPrivileged(VpnProfile profileToStart) {
            @Nullable Network underlying, @NonNull LinkProperties egress) {
        final VpnProfile profile = profileToStart.clone();
        final VpnProfile profile = profileToStart.clone();
        UserInfo user = mUserManager.getUserInfo(mUserId);
        UserInfo user = mUserManager.getUserInfo(mUserId);
        if (user.isRestricted() || mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN,
        if (user.isRestricted() || mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN,
+1 −1
Original line number Original line Diff line number Diff line
@@ -208,7 +208,7 @@ public class LockdownVpnTracker {
                //    network is the system default. So, if the VPN  is up and underlying network
                //    network is the system default. So, if the VPN  is up and underlying network
                //    (e.g., wifi) disconnects, CS will inform apps that the VPN's capabilities have
                //    (e.g., wifi) disconnects, CS will inform apps that the VPN's capabilities have
                //    changed to match the new default network (e.g., cell).
                //    changed to match the new default network (e.g., cell).
                mVpn.startLegacyVpnPrivileged(mProfile, network, egressProp);
                mVpn.startLegacyVpnPrivileged(mProfile);
            } catch (IllegalStateException e) {
            } catch (IllegalStateException e) {
                mAcceptedEgressIface = null;
                mAcceptedEgressIface = null;
                Log.e(TAG, "Failed to start VPN", e);
                Log.e(TAG, "Failed to start VPN", e);
+3 −3
Original line number Original line Diff line number Diff line
@@ -221,7 +221,7 @@ public class LockdownVpnTrackerTest {
        callCallbacksForNetworkConnect(defaultCallback, mNetwork);
        callCallbacksForNetworkConnect(defaultCallback, mNetwork);


        // Vpn is starting
        // Vpn is starting
        verify(mVpn).startLegacyVpnPrivileged(mProfile, mNetwork, TEST_CELL_LP);
        verify(mVpn).startLegacyVpnPrivileged(mProfile);
        verify(mNotificationManager).notify(any(), eq(SystemMessage.NOTE_VPN_STATUS),
        verify(mNotificationManager).notify(any(), eq(SystemMessage.NOTE_VPN_STATUS),
                argThat(notification -> isExpectedNotification(notification,
                argThat(notification -> isExpectedNotification(notification,
                        R.string.vpn_lockdown_connecting, R.drawable.vpn_disconnected)));
                        R.string.vpn_lockdown_connecting, R.drawable.vpn_disconnected)));
@@ -242,7 +242,7 @@ public class LockdownVpnTrackerTest {
        // LockdownVpnTracker#handleStateChangedLocked. This is a bug.
        // LockdownVpnTracker#handleStateChangedLocked. This is a bug.
        // TODO: consider fixing this.
        // TODO: consider fixing this.
        verify(mVpn, never()).stopVpnRunnerPrivileged();
        verify(mVpn, never()).stopVpnRunnerPrivileged();
        verify(mVpn, never()).startLegacyVpnPrivileged(any(), any(), any());
        verify(mVpn, never()).startLegacyVpnPrivileged(any());
        verify(mNotificationManager, never()).cancel(any(), eq(SystemMessage.NOTE_VPN_STATUS));
        verify(mNotificationManager, never()).cancel(any(), eq(SystemMessage.NOTE_VPN_STATUS));
    }
    }


@@ -302,7 +302,7 @@ public class LockdownVpnTrackerTest {


        // Vpn is restarted.
        // Vpn is restarted.
        verify(mVpn).stopVpnRunnerPrivileged();
        verify(mVpn).stopVpnRunnerPrivileged();
        verify(mVpn).startLegacyVpnPrivileged(mProfile, mNetwork2, wifiLp);
        verify(mVpn).startLegacyVpnPrivileged(mProfile);
        verify(mNotificationManager, never()).cancel(any(), eq(SystemMessage.NOTE_VPN_STATUS));
        verify(mNotificationManager, never()).cancel(any(), eq(SystemMessage.NOTE_VPN_STATUS));
        verify(mNotificationManager).notify(any(), eq(SystemMessage.NOTE_VPN_STATUS),
        verify(mNotificationManager).notify(any(), eq(SystemMessage.NOTE_VPN_STATUS),
                argThat(notification -> isExpectedNotification(notification,
                argThat(notification -> isExpectedNotification(notification,