Search in sources :

Example 6 with LegacyVpnInfo

use of com.android.internal.net.LegacyVpnInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConfigDialogFragment method disconnect.

private void disconnect(VpnProfile profile) {
    try {
        LegacyVpnInfo connected = mService.getLegacyVpnInfo(UserHandle.myUserId());
        if (connected != null && profile.key.equals(connected.key)) {
            VpnUtils.clearLockdownVpn(getContext());
            mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, UserHandle.myUserId());
        }
    } catch (RemoteException e) {
        Log.e(TAG, "Failed to disconnect", e);
    }
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) RemoteException(android.os.RemoteException)

Example 7 with LegacyVpnInfo

use of com.android.internal.net.LegacyVpnInfo in project android_frameworks_base by crdroidandroid.

the class Vpn method getLegacyVpnInfoPrivileged.

/**
     * Return the information of the current ongoing legacy VPN.
     * Callers are responsible for checking permissions if needed.
     */
public synchronized LegacyVpnInfo getLegacyVpnInfoPrivileged() {
    if (mLegacyVpnRunner == null)
        return null;
    final LegacyVpnInfo info = new LegacyVpnInfo();
    info.key = mConfig.user;
    info.state = LegacyVpnInfo.stateFromNetworkInfo(mNetworkInfo);
    if (mNetworkInfo.isConnected()) {
        info.intent = mStatusIntent;
    }
    return info;
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo)

Example 8 with LegacyVpnInfo

use of com.android.internal.net.LegacyVpnInfo in project android_frameworks_base by ParanoidAndroid.

the class Vpn method getLegacyVpnInfo.

/**
     * Return the information of the current ongoing legacy VPN.
     */
public synchronized LegacyVpnInfo getLegacyVpnInfo() {
    // Check if the caller is authorized.
    enforceControlPermission();
    if (mLegacyVpnRunner == null)
        return null;
    final LegacyVpnInfo info = new LegacyVpnInfo();
    info.key = mLegacyVpnRunner.mConfig.user;
    info.state = LegacyVpnInfo.stateFromNetworkInfo(mNetworkInfo);
    if (mNetworkInfo.isConnected()) {
        info.intent = mStatusIntent;
    }
    return info;
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo)

Example 9 with LegacyVpnInfo

use of com.android.internal.net.LegacyVpnInfo in project android_frameworks_base by AOSPA.

the class Vpn method getLegacyVpnInfoPrivileged.

/**
     * Return the information of the current ongoing legacy VPN.
     * Callers are responsible for checking permissions if needed.
     */
public synchronized LegacyVpnInfo getLegacyVpnInfoPrivileged() {
    if (mLegacyVpnRunner == null)
        return null;
    final LegacyVpnInfo info = new LegacyVpnInfo();
    info.key = mConfig.user;
    info.state = LegacyVpnInfo.stateFromNetworkInfo(mNetworkInfo);
    if (mNetworkInfo.isConnected()) {
        info.intent = mStatusIntent;
    }
    return info;
}
Also used : LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo)

Example 10 with LegacyVpnInfo

use of com.android.internal.net.LegacyVpnInfo in project android_frameworks_base by AOSPA.

the class SecurityControllerImpl method updateState.

private void updateState() {
    // Find all users with an active VPN
    SparseArray<VpnConfig> vpns = new SparseArray<>();
    try {
        for (UserInfo user : mUserManager.getUsers()) {
            VpnConfig cfg = mConnectivityManagerService.getVpnConfig(user.id);
            if (cfg == null) {
                continue;
            } else if (cfg.legacy) {
                // Legacy VPNs should do nothing if the network is disconnected. Third-party
                // VPN warnings need to continue as traffic can still go to the app.
                LegacyVpnInfo legacyVpn = mConnectivityManagerService.getLegacyVpnInfo(user.id);
                if (legacyVpn == null || legacyVpn.state != LegacyVpnInfo.STATE_CONNECTED) {
                    continue;
                }
            }
            vpns.put(user.id, cfg);
        }
    } catch (RemoteException rme) {
        // Roll back to previous state
        Log.e(TAG, "Unable to list active VPNs", rme);
        return;
    }
    mCurrentVpns = vpns;
}
Also used : SparseArray(android.util.SparseArray) VpnConfig(com.android.internal.net.VpnConfig) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

Aggregations

LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)14 RemoteException (android.os.RemoteException)6 UserInfo (android.content.pm.UserInfo)5 SparseArray (android.util.SparseArray)5 VpnConfig (com.android.internal.net.VpnConfig)5 Bundle (android.os.Bundle)1 InstrumentationTestRunner (android.test.InstrumentationTestRunner)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1