summaryrefslogtreecommitdiff
path: root/src/com/android/phone/CdmaPhoneCallState.java
blob: 30ab209f3e0741e4b24330648fdf7793ec3aacfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright (C) 2009 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.
 */

package com.android.phone;

/**
 * Class to internally keep track of Call states to maintain
 * information for Call Waiting and 3Way for CDMA instance of Phone App.
 *
 * Explanation for PhoneApp's Call states and why it is required:
 * IDLE - When no call is going on. This is just required as default state to reset the PhoneApp
 *        call state to when the complete call gets disconnected
 * SINGLE_ACTIVE - When only single call is active.
 *        In normal case(on a single call) this state would be similar for FW's state of ACTIVE
 *        call or phone state of OFFHOOK, but in more complex conditions e.g. when phone is already
 *        in a CONF_CALL state and user rejects a CW, which basically tells the PhoneApp that the
 *        Call is back to a single call, the FW's state still would remain ACTIVE or OFFHOOK and
 *        isGeneric would still be true. At this condition PhoneApp does need to enable the
 *        "Add Call" menu item and disable the "Swap" and "Merge" options
 * THRWAY_ACTIVE - When user initiate an outgoing call when already on a call.
 *        fgCall can have more than one connections from various scenarios (accepting the CW or
 *        making a 3way call) but once we are in this state and one of the parties drops off,
 *        when the user originates another call we need to remember this state to update the menu
 *        items accordingly. FW currently does not differentiate this condition hence PhoneApp
 *        needs to maintain it.
 * CONF_CALL - When the user merges two calls or on accepting the Call waiting call.
 *        This is required cause even though a call might be generic but that does not mean it is
 *        in conference. We can take the same example mention in the SINGLE_ACTIVE state.
 *
 * TODO: Eventually this state information should be maintained by Telephony FW.
 */
   public class CdmaPhoneCallState {

        /**
         * Allowable values for the PhoneCallState.
         *   IDLE - When no call is going on.
         *   SINGLE_ACTIVE - When only single call is active
         *   THRWAY_ACTIVE - When user initiate an outgoing call when already on a call
         *   CONF_CALL - When the user merges two calls or on accepting the Call waiting call
         */
        public enum PhoneCallState {
            IDLE,
            SINGLE_ACTIVE,
            THRWAY_ACTIVE,
            CONF_CALL
        }

        // For storing current and previous PhoneCallState's
        private PhoneCallState mPreviousCallState;
        private PhoneCallState mCurrentCallState;

        // Boolean to track 3Way display state
        private boolean mThreeWayCallOrigStateDialing;

        // Flag to indicate if the "Add Call" menu item in an InCallScreen is OK
        // to be displayed after a Call Waiting call was ignored or timed out
        private boolean mAddCallMenuStateAfterCW;

        /**
         * Initialize PhoneCallState related members - constructor
         */
        public void CdmaPhoneCallStateInit() {
            mCurrentCallState = PhoneCallState.IDLE;
            mPreviousCallState = PhoneCallState.IDLE;
            mThreeWayCallOrigStateDialing = false;
            mAddCallMenuStateAfterCW = true;
        }

        /**
         * Returns the current call state
         */
        public PhoneCallState getCurrentCallState() {
            return mCurrentCallState;
        }

        /**
         * Set current and previous PhoneCallState's
         */
        public void setCurrentCallState(PhoneCallState newState) {
            mPreviousCallState = mCurrentCallState;
            mCurrentCallState = newState;

            //Reset the 3Way display boolean
            mThreeWayCallOrigStateDialing = false;

            //Set mAddCallMenuStateAfterCW to true
            //if the current state is being set to SINGLE_ACTIVE
            //and previous state was IDLE as we could reach the SINGLE_ACTIVE
            //from CW ignore too. For all other cases let the timer or
            //specific calls to setAddCallMenuStateAfterCallWaiting set
            //mAddCallMenuStateAfterCW.
            if ((mCurrentCallState == PhoneCallState.SINGLE_ACTIVE)
                && (mPreviousCallState == PhoneCallState.IDLE)) {
                mAddCallMenuStateAfterCW = true;
            }
        }

        /**
         * Return 3Way display information
         */
        public boolean IsThreeWayCallOrigStateDialing() {
            return mThreeWayCallOrigStateDialing;
        }

        /**
         * Set 3Way display information
         */
        public void setThreeWayCallOrigState(boolean newState) {
            mThreeWayCallOrigStateDialing = newState;
        }

        /**
         * Return information for enabling/disabling "Add Call" menu item
         */
        public boolean getAddCallMenuStateAfterCallWaiting() {
            return mAddCallMenuStateAfterCW;
        }

        /**
         * Set mAddCallMenuStateAfterCW to enabling/disabling "Add Call" menu item
         */
        public void setAddCallMenuStateAfterCallWaiting(boolean newState) {
            mAddCallMenuStateAfterCW = newState;
        }

        /**
         * Return previous PhoneCallState's
         */
        public PhoneCallState getPreviousCallState() {
            return mPreviousCallState;
        }

        /**
         * Reset all PhoneCallState
         */
        public void resetCdmaPhoneCallState() {
            mCurrentCallState = PhoneCallState.IDLE;
            mPreviousCallState = PhoneCallState.IDLE;
            mThreeWayCallOrigStateDialing = false;
            mAddCallMenuStateAfterCW = true;
        }
   }