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 */
|
/** TODO: See if we can remove */
|
||||||
public String getActiveApnString() {
|
public String getActiveApnString(String apnType) {
|
||||||
String result = null;
|
String result = null;
|
||||||
if (mActiveApn != null) {
|
if (mActiveApn != null) {
|
||||||
result = mActiveApn.apn;
|
result = mActiveApn.apn;
|
||||||
@@ -466,6 +466,8 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
protected abstract void onVoiceCallEnded();
|
protected abstract void onVoiceCallEnded();
|
||||||
protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
|
protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
|
||||||
protected abstract void onCleanUpAllConnections(String cause);
|
protected abstract void onCleanUpAllConnections(String cause);
|
||||||
|
protected abstract boolean isDataPossible();
|
||||||
|
protected abstract boolean isDataPossible(String apnType);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
@@ -719,29 +721,6 @@ public abstract class DataConnectionTracker extends Handler {
|
|||||||
notifyOffApnsOfAvailability(reason, isDataPossible());
|
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) {
|
public boolean isApnTypeEnabled(String apnType) {
|
||||||
if (apnType == null) {
|
if (apnType == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
|||||||
try {
|
try {
|
||||||
mRegistry.notifyDataConnection(
|
mRegistry.notifyDataConnection(
|
||||||
convertDataState(state),
|
convertDataState(state),
|
||||||
sender.isDataConnectivityPossible(), reason,
|
sender.isDataConnectivityPossible(apnType), reason,
|
||||||
sender.getActiveApnHost(),
|
sender.getActiveApnHost(apnType),
|
||||||
apnType,
|
apnType,
|
||||||
linkProperties,
|
linkProperties,
|
||||||
linkCapabilities,
|
linkCapabilities,
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ public interface Phone {
|
|||||||
* Returns string for the active APN host.
|
* Returns string for the active APN host.
|
||||||
* @return type as a string or null if none.
|
* @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
|
* Return the LinkProperties for the named apn or null if not available
|
||||||
@@ -1374,6 +1374,11 @@ public interface Phone {
|
|||||||
*/
|
*/
|
||||||
boolean isDataConnectivityPossible();
|
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.
|
* 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();
|
return mDataConnectionTracker.getActiveApnTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActiveApnHost() {
|
public String getActiveApnHost(String apnType) {
|
||||||
return mDataConnectionTracker.getActiveApnString();
|
return mDataConnectionTracker.getActiveApnString(apnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkProperties getLinkProperties(String apnType) {
|
public LinkProperties getLinkProperties(String apnType) {
|
||||||
@@ -1001,6 +1001,11 @@ public abstract class PhoneBase extends Handler implements Phone {
|
|||||||
return ((mDataConnectionTracker != null) && (mDataConnectionTracker.isDataPossible()));
|
return ((mDataConnectionTracker != null) && (mDataConnectionTracker.isDataPossible()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDataConnectivityPossible(String apnType) {
|
||||||
|
return ((mDataConnectionTracker != null) &&
|
||||||
|
(mDataConnectionTracker.isDataPossible(apnType)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* simulateDataConnection
|
* simulateDataConnection
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -208,8 +208,8 @@ public class PhoneProxy extends Handler implements Phone {
|
|||||||
return mActivePhone.getActiveApnTypes();
|
return mActivePhone.getActiveApnTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActiveApnHost() {
|
public String getActiveApnHost(String apnType) {
|
||||||
return mActivePhone.getActiveApnHost();
|
return mActivePhone.getActiveApnHost(apnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkProperties getLinkProperties(String apnType) {
|
public LinkProperties getLinkProperties(String apnType) {
|
||||||
@@ -661,6 +661,10 @@ public class PhoneProxy extends Handler implements Phone {
|
|||||||
return mActivePhone.isDataConnectivityPossible();
|
return mActivePhone.isDataConnectivityPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDataConnectivityPossible(String apnType) {
|
||||||
|
return mActivePhone.isDataConnectivityPossible(apnType);
|
||||||
|
}
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return mActivePhone.getDeviceId();
|
return mActivePhone.getDeviceId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,10 +164,7 @@ public class CDMALTEPhone extends CDMAPhone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getActiveApn(String apnType) {
|
public String getActiveApn(String apnType) {
|
||||||
if (mDataConnectionTracker instanceof CdmaDataConnectionTracker)
|
return mDataConnectionTracker.getActiveApnString(apnType);
|
||||||
return mDataConnectionTracker.getActiveApnString();
|
|
||||||
|
|
||||||
return ((GsmDataConnectionTracker)mDataConnectionTracker).getActiveApnString(apnType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void log(String s) {
|
protected void log(String s) {
|
||||||
|
|||||||
@@ -215,6 +215,36 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return allowed;
|
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) {
|
private boolean trySetupData(String reason) {
|
||||||
if (DBG) log("***trySetupData due to " + (reason == null ? "(unspecified)" : reason));
|
if (DBG) log("***trySetupData due to " + (reason == null ? "(unspecified)" : reason));
|
||||||
|
|
||||||
|
|||||||
@@ -221,13 +221,35 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean isDataPossible() {
|
protected boolean isDataPossible() {
|
||||||
boolean possible = (isDataAllowed()
|
boolean possible = (isDataAllowed()
|
||||||
&& getAnyDataEnabled() && (getOverallState() == State.CONNECTED));
|
&& !(getAnyDataEnabled() && (getOverallState() == State.FAILED)));
|
||||||
if (!possible && DBG && isDataAllowed()) {
|
if (!possible && DBG && isDataAllowed()) {
|
||||||
log("Data not possible. No coverage: dataState = " + getOverallState());
|
log("Data not possible. No coverage: dataState = " + getOverallState());
|
||||||
}
|
}
|
||||||
return possible;
|
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
|
@Override
|
||||||
protected void finalize() {
|
protected void finalize() {
|
||||||
if(DBG) log("finalize");
|
if(DBG) log("finalize");
|
||||||
@@ -336,21 +358,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
// Return active apn of specific apn type
|
||||||
public String getActiveApnString(String apnType) {
|
public String getActiveApnString(String apnType) {
|
||||||
if (DBG) log( "get active apn string for type:" + apnType);
|
if (DBG) log( "get active apn string for type:" + apnType);
|
||||||
@@ -364,6 +371,15 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isApnTypeEnabled(String apnType) {
|
||||||
|
ApnContext apnContext = mApnContexts.get(apnType);
|
||||||
|
if (apnContext == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return apnContext.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setState(State s) {
|
protected void setState(State s) {
|
||||||
if (DBG) log("setState should not be used in GSM" + 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
|
// Return state of overall
|
||||||
public State getOverallState() {
|
public State getOverallState() {
|
||||||
boolean isConnecting = false;
|
boolean isConnecting = false;
|
||||||
|
boolean isFailed = true; // All enabled Apns should be FAILED.
|
||||||
|
boolean isAnyEnabled = false;
|
||||||
|
|
||||||
for (ApnContext apnContext : mApnContexts.values()) {
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
if (apnContext.getState() == State.CONNECTED ||
|
if (apnContext.isEnabled()) {
|
||||||
apnContext.getState() == State.DISCONNECTING) {
|
isAnyEnabled = true;
|
||||||
if (DBG) log("overall state is CONNECTED");
|
switch (apnContext.getState()) {
|
||||||
return State.CONNECTED;
|
case CONNECTED:
|
||||||
}
|
case DISCONNECTING:
|
||||||
else if (apnContext.getState() == State.CONNECTING
|
if (DBG) log("overall state is CONNECTED");
|
||||||
|| apnContext.getState() == State.INITING) {
|
return State.CONNECTED;
|
||||||
isConnecting = true;
|
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 (isConnecting) {
|
||||||
if (DBG) log( "overall state is CONNECTING");
|
if (DBG) log( "overall state is CONNECTING");
|
||||||
return State.CONNECTING;
|
return State.CONNECTING;
|
||||||
} else {
|
} else if (!isFailed) {
|
||||||
if (DBG) log( "overall state is IDLE");
|
if (DBG) log( "overall state is IDLE");
|
||||||
return State.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");
|
log("We're on the simulator; assuming data is connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPhone.mSIMRecords.getRecordsLoaded()) {
|
||||||
|
notifyDataAvailability(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (getOverallState() != State.IDLE) {
|
if (getOverallState() != State.IDLE) {
|
||||||
cleanUpConnection(true, null);
|
cleanUpConnection(true, null);
|
||||||
}
|
}
|
||||||
@@ -1473,8 +1513,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
log(String.format("onDataSetupComplete: success apn=%s",
|
log(String.format("onDataSetupComplete: success apn=%s",
|
||||||
apnContext.getWaitingApns().get(0).apn));
|
apnContext.getWaitingApns().get(0).apn));
|
||||||
}
|
}
|
||||||
mLinkProperties = getLinkProperties(apnContext.getDataConnection());
|
mLinkProperties = getLinkProperties(apnContext.getApnType());
|
||||||
mLinkCapabilities = getLinkCapabilities(apnContext.getDataConnection());
|
mLinkCapabilities = getLinkCapabilities(apnContext.getApnType());
|
||||||
|
|
||||||
ApnSetting apn = apnContext.getApnSetting();
|
ApnSetting apn = apnContext.getApnSetting();
|
||||||
if (apn.proxy != null && apn.proxy.length() != 0) {
|
if (apn.proxy != null && apn.proxy.length() != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user