resolved conflicts for merge of 0e9cd3b2 to master
Change-Id: I026b01805c81d8b26d22e4a195e5e38655a34d32
This commit is contained in:
@@ -254,6 +254,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
private static final int EVENT_RESTORE_DNS =
|
private static final int EVENT_RESTORE_DNS =
|
||||||
MAX_NETWORK_STATE_TRACKER_EVENT + 11;
|
MAX_NETWORK_STATE_TRACKER_EVENT + 11;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used internally to send a sticky broadcast delayed.
|
||||||
|
*/
|
||||||
|
private static final int EVENT_SEND_STICKY_BROADCAST_INTENT =
|
||||||
|
MAX_NETWORK_STATE_TRACKER_EVENT + 12;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
|
||||||
// list of DeathRecipients used to make sure features are turned off when
|
// list of DeathRecipients used to make sure features are turned off when
|
||||||
@@ -559,6 +565,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getConnectivityChangeDelay() {
|
||||||
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
|
|
||||||
|
/** Check system properties for the default value then use secure settings value, if any. */
|
||||||
|
int defaultDelay = SystemProperties.getInt(
|
||||||
|
"conn." + Settings.Secure.CONNECTIVITY_CHANGE_DELAY,
|
||||||
|
Settings.Secure.CONNECTIVITY_CHANGE_DELAY_DEFAULT);
|
||||||
|
return Settings.Secure.getInt(cr, Settings.Secure.CONNECTIVITY_CHANGE_DELAY,
|
||||||
|
defaultDelay);
|
||||||
|
}
|
||||||
|
|
||||||
private int getPersistedNetworkPreference() {
|
private int getPersistedNetworkPreference() {
|
||||||
final ContentResolver cr = mContext.getContentResolver();
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
|
|
||||||
@@ -1437,13 +1454,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// do this before we broadcast the change
|
// do this before we broadcast the change
|
||||||
handleConnectivityChange(prevNetType, doReset);
|
handleConnectivityChange(prevNetType, doReset);
|
||||||
|
|
||||||
sendStickyBroadcast(intent);
|
sendStickyBroadcastDelayed(intent, getConnectivityChangeDelay());
|
||||||
/*
|
/*
|
||||||
* If the failover network is already connected, then immediately send
|
* If the failover network is already connected, then immediately send
|
||||||
* out a followup broadcast indicating successful failover
|
* out a followup broadcast indicating successful failover
|
||||||
*/
|
*/
|
||||||
if (mActiveDefaultNetwork != -1) {
|
if (mActiveDefaultNetwork != -1) {
|
||||||
sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
|
sendConnectedBroadcastDelayed(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(),
|
||||||
|
getConnectivityChangeDelay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1497,11 +1515,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
sendGeneralBroadcast(info, ConnectivityManager.CONNECTIVITY_ACTION);
|
sendGeneralBroadcast(info, ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendConnectedBroadcastDelayed(NetworkInfo info, int delayMs) {
|
||||||
|
sendGeneralBroadcastDelayed(info, ConnectivityManager.CONNECTIVITY_ACTION, delayMs);
|
||||||
|
}
|
||||||
|
|
||||||
private void sendInetConditionBroadcast(NetworkInfo info) {
|
private void sendInetConditionBroadcast(NetworkInfo info) {
|
||||||
sendGeneralBroadcast(info, ConnectivityManager.INET_CONDITION_ACTION);
|
sendGeneralBroadcast(info, ConnectivityManager.INET_CONDITION_ACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendGeneralBroadcast(NetworkInfo info, String bcastType) {
|
private Intent makeGeneralIntent(NetworkInfo info, String bcastType) {
|
||||||
Intent intent = new Intent(bcastType);
|
Intent intent = new Intent(bcastType);
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
|
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
|
||||||
if (info.isFailover()) {
|
if (info.isFailover()) {
|
||||||
@@ -1516,7 +1538,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
info.getExtraInfo());
|
info.getExtraInfo());
|
||||||
}
|
}
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_INET_CONDITION, mDefaultInetConditionPublished);
|
intent.putExtra(ConnectivityManager.EXTRA_INET_CONDITION, mDefaultInetConditionPublished);
|
||||||
sendStickyBroadcast(intent);
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendGeneralBroadcast(NetworkInfo info, String bcastType) {
|
||||||
|
sendStickyBroadcast(makeGeneralIntent(info, bcastType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendGeneralBroadcastDelayed(NetworkInfo info, String bcastType, int delayMs) {
|
||||||
|
sendStickyBroadcastDelayed(makeGeneralIntent(info, bcastType), delayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1581,10 +1611,25 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mInitialBroadcast = new Intent(intent);
|
mInitialBroadcast = new Intent(intent);
|
||||||
}
|
}
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||||
|
if (DBG) {
|
||||||
|
log("sendStickyBroadcast: NetworkInfo=" +
|
||||||
|
intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
|
||||||
|
}
|
||||||
|
|
||||||
mContext.sendStickyBroadcast(intent);
|
mContext.sendStickyBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendStickyBroadcastDelayed(Intent intent, int delayMs) {
|
||||||
|
if (delayMs <= 0) {
|
||||||
|
sendStickyBroadcast(intent);
|
||||||
|
} else {
|
||||||
|
if (DBG) log("sendStickyBroadcastDelayed: delayMs=" + delayMs + " intent=" + intent);
|
||||||
|
mHandler.sendMessageDelayed(mHandler.obtainMessage(
|
||||||
|
EVENT_SEND_STICKY_BROADCAST_INTENT, intent), delayMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void systemReady() {
|
void systemReady() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
mSystemReady = true;
|
mSystemReady = true;
|
||||||
@@ -1658,7 +1703,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
thisNet.setTeardownRequested(false);
|
thisNet.setTeardownRequested(false);
|
||||||
updateNetworkSettings(thisNet);
|
updateNetworkSettings(thisNet);
|
||||||
handleConnectivityChange(type, false);
|
handleConnectivityChange(type, false);
|
||||||
sendConnectedBroadcast(info);
|
sendConnectedBroadcastDelayed(info, getConnectivityChangeDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2240,6 +2285,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EVENT_SEND_STICKY_BROADCAST_INTENT:
|
||||||
|
{
|
||||||
|
Intent intent = (Intent)msg.obj;
|
||||||
|
log("EVENT_SEND_STICKY_BROADCAST_INTENT: sendStickyBroadcast intent=" + intent);
|
||||||
|
sendStickyBroadcast(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2435,10 +2487,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (DBG) log("event hold for obsolete network - aborting");
|
if (DBG) log("event hold for obsolete network - aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mDefaultInetConditionPublished == mDefaultInetCondition) {
|
// TODO: Figure out why this optimization sometimes causes a
|
||||||
if (DBG) log("no change in condition - aborting");
|
// change in mDefaultInetCondition to be missed and the
|
||||||
return;
|
// UI to not be updated.
|
||||||
}
|
//if (mDefaultInetConditionPublished == mDefaultInetCondition) {
|
||||||
|
// if (DBG) log("no change in condition - aborting");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
if (networkInfo.isConnected() == false) {
|
if (networkInfo.isConnected() == false) {
|
||||||
if (DBG) log("default network not connected - aborting");
|
if (DBG) log("default network not connected - aborting");
|
||||||
|
|||||||
Reference in New Issue
Block a user