Merge "Listen for network disconnect." into jb-mr2-dev
This commit is contained in:
commit
665c912a4c
2 changed files with 18 additions and 1 deletions
|
|
@ -129,4 +129,6 @@ interface IConnectivityManager
|
|||
void captivePortalCheckComplete(in NetworkInfo info);
|
||||
|
||||
void supplyMessenger(int networkType, in Messenger messenger);
|
||||
|
||||
int findConnectionTypeForIface(in String iface);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
mTethering.getTetherableBluetoothRegexs().length != 0) &&
|
||||
mTethering.getUpstreamIfaceTypes().length != 0);
|
||||
|
||||
mVpn = new Vpn(mContext, mVpnCallback, mNetd);
|
||||
mVpn = new Vpn(mContext, mVpnCallback, mNetd, this);
|
||||
mVpn.startMonitoring(mContext, mTrackerHandler);
|
||||
|
||||
mClat = new Nat464Xlat(mContext, mNetd, this, mTrackerHandler);
|
||||
|
|
@ -3448,4 +3448,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
mNetTrackers[networkType].supplyMessenger(messenger);
|
||||
}
|
||||
}
|
||||
|
||||
public int findConnectionTypeForIface(String iface) {
|
||||
enforceConnectivityInternalPermission();
|
||||
|
||||
if (TextUtils.isEmpty(iface)) return ConnectivityManager.TYPE_NONE;
|
||||
for (NetworkStateTracker tracker : mNetTrackers) {
|
||||
if (tracker != null) {
|
||||
LinkProperties lp = tracker.getLinkProperties();
|
||||
if (lp != null && iface.equals(lp.getInterfaceName())) {
|
||||
return tracker.getNetworkInfo().getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConnectivityManager.TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue