Merge "Add DataConnection#isEmergency and use in trySetupData." into ics-mr0
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index 759a84b..97e7aa3 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -676,6 +676,15 @@
return result;
}
+ protected boolean isEmergency() {
+ final boolean result;
+ synchronized (mDataEnabledLock) {
+ result = mPhone.isInEcm() || mPhone.isInEmergencyCall();
+ }
+ log("isEmergency: result=" + result);
+ return result;
+ }
+
protected int apnTypeToId(String type) {
if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
return APN_DEFAULT_ID;
@@ -981,17 +990,14 @@
protected void onSetInternalDataEnabled(boolean enabled) {
synchronized (mDataEnabledLock) {
- final boolean prevEnabled = getAnyDataEnabled();
- if (mInternalDataEnabled != enabled) {
- mInternalDataEnabled = enabled;
- if (prevEnabled != getAnyDataEnabled()) {
- if (!prevEnabled) {
- resetAllRetryCounts();
- onTrySetupData(Phone.REASON_DATA_ENABLED);
- } else {
- cleanUpAllConnections(null);
- }
- }
+ mInternalDataEnabled = enabled;
+ if (enabled) {
+ log("onSetInternalDataEnabled: changed to enabled, try to setup data call");
+ resetAllRetryCounts();
+ onTrySetupData(Phone.REASON_DATA_ENABLED);
+ } else {
+ log("onSetInternalDataEnabled: changed to disabled, cleanUpAllConnections");
+ cleanUpAllConnections(null);
}
}
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index a7a4908..10121dd 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -832,6 +832,22 @@
mNotifier.notifyOtaspChanged(this, otaspMode);
}
+ /**
+ * @return true if a mobile originating emergency call is active
+ */
+ public boolean isInEmergencyCall() {
+ return false;
+ }
+
+ /**
+ * @return true if we are in the emergency call back mode. This is a period where
+ * the phone should be using as little power as possible and be ready to receive an
+ * incoming call from the emergency operator.
+ */
+ public boolean isInEcm() {
+ return false;
+ }
+
public abstract String getPhoneName();
public abstract int getPhoneType();
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 09ee28c..58e3e5f 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -848,6 +848,14 @@
mUnknownConnectionRegistrants.notifyResult(this);
}
+ public boolean isInEmergencyCall() {
+ return mCT.isInEmergencyCall();
+ }
+
+ public boolean isInEcm() {
+ return mIsPhoneInEcmState;
+ }
+
void sendEmergencyCallbackModeChange(){
//Send an Intent
Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 3c7ff05..f5d05a1 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -248,7 +248,7 @@
boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();
if ((mState == State.IDLE || mState == State.SCANNING) &&
- isDataAllowed() && getAnyDataEnabled()) {
+ isDataAllowed() && getAnyDataEnabled() && !isEmergency()) {
boolean retValue = setupData(reason);
notifyOffApnsOfAvailability(reason);
return retValue;
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 5497b7f..ac3cdb8 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -686,7 +686,7 @@
boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
if ((apnContext.getState() == State.IDLE || apnContext.getState() == State.SCANNING) &&
- isDataAllowed(apnContext) && getAnyDataEnabled()) {
+ isDataAllowed(apnContext) && getAnyDataEnabled() && !isEmergency()) {
if (apnContext.getState() == State.IDLE) {
ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType());