use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by SudaMod.
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);
}
use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by SudaMod.
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());
}
use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by SudaMod.
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());
}
use of com.android.internal.net.VpnProfile in project platform_packages_apps_Settings by BlissRoms.
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;
}
use of com.android.internal.net.VpnProfile in project platform_packages_apps_Settings by BlissRoms.
the class PreferenceListTest method testConnectedLegacyVpnShownExactlyOnce.
@SmallTest
public void testConnectedLegacyVpnShownExactlyOnce() {
final VpnProfile vpnProfile = new VpnProfile("test-no-duplicates");
final LegacyVpnInfo connectedLegacyVpn = new LegacyVpnInfo();
connectedLegacyVpn.key = new String(vpnProfile.key);
final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
updater.legacyVpns(/* vpnProfiles */
Collections.<VpnProfile>singletonList(vpnProfile), /* connectedLegacyVpns */
new HashMap<String, LegacyVpnInfo>() {
{
put(connectedLegacyVpn.key, connectedLegacyVpn);
}
}, /* lockdownVpnKey */
null);
updater.run();
final ArgumentMatcher<VpnProfile> equalsFake = new ArgumentMatcher<VpnProfile>() {
@Override
public boolean matchesObject(final Object arg) {
if (arg == vpnProfile)
return true;
if (arg == null)
return false;
return TextUtils.equals(((VpnProfile) arg).key, vpnProfile.key);
}
};
// The VPN profile should have been used to create a preference and set up at laest once
// with update=true to fill in all the fields.
verify(mSettings, atLeast(1)).findOrCreatePreference(argThat(equalsFake), eq(true));
// ...But no other VPN profile key should ever have been passed in.
verify(mSettings, never()).findOrCreatePreference(not(argThat(equalsFake)), anyBoolean());
// And so we should still have exactly 1 preference created.
assertEquals(1, mLegacyMocks.size());
assertEquals(0, mAppMocks.size());
}
Aggregations