Don't send NetworkMonitor bcast until systemReady

bug:16913951
Change-Id: I26c5c3353c2d8821452f81765875958d5b9d385b
This commit is contained in:
Robert Greenwalt
2014-08-13 13:43:32 -07:00
parent 8e083ec044
commit fb68f8fbe0
2 changed files with 20 additions and 0 deletions

View File

@@ -372,6 +372,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
*/
private static final int EVENT_EXPIRE_NET_TRANSITION_WAKELOCK = 24;
/**
* Used internally to indicate the system is ready.
*/
private static final int EVENT_SYSTEM_READY = 25;
/** Handler used for internal events. */
final private InternalHandler mHandler;
@@ -1437,6 +1442,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
final IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
mContext.registerReceiver(mUserPresentReceiver, filter);
}
mHandler.sendMessage(mHandler.obtainMessage(EVENT_SYSTEM_READY));
}
private BroadcastReceiver mUserPresentReceiver = new BroadcastReceiver() {
@@ -2270,6 +2277,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
handleReleaseNetworkRequest((NetworkRequest) msg.obj, msg.arg1);
break;
}
case EVENT_SYSTEM_READY: {
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
nai.networkMonitor.systemReady = true;
}
break;
}
}
}
}
@@ -4108,6 +4121,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
new NetworkInfo(networkInfo), new LinkProperties(linkProperties),
new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler,
networkMisc);
synchronized (this) {
nai.networkMonitor.systemReady = mSystemReady;
}
if (VDBG) log("registerNetworkAgent " + nai);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
}

View File

@@ -217,6 +217,8 @@ public class NetworkMonitor extends StateMachine {
private String mServer;
private boolean mIsCaptivePortalCheckEnabled = false;
public boolean systemReady = false;
private State mDefaultState = new DefaultState();
private State mOfflineState = new OfflineState();
private State mValidatedState = new ValidatedState();
@@ -709,6 +711,8 @@ public class NetworkMonitor extends StateMachine {
return;
}
if (systemReady == false) return;
Intent latencyBroadcast = new Intent(ACTION_NETWORK_CONDITIONS_MEASURED);
switch (mNetworkAgentInfo.networkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI: