/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";
package android.telecom;

option java_outer_classname = "TelecomProtoEnums";
option java_multiple_files = true;

/**
 * Call states, primarily used in CallState.java,
 * Call.java, and CallsManager.java in packages/services.
 */
enum CallStateEnum {
    /**
     * Indicates that a call is new and not connected. This is used as the default state internally
     * within Telecom and should not be used between Telecom and call services. Call services are
     * not expected to ever interact with NEW calls, but {@link android.telecom.InCallService}s will
     * see calls in this state.
     */
    NEW = 0;

    /**
     * The initial state of an outgoing {@code Call}.
     * Common transitions are to {@link #DIALING} state for a successful call or
     * {@link #DISCONNECTED} if it failed.
     */
    CONNECTING = 1;

    /**
     * The state of an outgoing {@code Call} when waiting on user to select a
     * {@link android.telecom.PhoneAccount} through which to place the call.
     */
    SELECT_PHONE_ACCOUNT = 2;

    /**
     * Indicates that a call is outgoing and in the dialing state. A call transitions to this state
     * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this
     * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED}
     * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user).
     */
    DIALING = 3;

    /**
     * Indicates that a call is incoming and the user still has the option of answering, rejecting,
     * or doing nothing with the call. This state is usually associated with some type of audible
     * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED}
     * otherwise.
     */
    RINGING = 4;

    /**
     * Indicates that a call is currently connected to another party and a communication channel is
     * open between them. The normal transition to this state is by the user answering a
     * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party.
     */
    ACTIVE = 5;

    /**
     * Indicates that the call is currently on hold. In this state, the call is not terminated
     * but no communication is allowed until the call is no longer on hold. The typical transition
     * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing
     * an action, such as clicking the hold button.
     */
    ON_HOLD = 6;

    /**
     * Indicates that a call is currently disconnected. All states can transition to this state
     * by the call service giving notice that the connection has been severed. When the user
     * explicitly ends a call, it will not transition to this state until the call service confirms
     * the disconnection or communication was lost to the call service currently responsible for
     * this call (e.g., call service crashes).
     */
    DISCONNECTED = 7;

    /**
     * Indicates that the call was attempted (mostly in the context of outgoing, at least at the
     * time of writing) but cancelled before it was successfully connected.
     */
    ABORTED = 8;

    /**
     * Indicates that the call is in the process of being disconnected and will transition next
     * to a {@link #DISCONNECTED} state.
     * <p>
     * This state is not expected to be communicated from the Telephony layer, but will be reported
     * to the InCall UI for calls where disconnection has been initiated by the user but the
     * ConnectionService has confirmed the call as disconnected.
     */
    DISCONNECTING = 9;

    /**
     * Indicates that the call is in the process of being pulled to the local device.
     * <p>
     * This state should only be set on a call with
     * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} and
     * {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL}.
     */
    PULLING = 10;

    /**
     * Indicates that an incoming call has been answered by the in-call UI, but Telephony hasn't yet
     * set the call to active.
     */
    ANSWERED = 11;

    /**
     * Indicates that the call is undergoing audio processing by a different app in the background.
     * @see android.telecom.Call#STATE_AUDIO_PROCESSING
     */
    AUDIO_PROCESSING = 12;

    /**
     * Indicates that the call is in a fake ringing state.
     * @see android.telecom.Call#STATE_SIMULATED_RINGING
     */
    SIMULATED_RINGING = 13;
}

// Disconnect causes for a call. Primarily used by android/telecom/DisconnectCause.java
enum DisconnectCauseEnum {
    /**
     * Disconnected because of an unknown or unspecified reason.
     */
    UNKNOWN = 0;

    /**
     * Disconnected because there was an error, such as a problem with the network.
     */
    ERROR = 1;

    /**
     * Disconnected because of a local user-initiated action, such as hanging up.
     */
    LOCAL = 2;

    /**
     * Disconnected because of a remote user-initiated action, such as the other party hanging up
     * up.
     */
    REMOTE = 3;

    /**
     * Disconnected because it has been canceled.
     */
    CANCELED = 4;

    /**
     * Disconnected because there was no response to an incoming call.
     */
    MISSED = 5;

    /**
     * Disconnected because the user rejected an incoming call.
     */
    REJECTED = 6;

    /**
     * Disconnected because the other party was busy.
     */
    BUSY = 7;

    /**
     * Disconnected because of a restriction on placing the call, such as dialing in airplane
     * mode.
     */
    RESTRICTED = 8;

    /**
     * Disconnected for reason not described by other disconnect codes.
     */
    OTHER = 9;

    /**
     * Disconnected because the connection manager did not support the call. The call will be tried
     * again without a connection manager. See {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}.
     */
    CONNECTION_MANAGER_NOT_SUPPORTED = 10;

    /**
     * Disconnected because the user did not locally answer the incoming call, but it was answered
     * on another device where the call was ringing.
     */
    ANSWERED_ELSEWHERE = 11;

    /**
     * Disconnected because the call was pulled from the current device to another device.
     */
    CALL_PULLED = 12;
}

/**
 * Indicating the failure reason why a new call cannot be made.
 */
enum CallFailureCauseEnum {
    /**
     * The call is normally started.
     */
    FAILURE_CAUSE_NONE = 0;

    /**
     * Necessary parameters are invalid or null.
     */
    FAILURE_CAUSE_INVALID_USE = 1;

    /**
     * There is an emergency call ongoing.
     */
    FAILURE_CAUSE_IN_EMERGENCY_CALL = 2;

    /**
     * There is an live call that cannot be held.
     */
    FAILURE_CAUSE_CANNOT_HOLD_CALL = 3;

    /**
     * There are maximum outgoing calls already.
     */
    FAILURE_CAUSE_MAX_OUTGOING_CALLS = 4;

    /**
     * There are maximum ringing calls already.
     */
    FAILURE_CAUSE_MAX_RINGING_CALLS = 5;

    /**
     * There are maximum calls in hold already.
     */
    FAILURE_CAUSE_MAX_HOLD_CALLS = 6;

    /**
     * There are maximum self-managed calls already.
     */
    FAILURE_CAUSE_MAX_SELF_MANAGED_CALLS = 7;
}

/**
 * Indicating the call direction
 */
enum CallDirectionEnum {
    DIR_UNKNOWN = 0;
    DIR_INCOMING = 1;
    DIR_OUTGOING = 2;
}

/**
 * Indicating the account type
 */
enum AccountTypeEnum {
     ACCOUNT_UNKNOWN = 0;
     ACCOUNT_MANAGED = 1;
     ACCOUNT_SELFMANAGED = 2;
     ACCOUNT_SIM = 3;
     ACCOUNT_VOIP_API = 4;
     /**
      * A VoIP call that was made without the telecom framework.
      */
     ACCOUNT_NON_TELECOM_VOIP = 5;
     /**
      * A VoIP call that was made without the telecom framework where the app has declared support
      * for telecom but chose not to use it.
      */
     ACCOUNT_NON_TELECOM_VOIP_WITH_TELECOM_SUPPORT = 6;
}

/**
 * Indicating the call audio events
 */
enum CallAudioEnum {
    CALL_AUDIO_UNSPECIFIED = 0;
    CALL_AUDIO_PHONE_SPEAKER = 1;
    CALL_AUDIO_WATCH_SPEAKER = 2;
    CALL_AUDIO_BLUETOOTH = 3;
    CALL_AUDIO_AUTO = 4;
    CALL_AUDIO_EARPIECE = 5;
    CALL_AUDIO_WIRED_HEADSET = 6;
    CALL_AUDIO_HEARING_AID = 7;
    CALL_AUDIO_BLUETOOTH_LE = 8;
}

/**
 * Indicating the API name
 */
enum ApiNameEnum {
    API_UNSPECIFIED = 0;
    API_ACCEPT_HANDOVER = 1;
    API_ACCEPT_RINGING_CALL = 2;
    API_ACCEPT_RINGING_CALL_WITH_VIDEO_STATE = 3;
    API_ADD_CALL = 4;
    API_ADD_NEW_INCOMING_CALL = 5;
    API_ADD_NEW_INCOMING_CONFERENCE = 6;
    API_ADD_NEW_UNKNOWN_CALL = 7;
    API_CANCEL_MISSED_CALLS_NOTIFICATION = 8;
    API_CLEAR_ACCOUNTS = 9;
    API_CREATE_LAUNCH_EMERGENCY_DIALER_INTENT = 10;
    API_CREATE_MANAGE_BLOCKED_NUMBERS_INTENT = 11;
    API_DUMP = 12;
    API_DUMP_CALL_ANALYTICS = 13;
    API_ENABLE_PHONE_ACCOUNT = 14;
    API_END_CALL = 15;
    API_GET_ADN_URI_FOR_PHONE_ACCOUNT = 16;
    API_GET_ALL_PHONE_ACCOUNT_HANDLES = 17;
    API_GET_ALL_PHONE_ACCOUNTS = 18;
    API_GET_ALL_PHONE_ACCOUNTS_COUNT = 19;
    API_GET_CALL_CAPABLE_PHONE_ACCOUNTS = 20;
    API_GET_CALL_STATE = 21;
    API_GET_CALL_STATE_USING_PACKAGE = 22;
    API_GET_CURRENT_TTY_MODE = 23;
    API_GET_DEFAULT_DIALER_PACKAGE = 24;
    API_GET_DEFAULT_DIALER_PACKAGE_FOR_USER = 25;
    API_GET_DEFAULT_OUTGOING_PHONE_ACCOUNT = 26;
    API_GET_DEFAULT_PHONE_APP = 27;
    API_GET_LINE1_NUMBER = 28;
    API_GET_OWN_SELF_MANAGED_PHONE_ACCOUNTS = 29;
    API_GET_PHONE_ACCOUNT = 30;
    API_GET_PHONE_ACCOUNTS_FOR_PACKAGE = 31;
    API_GET_PHONE_ACCOUNTS_SUPPORTING_SCHEME = 32;
    API_GET_REGISTERED_PHONE_ACCOUNTS = 33;
    API_GET_SELF_MANAGED_PHONE_ACCOUNTS = 34;
    API_GET_SIM_CALL_MANAGER = 35;
    API_GET_SIM_CALL_MANAGER_FOR_USER = 36;
    API_GET_SYSTEM_DIALER_PACKAGE = 37;
    API_GET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT = 38;
    API_GET_VOICE_MAIL_NUMBER = 39;
    API_HANDLE_PIN_MMI = 40;
    API_HANDLE_PIN_MMI_FOR_PHONE_ACCOUNT = 41;
    API_HAS_MANAGE_ONGOING_CALLS_PERMISSION = 42;
    API_IS_IN_CALL = 43;
    API_IS_IN_EMERGENCY_CALL = 44;
    API_IS_IN_MANAGED_CALL = 45;
    API_IS_IN_SELF_MANAGED_CALL = 46;
    API_IS_INCOMING_CALL_PERMITTED = 47;
    API_IS_OUTGOING_CALL_PERMITTED = 48;
    API_IS_RINGING = 49;
    API_IS_TTY_SUPPORTED = 50;
    API_IS_VOICE_MAIL_NUMBER = 51;
    API_PLACE_CALL = 52;
    API_REGISTER_PHONE_ACCOUNT = 53;
    API_SET_DEFAULT_DIALER = 54;
    API_SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT = 55;
    API_SHOW_IN_CALL_SCREEN = 56;
    API_SILENCE_RINGER = 57;
    API_START_CONFERENCE = 58;
    API_UNREGISTER_PHONE_ACCOUNT = 59;
    // API usage enum for method:
    // TelecomManager#getCallConnectedIndicatorPreference
    API_GET_CALL_CONNECTED_INDICATOR_PREF = 60;
    // API usage enum for method:
    // TelecomManager#setCallConnectedIndicatorPreference
    API_SET_CALL_CONNECTED_INDICATOR_PREF = 61;
}

/**
 * Indicating the result of the API call
 */
enum ApiResultEnum {
    RESULT_UNKNOWN = 0;
    RESULT_SUCCESS = 1;
    RESULT_PERMISSION = 2;
    RESULT_EXCEPTION = 3;
}

/**
 * Indicating the sub module name
 */
enum SubmoduleEnum {
    SUB_UNKNOWN = 0;
    SUB_CALL_AUDIO = 1;
    SUB_CALL_LOGS = 2;
    SUB_CALL_MANAGER = 3;
    SUB_CONNECTION_SERVICE = 4;
    SUB_EMERGENCY_CALL = 5;
    SUB_IN_CALL_SERVICE = 6;
    SUB_MISC = 7;
    SUB_PHONE_ACCOUNT = 8;
    SUB_SYSTEM_SERVICE = 9;
    SUB_TELEPHONY = 10;
    SUB_UI = 11;
    SUB_VOIP_CALL = 12;
}

/**
 * Indicating the error name
 */
enum ErrorEnum {
    ERROR_UNKNOWN = 0;
    ERROR_EXTERNAL_EXCEPTION = 1;
    ERROR_INTERNAL_EXCEPTION = 2;
    ERROR_AUDIO_ROUTE_RETRY_REJECTED = 3;
    ERROR_BT_GET_SERVICE_FAILURE = 4;
    ERROR_BT_REGISTER_CALLBACK_FAILURE = 5;
    ERROR_AUDIO_ROUTE_UNAVAILABLE = 6;
    ERROR_EMERGENCY_NUMBER_DETERMINED_FAILURE = 7;
    ERROR_NOTIFY_CALL_STREAM_START_FAILURE = 8;
    ERROR_NOTIFY_CALL_STREAM_STATE_CHANGED_FAILURE = 9;
    ERROR_NOTIFY_CALL_STREAM_STOP_FAILURE = 10;
    ERROR_RTT_STREAM_CLOSE_FAILURE = 11;
    ERROR_RTT_STREAM_CREATE_FAILURE = 12;
    ERROR_SET_MUTED_FAILURE = 13;
    ERROR_VIDEO_PROVIDER_SET_FAILURE = 14;
    ERROR_WIRED_HEADSET_NOT_AVAILABLE = 15;
    ERROR_LOG_CALL_FAILURE = 16;
    ERROR_RETRIEVING_ACCOUNT_EMERGENCY = 17;
    ERROR_RETRIEVING_ACCOUNT = 18;
    ERROR_EMERGENCY_CALL_ABORTED_NO_ACCOUNT = 19;
    ERROR_DEFAULT_MO_ACCOUNT_MISMATCH = 20;
    ERROR_ESTABLISHING_CONNECTION = 21;
    ERROR_REMOVING_CALL = 22;
    ERROR_STUCK_CONNECTING_EMERGENCY = 23;
    ERROR_STUCK_CONNECTING = 24;
    // Errors from android.telecom.CallException
    ERROR_TRANSACTION_UNKNOWN = 25;
    ERROR_CANNOT_HOLD_CALL = 26;
    ERROR_CALL_NOT_TRACKED = 27;
    ERROR_CANNOT_SET_ACTIVE = 28;
    ERROR_CALL_NOT_PERMITTED = 29;
    ERROR_OPERATION_TIMED_OUT = 30;
}

/**
 * Indicating the simultaneous call type
 */
enum SimultaneousTypeEnum {
    TYPE_UNKNOWN = 0;
    TYPE_SIMULTANEOUS_DISABLED_SAME_ACCOUNT = 1;
    TYPE_SIMULTANEOUS_DISABLED_DIFF_ACCOUNT = 2;
    TYPE_DUAL_SAME_ACCOUNT = 3;
    TYPE_DUAL_DIFF_ACCOUNT = 4;
}

/**
 * Indicating telecom key event name
 */
enum EventEnum {
    EVENT_UNKNOWN = 0;
    EVENT_INIT = 1;
    EVENT_DEFAULT_DIALER_CHANGED = 2;
    EVENT_ADD_CALL = 3;
    EVENT_LOG_VOIP_CALL_INCOMING_VOICE = 4;
    EVENT_LOG_VOIP_CALL_INCOMING_VIDEO = 5;
    EVENT_LOG_VOIP_CALL_OUTGOING_VOICE = 6;
    EVENT_LOG_VOIP_CALL_OUTGOING_VIDEO = 7;
    EVENT_CALL_BACK = 8;
}

/**
 * Indicating the cause of telecom key event
 */
enum EventCauseEnum {
    CAUSE_UNKNOWN = 0;
    CAUSE_GENERIC_SUCCESS = 1;
    CAUSE_GENERIC_FAILURE = 2;
    // [1,000 - 1,100) Call transaction result
    CALL_TRANSACTION_SUCCESS = 1000;
    CALL_TRANSACTION_ERROR_UNKNOWN = 1001;
    CALL_TRANSACTION_CANNOT_HOLD_CURRENT_ACTIVE_CALL = 1002;
    CALL_TRANSACTION_CALL_IS_NOT_BEING_TRACKED = 1003;
    CALL_TRANSACTION_CALL_CANNOT_BE_SET_TO_ACTIVE = 1004;
    CALL_TRANSACTION_CALL_NOT_PERMITTED_AT_PRESENT_TIME = 1005;
    CALL_TRANSACTION_CODE_OPERATION_TIMED_OUT = 1006;
    // [1,100 - 1,200) Integrated call logs
    CALL_LOG_OPT_OUT = 1100;
    CALL_LOG_OPT_IN = 1101;
    CALL_LOG_OPT_IN_EXCLUDED = 1103;
}

/**
 * Indicating the operation being performed on the call. This includes
 * answer, hold, unhold, disconnect, and reject.
 */
enum CallOperationTypeEnum {
    CALL_OPERATION_UNKNOWN = 0;
    CALL_OPERATION_ANSWER = 1;
    CALL_OPERATION_HOLD = 2;
    CALL_OPERATION_UNHOLD = 3;
    CALL_OPERATION_DISCONNECT = 4;
    CALL_OPERATION_REJECT = 5;
}

/**
 * Indicating the result of the call operation being performed. This can either succeed, fail due
 * to an external issue, or timeout.
 */
enum CallOperationResultEnum {
    CALL_OPERATION_RESULT_UNKNOWN = 0;
    CALL_OPERATION_RESULT_SUCCESS = 1;
    CALL_OPERATION_RESULT_ERROR = 2;
    CALL_OPERATION_RESULT_TIMEOUT = 3;
}

/**
 * Indicating the type of the call - managed, self-managed, transactional, or unknown.
 */
enum CallTypeEnum {
    UNKNOWN_CALL_TYPE = 0;
    MANAGED_CALL_TYPE = 1;
    SELF_MANAGED_CALL_TYPE = 2;
    TRANSACTIONAL_CALL_TYPE = 3;
}
