summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorJohn Wang <johnwang@google.com>2010-11-15 18:44:46 -0800
committerJohn Wang <johnwang@google.com>2010-12-01 10:26:49 -0800
commit4567847d461afac08a80518637a0e48eff3c5247 (patch)
tree48af8d62a03ba5aa5655194a4fb7bffc3daa5109 /telephony/java
parent525566893bc17101e50b67af76d75abb412b95e0 (diff)
downloadframeworks_base-4567847d461afac08a80518637a0e48eff3c5247.zip
frameworks_base-4567847d461afac08a80518637a0e48eff3c5247.tar.gz
frameworks_base-4567847d461afac08a80518637a0e48eff3c5247.tar.bz2
Add "canDial" check.
For bug #3164802. CallManager allow a new phone call only if ALL of the following are true: - Phone is not powered off - There's no incoming or waiting call - There's available call slot in either foreground or background - The foreground call is ACTIVE or IDLE or DISCONNECTED. Change-Id: I0124d600fd8c63b8c608301f3889b3faec47f1db
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/com/android/internal/telephony/CallManager.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java
index d74a547..a8dd9c2 100644
--- a/telephony/java/com/android/internal/telephony/CallManager.java
+++ b/telephony/java/com/android/internal/telephony/CallManager.java
@@ -695,6 +695,10 @@ public final class CallManager {
Log.d(LOG_TAG, this.toString());
}
+ if (!canDial(phone)) {
+ throw new CallStateException("cannot dial in current state");
+ }
+
if ( hasActiveFgCall() ) {
Phone activePhone = getActiveFgCall().getPhone();
boolean hasBgCall = !(activePhone.getBackgroundCall().isIdle());
@@ -748,6 +752,32 @@ public final class CallManager {
}
/**
+ * Phone can make a call only if ALL of the following are true:
+ * - Phone is not powered off
+ * - There's no incoming or waiting call
+ * - There's available call slot in either foreground or background
+ * - The foreground call is ACTIVE or IDLE or DISCONNECTED.
+ * (We mainly need to make sure it *isn't* DIALING or ALERTING.)
+ * @param phone
+ * @return true if the phone can make a new call
+ */
+ private boolean canDial(Phone phone) {
+ int serviceState = phone.getServiceState().getState();
+ boolean hasRingingCall = hasActiveRingingCall();
+ boolean hasActiveCall = hasActiveFgCall();
+ boolean hasHoldingCall = hasActiveBgCall();
+ boolean allLinesTaken = hasActiveCall && hasHoldingCall;
+ Call.State fgCallState = getActiveFgCallState();
+
+ return (serviceState != ServiceState.STATE_POWER_OFF
+ && !hasRingingCall
+ && !allLinesTaken
+ && ((fgCallState == Call.State.ACTIVE)
+ || (fgCallState == Call.State.IDLE)
+ || (fgCallState == Call.State.DISCONNECTED)));
+ }
+
+ /**
* Whether or not the phone can do explicit call transfer in the current
* phone state--that is, one call holding and one call active.
* @return true if the phone can do explicit call transfer; false otherwise.