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

Commit a49cea63 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 033168b1: Merge "Lockdown VPN handles its own connection teardown." into jb-mr2-dev

* commit '033168b1':
  Lockdown VPN handles its own connection teardown.
parents 334c04e2 033168b1
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -95,7 +95,8 @@ public class Vpn extends BaseNetworkStateTracker {
    private Connection mConnection;
    private LegacyVpnRunner mLegacyVpnRunner;
    private PendingIntent mStatusIntent;
    private boolean mEnableNotif = true;
    private volatile boolean mEnableNotif = true;
    private volatile boolean mEnableTeardown = true;
    private final IConnectivityManager mConnService;

    public Vpn(Context context, VpnCallback callback, INetworkManagementService netService,
@@ -113,10 +114,23 @@ public class Vpn extends BaseNetworkStateTracker {
        }
    }

    /**
     * Set if this object is responsible for showing its own notifications. When
     * {@code false}, notifications are handled externally by someone else.
     */
    public void setEnableNotifications(boolean enableNotif) {
        mEnableNotif = enableNotif;
    }

    /**
     * Set if this object is responsible for watching for {@link NetworkInfo}
     * teardown. When {@code false}, teardown is handled externally by someone
     * else.
     */
    public void setEnableTeardown(boolean enableTeardown) {
        mEnableTeardown = enableTeardown;
    }

    @Override
    protected void startMonitoringInternal() {
        // Ignored; events are sent through callbacks for now
@@ -647,6 +661,8 @@ public class Vpn extends BaseNetworkStateTracker {
        private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (!mEnableTeardown) return;

                if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                    if (intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE,
                            ConnectivityManager.TYPE_NONE) == mOuterConnection.get()) {
@@ -688,7 +704,6 @@ public class Vpn extends BaseNetworkStateTracker {
            IntentFilter filter = new IntentFilter();
            filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
            mContext.registerReceiver(mBroadcastReceiver, filter);

        }

        public void check(String interfaze) {
+6 −1
Original line number Diff line number Diff line
@@ -128,7 +128,10 @@ public class LockdownVpnTracker {
            mAcceptedEgressIface = null;
            mVpn.stopLegacyVpn();
        }
        if (egressDisconnected) return;
        if (egressDisconnected) {
            hideNotification();
            return;
        }

        final int egressType = egressInfo.getType();
        if (vpnInfo.getDetailedState() == DetailedState.FAILED) {
@@ -192,6 +195,7 @@ public class LockdownVpnTracker {
        Slog.d(TAG, "initLocked()");

        mVpn.setEnableNotifications(false);
        mVpn.setEnableTeardown(false);

        final IntentFilter resetFilter = new IntentFilter(ACTION_LOCKDOWN_RESET);
        mContext.registerReceiver(mResetReceiver, resetFilter, CONNECTIVITY_INTERNAL, null);
@@ -235,6 +239,7 @@ public class LockdownVpnTracker {

        mContext.unregisterReceiver(mResetReceiver);
        mVpn.setEnableNotifications(true);
        mVpn.setEnableTeardown(true);
    }

    public void reset() {