• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 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.phone;
18 
19 /**
20  * Class to internally keep track of Call states to maintain
21  * information for Call Waiting and 3Way for CDMA instance of Phone App.
22  *
23  * Explanation for PhoneApp's Call states and why it is required:
24  * IDLE - When no call is going on. This is just required as default state to reset the PhoneApp
25  *        call state to when the complete call gets disconnected
26  * SINGLE_ACTIVE - When only single call is active.
27  *        In normal case(on a single call) this state would be similar for FW's state of ACTIVE
28  *        call or phone state of OFFHOOK, but in more complex conditions e.g. when phone is already
29  *        in a CONF_CALL state and user rejects a CW, which basically tells the PhoneApp that the
30  *        Call is back to a single call, the FW's state still would remain ACTIVE or OFFHOOK and
31  *        isGeneric would still be true. At this condition PhoneApp does need to enable the
32  *        "Add Call" menu item and disable the "Swap" and "Merge" options
33  * THRWAY_ACTIVE - When user initiate an outgoing call when already on a call.
34  *        fgCall can have more than one connections from various scenarios (accepting the CW or
35  *        making a 3way call) but once we are in this state and one of the parties drops off,
36  *        when the user originates another call we need to remember this state to update the menu
37  *        items accordingly. FW currently does not differentiate this condition hence PhoneApp
38  *        needs to maintain it.
39  * CONF_CALL - When the user merges two calls or on accepting the Call waiting call.
40  *        This is required cause even though a call might be generic but that does not mean it is
41  *        in conference. We can take the same example mention in the SINGLE_ACTIVE state.
42  *
43  * TODO: Eventually this state information should be maintained by Telephony FW.
44  */
45    public class CdmaPhoneCallState {
46 
47         /**
48          * Allowable values for the PhoneCallState.
49          *   IDLE - When no call is going on.
50          *   SINGLE_ACTIVE - When only single call is active
51          *   THRWAY_ACTIVE - When user initiate an outgoing call when already on a call
52          *   CONF_CALL - When the user merges two calls or on accepting the Call waiting call
53          */
54         public enum PhoneCallState {
55             IDLE,
56             SINGLE_ACTIVE,
57             THRWAY_ACTIVE,
58             CONF_CALL
59         }
60 
61         // For storing current and previous PhoneCallState's
62         private PhoneCallState mPreviousCallState;
63         private PhoneCallState mCurrentCallState;
64 
65         // Boolean to track 3Way display state
66         private boolean mThreeWayCallOrigStateDialing;
67 
68         // Flag to indicate if the "Add Call" menu item in an InCallScreen is OK
69         // to be displayed after a Call Waiting call was ignored or timed out
70         private boolean mAddCallMenuStateAfterCW;
71 
72         /**
73          * Initialize PhoneCallState related members - constructor
74          */
CdmaPhoneCallStateInit()75         public void CdmaPhoneCallStateInit() {
76             mCurrentCallState = PhoneCallState.IDLE;
77             mPreviousCallState = PhoneCallState.IDLE;
78             mThreeWayCallOrigStateDialing = false;
79             mAddCallMenuStateAfterCW = true;
80         }
81 
82         /**
83          * Returns the current call state
84          */
getCurrentCallState()85         public PhoneCallState getCurrentCallState() {
86             return mCurrentCallState;
87         }
88 
89         /**
90          * Set current and previous PhoneCallState's
91          */
setCurrentCallState(PhoneCallState newState)92         public void setCurrentCallState(PhoneCallState newState) {
93             mPreviousCallState = mCurrentCallState;
94             mCurrentCallState = newState;
95 
96             //Reset the 3Way display boolean
97             mThreeWayCallOrigStateDialing = false;
98 
99             //Set mAddCallMenuStateAfterCW to true
100             //if the current state is being set to SINGLE_ACTIVE
101             //and previous state was IDLE as we could reach the SINGLE_ACTIVE
102             //from CW ignore too. For all other cases let the timer or
103             //specific calls to setAddCallMenuStateAfterCallWaiting set
104             //mAddCallMenuStateAfterCW.
105             if ((mCurrentCallState == PhoneCallState.SINGLE_ACTIVE)
106                 && (mPreviousCallState == PhoneCallState.IDLE)) {
107                 mAddCallMenuStateAfterCW = true;
108             }
109         }
110 
111         /**
112          * Return 3Way display information
113          */
IsThreeWayCallOrigStateDialing()114         public boolean IsThreeWayCallOrigStateDialing() {
115             return mThreeWayCallOrigStateDialing;
116         }
117 
118         /**
119          * Set 3Way display information
120          */
setThreeWayCallOrigState(boolean newState)121         public void setThreeWayCallOrigState(boolean newState) {
122             mThreeWayCallOrigStateDialing = newState;
123         }
124 
125         /**
126          * Return information for enabling/disabling "Add Call" menu item
127          */
getAddCallMenuStateAfterCallWaiting()128         public boolean getAddCallMenuStateAfterCallWaiting() {
129             return mAddCallMenuStateAfterCW;
130         }
131 
132         /**
133          * Set mAddCallMenuStateAfterCW to enabling/disabling "Add Call" menu item
134          */
setAddCallMenuStateAfterCallWaiting(boolean newState)135         public void setAddCallMenuStateAfterCallWaiting(boolean newState) {
136             mAddCallMenuStateAfterCW = newState;
137         }
138 
139         /**
140          * Return previous PhoneCallState's
141          */
getPreviousCallState()142         public PhoneCallState getPreviousCallState() {
143             return mPreviousCallState;
144         }
145 
146         /**
147          * Reset all PhoneCallState
148          */
resetCdmaPhoneCallState()149         public void resetCdmaPhoneCallState() {
150             mCurrentCallState = PhoneCallState.IDLE;
151             mPreviousCallState = PhoneCallState.IDLE;
152             mThreeWayCallOrigStateDialing = false;
153             mAddCallMenuStateAfterCW = true;
154         }
155    }
156