diff options
author | Jeff Davidson <jpd@google.com> | 2014-08-23 00:55:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-23 00:55:11 +0000 |
commit | 79dbce8661f0ab3c345858b0bc69e0eae147dcde (patch) | |
tree | a202ebacfbd92a30db446f1cd4140cfbd3f3a103 /services | |
parent | 3edb23bc8e7ebc7c8b8daa6afae3d8df6324d8db (diff) | |
parent | 90b1b9f985a91fb54254705515f822b09c68ac26 (diff) | |
download | frameworks_base-79dbce8661f0ab3c345858b0bc69e0eae147dcde.zip frameworks_base-79dbce8661f0ab3c345858b0bc69e0eae147dcde.tar.gz frameworks_base-79dbce8661f0ab3c345858b0bc69e0eae147dcde.tar.bz2 |
Merge "Restore legacy VPN stats dialog." into lmp-dev
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; } |