blob: bd9223affbff1478247481c2d38f1c4e33e8a250 [file] [log] [blame]
Santos Cordon3d3735e2014-01-29 14:10:10 -08001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Santos Cordon3d3735e2014-01-29 14:10:10 -080018
Gabriel Pealb95f1692014-08-19 14:24:18 -070019import android.annotation.SystemApi;
20
Santos Cordon3d3735e2014-01-29 14:10:10 -080021/**
22 * Defines call-state constants of the different states in which a call can exist. Although states
23 * have the notion of normal transitions, due to the volatile nature of telephony systems, code
24 * that uses these states should be resilient to unexpected state changes outside of what is
25 * considered traditional.
Ihab Awadb19a0bc2014-08-07 19:46:01 -070026 *
27 * {@hide}
Santos Cordon3d3735e2014-01-29 14:10:10 -080028 */
Gabriel Pealb95f1692014-08-19 14:24:18 -070029@SystemApi
Ihab Awadb19a0bc2014-08-07 19:46:01 -070030public final class CallState {
31
32 private CallState() {}
33
Santos Cordon3d3735e2014-01-29 14:10:10 -080034 /**
35 * Indicates that a call is new and not connected. This is used as the default state internally
Tyler Gunnef9f6f92014-09-12 22:16:17 -070036 * within Telecom and should not be used between Telecom and call services. Call services are
Evan Charltone9aa1aa2014-04-10 09:21:03 -070037 * not expected to ever interact with NEW calls, but {@link InCallService}s will see calls in
38 * this state.
Santos Cordon3d3735e2014-01-29 14:10:10 -080039 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070040 public static final int NEW = 0;
Santos Cordon3d3735e2014-01-29 14:10:10 -080041
42 /**
Nancy Chene9b7a8e2014-08-08 14:26:27 -070043 * The initial state of an outgoing {@code Call}.
44 * Common transitions are to {@link #DIALING} state for a successful call or
45 * {@link #DISCONNECTED} if it failed.
Nancy Chene20930f2014-08-07 16:17:21 -070046 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070047 public static final int CONNECTING = 1;
Nancy Chene20930f2014-08-07 16:17:21 -070048
49 /**
Nancy Chen5da0fd52014-07-08 14:16:17 -070050 * Indicates that the call is about to go into the outgoing and dialing state but is waiting for
Evan Charlton8c8a0622014-07-20 12:31:00 -070051 * user input before it proceeds. For example, where no default {@link PhoneAccount} is set,
52 * this is the state where the InCallUI is waiting for the user to select a
53 * {@link PhoneAccount} to call from.
Nancy Chen5da0fd52014-07-08 14:16:17 -070054 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070055 public static final int PRE_DIAL_WAIT = 2;
Nancy Chen5da0fd52014-07-08 14:16:17 -070056
57 /**
Santos Cordon3d3735e2014-01-29 14:10:10 -080058 * Indicates that a call is outgoing and in the dialing state. A call transitions to this state
59 * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this
60 * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED}
61 * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user).
62 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070063 public static final int DIALING = 3;
Santos Cordon3d3735e2014-01-29 14:10:10 -080064
65 /**
66 * Indicates that a call is incoming and the user still has the option of answering, rejecting,
67 * or doing nothing with the call. This state is usually associated with some type of audible
68 * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED}
69 * otherwise.
70 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070071 public static final int RINGING = 4;
Santos Cordon3d3735e2014-01-29 14:10:10 -080072
73 /**
74 * Indicates that a call is currently connected to another party and a communication channel is
75 * open between them. The normal transition to this state is by the user answering a
76 * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party.
77 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070078 public static final int ACTIVE = 5;
Santos Cordon3d3735e2014-01-29 14:10:10 -080079
80 /**
Yorke Lee81ccaaa2014-03-12 18:33:19 -070081 * Indicates that the call is currently on hold. In this state, the call is not terminated
82 * but no communication is allowed until the call is no longer on hold. The typical transition
83 * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing
84 * an action, such as clicking the hold button.
85 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070086 public static final int ON_HOLD = 6;
Yorke Lee81ccaaa2014-03-12 18:33:19 -070087
88 /**
Santos Cordon3d3735e2014-01-29 14:10:10 -080089 * Indicates that a call is currently disconnected. All states can transition to this state
90 * by the call service giving notice that the connection has been severed. When the user
91 * explicitly ends a call, it will not transition to this state until the call service confirms
92 * the disconnection or communication was lost to the call service currently responsible for
93 * this call (e.g., call service crashes).
94 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070095 public static final int DISCONNECTED = 7;
Ben Gilad6c874e32014-03-04 16:01:22 -080096
97 /**
98 * Indicates that the call was attempted (mostly in the context of outgoing, at least at the
99 * time of writing) but cancelled before it was successfully connected.
100 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700101 public static final int ABORTED = 8;
102
Tyler Gunn4afc6af2014-10-07 10:14:55 -0700103 /**
104 * Indicates that the call is in the process of being disconnected and will transition next
105 * to a {@link #DISCONNECTED} state.
106 * <p>
107 * This state is not expected to be communicated from the Telephony layer, but will be reported
108 * to the InCall UI for calls where disconnection has been initiated by the user but the
109 * ConnectionService has confirmed the call as disconnected.
110 */
111 public static final int DISCONNECTING = 9;
112
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700113 public static String toString(int callState) {
114 switch (callState) {
115 case NEW:
116 return "NEW";
117 case CONNECTING:
118 return "CONNECTING";
119 case PRE_DIAL_WAIT:
120 return "PRE_DIAL_WAIT";
121 case DIALING:
122 return "DIALING";
123 case RINGING:
124 return "RINGING";
125 case ACTIVE:
126 return "ACTIVE";
127 case ON_HOLD:
128 return "ON_HOLD";
129 case DISCONNECTED:
130 return "DISCONNECTED";
131 case ABORTED:
132 return "ABORTED";
Tyler Gunn4afc6af2014-10-07 10:14:55 -0700133 case DISCONNECTING:
134 return "DISCONNECTING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700135 default:
136 return "UNKNOWN";
137 }
138 }
Santos Cordon3d3735e2014-01-29 14:10:10 -0800139}