Fields Summary |
---|
private static final String | TAG |
private static final boolean | DEBUG |
private static final android.net.NetworkRequest | REQUEST |
private static final int | NO_NETWORK |
private final android.content.Context | mContext |
private final android.net.ConnectivityManager | mConnectivityManager |
private final android.net.IConnectivityManager | mConnectivityService |
private final android.app.admin.DevicePolicyManager | mDevicePolicyManager |
private final ArrayList | mCallbacks |
private com.android.internal.net.VpnConfig | mVpnConfig |
private String | mVpnName |
private int | mCurrentVpnNetworkId |
private int | mCurrentUserId |
private final android.net.ConnectivityManager.NetworkCallback | mNetworkCallback |
Methods Summary |
---|
public void | addCallback(SecurityControllerCallback callback)
if (callback == null || mCallbacks.contains(callback)) return;
if (DEBUG) Log.d(TAG, "addCallback " + callback);
mCallbacks.add(callback);
|
public void | disconnectFromVpn()
try {
if (isLegacyVpn()) {
mConnectivityService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN);
} else {
// Prevent this app from initiating VPN connections in the future without user
// intervention.
mConnectivityService.setVpnPackageAuthorization(false);
mConnectivityService.prepareVpn(mVpnConfig.user, VpnConfig.LEGACY_VPN);
}
} catch (Exception e) {
Log.e(TAG, "Unable to disconnect from VPN", e);
}
|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
pw.println("SecurityController state:");
pw.print(" mCurrentVpnNetworkId="); pw.println(mCurrentVpnNetworkId);
pw.print(" mVpnConfig="); pw.println(mVpnConfig);
pw.print(" mVpnName="); pw.println(mVpnName);
|
private void | fireCallbacks()
for (SecurityControllerCallback callback : mCallbacks) {
callback.onStateChanged();
}
|
public java.lang.String | getDeviceOwnerName()
return mDevicePolicyManager.getDeviceOwnerName();
|
public java.lang.String | getLegacyVpnName()
return mVpnConfig.session;
|
public java.lang.String | getProfileOwnerName()
return mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId);
|
public java.lang.String | getVpnApp()
return mVpnName;
|
public boolean | hasDeviceOwner()
return !TextUtils.isEmpty(mDevicePolicyManager.getDeviceOwner());
|
public boolean | hasProfileOwner()
return !TextUtils.isEmpty(mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId));
|
public boolean | isLegacyVpn()
return mVpnConfig.legacy;
|
public boolean | isVpnEnabled()
return mCurrentVpnNetworkId != NO_NETWORK;
|
public void | onUserSwitched(int newUserId)
mCurrentUserId = newUserId;
fireCallbacks();
|
public void | removeCallback(SecurityControllerCallback callback)
if (callback == null) return;
if (DEBUG) Log.d(TAG, "removeCallback " + callback);
mCallbacks.remove(callback);
|
private void | setCurrentNetid(int netId)
if (netId != mCurrentVpnNetworkId) {
mCurrentVpnNetworkId = netId;
updateState();
fireCallbacks();
}
|
private void | updateState()
try {
mVpnConfig = mConnectivityService.getVpnConfig();
if (mVpnConfig != null && !mVpnConfig.legacy) {
mVpnName = VpnConfig.getVpnLabel(mContext, mVpnConfig.user).toString();
}
} catch (RemoteException | NameNotFoundException e) {
Log.w(TAG, "Unable to get current VPN", e);
}
|