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

Commit 98801e9f authored by Victor Chang's avatar Victor Chang Committed by Android (Google) Code Review
Browse files

Merge "Finish ConfirmDialog when another vpn app is always-on" into nyc-dev

parents 76609106 aa2e0234
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
        package="com.android.vpndialogs">

    <uses-permission android:name="android.permission.CONTROL_VPN" />
    <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />

    <application android:label="VpnDialogs"
            android:allowBackup="false" >
+16 −0
Original line number Diff line number Diff line
@@ -60,6 +60,12 @@ public class ConfirmDialog extends AlertActivity
            finish();
            return;
        }
        final String alwaysOnVpnPackage = getAlwaysOnVpnPackage();
        // Can't prepare new vpn app when another vpn is always-on
        if (alwaysOnVpnPackage != null && !alwaysOnVpnPackage.equals(mPackage)) {
            finish();
            return;
        }
        View view = View.inflate(this, R.layout.confirm, null);
        ((TextView) view.findViewById(R.id.warning)).setText(
                Html.fromHtml(getString(R.string.warning, getVpnLabel()),
@@ -76,6 +82,16 @@ public class ConfirmDialog extends AlertActivity
        button.setFilterTouchesWhenObscured(true);
    }

    private String getAlwaysOnVpnPackage() {
        try {
           return mService.getAlwaysOnVpnPackage(UserHandle.myUserId());
        } catch (RemoteException e) {
            Log.e(TAG, "fail to call getAlwaysOnVpnPackage", e);
            // Fallback to null to show the dialog
            return null;
        }
    }

    private boolean prepareVpn() {
        try {
            return mService.prepareVpn(mPackage, null, UserHandle.myUserId());