Search in sources :

Example 86 with VpnProfile

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

the class VpnTests method testL2tpIpsecRsaConnection.

/**
 * Test L2TP/IPSec RSA VPN connection
 */
@LargeTest
public void testL2tpIpsecRsaConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_L2TP_IPSEC_RSA);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    if (DEBUG) {
        printVpnProfile(vpnProfile);
    }
    String certFile = curVpnInfo.getCertificateFile();
    String password = curVpnInfo.getPassword();
    installCertificatesFromFile(vpnProfile, certFile, password);
    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 87 with VpnProfile

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

the class VpnTests method testIpsecHybridRsaConnection.

/**
 * Test IPSec Hybrid RSA VPN connection
 */
@LargeTest
public void testIpsecHybridRsaConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_IPSEC_HYBRID_RSA);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    if (DEBUG) {
        printVpnProfile(vpnProfile);
    }
    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 88 with VpnProfile

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

the class ConfigDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();
    VpnProfile profile = (VpnProfile) args.getParcelable(ARG_PROFILE);
    boolean editing = args.getBoolean(ARG_EDITING);
    boolean exists = args.getBoolean(ARG_EXISTS);
    final Dialog dialog = new ConfigDialog(getActivity(), this, profile, editing, exists);
    dialog.setOnShowListener(this);
    return dialog;
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) Bundle(android.os.Bundle) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog)

Example 89 with VpnProfile

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

the class VpnSettings method onPreferenceClick.

@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference instanceof LegacyVpnPreference) {
        LegacyVpnPreference pref = (LegacyVpnPreference) preference;
        VpnProfile profile = pref.getProfile();
        if (mConnectedLegacyVpn != null && profile.key.equals(mConnectedLegacyVpn.key) && mConnectedLegacyVpn.state == LegacyVpnInfo.STATE_CONNECTED) {
            try {
                mConnectedLegacyVpn.intent.send();
                return true;
            } catch (Exception e) {
                Log.w(LOG_TAG, "Starting config intent failed", e);
            }
        }
        ConfigDialogFragment.show(this, profile, false, /* editing */
        true);
        return true;
    } else if (preference instanceof AppPreference) {
        AppPreference pref = (AppPreference) preference;
        boolean connected = (pref.getState() == AppPreference.STATE_CONNECTED);
        if (!connected) {
            try {
                UserHandle user = UserHandle.of(pref.getUserId());
                Context userContext = getActivity().createPackageContextAsUser(getActivity().getPackageName(), 0, /* flags */
                user);
                PackageManager pm = userContext.getPackageManager();
                Intent appIntent = pm.getLaunchIntentForPackage(pref.getPackageName());
                if (appIntent != null) {
                    userContext.startActivityAsUser(appIntent, user);
                    return true;
                }
            } catch (PackageManager.NameNotFoundException nnfe) {
                Log.w(LOG_TAG, "VPN provider does not exist: " + pref.getPackageName(), nnfe);
            }
        }
        // Already connected or no launch intent available - show an info dialog
        PackageInfo pkgInfo = pref.getPackageInfo();
        AppDialogFragment.show(this, pkgInfo, pref.getLabel(), false, /* editing */
        connected);
        return true;
    }
    return false;
}
Also used : Context(android.content.Context) VpnProfile(com.android.internal.net.VpnProfile) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) UserHandle(android.os.UserHandle) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 90 with VpnProfile

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

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)

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