Make reportInetCondition revalidate if the report differs from our state

1. If reportInetCondition says the network is not working, and
   the network is already marked not validated, don't revalidate
   it. This was superfluous and should save battery.
2. If reportInetCondition says the network is working, and the
   network is not marked as validated, revalidated. This will
   allow us to get out of a validated state quickly based on app
   input (e.g., allowing GCM's exponential backoff timer to drive
   revalidation instead of our 10-minute timer).

Bug: 19258761
Bug: 19209043
Change-Id: Iaa4bac82d117ed1f4088dab106e6f6ce46b34bc3
This commit is contained in:
Lorenzo Colitti
2015-02-11 07:39:20 +09:00
parent 489eb043d7
commit 4e858cbafa

View File

@@ -2636,9 +2636,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
// 100 percent is full good, 0 is full bad.
public void reportInetCondition(int networkType, int percentage) {
if (percentage > 50) return; // don't handle good network reports
NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
if (nai != null) reportBadNetwork(nai.network);
if (nai == null) return;
boolean isGood = percentage > 50;
// Revalidate if the app report does not match our current validated state.
if (isGood != nai.lastValidated) {
// Make the message logged by reportBadNetwork below less confusing.
if (DBG && isGood) log("reportInetCondition: type=" + networkType + " ok, revalidate");
reportBadNetwork(nai.network);
}
}
public void reportBadNetwork(Network network) {