diff options
author | Jeff Davidson <jpd@google.com> | 2014-08-22 13:05:43 -0700 |
---|---|---|
committer | Jeff Davidson <jpd@google.com> | 2014-08-22 17:06:37 -0700 |
commit | 90b1b9f985a91fb54254705515f822b09c68ac26 (patch) | |
tree | 60a8c7c53481fa84aa26663d6a76221fdf444379 /services | |
parent | 8288c5b821532281d87f9ef881018074d2b3a327 (diff) | |
download | frameworks_base-90b1b9f985a91fb54254705515f822b09c68ac26.zip frameworks_base-90b1b9f985a91fb54254705515f822b09c68ac26.tar.gz frameworks_base-90b1b9f985a91fb54254705515f822b09c68ac26.tar.bz2 |
Restore legacy VPN stats dialog.
Was originally removed in ag/522961, but restoring to keep legacy VPN
behavior the same from within VpnSettings. This dialog is only
accesible from VpnSettings and so should only ever be shown for legacy
VPNs.
Bug: 17164793
Change-Id: I06c4e136e1023b8f84edfd15a15264d2e41d325b
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/connectivity/Vpn.java | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 69caab9..94aa421 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -22,6 +22,7 @@ import static android.system.OsConstants.AF_INET6; import android.app.AppGlobals; import android.app.AppOpsManager; +import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -105,6 +106,7 @@ public class Vpn { private boolean mAllowIPv6; private Connection mConnection; private LegacyVpnRunner mLegacyVpnRunner; + private PendingIntent mStatusIntent; private volatile boolean mEnableTeardown = true; private final IConnectivityManager mConnService; private final INetworkManagementService mNetd; @@ -237,6 +239,7 @@ public class Vpn { // Reset the interface. if (mInterface != null) { + mStatusIntent = null; agentDisconnect(); jniReset(mInterface); mInterface = null; @@ -567,17 +570,20 @@ public class Vpn { // add the user mVpnUsers.add(UidRange.createForUser(user)); + + prepareStatusIntent(); } private void removeVpnUserLocked(int user) { - if (!isRunningLocked()) { - throw new IllegalStateException("VPN is not active"); - } - UidRange uidRange = UidRange.createForUser(user); - if (mNetworkAgent != null) { - mNetworkAgent.removeUidRanges(new UidRange[] { uidRange }); - } - mVpnUsers.remove(uidRange); + if (!isRunningLocked()) { + throw new IllegalStateException("VPN is not active"); + } + UidRange uidRange = UidRange.createForUser(user); + if (mNetworkAgent != null) { + mNetworkAgent.removeUidRanges(new UidRange[] { uidRange }); + } + mVpnUsers.remove(uidRange); + mStatusIntent = null; } private void onUserAdded(int userId) { @@ -645,6 +651,7 @@ public class Vpn { public void interfaceRemoved(String interfaze) { synchronized (Vpn.this) { if (interfaze.equals(mInterface) && jniCheck(interfaze) == 0) { + mStatusIntent = null; mVpnUsers = null; mInterface = null; if (mConnection != null) { @@ -702,6 +709,15 @@ public class Vpn { } } + private void prepareStatusIntent() { + final long token = Binder.clearCallingIdentity(); + try { + mStatusIntent = VpnConfig.getIntentForStatusPanel(mContext); + } finally { + Binder.restoreCallingIdentity(token); + } + } + public synchronized boolean addAddress(String address, int prefixLength) { if (Binder.getCallingUid() != mOwnerUID || mInterface == null || mNetworkAgent == null) { return false; @@ -911,6 +927,9 @@ public class Vpn { final LegacyVpnInfo info = new LegacyVpnInfo(); info.key = mConfig.user; info.state = LegacyVpnInfo.stateFromNetworkInfo(mNetworkInfo); + if (mNetworkInfo.isConnected()) { + info.intent = mStatusIntent; + } return info; } |