am 01758e81: Linkproperties update via unsol data call state change.
* commit '01758e81b3ad89934581885bb2fc7006510ec639': Linkproperties update via unsol data call state change.
This commit is contained in:
@@ -509,24 +509,58 @@ public abstract class DataConnection extends StateMachine {
|
||||
result.mFailCause = FailCause.fromInt(response.status);
|
||||
} else {
|
||||
log("onSetupConnectionCompleted received DataCallState: " + response);
|
||||
|
||||
// Check if system property dns usable
|
||||
boolean okToUseSystemPropertyDns = false;
|
||||
cid = response.cid;
|
||||
String propertyPrefix = "net." + response.ifname + ".";
|
||||
String dnsServers[] = new String[2];
|
||||
dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1");
|
||||
dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2");
|
||||
okToUseSystemPropertyDns = isDnsOk(dnsServers);
|
||||
|
||||
// set link properties based on data call response
|
||||
result = response.setLinkProperties(mLinkProperties,
|
||||
okToUseSystemPropertyDns);
|
||||
isOkToUseSystemPropertyDns(response));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isOkToUseSystemPropertyDns(DataCallState response) {
|
||||
// Check if system property dns usable
|
||||
boolean okToUseSystemPropertyDns = false;
|
||||
String propertyPrefix = "net." + response.ifname + ".";
|
||||
String dnsServers[] = new String[2];
|
||||
dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1");
|
||||
dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2");
|
||||
okToUseSystemPropertyDns = isDnsOk(dnsServers);
|
||||
return okToUseSystemPropertyDns;
|
||||
}
|
||||
|
||||
private boolean updateLinkProperty(DataCallState newState) {
|
||||
boolean changed = false;
|
||||
|
||||
if (newState == null) return changed;
|
||||
|
||||
DataCallState.SetupResult result;
|
||||
LinkProperties linkProperties = new LinkProperties();
|
||||
|
||||
// set link properties based on data call response
|
||||
result = newState.setLinkProperties(linkProperties,
|
||||
isOkToUseSystemPropertyDns(newState));
|
||||
|
||||
if (result != DataCallState.SetupResult.SUCCESS) {
|
||||
log("updateLinkProperty failed : " + result);
|
||||
return changed;
|
||||
}
|
||||
|
||||
if (mLinkProperties != null) {
|
||||
// Before comparison, copy HTTP proxy from the original
|
||||
// as it is not part DataCallState.
|
||||
linkProperties.setHttpProxy(mLinkProperties.getHttpProxy());
|
||||
if (!mLinkProperties.equals(linkProperties)) {
|
||||
mLinkProperties = linkProperties;
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
mLinkProperties = linkProperties;
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parent state for all other states.
|
||||
*/
|
||||
@@ -597,17 +631,24 @@ public abstract class DataConnection extends StateMachine {
|
||||
mAc.replyToMessage(msg, DataConnectionAc.RSP_SET_LINK_PROPERTIES_HTTP_PROXY);
|
||||
break;
|
||||
}
|
||||
case DataConnectionAc.REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE: {
|
||||
DataCallState newState = (DataCallState) msg.obj;
|
||||
int updated = updateLinkProperty(newState) ? 1 : 0;
|
||||
if (DBG) {
|
||||
log("REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE updated=" + updated +
|
||||
" newState=" + newState);
|
||||
}
|
||||
mAc.replyToMessage(msg,
|
||||
DataConnectionAc.RSP_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE,
|
||||
updated);
|
||||
break;
|
||||
}
|
||||
case DataConnectionAc.REQ_GET_LINK_CAPABILITIES: {
|
||||
LinkCapabilities lc = new LinkCapabilities(mCapabilities);
|
||||
log("REQ_GET_LINK_CAPABILITIES linkCapabilities" + lc);
|
||||
mAc.replyToMessage(msg, DataConnectionAc.RSP_GET_LINK_CAPABILITIES, lc);
|
||||
break;
|
||||
}
|
||||
case DataConnectionAc.REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE: {
|
||||
Bundle data = msg.getData();
|
||||
mLinkProperties = (LinkProperties) data.get("linkProperties");
|
||||
break;
|
||||
}
|
||||
case DataConnectionAc.REQ_RESET:
|
||||
if (DBG) log("DcDefaultState: msg.what=REQ_RESET");
|
||||
clearSettings();
|
||||
|
||||
@@ -225,6 +225,38 @@ public class DataConnectionAc extends AsyncChannel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request update LinkProperties from DataCallState
|
||||
* Response {@link #rspUpdateLinkPropertiesDataCallState}
|
||||
*/
|
||||
public void reqUpdateLinkPropertiesDataCallState(DataCallState newState) {
|
||||
sendMessage(REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE, newState);
|
||||
if (DBG) log("reqUpdateLinkPropertiesDataCallState");
|
||||
}
|
||||
|
||||
public boolean rspUpdateLinkPropertiesDataCallState(Message response) {
|
||||
boolean retVal = response.arg1 == 1;
|
||||
if (DBG) log("rspUpdateLinkPropertiesState=" + retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update link properties in the data connection
|
||||
*
|
||||
* @return true if link property has been updated. false otherwise.
|
||||
*/
|
||||
public boolean updateLinkPropertiesDataCallStateSync(DataCallState newState) {
|
||||
Message response =
|
||||
sendMessageSynchronously(REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE, newState);
|
||||
if ((response != null) &&
|
||||
(response.what == RSP_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE)) {
|
||||
return rspUpdateLinkPropertiesDataCallState(response);
|
||||
} else {
|
||||
log("getLinkProperties error response=" + response);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the connections LinkCapabilities.
|
||||
* Response {@link #rspLinkCapabilities}
|
||||
|
||||
@@ -178,6 +178,7 @@ public interface Phone {
|
||||
static final String REASON_NW_TYPE_CHANGED = "nwTypeChanged";
|
||||
static final String REASON_DATA_DEPENDENCY_MET = "dependencyMet";
|
||||
static final String REASON_DATA_DEPENDENCY_UNMET = "dependencyUnmet";
|
||||
static final String REASON_LINK_PROPERTIES_CHANGED = "linkPropertiesChanged";
|
||||
|
||||
// Used for band mode selection methods
|
||||
static final int BM_UNSPECIFIED = 0; // selected by baseband automatically
|
||||
|
||||
@@ -987,6 +987,15 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
private DataCallState findDataCallStateByCID (ArrayList<DataCallState> states, int cid) {
|
||||
for (int i = 0, s = states.size() ; i < s ; i++) {
|
||||
if (states.get(i).cid == cid) {
|
||||
return states.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles changes to the APN database.
|
||||
*/
|
||||
@@ -1090,6 +1099,19 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
TelephonyManager.getDefault().getNetworkType());
|
||||
|
||||
cleanUpConnection(true, apnContext);
|
||||
} else {
|
||||
// Here, data call list has active cid for given ApnContext.
|
||||
// Check if link property has been updated.
|
||||
DataCallState state = findDataCallStateByCID(dataCallStates,
|
||||
apnContext.getDataConnectionAc().getCidSync());
|
||||
|
||||
if ((dcac != null) && (state != null)){
|
||||
if (dcac.updateLinkPropertiesDataCallStateSync(state)) {
|
||||
// notify data change for this apn
|
||||
mPhone.notifyDataConnection(Phone.REASON_LINK_PROPERTIES_CHANGED,
|
||||
apnContext.getApnType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user