Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [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 | |
| 17 | package com.android.server.telecom; |
| 18 | |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 19 | import android.telecom.TelecomProtoEnums; |
| 20 | |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 21 | /** |
| 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. |
| 26 | */ |
| 27 | public final class CallState { |
| 28 | |
| 29 | private CallState() {} |
| 30 | |
| 31 | /** |
| 32 | * Indicates that a call is new and not connected. This is used as the default state internally |
| 33 | * within Telecom and should not be used between Telecom and call services. Call services are |
| 34 | * not expected to ever interact with NEW calls, but {@link android.telecom.InCallService}s will |
| 35 | * see calls in this state. |
| 36 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 37 | public static final int NEW = TelecomProtoEnums.NEW; // = 0 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * The initial state of an outgoing {@code Call}. |
| 41 | * Common transitions are to {@link #DIALING} state for a successful call or |
| 42 | * {@link #DISCONNECTED} if it failed. |
| 43 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 44 | public static final int CONNECTING = TelecomProtoEnums.CONNECTING; // = 1 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * The state of an outgoing {@code Call} when waiting on user to select a |
| 48 | * {@link android.telecom.PhoneAccount} through which to place the call. |
| 49 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 50 | public static final int SELECT_PHONE_ACCOUNT = TelecomProtoEnums.SELECT_PHONE_ACCOUNT; // = 2 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 58 | public static final int DIALING = TelecomProtoEnums.DIALING; // = 3 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 66 | public static final int RINGING = TelecomProtoEnums.RINGING; // = 4 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 73 | public static final int ACTIVE = TelecomProtoEnums.ACTIVE; // = 5 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 81 | public static final int ON_HOLD = TelecomProtoEnums.ON_HOLD; // = 6 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 90 | public static final int DISCONNECTED = TelecomProtoEnums.DISCONNECTED; // = 7 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 96 | public static final int ABORTED = TelecomProtoEnums.ABORTED; // = 8 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 97 | |
| 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 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 106 | public static final int DISCONNECTING = TelecomProtoEnums.DISCONNECTING; // = 9 |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 107 | |
Tyler Gunn | 1e37be5 | 2016-07-11 08:54:23 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Indicates that the call is in the process of being pulled to the local device. |
| 110 | * <p> |
| 111 | * This state should only be set on a call with |
| 112 | * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} and |
| 113 | * {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL}. |
| 114 | */ |
Tej Singh | 95daef7 | 2018-02-05 18:34:19 -0800 | [diff] [blame] | 115 | public static final int PULLING = TelecomProtoEnums.PULLING; // = 10 |
Tyler Gunn | 1e37be5 | 2016-07-11 08:54:23 -0700 | [diff] [blame] | 116 | |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 117 | public static String toString(int callState) { |
| 118 | switch (callState) { |
| 119 | case NEW: |
| 120 | return "NEW"; |
| 121 | case CONNECTING: |
| 122 | return "CONNECTING"; |
| 123 | case SELECT_PHONE_ACCOUNT: |
| 124 | return "SELECT_PHONE_ACCOUNT"; |
| 125 | case DIALING: |
| 126 | return "DIALING"; |
| 127 | case RINGING: |
| 128 | return "RINGING"; |
| 129 | case ACTIVE: |
| 130 | return "ACTIVE"; |
| 131 | case ON_HOLD: |
| 132 | return "ON_HOLD"; |
| 133 | case DISCONNECTED: |
| 134 | return "DISCONNECTED"; |
| 135 | case ABORTED: |
| 136 | return "ABORTED"; |
| 137 | case DISCONNECTING: |
| 138 | return "DISCONNECTING"; |
Tyler Gunn | 1e37be5 | 2016-07-11 08:54:23 -0700 | [diff] [blame] | 139 | case PULLING: |
| 140 | return "PULLING"; |
Santos Cordon | 9269451 | 2015-04-23 14:47:28 -0700 | [diff] [blame] | 141 | default: |
| 142 | return "UNKNOWN"; |
| 143 | } |
| 144 | } |
| 145 | } |