192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon/* 292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Copyright 2014, The Android Open Source Project 392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * 492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Licensed under the Apache License, Version 2.0 (the "License"); 592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * you may not use this file except in compliance with the License. 692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * You may obtain a copy of the License at 792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * 892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * http://www.apache.org/licenses/LICENSE-2.0 992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * 1092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Unless required by applicable law or agreed to in writing, software 1192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * distributed under the License is distributed on an "AS IS" BASIS, 1292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * See the License for the specific language governing permissions and 1492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * limitations under the License. 1592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 1692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 1792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordonpackage com.android.server.telecom; 1892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 1992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon/** 2092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Defines call-state constants of the different states in which a call can exist. Although states 2192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * have the notion of normal transitions, due to the volatile nature of telephony systems, code 2292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * that uses these states should be resilient to unexpected state changes outside of what is 2392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * considered traditional. 2492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 2592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordonpublic final class CallState { 2692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 2792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon private CallState() {} 2892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 2992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 3092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that a call is new and not connected. This is used as the default state internally 3192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * within Telecom and should not be used between Telecom and call services. Call services are 3292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * not expected to ever interact with NEW calls, but {@link android.telecom.InCallService}s will 3392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * see calls in this state. 3492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 3592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int NEW = 0; 3692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 3792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 3892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * The initial state of an outgoing {@code Call}. 3992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Common transitions are to {@link #DIALING} state for a successful call or 4092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * {@link #DISCONNECTED} if it failed. 4192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 4292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int CONNECTING = 1; 4392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 4492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 4592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * The state of an outgoing {@code Call} when waiting on user to select a 4692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * {@link android.telecom.PhoneAccount} through which to place the call. 4792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 4892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int SELECT_PHONE_ACCOUNT = 2; 4992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 5092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 5192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that a call is outgoing and in the dialing state. A call transitions to this state 5292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this 5392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED} 5492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user). 5592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 5692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int DIALING = 3; 5792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 5892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 5992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that a call is incoming and the user still has the option of answering, rejecting, 6092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * or doing nothing with the call. This state is usually associated with some type of audible 6192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED} 6292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * otherwise. 6392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 6492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int RINGING = 4; 6592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 6692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 6792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that a call is currently connected to another party and a communication channel is 6892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * open between them. The normal transition to this state is by the user answering a 6992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party. 7092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 7192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int ACTIVE = 5; 7292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 7392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 7492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that the call is currently on hold. In this state, the call is not terminated 7592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * but no communication is allowed until the call is no longer on hold. The typical transition 7692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing 7792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * an action, such as clicking the hold button. 7892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 7992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int ON_HOLD = 6; 8092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 8192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 8292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that a call is currently disconnected. All states can transition to this state 8392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * by the call service giving notice that the connection has been severed. When the user 8492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * explicitly ends a call, it will not transition to this state until the call service confirms 8592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * the disconnection or communication was lost to the call service currently responsible for 8692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * this call (e.g., call service crashes). 8792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 8892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int DISCONNECTED = 7; 8992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 9092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 9192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that the call was attempted (mostly in the context of outgoing, at least at the 9292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * time of writing) but cancelled before it was successfully connected. 9392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 9492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int ABORTED = 8; 9592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 9692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon /** 9792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * Indicates that the call is in the process of being disconnected and will transition next 9892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * to a {@link #DISCONNECTED} state. 9992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * <p> 10092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * This state is not expected to be communicated from the Telephony layer, but will be reported 10192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * to the InCall UI for calls where disconnection has been initiated by the user but the 10292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon * ConnectionService has confirmed the call as disconnected. 10392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon */ 10492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static final int DISCONNECTING = 9; 10592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon 10692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon public static String toString(int callState) { 10792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon switch (callState) { 10892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case NEW: 10992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "NEW"; 11092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case CONNECTING: 11192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "CONNECTING"; 11292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case SELECT_PHONE_ACCOUNT: 11392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "SELECT_PHONE_ACCOUNT"; 11492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case DIALING: 11592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "DIALING"; 11692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case RINGING: 11792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "RINGING"; 11892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case ACTIVE: 11992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "ACTIVE"; 12092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case ON_HOLD: 12192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "ON_HOLD"; 12292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case DISCONNECTED: 12392694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "DISCONNECTED"; 12492694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case ABORTED: 12592694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "ABORTED"; 12692694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon case DISCONNECTING: 12792694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "DISCONNECTING"; 12892694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon default: 12992694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon return "UNKNOWN"; 13092694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon } 13192694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon } 13292694519535c54f542b4ef3973e9c1934f2feeffSantos Cordon} 133