Loading services/java/com/android/server/ConnectivityService.java +43 −21 Original line number Original line Diff line number Diff line Loading @@ -811,6 +811,28 @@ public class ConnectivityService extends IConnectivityManager.Stub { info.getExtraInfo()); info.getExtraInfo()); } } NetworkStateTracker newNet = tryFailover(prevNetType); if (newNet != null) { NetworkInfo switchTo = newNet.getNetworkInfo(); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) { sendConnectedBroadcast(newNet.getNetworkInfo()); } } // returns -1 if no failover available private NetworkStateTracker tryFailover(int prevNetType) { /* /* * If this is a default network, check if other defaults are available * If this is a default network, check if other defaults are available * or active * or active Loading @@ -823,8 +845,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { int newType = -1; int newType = -1; int newPriority = -1; int newPriority = -1; for (int checkType=0; checkType <= for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) { ConnectivityManager.MAX_NETWORK_TYPE; checkType++) { if (checkType == prevNetType) { if (checkType == prevNetType) { continue; continue; } } Loading @@ -839,8 +860,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (mRadioAttributes[mNetAttributes[checkType].mRadio]. if (mRadioAttributes[mNetAttributes[checkType].mRadio]. mPriority > newPriority) { mPriority > newPriority) { newType = checkType; newType = checkType; newPriority = mRadioAttributes[mNetAttributes[newType]. newPriority = mRadioAttributes[mNetAttributes[newType].mRadio].mPriority; mRadio].mPriority; } } } } } } Loading Loading @@ -870,29 +890,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { switchTo.getTypeName()); switchTo.getTypeName()); } } } } intent.putExtra(ConnectivityManager. EXTRA_OTHER_NETWORK_INFO, switchTo); } else { } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); newNet.reconnect(); newNet.reconnect(); } } } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } } } } // do this before we broadcast the change return newNet; handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) sendConnectedBroadcast(newNet.getNetworkInfo()); } } private void sendConnectedBroadcast(NetworkInfo info) { private void sendConnectedBroadcast(NetworkInfo info) { Loading Loading @@ -948,7 +952,25 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); info.setFailover(false); info.setFailover(false); } } NetworkStateTracker newNet = tryFailover(info.getType()); if (newNet != null) { NetworkInfo switchTo = newNet.getNetworkInfo(); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) { sendConnectedBroadcast(newNet.getNetworkInfo()); } } } private void sendStickyBroadcast(Intent intent) { private void sendStickyBroadcast(Intent intent) { Loading Loading
services/java/com/android/server/ConnectivityService.java +43 −21 Original line number Original line Diff line number Diff line Loading @@ -811,6 +811,28 @@ public class ConnectivityService extends IConnectivityManager.Stub { info.getExtraInfo()); info.getExtraInfo()); } } NetworkStateTracker newNet = tryFailover(prevNetType); if (newNet != null) { NetworkInfo switchTo = newNet.getNetworkInfo(); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) { sendConnectedBroadcast(newNet.getNetworkInfo()); } } // returns -1 if no failover available private NetworkStateTracker tryFailover(int prevNetType) { /* /* * If this is a default network, check if other defaults are available * If this is a default network, check if other defaults are available * or active * or active Loading @@ -823,8 +845,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { int newType = -1; int newType = -1; int newPriority = -1; int newPriority = -1; for (int checkType=0; checkType <= for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) { ConnectivityManager.MAX_NETWORK_TYPE; checkType++) { if (checkType == prevNetType) { if (checkType == prevNetType) { continue; continue; } } Loading @@ -839,8 +860,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (mRadioAttributes[mNetAttributes[checkType].mRadio]. if (mRadioAttributes[mNetAttributes[checkType].mRadio]. mPriority > newPriority) { mPriority > newPriority) { newType = checkType; newType = checkType; newPriority = mRadioAttributes[mNetAttributes[newType]. newPriority = mRadioAttributes[mNetAttributes[newType].mRadio].mPriority; mRadio].mPriority; } } } } } } Loading Loading @@ -870,29 +890,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { switchTo.getTypeName()); switchTo.getTypeName()); } } } } intent.putExtra(ConnectivityManager. EXTRA_OTHER_NETWORK_INFO, switchTo); } else { } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); newNet.reconnect(); newNet.reconnect(); } } } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } } } } // do this before we broadcast the change return newNet; handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) sendConnectedBroadcast(newNet.getNetworkInfo()); } } private void sendConnectedBroadcast(NetworkInfo info) { private void sendConnectedBroadcast(NetworkInfo info) { Loading Loading @@ -948,7 +952,25 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); info.setFailover(false); info.setFailover(false); } } NetworkStateTracker newNet = tryFailover(info.getType()); if (newNet != null) { NetworkInfo switchTo = newNet.getNetworkInfo(); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); } else { intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover */ if (newNet != null && newNet.getNetworkInfo().isConnected()) { sendConnectedBroadcast(newNet.getNetworkInfo()); } } } private void sendStickyBroadcast(Intent intent) { private void sendStickyBroadcast(Intent intent) { Loading