am a16ca5ec: Merge change 27141 into eclair
Merge commit 'a16ca5ec4ba936ed2731a74650b6882d0ffde404' into eclair-plus-aosp * commit 'a16ca5ec4ba936ed2731a74650b6882d0ffde404': Fix ConnectivityManager's handling of apn switch.
This commit is contained in:
@@ -157,7 +157,8 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
// if we're not enabled but the APN Type is supported by this connection
|
// if we're not enabled but the APN Type is supported by this connection
|
||||||
// we should record the interface name if one's provided. If the user
|
// we should record the interface name if one's provided. If the user
|
||||||
// turns on this network we will need the interfacename but won't get
|
// turns on this network we will need the interfacename but won't get
|
||||||
// a fresh connected message - TODO fix this..
|
// a fresh connected message - TODO fix this when we get per-APN
|
||||||
|
// notifications
|
||||||
if (state == Phone.DataState.CONNECTED) {
|
if (state == Phone.DataState.CONNECTED) {
|
||||||
if (DBG) Log.d(TAG, "replacing old mInterfaceName (" +
|
if (DBG) Log.d(TAG, "replacing old mInterfaceName (" +
|
||||||
mInterfaceName + ") with " +
|
mInterfaceName + ") with " +
|
||||||
@@ -186,10 +187,13 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
if (mInterfaceName != null) {
|
if (mInterfaceName != null) {
|
||||||
NetworkUtils.resetConnections(mInterfaceName);
|
NetworkUtils.resetConnections(mInterfaceName);
|
||||||
}
|
}
|
||||||
if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
|
// can't do this here - ConnectivityService needs it to clear stuff
|
||||||
" as it DISCONNECTED");
|
// it's ok though - just leave it to be refreshed next time
|
||||||
mInterfaceName = null;
|
// we connect.
|
||||||
mDefaultGatewayAddr = 0;
|
//if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
|
||||||
|
// " as it DISCONNECTED");
|
||||||
|
//mInterfaceName = null;
|
||||||
|
//mDefaultGatewayAddr = 0;
|
||||||
break;
|
break;
|
||||||
case CONNECTING:
|
case CONNECTING:
|
||||||
setDetailedState(DetailedState.CONNECTING, reason, apnName);
|
setDetailedState(DetailedState.CONNECTING, reason, apnName);
|
||||||
@@ -310,6 +314,11 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean teardown() {
|
public boolean teardown() {
|
||||||
|
// since we won't get a notification currently (TODO - per APN notifications)
|
||||||
|
// we won't get a disconnect message until all APN's on the current connection's
|
||||||
|
// APN list are disabled. That means privateRoutes for DNS and such will remain on -
|
||||||
|
// not a problem since that's all shared with whatever other APN is still on, but
|
||||||
|
// ugly.
|
||||||
setTeardownRequested(true);
|
setTeardownRequested(true);
|
||||||
return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
|
return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
|
||||||
}
|
}
|
||||||
@@ -321,6 +330,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
|
|||||||
setTeardownRequested(false);
|
setTeardownRequested(false);
|
||||||
switch (setEnableApn(mApnType, true)) {
|
switch (setEnableApn(mApnType, true)) {
|
||||||
case Phone.APN_ALREADY_ACTIVE:
|
case Phone.APN_ALREADY_ACTIVE:
|
||||||
|
// TODO - remove this when we get per-apn notifications
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
// need to set self to CONNECTING so the below message is handled.
|
// need to set self to CONNECTING so the below message is handled.
|
||||||
mMobileDataState = Phone.DataState.CONNECTING;
|
mMobileDataState = Phone.DataState.CONNECTING;
|
||||||
|
|||||||
@@ -124,11 +124,12 @@ public abstract class NetworkStateTracker extends Handler {
|
|||||||
|
|
||||||
public void addPrivateDnsRoutes() {
|
public void addPrivateDnsRoutes() {
|
||||||
if (DBG) Log.d(TAG, "addPrivateDnsRoutes for " + this +
|
if (DBG) Log.d(TAG, "addPrivateDnsRoutes for " + this +
|
||||||
"(" + mInterfaceName + ")");
|
"(" + mInterfaceName + ") - mPrivateDnsRouteSet = "+mPrivateDnsRouteSet);
|
||||||
if (mInterfaceName != null && !mPrivateDnsRouteSet) {
|
if (mInterfaceName != null && !mPrivateDnsRouteSet) {
|
||||||
for (String addrString : getNameServers()) {
|
for (String addrString : getNameServers()) {
|
||||||
int addr = NetworkUtils.lookupHost(addrString);
|
int addr = NetworkUtils.lookupHost(addrString);
|
||||||
if (addr != -1) {
|
if (addr != -1 && addr != 0) {
|
||||||
|
if (DBG) Log.d(TAG, " adding "+addrString+" ("+addr+")");
|
||||||
NetworkUtils.addHostRoute(mInterfaceName, addr);
|
NetworkUtils.addHostRoute(mInterfaceName, addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,26 +425,28 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
* will be sent by the ConnectivityManager when a connection to
|
* will be sent by the ConnectivityManager when a connection to
|
||||||
* the APN has been established.
|
* the APN has been established.
|
||||||
*/
|
*/
|
||||||
public int enableApnType(String type) {
|
public synchronized int enableApnType(String type) {
|
||||||
int id = apnTypeToId(type);
|
int id = apnTypeToId(type);
|
||||||
if (id == APN_INVALID_ID) {
|
if (id == APN_INVALID_ID) {
|
||||||
return Phone.APN_REQUEST_FAILED;
|
return Phone.APN_REQUEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If already active, return
|
|
||||||
if(DBG) Log.d(LOG_TAG, "enableApnType("+type+"), isApnTypeActive = "
|
if(DBG) Log.d(LOG_TAG, "enableApnType("+type+"), isApnTypeActive = "
|
||||||
+ isApnTypeActive(type) + " and state = " + state);
|
+ isApnTypeActive(type) + " and state = " + state);
|
||||||
|
|
||||||
if (isApnTypeActive(type)) {
|
|
||||||
if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
|
|
||||||
else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isApnTypeAvailable(type)) {
|
if (!isApnTypeAvailable(type)) {
|
||||||
return Phone.APN_TYPE_NOT_AVAILABLE;
|
return Phone.APN_TYPE_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// just because it's active doesn't mean we had it explicitly requested before
|
||||||
|
// (a broad default may handle many types). make sure we mark it enabled
|
||||||
|
// so if the default is disabled we keep the connection for others
|
||||||
setEnabled(id, true);
|
setEnabled(id, true);
|
||||||
|
|
||||||
|
if (isApnTypeActive(type)) {
|
||||||
|
if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
|
||||||
|
else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
|
||||||
|
}
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,20 +492,21 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
|
|
||||||
protected synchronized void onEnableApn(int apnId, int enabled) {
|
protected synchronized void onEnableApn(int apnId, int enabled) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(LOG_TAG, "got EVENT_APN_ENABLE_REQUEST with apnType = " + apnId +
|
Log.d(LOG_TAG, "EVENT_APN_ENABLE_REQUEST " + apnId + ", " + enabled);
|
||||||
" and enable = " + enabled);
|
Log.d(LOG_TAG, " dataEnabled = " + dataEnabled[apnId] +
|
||||||
Log.d(LOG_TAG, "dataEnabled[apnId] = " + dataEnabled[apnId] +
|
", enabledCount = " + enabledCount +
|
||||||
", enabledCount = " + enabledCount);
|
", isApnTypeActive = " + isApnTypeActive(apnIdToType(apnId)));
|
||||||
}
|
}
|
||||||
if (enabled == APN_ENABLED) {
|
if (enabled == APN_ENABLED) {
|
||||||
if (!dataEnabled[apnId]) {
|
if (!dataEnabled[apnId]) {
|
||||||
mRequestedApnType = apnIdToType(apnId);
|
|
||||||
onEnableNewApn();
|
|
||||||
|
|
||||||
dataEnabled[apnId] = true;
|
dataEnabled[apnId] = true;
|
||||||
enabledCount++;
|
enabledCount++;
|
||||||
}
|
}
|
||||||
onTrySetupData(null);
|
String type = apnIdToType(apnId);
|
||||||
|
if (!isApnTypeActive(type)) {
|
||||||
|
mRequestedApnType = type;
|
||||||
|
onEnableNewApn();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// disable
|
// disable
|
||||||
if (dataEnabled[apnId]) {
|
if (dataEnabled[apnId]) {
|
||||||
@@ -511,7 +514,8 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
enabledCount--;
|
enabledCount--;
|
||||||
if (enabledCount == 0) {
|
if (enabledCount == 0) {
|
||||||
onCleanUpConnection(true, Phone.REASON_DATA_DISABLED);
|
onCleanUpConnection(true, Phone.REASON_DATA_DISABLED);
|
||||||
} else if (dataEnabled[APN_DEFAULT_ID] == true) {
|
} else if (dataEnabled[APN_DEFAULT_ID] == true &&
|
||||||
|
!isApnTypeActive(Phone.APN_TYPE_DEFAULT)) {
|
||||||
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
|
||||||
onEnableNewApn();
|
onEnableNewApn();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user