am a5c9c724: Data Availability Indication changes.
* commit 'a5c9c7246b065710227395ec4a7c1df0168363ef': Data Availability Indication changes.
This commit is contained in:
@@ -408,7 +408,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
|
||||
/** TODO: See if we can remove */
|
||||
public String getActiveApnString() {
|
||||
public String getActiveApnString(String apnType) {
|
||||
String result = null;
|
||||
if (mActiveApn != null) {
|
||||
result = mActiveApn.apn;
|
||||
@@ -466,6 +466,8 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected abstract void onVoiceCallEnded();
|
||||
protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
|
||||
protected abstract void onCleanUpAllConnections(String cause);
|
||||
protected abstract boolean isDataPossible();
|
||||
protected abstract boolean isDataPossible(String apnType);
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
@@ -719,29 +721,6 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
notifyOffApnsOfAvailability(reason, isDataPossible());
|
||||
}
|
||||
|
||||
/**
|
||||
* The only circumstances under which we report that data connectivity is not
|
||||
* possible are
|
||||
* <ul>
|
||||
* <li>Data is disallowed (roaming, power state, voice call, etc).</li>
|
||||
* <li>The current data state is {@code DISCONNECTED} for a reason other than
|
||||
* having explicitly disabled connectivity. In other words, data is not available
|
||||
* because the phone is out of coverage or some like reason.</li>
|
||||
* </ul>
|
||||
* @return {@code true} if data connectivity is possible, {@code false} otherwise.
|
||||
*/
|
||||
protected boolean isDataPossible() {
|
||||
boolean dataAllowed = isDataAllowed();
|
||||
boolean anyDataEnabled = getAnyDataEnabled();
|
||||
boolean possible = (dataAllowed
|
||||
&& !(anyDataEnabled && (mState == State.FAILED || mState == State.IDLE)));
|
||||
if (!possible && DBG) {
|
||||
log("isDataPossible() " + possible + ", dataAllowed=" + dataAllowed +
|
||||
" anyDataEnabled=" + anyDataEnabled + " dataState=" + mState);
|
||||
}
|
||||
return possible;
|
||||
}
|
||||
|
||||
public boolean isApnTypeEnabled(String apnType) {
|
||||
if (apnType == null) {
|
||||
return false;
|
||||
|
||||
@@ -114,8 +114,8 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
||||
try {
|
||||
mRegistry.notifyDataConnection(
|
||||
convertDataState(state),
|
||||
sender.isDataConnectivityPossible(), reason,
|
||||
sender.getActiveApnHost(),
|
||||
sender.isDataConnectivityPossible(apnType), reason,
|
||||
sender.getActiveApnHost(apnType),
|
||||
apnType,
|
||||
linkProperties,
|
||||
linkCapabilities,
|
||||
|
||||
@@ -333,7 +333,7 @@ public interface Phone {
|
||||
* Returns string for the active APN host.
|
||||
* @return type as a string or null if none.
|
||||
*/
|
||||
String getActiveApnHost();
|
||||
String getActiveApnHost(String apnType);
|
||||
|
||||
/**
|
||||
* Return the LinkProperties for the named apn or null if not available
|
||||
@@ -1374,6 +1374,11 @@ public interface Phone {
|
||||
*/
|
||||
boolean isDataConnectivityPossible();
|
||||
|
||||
/**
|
||||
* Report on whether data connectivity is allowed for an APN.
|
||||
*/
|
||||
boolean isDataConnectivityPossible(String apnType);
|
||||
|
||||
/**
|
||||
* Retrieves the unique device ID, e.g., IMEI for GSM phones and MEID for CDMA phones.
|
||||
*/
|
||||
|
||||
@@ -977,8 +977,8 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
return mDataConnectionTracker.getActiveApnTypes();
|
||||
}
|
||||
|
||||
public String getActiveApnHost() {
|
||||
return mDataConnectionTracker.getActiveApnString();
|
||||
public String getActiveApnHost(String apnType) {
|
||||
return mDataConnectionTracker.getActiveApnString(apnType);
|
||||
}
|
||||
|
||||
public LinkProperties getLinkProperties(String apnType) {
|
||||
@@ -1001,6 +1001,11 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
return ((mDataConnectionTracker != null) && (mDataConnectionTracker.isDataPossible()));
|
||||
}
|
||||
|
||||
public boolean isDataConnectivityPossible(String apnType) {
|
||||
return ((mDataConnectionTracker != null) &&
|
||||
(mDataConnectionTracker.isDataPossible(apnType)));
|
||||
}
|
||||
|
||||
/**
|
||||
* simulateDataConnection
|
||||
*
|
||||
|
||||
@@ -208,8 +208,8 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
return mActivePhone.getActiveApnTypes();
|
||||
}
|
||||
|
||||
public String getActiveApnHost() {
|
||||
return mActivePhone.getActiveApnHost();
|
||||
public String getActiveApnHost(String apnType) {
|
||||
return mActivePhone.getActiveApnHost(apnType);
|
||||
}
|
||||
|
||||
public LinkProperties getLinkProperties(String apnType) {
|
||||
@@ -661,6 +661,10 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
return mActivePhone.isDataConnectivityPossible();
|
||||
}
|
||||
|
||||
public boolean isDataConnectivityPossible(String apnType) {
|
||||
return mActivePhone.isDataConnectivityPossible(apnType);
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return mActivePhone.getDeviceId();
|
||||
}
|
||||
|
||||
@@ -164,10 +164,7 @@ public class CDMALTEPhone extends CDMAPhone {
|
||||
}
|
||||
|
||||
public String getActiveApn(String apnType) {
|
||||
if (mDataConnectionTracker instanceof CdmaDataConnectionTracker)
|
||||
return mDataConnectionTracker.getActiveApnString();
|
||||
|
||||
return ((GsmDataConnectionTracker)mDataConnectionTracker).getActiveApnString(apnType);
|
||||
return mDataConnectionTracker.getActiveApnString(apnType);
|
||||
}
|
||||
|
||||
protected void log(String s) {
|
||||
|
||||
@@ -215,6 +215,36 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* The only circumstances under which we report that data connectivity is not
|
||||
* possible are
|
||||
* <ul>
|
||||
* <li>Data is disallowed (roaming, power state, voice call, etc).</li>
|
||||
* <li>The current data state is {@code DISCONNECTED} for a reason other than
|
||||
* having explicitly disabled connectivity. In other words, data is not available
|
||||
* because the phone is out of coverage or some like reason.</li>
|
||||
* </ul>
|
||||
* @return {@code true} if data connectivity is possible, {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
protected boolean isDataPossible() {
|
||||
boolean dataAllowed = isDataAllowed();
|
||||
boolean anyDataEnabled = getAnyDataEnabled();
|
||||
boolean possible = (dataAllowed
|
||||
&& !(anyDataEnabled && (mState == State.FAILED || mState == State.IDLE)));
|
||||
if (!possible && DBG) {
|
||||
log("isDataPossible() " + possible + ", dataAllowed=" + dataAllowed +
|
||||
" anyDataEnabled=" + anyDataEnabled + " dataState=" + mState);
|
||||
}
|
||||
return possible;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDataPossible(String apnType) {
|
||||
return isDataPossible();
|
||||
}
|
||||
|
||||
|
||||
private boolean trySetupData(String reason) {
|
||||
if (DBG) log("***trySetupData due to " + (reason == null ? "(unspecified)" : reason));
|
||||
|
||||
|
||||
@@ -221,13 +221,35 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
@Override
|
||||
protected boolean isDataPossible() {
|
||||
boolean possible = (isDataAllowed()
|
||||
&& getAnyDataEnabled() && (getOverallState() == State.CONNECTED));
|
||||
&& !(getAnyDataEnabled() && (getOverallState() == State.FAILED)));
|
||||
if (!possible && DBG && isDataAllowed()) {
|
||||
log("Data not possible. No coverage: dataState = " + getOverallState());
|
||||
}
|
||||
return possible;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDataPossible(String apnType) {
|
||||
ApnContext apnContext = mApnContexts.get(apnType);
|
||||
if (apnContext == null) {
|
||||
return false;
|
||||
}
|
||||
boolean apnContextIsEnabled = apnContext.isEnabled();
|
||||
State apnContextState = apnContext.getState();
|
||||
boolean apnTypePossible = !(apnContextIsEnabled &&
|
||||
(apnContextState == State.FAILED));
|
||||
boolean dataAllowed = isDataAllowed();
|
||||
boolean possible = dataAllowed && apnTypePossible;
|
||||
|
||||
if (DBG) {
|
||||
log(String.format("isDataPossible(%s): possible=%b isDataAllowed=%b " +
|
||||
"apnTypePossible=%b apnContextisEnabled=%b apnContextState()=%s",
|
||||
apnType, possible, dataAllowed, apnTypePossible,
|
||||
apnContextIsEnabled, apnContextState));
|
||||
}
|
||||
return possible;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
if(DBG) log("finalize");
|
||||
@@ -336,21 +358,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Return DEFAULT APN due to the limit of the interface
|
||||
*/
|
||||
public String getActiveApnString() {
|
||||
if (DBG) log( "get default active apn string");
|
||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
||||
if (defaultApnContext != null) {
|
||||
ApnSetting apnSetting = defaultApnContext.getApnSetting();
|
||||
if (apnSetting != null) {
|
||||
return apnSetting.apn;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return active apn of specific apn type
|
||||
public String getActiveApnString(String apnType) {
|
||||
if (DBG) log( "get active apn string for type:" + apnType);
|
||||
@@ -364,6 +371,15 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApnTypeEnabled(String apnType) {
|
||||
ApnContext apnContext = mApnContexts.get(apnType);
|
||||
if (apnContext == null) {
|
||||
return false;
|
||||
}
|
||||
return apnContext.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setState(State s) {
|
||||
if (DBG) log("setState should not be used in GSM" + s);
|
||||
@@ -382,23 +398,43 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
// Return state of overall
|
||||
public State getOverallState() {
|
||||
boolean isConnecting = false;
|
||||
boolean isFailed = true; // All enabled Apns should be FAILED.
|
||||
boolean isAnyEnabled = false;
|
||||
|
||||
for (ApnContext apnContext : mApnContexts.values()) {
|
||||
if (apnContext.getState() == State.CONNECTED ||
|
||||
apnContext.getState() == State.DISCONNECTING) {
|
||||
if (DBG) log("overall state is CONNECTED");
|
||||
return State.CONNECTED;
|
||||
}
|
||||
else if (apnContext.getState() == State.CONNECTING
|
||||
|| apnContext.getState() == State.INITING) {
|
||||
isConnecting = true;
|
||||
if (apnContext.isEnabled()) {
|
||||
isAnyEnabled = true;
|
||||
switch (apnContext.getState()) {
|
||||
case CONNECTED:
|
||||
case DISCONNECTING:
|
||||
if (DBG) log("overall state is CONNECTED");
|
||||
return State.CONNECTED;
|
||||
case CONNECTING:
|
||||
case INITING:
|
||||
isConnecting = true;
|
||||
isFailed = false;
|
||||
break;
|
||||
case IDLE:
|
||||
case SCANNING:
|
||||
isFailed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAnyEnabled) { // Nothing enabled. return IDLE.
|
||||
return State.IDLE;
|
||||
}
|
||||
|
||||
if (isConnecting) {
|
||||
if (DBG) log( "overall state is CONNECTING");
|
||||
return State.CONNECTING;
|
||||
} else {
|
||||
} else if (!isFailed) {
|
||||
if (DBG) log( "overall state is IDLE");
|
||||
return State.IDLE;
|
||||
} else {
|
||||
if (DBG) log( "overall state is FAILED");
|
||||
return State.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1432,6 +1468,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
log("We're on the simulator; assuming data is connected");
|
||||
}
|
||||
|
||||
if (mPhone.mSIMRecords.getRecordsLoaded()) {
|
||||
notifyDataAvailability(null);
|
||||
}
|
||||
|
||||
if (getOverallState() != State.IDLE) {
|
||||
cleanUpConnection(true, null);
|
||||
}
|
||||
@@ -1473,8 +1513,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
log(String.format("onDataSetupComplete: success apn=%s",
|
||||
apnContext.getWaitingApns().get(0).apn));
|
||||
}
|
||||
mLinkProperties = getLinkProperties(apnContext.getDataConnection());
|
||||
mLinkCapabilities = getLinkCapabilities(apnContext.getDataConnection());
|
||||
mLinkProperties = getLinkProperties(apnContext.getApnType());
|
||||
mLinkCapabilities = getLinkCapabilities(apnContext.getApnType());
|
||||
|
||||
ApnSetting apn = apnContext.getApnSetting();
|
||||
if (apn.proxy != null && apn.proxy.length() != 0) {
|
||||
|
||||
Reference in New Issue
Block a user