Search in sources :

Example 76 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class VpnTests method testL2tpIpsecPskConnection.

/**
 * Test L2TP/IPSec PSK VPN connection
 */
@LargeTest
public void testL2tpIpsecPskConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_L2TP_IPSEC_PSK);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    connect(vpnProfile);
    validateVpnConnection(vpnProfile);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 77 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class PreferenceListTest method testDisconnectedLegacyVpnShown.

@SmallTest
public void testDisconnectedLegacyVpnShown() {
    final VpnProfile vpnProfile = new VpnProfile("test-disconnected");
    final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
    updater.legacyVpns(/* vpnProfiles */
    Collections.<VpnProfile>singletonList(vpnProfile), /* connectedLegacyVpns */
    Collections.<String, LegacyVpnInfo>emptyMap(), /* lockdownVpnKey */
    null);
    updater.run();
    verify(mSettings, times(1)).findOrCreatePreference(any(VpnProfile.class), eq(true));
    assertEquals(1, mLegacyMocks.size());
    assertEquals(0, mAppMocks.size());
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) VpnSettings(com.android.settings.vpn2.VpnSettings) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 78 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class PreferenceListTest method testConnectedLegacyVpnShownIfDeleted.

@SmallTest
public void testConnectedLegacyVpnShownIfDeleted() {
    final LegacyVpnInfo connectedLegacyVpn = new LegacyVpnInfo();
    connectedLegacyVpn.key = "test-connected";
    final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
    updater.legacyVpns(/* vpnProfiles */
    Collections.<VpnProfile>emptyList(), /* connectedLegacyVpns */
    new HashMap<String, LegacyVpnInfo>() {

        {
            put(connectedLegacyVpn.key, connectedLegacyVpn);
        }
    }, /* lockdownVpnKey */
    null);
    updater.run();
    verify(mSettings, times(1)).findOrCreatePreference(any(VpnProfile.class), eq(false));
    assertEquals(1, mLegacyMocks.size());
    assertEquals(0, mAppMocks.size());
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) VpnSettings(com.android.settings.vpn2.VpnSettings) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 79 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class VpnSettings method handleMessage.

@Override
@WorkerThread
public boolean handleMessage(Message message) {
    // Return if activity has been recycled
    final Activity activity = getActivity();
    if (activity == null) {
        return true;
    }
    final Context context = activity.getApplicationContext();
    // Run heavy RPCs before switching to UI thread
    final List<VpnProfile> vpnProfiles = loadVpnProfiles(mKeyStore);
    final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */
    true);
    final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
    final Set<AppVpnInfo> connectedAppVpns = getConnectedAppVpns();
    final Set<AppVpnInfo> alwaysOnAppVpnInfos = getAlwaysOnAppVpnInfos();
    final String lockdownVpnKey = VpnUtils.getLockdownVpn();
    // Refresh list of VPNs
    activity.runOnUiThread(new UpdatePreferences(this).legacyVpns(vpnProfiles, connectedLegacyVpns, lockdownVpnKey).appVpns(vpnApps, connectedAppVpns, alwaysOnAppVpnInfos));
    synchronized (this) {
        if (mUpdater != null) {
            mUpdater.removeMessages(RESCAN_MESSAGE);
            mUpdater.sendEmptyMessageDelayed(RESCAN_MESSAGE, RESCAN_INTERVAL_MS);
        }
    }
    return true;
}
Also used : Context(android.content.Context) VpnProfile(com.android.internal.net.VpnProfile) Activity(android.app.Activity) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) WorkerThread(android.annotation.WorkerThread)

Example 80 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class ConfigDialog method updateUiControls.

/**
 * Updates the UI according to the current configuration entered by the user.
 *
 * These include:
 * "Always-on VPN" checkbox
 * Reason for "Always-on VPN" being disabled, when necessary
 * "Save account information" checkbox
 * "Save" and "Connect" buttons
 */
private void updateUiControls() {
    VpnProfile profile = getProfile();
    // Always-on VPN
    if (profile.isValidLockdownProfile()) {
        mAlwaysOnVpn.setEnabled(true);
        mAlwaysOnInvalidReason.setVisibility(View.GONE);
    } else {
        mAlwaysOnVpn.setChecked(false);
        mAlwaysOnVpn.setEnabled(false);
        if (!profile.isTypeValidForLockdown()) {
            mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_type);
        } else if (!profile.isServerAddressNumeric()) {
            mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_server);
        } else if (!profile.hasDns()) {
            mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_no_dns);
        } else if (!profile.areDnsAddressesNumeric()) {
            mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_dns);
        } else {
            mAlwaysOnInvalidReason.setText(R.string.vpn_always_on_invalid_reason_other);
        }
        mAlwaysOnInvalidReason.setVisibility(View.VISIBLE);
    }
    // Save account information
    if (mAlwaysOnVpn.isChecked()) {
        mSaveLogin.setChecked(true);
        mSaveLogin.setEnabled(false);
    } else {
        mSaveLogin.setChecked(mProfile.saveLogin);
        mSaveLogin.setEnabled(true);
    }
    // Save or Connect button
    getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(validate(mEditing));
}
Also used : VpnProfile(com.android.internal.net.VpnProfile)

Aggregations

VpnProfile (com.android.internal.net.VpnProfile)119 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)63 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 SmallTest (android.test.suitebuilder.annotation.SmallTest)21 VpnSettings (com.android.settings.vpn2.VpnSettings)15 Context (android.content.Context)14 Bundle (android.os.Bundle)14 RemoteException (android.os.RemoteException)13 WorkerThread (android.annotation.WorkerThread)7 Activity (android.app.Activity)7 Dialog (android.app.Dialog)7 Intent (android.content.Intent)7 PackageInfo (android.content.pm.PackageInfo)7 PackageManager (android.content.pm.PackageManager)7 UserHandle (android.os.UserHandle)7 KeyStore (android.security.KeyStore)6 LockdownVpnTracker (com.android.server.net.LockdownVpnTracker)6 AlertDialog (android.app.AlertDialog)5 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5 Vpn (com.android.server.connectivity.Vpn)5