blob: 0d2ca48b31857a00b1901bbd997242e4de7aaa82 [file] [log] [blame]
Santos Cordon92694512015-04-23 14:47:28 -07001/*
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
17package com.android.server.telecom;
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 */
25public final class CallState {
26
27 private CallState() {}
28
29 /**
30 * Indicates that a call is new and not connected. This is used as the default state internally
31 * within Telecom and should not be used between Telecom and call services. Call services are
32 * not expected to ever interact with NEW calls, but {@link android.telecom.InCallService}s will
33 * see calls in this state.
34 */
35 public static final int NEW = 0;
36
37 /**
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.
41 */
42 public static final int CONNECTING = 1;
43
44 /**
45 * The state of an outgoing {@code Call} when waiting on user to select a
46 * {@link android.telecom.PhoneAccount} through which to place the call.
47 */
48 public static final int SELECT_PHONE_ACCOUNT = 2;
49
50 /**
51 * Indicates that a call is outgoing and in the dialing state. A call transitions to this state
52 * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this
53 * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED}
54 * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user).
55 */
56 public static final int DIALING = 3;
57
58 /**
59 * Indicates that a call is incoming and the user still has the option of answering, rejecting,
60 * or doing nothing with the call. This state is usually associated with some type of audible
61 * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED}
62 * otherwise.
63 */
64 public static final int RINGING = 4;
65
66 /**
67 * Indicates that a call is currently connected to another party and a communication channel is
68 * open between them. The normal transition to this state is by the user answering a
69 * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party.
70 */
71 public static final int ACTIVE = 5;
72
73 /**
74 * Indicates that the call is currently on hold. In this state, the call is not terminated
75 * but no communication is allowed until the call is no longer on hold. The typical transition
76 * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing
77 * an action, such as clicking the hold button.
78 */
79 public static final int ON_HOLD = 6;
80
81 /**
82 * Indicates that a call is currently disconnected. All states can transition to this state
83 * by the call service giving notice that the connection has been severed. When the user
84 * explicitly ends a call, it will not transition to this state until the call service confirms
85 * the disconnection or communication was lost to the call service currently responsible for
86 * this call (e.g., call service crashes).
87 */
88 public static final int DISCONNECTED = 7;
89
90 /**
91 * Indicates that the call was attempted (mostly in the context of outgoing, at least at the
92 * time of writing) but cancelled before it was successfully connected.
93 */
94 public static final int ABORTED = 8;
95
96 /**
97 * Indicates that the call is in the process of being disconnected and will transition next
98 * to a {@link #DISCONNECTED} state.
99 * <p>
100 * This state is not expected to be communicated from the Telephony layer, but will be reported
101 * to the InCall UI for calls where disconnection has been initiated by the user but the
102 * ConnectionService has confirmed the call as disconnected.
103 */
104 public static final int DISCONNECTING = 9;
105
106 public static String toString(int callState) {
107 switch (callState) {
108 case NEW:
109 return "NEW";
110 case CONNECTING:
111 return "CONNECTING";
112 case SELECT_PHONE_ACCOUNT:
113 return "SELECT_PHONE_ACCOUNT";
114 case DIALING:
115 return "DIALING";
116 case RINGING:
117 return "RINGING";
118 case ACTIVE:
119 return "ACTIVE";
120 case ON_HOLD:
121 return "ON_HOLD";
122 case DISCONNECTED:
123 return "DISCONNECTED";
124 case ABORTED:
125 return "ABORTED";
126 case DISCONNECTING:
127 return "DISCONNECTING";
128 default:
129 return "UNKNOWN";
130 }
131 }
132}