Skip to content

Commit e025391

Browse files
author
Wink Saville
committed
Add DataConnection#isEmergency and use in trySetupData.
If an emergency is occurring we may not want to allow data calls. An emergency is defined as in an Emergency call or in the emergency call back mode. I've added isInEcm and isEmergencyCall to PhoneBase and CDMAPhone. And in DataConnectionTracker added isEmergency which is the or of isInEcm, isEmergencyCall. Also, removed some optimization code in DataConnectionTracker onSetInternalDataEnabled because mInternalDataEnabled defaults to true when a DCT is constructed and without this change trySetupData will not be called leaving ECM if the DCT was just created. Which is what is currently happening on the ICS lead device. Also see b/5471660 as there is similar optimizations in onSetUserDataEnabled and onSetPolicyDataEnabled. Bug: 5437885 Change-Id: Iba81366300fe46eaa9aa6e457d6659b42d6fe927
1 parent d814d4f commit e025391

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

telephony/java/com/android/internal/telephony/DataConnectionTracker.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,15 @@ public boolean getAnyDataEnabled() {
679679
return result;
680680
}
681681

682+
protected boolean isEmergency() {
683+
final boolean result;
684+
synchronized (mDataEnabledLock) {
685+
result = mPhone.isInEcm() || mPhone.isInEmergencyCall();
686+
}
687+
log("isEmergency: result=" + result);
688+
return result;
689+
}
690+
682691
protected int apnTypeToId(String type) {
683692
if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
684693
return APN_DEFAULT_ID;
@@ -998,17 +1007,14 @@ public boolean setInternalDataEnabled(boolean enable) {
9981007

9991008
protected void onSetInternalDataEnabled(boolean enabled) {
10001009
synchronized (mDataEnabledLock) {
1001-
final boolean prevEnabled = getAnyDataEnabled();
1002-
if (mInternalDataEnabled != enabled) {
1003-
mInternalDataEnabled = enabled;
1004-
if (prevEnabled != getAnyDataEnabled()) {
1005-
if (!prevEnabled) {
1006-
resetAllRetryCounts();
1007-
onTrySetupData(Phone.REASON_DATA_ENABLED);
1008-
} else {
1009-
cleanUpAllConnections(null);
1010-
}
1011-
}
1010+
mInternalDataEnabled = enabled;
1011+
if (enabled) {
1012+
log("onSetInternalDataEnabled: changed to enabled, try to setup data call");
1013+
resetAllRetryCounts();
1014+
onTrySetupData(Phone.REASON_DATA_ENABLED);
1015+
} else {
1016+
log("onSetInternalDataEnabled: changed to disabled, cleanUpAllConnections");
1017+
cleanUpAllConnections(null);
10121018
}
10131019
}
10141020
}

telephony/java/com/android/internal/telephony/PhoneBase.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,22 @@ public void notifyOtaspChanged(int otaspMode) {
832832
mNotifier.notifyOtaspChanged(this, otaspMode);
833833
}
834834

835+
/**
836+
* @return true if a mobile originating emergency call is active
837+
*/
838+
public boolean isInEmergencyCall() {
839+
return false;
840+
}
841+
842+
/**
843+
* @return true if we are in the emergency call back mode. This is a period where
844+
* the phone should be using as little power as possible and be ready to receive an
845+
* incoming call from the emergency operator.
846+
*/
847+
public boolean isInEcm() {
848+
return false;
849+
}
850+
835851
public abstract String getPhoneName();
836852

837853
public abstract int getPhoneType();

telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,14 @@ void notifyUnknownConnection() {
848848
mUnknownConnectionRegistrants.notifyResult(this);
849849
}
850850

851+
public boolean isInEmergencyCall() {
852+
return mCT.isInEmergencyCall();
853+
}
854+
855+
public boolean isInEcm() {
856+
return mIsPhoneInEcmState;
857+
}
858+
851859
void sendEmergencyCallbackModeChange(){
852860
//Send an Intent
853861
Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);

telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private boolean trySetupData(String reason) {
248248
boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();
249249

250250
if ((mState == State.IDLE || mState == State.SCANNING) &&
251-
isDataAllowed() && getAnyDataEnabled()) {
251+
isDataAllowed() && getAnyDataEnabled() && !isEmergency()) {
252252
boolean retValue = setupData(reason);
253253
notifyOffApnsOfAvailability(reason, retValue);
254254
return retValue;

telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ private boolean trySetupData(ApnContext apnContext) {
686686
boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
687687

688688
if ((apnContext.getState() == State.IDLE || apnContext.getState() == State.SCANNING) &&
689-
isDataAllowed(apnContext) && getAnyDataEnabled()) {
689+
isDataAllowed(apnContext) && getAnyDataEnabled() && !isEmergency()) {
690690

691691
if (apnContext.getState() == State.IDLE) {
692692
ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType());

0 commit comments

Comments
 (0)