| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Defines call-state constants of the different states in which a call can exist. Although states |
| 21 | * have the notion of normal transitions, due to the volatile nature of telephony systems, code |
| 22 | * that uses these states should be resilient to unexpected state changes outside of what is |
| 23 | * considered traditional. |
| 24 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 25 | public final class CallState { |
| 26 | |
| 27 | private CallState() {} |
| 28 | |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Indicates that a call is new and not connected. This is used as the default state internally |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 31 | * within Telecom and should not be used between Telecom and call services. Call services are |
| Evan Charlton | e9aa1aa | 2014-04-10 09:21:03 -0700 | [diff] [blame] | 32 | * not expected to ever interact with NEW calls, but {@link InCallService}s will see calls in |
| 33 | * this state. |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 34 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 35 | public static final int NEW = 0; |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
| Nancy Chen | e9b7a8e | 2014-08-08 14:26:27 -0700 | [diff] [blame] | 38 | * The initial state of an outgoing {@code Call}. |
| 39 | * Common transitions are to {@link #DIALING} state for a successful call or |
| 40 | * {@link #DISCONNECTED} if it failed. |
| Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 41 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 42 | public static final int CONNECTING = 1; |
| Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 45 | * Indicates that the call is about to go into the outgoing and dialing state but is waiting for |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 46 | * user input before it proceeds. For example, where no default {@link PhoneAccount} is set, |
| 47 | * this is the state where the InCallUI is waiting for the user to select a |
| 48 | * {@link PhoneAccount} to call from. |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 49 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 50 | public static final int PRE_DIAL_WAIT = 2; |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 53 | * Indicates that a call is outgoing and in the dialing state. A call transitions to this state |
| 54 | * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this |
| 55 | * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED} |
| 56 | * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user). |
| 57 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 58 | public static final int DIALING = 3; |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Indicates that a call is incoming and the user still has the option of answering, rejecting, |
| 62 | * or doing nothing with the call. This state is usually associated with some type of audible |
| 63 | * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED} |
| 64 | * otherwise. |
| 65 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 66 | public static final int RINGING = 4; |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Indicates that a call is currently connected to another party and a communication channel is |
| 70 | * open between them. The normal transition to this state is by the user answering a |
| 71 | * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party. |
| 72 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 73 | public static final int ACTIVE = 5; |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 74 | |
| 75 | /** |
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 76 | * Indicates that the call is currently on hold. In this state, the call is not terminated |
| 77 | * but no communication is allowed until the call is no longer on hold. The typical transition |
| 78 | * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing |
| 79 | * an action, such as clicking the hold button. |
| 80 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 81 | public static final int ON_HOLD = 6; |
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 84 | * Indicates that a call is currently disconnected. All states can transition to this state |
| 85 | * by the call service giving notice that the connection has been severed. When the user |
| 86 | * explicitly ends a call, it will not transition to this state until the call service confirms |
| 87 | * the disconnection or communication was lost to the call service currently responsible for |
| 88 | * this call (e.g., call service crashes). |
| 89 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 90 | public static final int DISCONNECTED = 7; |
| Ben Gilad | 6c874e3 | 2014-03-04 16:01:22 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Indicates that the call was attempted (mostly in the context of outgoing, at least at the |
| 94 | * time of writing) but cancelled before it was successfully connected. |
| 95 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 96 | public static final int ABORTED = 8; |
| 97 | |
| Tyler Gunn | 4afc6af | 2014-10-07 10:14:55 -0700 | [diff] [blame] | 98 | /** |
| 99 | * Indicates that the call is in the process of being disconnected and will transition next |
| 100 | * to a {@link #DISCONNECTED} state. |
| 101 | * <p> |
| 102 | * This state is not expected to be communicated from the Telephony layer, but will be reported |
| 103 | * to the InCall UI for calls where disconnection has been initiated by the user but the |
| 104 | * ConnectionService has confirmed the call as disconnected. |
| 105 | */ |
| 106 | public static final int DISCONNECTING = 9; |
| 107 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 108 | public static String toString(int callState) { |
| 109 | switch (callState) { |
| 110 | case NEW: |
| 111 | return "NEW"; |
| 112 | case CONNECTING: |
| 113 | return "CONNECTING"; |
| 114 | case PRE_DIAL_WAIT: |
| 115 | return "PRE_DIAL_WAIT"; |
| 116 | case DIALING: |
| 117 | return "DIALING"; |
| 118 | case RINGING: |
| 119 | return "RINGING"; |
| 120 | case ACTIVE: |
| 121 | return "ACTIVE"; |
| 122 | case ON_HOLD: |
| 123 | return "ON_HOLD"; |
| 124 | case DISCONNECTED: |
| 125 | return "DISCONNECTED"; |
| 126 | case ABORTED: |
| 127 | return "ABORTED"; |
| Tyler Gunn | 4afc6af | 2014-10-07 10:14:55 -0700 | [diff] [blame] | 128 | case DISCONNECTING: |
| 129 | return "DISCONNECTING"; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 130 | default: |
| 131 | return "UNKNOWN"; |
| 132 | } |
| 133 | } |
| Santos Cordon | 3d3735e | 2014-01-29 14:10:10 -0800 | [diff] [blame] | 134 | } |