diff options
author | John Wang <johnwang@google.com> | 2010-12-01 11:20:56 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-12-01 11:20:56 -0800 |
commit | 447a2b014b3dfdbd3294f07529d7758f81def73e (patch) | |
tree | 79296a8b1f3a6e9b51259eeb56a20d6256c82d98 /telephony | |
parent | fd49d920aee6068f923359f71490caf14db0fffc (diff) | |
parent | ae2a44191188cde1dc4a1bbb0134d775f0dc4126 (diff) | |
download | frameworks_base-447a2b014b3dfdbd3294f07529d7758f81def73e.zip frameworks_base-447a2b014b3dfdbd3294f07529d7758f81def73e.tar.gz frameworks_base-447a2b014b3dfdbd3294f07529d7758f81def73e.tar.bz2 |
am ae2a4419: am 4567847d: Add "canDial" check.
* commit 'ae2a44191188cde1dc4a1bbb0134d775f0dc4126':
Add "canDial" check.
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/CallManager.java | 30 |
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 5b49305..719e5b4 100644 --- a/telephony/java/com/android/internal/telephony/CallManager.java +++ b/telephony/java/com/android/internal/telephony/CallManager.java @@ -700,6 +700,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()); @@ -753,6 +757,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. |