summaryrefslogtreecommitdiffstats
path: root/telephony/java/com
diff options
context:
space:
mode:
authorRamesh Sudini <ramesh.sudini@motorola.com>2011-04-16 14:45:19 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-04-16 14:45:19 -0700
commitdff90b7d161bd7d11d931a43aad79d87e7f4dfc1 (patch)
treecadf0fb83d37ee86a2604365d419d876293dc4d4 /telephony/java/com
parent9bd1368bb431d701604a48b226ee362fc7838c6a (diff)
parenta5c9c7246b065710227395ec4a7c1df0168363ef (diff)
downloadframeworks_base-dff90b7d161bd7d11d931a43aad79d87e7f4dfc1.zip
frameworks_base-dff90b7d161bd7d11d931a43aad79d87e7f4dfc1.tar.gz
frameworks_base-dff90b7d161bd7d11d931a43aad79d87e7f4dfc1.tar.bz2
am a5c9c724: Data Availability Indication changes.
* commit 'a5c9c7246b065710227395ec4a7c1df0168363ef': Data Availability Indication changes.
Diffstat (limited to 'telephony/java/com')
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnectionTracker.java27
-rw-r--r--telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java4
-rw-r--r--telephony/java/com/android/internal/telephony/Phone.java7
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneBase.java9
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneProxy.java8
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java5
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java30
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java94
8 files changed, 122 insertions, 62 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index a2c08ed..dfbe1272 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -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;
diff --git a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
index 83db3d1..910905a 100644
--- a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
+++ b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
@@ -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,
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index 9f16d31..488794f 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -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
@@ -1375,6 +1375,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.
*/
String getDeviceId();
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index 3224995..5a77da7 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -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
*
diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java
index 49497b4..5e506b3 100644
--- a/telephony/java/com/android/internal/telephony/PhoneProxy.java
+++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java
@@ -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();
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
index 1cb1118..e45141a 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
@@ -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) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 2637507..dc85017 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -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));
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 1d0e0fc..a67f36b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -221,7 +221,7 @@ 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());
}
@@ -229,6 +229,28 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
@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);
@@ -365,6 +372,15 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
@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) {