DO NOT MERGE Backport of I1f55df8a from master.
Fixes false reporting of NO_CONNECTION. bug:4057115 Change-Id: Ie11e81180276ac3aa486607ec3a8eb1088b2ece6
This commit is contained in:
@@ -1089,18 +1089,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
info.getExtraInfo());
|
||||
}
|
||||
|
||||
NetworkStateTracker newNet = null;
|
||||
if (mNetAttributes[prevNetType].isDefault()) {
|
||||
newNet = tryFailover(prevNetType);
|
||||
if (newNet != null) {
|
||||
NetworkInfo switchTo = newNet.getNetworkInfo();
|
||||
if (!switchTo.isConnected()) {
|
||||
// if the other net is connected they've already reset this and perhaps even gotten
|
||||
// a positive report we don't want to overwrite, but if not we need to clear this now
|
||||
// to turn our cellular sig strength white
|
||||
mDefaultInetConditionPublished = 0;
|
||||
intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
|
||||
}
|
||||
tryFailover(prevNetType);
|
||||
if (mActiveDefaultNetwork != -1) {
|
||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
|
||||
} else {
|
||||
mDefaultInetConditionPublished = 0; // we're not connected anymore
|
||||
@@ -1116,25 +1108,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
* 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());
|
||||
if (mActiveDefaultNetwork != -1) {
|
||||
sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
|
||||
}
|
||||
}
|
||||
|
||||
// returns null if no failover available
|
||||
private NetworkStateTracker tryFailover(int prevNetType) {
|
||||
private void tryFailover(int prevNetType) {
|
||||
/*
|
||||
* If this is a default network, check if other defaults are available
|
||||
* or active
|
||||
*/
|
||||
NetworkStateTracker newNet = null;
|
||||
if (mNetAttributes[prevNetType].isDefault()) {
|
||||
if (mActiveDefaultNetwork == prevNetType) {
|
||||
mActiveDefaultNetwork = -1;
|
||||
}
|
||||
|
||||
int newType = -1;
|
||||
int newPriority = -1;
|
||||
boolean noMobileData = !getMobileDataEnabled();
|
||||
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
||||
if (checkType == prevNetType) continue;
|
||||
@@ -1146,29 +1134,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
" because Mobile Data Disabled");
|
||||
continue;
|
||||
}
|
||||
NetworkStateTracker tracker = mNetTrackers[checkType];
|
||||
NetworkInfo info = tracker.getNetworkInfo();
|
||||
if (!info.isConnectedOrConnecting() ||
|
||||
tracker.isTeardownRequested()) {
|
||||
info.setFailover(true);
|
||||
tracker.reconnect();
|
||||
}
|
||||
if (DBG) Slog.d(TAG, "Attempting to switch to " + info.getTypeName());
|
||||
|
||||
// figure out if this is the highest priority network
|
||||
// so we send an appropriate return value
|
||||
if (checkType == mNetworkPreference) {
|
||||
newType = checkType;
|
||||
}
|
||||
if (mNetAttributes[checkType].mPriority > newPriority &&
|
||||
newType != mNetworkPreference) {
|
||||
newType = checkType;
|
||||
newPriority = mNetAttributes[checkType].mPriority;
|
||||
NetworkStateTracker checkTracker = mNetTrackers[checkType];
|
||||
NetworkInfo checkInfo = checkTracker.getNetworkInfo();
|
||||
if (!checkInfo.isConnectedOrConnecting() || checkTracker.isTeardownRequested()) {
|
||||
checkInfo.setFailover(true);
|
||||
checkTracker.reconnect();
|
||||
}
|
||||
if (DBG) Slog.d(TAG, "Attempting to switch to " + checkInfo.getTypeName());
|
||||
}
|
||||
}
|
||||
|
||||
return newNet;
|
||||
}
|
||||
|
||||
private void sendConnectedBroadcast(NetworkInfo info) {
|
||||
@@ -1231,17 +1205,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
info.setFailover(false);
|
||||
}
|
||||
|
||||
NetworkStateTracker newNet = null;
|
||||
if (mNetAttributes[info.getType()].isDefault()) {
|
||||
newNet = tryFailover(info.getType());
|
||||
if (newNet != null) {
|
||||
NetworkInfo switchTo = newNet.getNetworkInfo();
|
||||
if (!switchTo.isConnected()) {
|
||||
// if the other net is connected they've already reset this and perhaps
|
||||
// even gotten a positive report we don't want to overwrite, but if not
|
||||
// we need to clear this now to turn our cellular sig strength white
|
||||
mDefaultInetConditionPublished = 0;
|
||||
}
|
||||
tryFailover(info.getType());
|
||||
if (mActiveDefaultNetwork != -1) {
|
||||
NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
|
||||
} else {
|
||||
mDefaultInetConditionPublished = 0;
|
||||
@@ -1255,8 +1222,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
* 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());
|
||||
if (mActiveDefaultNetwork != -1) {
|
||||
sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user