Log upstream network suspend/resume callbacks
Also log signal strength while we're at it:
2017-10-10T14:05:00.968 - [UpstreamNetworkMonitor] preferred upstream type: WIFI
2017-10-10T14:06:07.654 - [UpstreamNetworkMonitor] upstream network signal strength: -62 -> -67
2017-10-10T14:06:13.704 - [UpstreamNetworkMonitor] upstream network signal strength: -67 -> -64
Test: as follows
- built
- flashed
- booted
- runtest frameworks-net passes
Bug: 29337859
Bug: 32163131
Bug: 64976634
Bug: 67396342
Merged-In: I9121798bba0be9dcdf1e45d39c092020620fa53b
Merged-In: I1d3420380691efd886315275598134b98f4041ed
Change-Id: Id6e143edc9f5b0256aa637643680f6c8dce70d90
(cherry picked from commit 60caf7d291)
This commit is contained in:
@@ -1371,6 +1371,7 @@ public class Tethering extends BaseNetworkObserver {
|
||||
sendMessageDelayed(CMD_RETRY_UPSTREAM, UPSTREAM_SETTLE_TIME_MS);
|
||||
}
|
||||
}
|
||||
mUpstreamNetworkMonitor.setCurrentUpstream((ns != null) ? ns.network : null);
|
||||
setUpstreamNetwork(ns);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,10 @@ public class UpstreamNetworkMonitor {
|
||||
private NetworkCallback mDefaultNetworkCallback;
|
||||
private NetworkCallback mMobileNetworkCallback;
|
||||
private boolean mDunRequired;
|
||||
private Network mCurrentDefault;
|
||||
// The current system default network (not really used yet).
|
||||
private Network mDefaultInternetNetwork;
|
||||
// The current upstream network used for tethering.
|
||||
private Network mTetheringUpstreamNetwork;
|
||||
|
||||
public UpstreamNetworkMonitor(Context ctx, StateMachine tgt, SharedLog log, int what) {
|
||||
mContext = ctx;
|
||||
@@ -130,10 +133,12 @@ public class UpstreamNetworkMonitor {
|
||||
|
||||
releaseCallback(mDefaultNetworkCallback);
|
||||
mDefaultNetworkCallback = null;
|
||||
mDefaultInternetNetwork = null;
|
||||
|
||||
releaseCallback(mListenAllCallback);
|
||||
mListenAllCallback = null;
|
||||
|
||||
mTetheringUpstreamNetwork = null;
|
||||
mNetworkMap.clear();
|
||||
}
|
||||
|
||||
@@ -207,7 +212,7 @@ public class UpstreamNetworkMonitor {
|
||||
break;
|
||||
default:
|
||||
/* If we've found an active upstream connection that's not DUN/HIPRI
|
||||
* we should stop any outstanding DUN/HIPRI start requests.
|
||||
* we should stop any outstanding DUN/HIPRI requests.
|
||||
*
|
||||
* If we found NONE we don't want to do this as we want any previous
|
||||
* requests to keep trying to bring up something we can use.
|
||||
@@ -219,6 +224,10 @@ public class UpstreamNetworkMonitor {
|
||||
return typeStatePair.ns;
|
||||
}
|
||||
|
||||
public void setCurrentUpstream(Network upstream) {
|
||||
mTetheringUpstreamNetwork = upstream;
|
||||
}
|
||||
|
||||
public Set<IpPrefix> getLocalPrefixes() {
|
||||
return (Set<IpPrefix>) mLocalPrefixes.clone();
|
||||
}
|
||||
@@ -250,7 +259,7 @@ public class UpstreamNetworkMonitor {
|
||||
// These request*() calls can be deleted post oag/339444.
|
||||
return;
|
||||
}
|
||||
mCurrentDefault = network;
|
||||
mDefaultInternetNetwork = network;
|
||||
break;
|
||||
|
||||
case CALLBACK_MOBILE_REQUEST:
|
||||
@@ -302,6 +311,13 @@ public class UpstreamNetworkMonitor {
|
||||
network, newNc));
|
||||
}
|
||||
|
||||
// Log changes in upstream network signal strength, if available.
|
||||
if (network.equals(mTetheringUpstreamNetwork) && newNc.hasSignalStrength()) {
|
||||
final int newSignal = newNc.getSignalStrength();
|
||||
final String prevSignal = getSignalStrength(prev.networkCapabilities);
|
||||
mLog.logf("upstream network signal strength: %s -> %s", prevSignal, newSignal);
|
||||
}
|
||||
|
||||
mNetworkMap.put(network, new NetworkState(
|
||||
null, prev.linkProperties, newNc, network, null, null));
|
||||
// TODO: If sufficient information is available to select a more
|
||||
@@ -330,9 +346,21 @@ public class UpstreamNetworkMonitor {
|
||||
notifyTarget(EVENT_ON_LINKPROPERTIES, network);
|
||||
}
|
||||
|
||||
private void handleSuspended(int callbackType, Network network) {
|
||||
if (callbackType != CALLBACK_LISTEN_ALL) return;
|
||||
if (!network.equals(mTetheringUpstreamNetwork)) return;
|
||||
mLog.log("SUSPENDED current upstream: " + network);
|
||||
}
|
||||
|
||||
private void handleResumed(int callbackType, Network network) {
|
||||
if (callbackType != CALLBACK_LISTEN_ALL) return;
|
||||
if (!network.equals(mTetheringUpstreamNetwork)) return;
|
||||
mLog.log("RESUMED current upstream: " + network);
|
||||
}
|
||||
|
||||
private void handleLost(int callbackType, Network network) {
|
||||
if (callbackType == CALLBACK_TRACK_DEFAULT) {
|
||||
mCurrentDefault = null;
|
||||
mDefaultInternetNetwork = null;
|
||||
// Receiving onLost() for a default network does not necessarily
|
||||
// mean the network is gone. We wait for a separate notification
|
||||
// on either the LISTEN_ALL or MOBILE_REQUEST callbacks before
|
||||
@@ -401,8 +429,15 @@ public class UpstreamNetworkMonitor {
|
||||
recomputeLocalPrefixes();
|
||||
}
|
||||
|
||||
// TODO: Handle onNetworkSuspended();
|
||||
// TODO: Handle onNetworkResumed();
|
||||
@Override
|
||||
public void onNetworkSuspended(Network network) {
|
||||
handleSuspended(mCallbackType, network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworkResumed(Network network) {
|
||||
handleResumed(mCallbackType, network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLost(Network network) {
|
||||
@@ -467,4 +502,9 @@ public class UpstreamNetworkMonitor {
|
||||
|
||||
return prefixSet;
|
||||
}
|
||||
|
||||
private static String getSignalStrength(NetworkCapabilities nc) {
|
||||
if (nc == null || !nc.hasSignalStrength()) return "unknown";
|
||||
return Integer.toString(nc.getSignalStrength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,10 @@ public class SharedLog {
|
||||
record(Category.NONE, msg);
|
||||
}
|
||||
|
||||
public void logf(String fmt, Object... args) {
|
||||
log(String.format(fmt, args));
|
||||
}
|
||||
|
||||
public void mark(String msg) {
|
||||
record(Category.MARK, msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user