OtaUtils.java revision 425b8e3c9846d5e0e76466604b35cad8856d79de
1af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville/*
2af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Copyright (C) 2009 The Android Open Source Project
3af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville *
4af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Licensed under the Apache License, Version 2.0 (the "License");
5af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * you may not use this file except in compliance with the License.
6af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * You may obtain a copy of the License at
7af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville *
8af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville *      http://www.apache.org/licenses/LICENSE-2.0
9af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville *
10af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Unless required by applicable law or agreed to in writing, software
11af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * distributed under the License is distributed on an "AS IS" BASIS,
12af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * See the License for the specific language governing permissions and
14af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * limitations under the License.
15af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville */
16af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
17af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savillepackage com.android.phone;
18af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
19af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport com.android.internal.telephony.Phone;
20af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
21af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.app.AlertDialog;
22af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.Context;
23af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.DialogInterface;
24af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.Intent;
25839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.content.pm.ResolveInfo;
26af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.AsyncResult;
27839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.os.Handler;
28839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.os.Message;
29af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.SystemClock;
30af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.SystemProperties;
31839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.provider.Settings;
32af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
33af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.util.Log;
34af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.KeyEvent;
35af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.View;
36af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.ViewGroup;
37af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.ViewStub;
38af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.WindowManager;
39af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
40af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.Button;
41af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.ToggleButton;
42af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.ProgressBar;
43af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.SlidingDrawer;
44af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.TextView;
45af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
46af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville/**
47af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Handles all OTA Call related logic and UI functionality.
48af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * InCallScreen interacts with this class to perform OTA Call
49af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville */
50af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
51af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savillepublic class OtaUtils {
52af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static final String LOG_TAG = "OtaUtils";
53839b14d460986608fe577f89f789de854dc85b58Jim Miller    private static final String UNACTIVATED_MIN2_VALUE = "000000";
54839b14d460986608fe577f89f789de854dc85b58Jim Miller    private static final String UNACTIVATED_MIN_VALUE = "1111110111";
55af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static final boolean DBG = (PhoneApp.DBG_LEVEL >= 2);
56af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
57af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATION_SCREEN_OFF = 0;
58af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATION_SCREEN_ON = 1;
59af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_LISTENING_SCREEN_OFF =0;
60af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_LISTENING_SCREEN_ON =1;
61af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATE_FAIL_COUNT_OFF = 0;
62af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATE_FAIL_COUNT_THREE = 3;
63af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_PLAY_SUCCESS_FAILURE_TONE_OFF = 0;
64af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_PLAY_SUCCESS_FAILURE_TONE_ON = 1;
65af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
6617c36a10d09fac3e2312c0bcb839e0a704f42105w    // SPC Timeout is 60 seconds
6717c36a10d09fac3e2312c0bcb839e0a704f42105w    public final int OTA_SPC_TIMEOUT = 60;
68af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public final int OTA_FAILURE_DIALOG_TIMEOUT = 2;
69af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
70af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private InCallScreen mInCallScreen;
71af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private Context mContext;
72af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private PhoneApp mApplication;
73af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private OtaWidgetData mOtaWidgetData;
74af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private ViewGroup mInCallPanel;
75af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private CallCard mCallCard;
76af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private DTMFTwelveKeyDialer mDialer;
77af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private SlidingDrawer mDialerDrawer;
78af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
79af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
80af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * OtaWidgetData class represent all OTA UI elements
81af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
82af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private class OtaWidgetData {
83af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaEndButton;
84af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaActivateButton;
85af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaCancelButton;
86af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaDialogOKButton;
87af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaKeypadButton;
88af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ToggleButton otaSpeakerButton;
89af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View otaCallCardBase;
90af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsFailSuccess;
91af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ProgressBar otaTextProgressBar;
92af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextSuccessFail;
93af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsActivate;
94af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsListenProgress;
95af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextActivate;
96af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextListenProgress;
97af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog spcErrorDialog;
98af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog otaFailureDialog;
99af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
100af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
101af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public OtaUtils(Context context,
102af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    InCallScreen inCallScreen,
103af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    ViewGroup inCallPanel,
104af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CallCard callCard,
105af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    DTMFTwelveKeyDialer dialer,
106af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    SlidingDrawer dialerDrawer) {
107af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
108af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Enter OtaUtil constructor");
109af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
110af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen = inCallScreen;
111af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext = context;
112af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallPanel = inCallPanel;
113af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mCallCard = callCard;
114af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mDialer = dialer;
115af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mDialerDrawer = dialerDrawer;
116af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication = PhoneApp.getInstance();
117af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData = new OtaWidgetData();
118af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
119af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // inflate OTA Call card and footers
120af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        ViewStub otaCallCardStub = (ViewStub) mInCallScreen.findViewById(R.id.otaCallCardStub);
121af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaCallCardStub.inflate();
122af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        readXmlSettings();
123af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        initOtaInCallScreen();
124af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
125839b14d460986608fe577f89f789de854dc85b58Jim Miller
126839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
127839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Returns true if the phone needs activation.
128839b14d460986608fe577f89f789de854dc85b58Jim Miller     *
129839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param minString the phone's MIN configuration string
130839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if phone needs activation
131839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @throws OtaConfigurationException if the string is invalid
132839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
133839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean needsActivation(String minString) throws IllegalArgumentException {
134839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (minString == null || (minString.length() < 6)) {
135839b14d460986608fe577f89f789de854dc85b58Jim Miller            throw new IllegalArgumentException();
136839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
137839b14d460986608fe577f89f789de854dc85b58Jim Miller        return (minString.equals(UNACTIVATED_MIN_VALUE)
138839b14d460986608fe577f89f789de854dc85b58Jim Miller                || minString.substring(0,6).equals(UNACTIVATED_MIN2_VALUE))
139839b14d460986608fe577f89f789de854dc85b58Jim Miller                || SystemProperties.getBoolean("test_cdma_setup", false);
140839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
141839b14d460986608fe577f89f789de854dc85b58Jim Miller
142839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
143839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Starts the OTA provisioning call.  If the MIN isn't available yet, it returns false and adds
144839b14d460986608fe577f89f789de854dc85b58Jim Miller     * an event to return the request to the calling app when it becomes available.
145839b14d460986608fe577f89f789de854dc85b58Jim Miller     *
146839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param context
147839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param handler
148839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param request
149839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if we were able to launch Ota activity or it's not required; false otherwise
150839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
151839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean maybeDoOtaCall(Context context, Handler handler, int request) {
152839b14d460986608fe577f89f789de854dc85b58Jim Miller        PhoneApp app = PhoneApp.getInstance();
153839b14d460986608fe577f89f789de854dc85b58Jim Miller        Phone phone = app.phone;
154839b14d460986608fe577f89f789de854dc85b58Jim Miller
155839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!isCdmaPhone()) {
156839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) Log.v("OtaUtils", "Can't run provisioning on a non-CDMA phone");
157839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // sanity check - a non-cdma phone doesn't need to run this
158839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
159839b14d460986608fe577f89f789de854dc85b58Jim Miller
160839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!phone.isMinInfoReady()) {
161839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("MIN is not ready. Registering to receive notification.");
162839b14d460986608fe577f89f789de854dc85b58Jim Miller            phone.registerForSubscriptionInfoReady(handler, request, null);
163839b14d460986608fe577f89f789de854dc85b58Jim Miller            return false;
164839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
165839b14d460986608fe577f89f789de854dc85b58Jim Miller
166839b14d460986608fe577f89f789de854dc85b58Jim Miller        phone.unregisterForSubscriptionInfoReady(handler);
167839b14d460986608fe577f89f789de854dc85b58Jim Miller        String min = phone.getCdmaMin();
168839b14d460986608fe577f89f789de854dc85b58Jim Miller
169839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("min_string: " + min);
170839b14d460986608fe577f89f789de854dc85b58Jim Miller
171839b14d460986608fe577f89f789de854dc85b58Jim Miller        boolean phoneNeedsActivation = false;
172839b14d460986608fe577f89f789de854dc85b58Jim Miller        try {
173839b14d460986608fe577f89f789de854dc85b58Jim Miller            phoneNeedsActivation = needsActivation(min);
174839b14d460986608fe577f89f789de854dc85b58Jim Miller        } catch (IllegalArgumentException e) {
175839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("invalid MIN string, exit");
176839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // If the MIN string is wrong, there's nothing else we can do.
177839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
178839b14d460986608fe577f89f789de854dc85b58Jim Miller
179839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("phoneNeedsActivation is set to " + phoneNeedsActivation);
180839b14d460986608fe577f89f789de854dc85b58Jim Miller
181839b14d460986608fe577f89f789de854dc85b58Jim Miller        int otaShowActivationScreen = context.getResources().getInteger(
182839b14d460986608fe577f89f789de854dc85b58Jim Miller                R.integer.OtaShowActivationScreen);
183839b14d460986608fe577f89f789de854dc85b58Jim Miller
184839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("otaShowActivationScreen: " + otaShowActivationScreen);
185839b14d460986608fe577f89f789de854dc85b58Jim Miller
186839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (phoneNeedsActivation && (otaShowActivationScreen == OTA_SHOW_ACTIVATION_SCREEN_ON)) {
187839b14d460986608fe577f89f789de854dc85b58Jim Miller            app.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
188839b14d460986608fe577f89f789de854dc85b58Jim Miller            Intent newIntent = new Intent(InCallScreen.ACTION_SHOW_ACTIVATION);
189839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setClass(context, InCallScreen.class);
190839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
191839b14d460986608fe577f89f789de854dc85b58Jim Miller            context.startActivity(newIntent);
192839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent sent.");
193839b14d460986608fe577f89f789de854dc85b58Jim Miller        } else {
194839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent NOT sent.");
195839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
196839b14d460986608fe577f89f789de854dc85b58Jim Miller        return true;
197839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
198af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
199af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void setSpeaker(boolean state) {
200af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("setSpeaker : " + state );
201af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state == PhoneUtils.isSpeakerOn(mContext)) {
202af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("no change. returning");
203af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
204af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
205af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
206af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state && mInCallScreen.isBluetoothAvailable()
207af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && mInCallScreen.isBluetoothAudioConnected()) {
208af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.disconnectBluetoothAudio();
209af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
210425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent        PhoneUtils.turnOnSpeaker(mContext, state, true);
211af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
212af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
213af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
214af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA Provision events from Framework. Possible events are:
215af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * OTA Commit Event - OTA provisioning was successful
216af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * SPC retries exceeded - SPC failure retries has exceeded, and Phone needs to
217af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     *    power down.
218af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
219af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaProvisionStatusChanged(AsyncResult r) {
220af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int OtaStatus[] = (int[]) r.result;
221af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaProvisionStatusChanged(): OtaStatus[0]" + OtaStatus[0]);
222af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
223af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaShowInProgressScreen();
224af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch(OtaStatus[0]) {
225af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED:
226af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.otaSpcUptime = SystemClock.elapsedRealtime();
227af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(OTA_SPC_TIMEOUT);
228af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                // Power.shutdown();
229af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
230af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED:
231af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.isOtaCallCommitted = true;
232af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                if (DBG) log("onOtaProvisionStatusChanged(): isOtaCallCommitted set to true");
233af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
234af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
235af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
236af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
237af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowHome() {
238af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowHome()...");
239af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
240af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
241af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        cleanOtaScreen();
242af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Intent intent = new Intent(Intent.ACTION_MAIN);
243af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.addCategory (Intent.CATEGORY_HOME);
244af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
245af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext.startActivity(intent);
246af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen.finish();
247af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
248af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
249af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
250af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
251af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show Activation Screen when phone powers up and OTA provision is
252af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * required. Also shown when activation fails and user needs
253af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * to re-attempt it. Contains ACTIVE and CANCEL buttons
254af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * which allow user to start OTA activation or cancel the activation process.
255af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
256af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowActivateScreen() {
257af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowActivationScreen()...");
258af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowActivationScreen
259af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_ACTIVATION_SCREEN_ON) {
260af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show activation screen");
261e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
262af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
263af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextActivate.setVisibility(View.VISIBLE);
264af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.VISIBLE);
265e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
266e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman                if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
267af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
268af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
269af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION;
270af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
271af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show home screen");
272af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
273af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
274af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     }
275af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
276af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
277af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Listen for Instruction" screen during OTA call. Shown when OTA Call
278af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is initiated and user needs to listen for network instructions and press
279af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * appropriate DTMF digits to proceed to the "Programming in Progress" phase.
280af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
281af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowListeningScreen() {
282af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowListeningScreen()...");
283af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowListeningScreen
284af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_LISTENING_SCREEN_ON) {
285af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show listening screen");
286e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
287af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
288af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextListenProgress.setVisibility(View.VISIBLE);
289af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_listen);
290af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
291e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
292e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman                if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
293af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
294af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
295af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING;
296af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
297af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            // Update the state of the in-call menu items.
298af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.updateMenuItems();
299af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
300af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show progress screen");
301af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowInProgressScreen();
302af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
303af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
304af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
305af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
306af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Programming In Progress" screen during OTA call. Shown when OTA
307af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * provisioning is in progress after user has selected an option.
308af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
309af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowInProgressScreen() {
310af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowInProgressScreen()...");
311e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (!isDialerOpened()) {
312af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenInitialize();
313af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setVisibility(View.VISIBLE);
314af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_progress);
315af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextProgressBar.setVisibility(View.VISIBLE);
316af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
317e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        } else {
318e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
319af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
320af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
321af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS;
322af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
323af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // Update the state of the in-call menu items.
324af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen.updateMenuItems();
325af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
326af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
327af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
328af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails.
329af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * If OTA provisioning attempts fail more than 3 times, then unsuccessful
330af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * dialog is shown. Otherwise a two-second notice is shown with unsuccessful
331af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * information. When notice expires, phone returns to activation screen.
332af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
333af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailure( int length) {
334af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailure()...");
335af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaProvisionData.activationCount++;
336af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if ((mApplication.cdmaOtaProvisionData.activationCount <
337af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaConfigData.otaShowActivateFailTimes)
338af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && (mApplication.cdmaOtaConfigData.otaShowActivationScreen ==
339af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                OTA_SHOW_ACTIVATION_SCREEN_ON)) {
340af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): activationCount"
341af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaProvisionData.activationCount);
342af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure notice");
343af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureNotice(length);
344af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
345af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure dialog");
346af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureDialog();
347af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
348af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
349af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
350af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
351af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show either programming success dialog when OTA provisioning succeeds, or
352af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * programming failure dialog when it fails. See {@link otaShowProgramFailure}
353af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * for more details.
354af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
355af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowSuccessFailure() {
356af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure()...");
357af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaScreenInitialize();
358af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure(): isOtaCallCommitted"
359af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaProvisionData.isOtaCallCommitted);
360af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.isOtaCallCommitted) {
361af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show success dialog");
362af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramSuccessDialog();
363af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
364af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show failure dialog");
365af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailure(OTA_FAILURE_DIALOG_TIMEOUT);
366af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
367af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
368af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
369af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
370af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
371af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails more than 3
372af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * times.
373af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
374af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureDialog() {
375af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureDialog()...");
376af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
377af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
378af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
379af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_unsuccessful);
380af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
381af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
382e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
383af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
384af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
385af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
386af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
387af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
388af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming success dialog when OTA provisioning succeeds.
389af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
390af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramSuccessDialog() {
391af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramSuccessDialog()...");
392af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
393af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
394af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
395af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_successful);
396af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
397af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
398e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
399af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
400af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
401af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
402af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
403af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
404af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show SPC failure notice when SPC attempts exceed 15 times.
405af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * During OTA provisioning, if SPC code is incorrect OTA provisioning will
406af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * fail. When SPC attempts are over 15, it shows SPC failure notice for one minute and
407af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * then phone will power down.
408af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
409af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowSpcErrorNotice(int length) {
410af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSpcErrorNotice()...");
411af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog == null) {
412af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.inOtaSpcState = true;
413af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            DialogInterface.OnKeyListener keyListener;
414af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            keyListener = new DialogInterface.OnKeyListener() {
415af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
416af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    log("Ignoring key events...");
417af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    return true;
418af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                }};
419af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = new AlertDialog.Builder(mInCallScreen)
420af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_spc_failure)
421af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setOnKeyListener(keyListener)
422af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
423af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.getWindow().addFlags(
424af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
425af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
426af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.show();
427af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            //close the dialer if open
428e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (isDialerOpened()) {
429af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mDialer.closeDialer(false);
430af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
431af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
432af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSpcErrorNotice(), remaining SPC noticeTime"+noticeTime);
433af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.postNewMessageDelay(InCallScreen.CLOSE_SPC_ERROR_NOTICE,noticeTime);
434af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
435af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
436af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
437af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
438af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * When SPC notice times out, force phone to power down.
439af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
440af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseSpcNotice() {
44117c36a10d09fac3e2312c0bcb839e0a704f42105w        if (DBG) log("onOtaCloseSpcNotice(), send shutdown intent");
44217c36a10d09fac3e2312c0bcb839e0a704f42105w        Intent shutdown = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
44317c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
44417c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
44517c36a10d09fac3e2312c0bcb839e0a704f42105w        mContext.startActivity(shutdown);
446af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
447af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
448af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
449af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show two-second notice when OTA provisioning fails and number of failed attempts
450af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is less then 3.
451af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
452af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureNotice(int length) {
453af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureNotice()...");
454af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog == null) {
455af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = new AlertDialog.Builder(mInCallScreen)
456af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_failure)
457af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
458af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.getWindow().addFlags(
459af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
460af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
461af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.show();
462af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
463af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
464af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.postNewMessageDelay(InCallScreen.CLOSE_OTA_FAILURE_NOTICE, noticeTime);
465af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
466af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
467af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
468af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
469af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA unsuccessful notice expiry. Dismisses the
470af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * two-second notice and shows the activation screen.
471af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
472af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseFailureNotice() {
473af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaCloseFailureNotice()...");
474af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
475af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
476af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
477af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
478af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaShowActivateScreen();
479af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
480af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
481af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
482af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize all OTA UI elements to be gone. Also set inCallPanel,
483af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * callCard and dialerDrawer to be gone. This is called before any OTA screen
484af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * gets drawn.
485af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
486af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaScreenInitialize() {
487af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaScreenInitialize()...");
488af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
489af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallPanel != null) mInCallPanel.setVisibility(View.GONE);
490af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mCallCard != null) mCallCard.hideCallCardElements();
491af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.GONE);
492af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
493af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
494af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextListenProgress.setVisibility(View.GONE);
495af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
496af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
497af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
498af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
499af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
500af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.VISIBLE);
501af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
502af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
503af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void hideOtaScreen() {
504af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("hideOtaScreen()...");
505af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
506af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
507af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
508af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
509af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
510af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
511af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
512e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    public boolean isDialerOpened() {
513e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        return (mDialer != null && mDialer.isOpened());
514e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    }
515e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman
516af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
517af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show the appropriate OTA screen based on the current state of OTA call.
518af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Shown whenever calling screen is resumed.
519af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
520af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowProperScreen() {
521af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("otaShowProperScreen()...");
522af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallScreen.isForegroundActivity()) {
523af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("otaShowProperScreen(), OTA is foreground activity, currentstate ="
524af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaScreenState.otaScreenState);
525af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mInCallPanel != null) {
526af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mInCallPanel.setVisibility(View.GONE);
527af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
528af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaScreenState.otaScreenState
529af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION) {
530af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowActivateScreen();
531af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
532af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING) {
533af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowListeningScreen();
534af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
535af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS) {
536af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowInProgressScreen();
537af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
538af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
539af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
540af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(getOtaSpcDisplayTime());
541af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
542af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
543af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
544af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
545af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
546af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Read configuration values for each OTA screen from config.xml.
547af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * These configuration values control visibility of each screen.
548af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
549af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void readXmlSettings() {
550af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings()...");
551af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.configComplete) {
552af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
553af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
554af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
555af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.configComplete = true;
556af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivationScreen =
557af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivationScreen);
558af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivationScreen = tmpOtaShowActivationScreen;
559af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivationScreen"
560af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivationScreen);
561af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
562af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowListeningScreen =
563af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowListeningScreen);
564af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowListeningScreen = tmpOtaShowListeningScreen;
565af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowListeningScreen"
566af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowListeningScreen);
567af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
568af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivateFailTimes =
569af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivateFailTimes);
570af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivateFailTimes = tmpOtaShowActivateFailTimes;
571af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivateFailTimes"
572af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivateFailTimes);
573af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
574af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaPlaySuccessFailureTone =
575af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaPlaySuccessFailureTone);
576af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone = tmpOtaPlaySuccessFailureTone;
577af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaPlaySuccessFailureTone"
578af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone);
579af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
580af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
581af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
582af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle the click events for OTA buttons.
583af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
584af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onClickHandler(int id) {
585af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch (id) {
586af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaEndButton:
587af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaEndButton();
588af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
589af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
590af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaSpeakerButton:
591af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaSpeakerButton();
592af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
593af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
594af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaActivateButton:
595af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateButton();
596af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
597af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
598af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaCancelButton:
599af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateCancelButton();
600af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
601af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
602af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaOkButton:
603af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateDialogOkButton();
604af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
605af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
606af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaDialButton:
607af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaKeypadButton();
608af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
609af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
610af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            default:
611af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                if (DBG) log ("onClickHandler: received a click event for unrecognized id");
612af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
613af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
614af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
615af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
616af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaEndButton() {
617af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Activation Cancel Clicked!");
618af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
619af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            PhoneUtils.hangup(mApplication.phone);
620af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
621af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
622af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
623af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaSpeakerButton() {
624af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA Speaker button Clicked!");
625af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
626af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            boolean isChecked = !PhoneUtils.isSpeakerOn(mContext);
627af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            setSpeaker(isChecked);
628af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
629af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
630af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
631af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateButton() {
632af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Call Activation Clicked!");
633af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
634af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            Intent newIntent = new Intent(Intent.ACTION_CALL);
635af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            newIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, InCallScreen.OTA_NUMBER);
636af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.internalResolveIntent(newIntent);
637af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowListeningScreen();
638af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
639af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
640af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
641af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateCancelButton() {
642af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Activation Cancel Clicked!");
643af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
644af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
645af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
646af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
647af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
648af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateDialogOkButton() {
649af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Dialog OK Clicked!");
650af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
651af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
652af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
653af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
654af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.finish();
655af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
656af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
657af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
658af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaKeypadButton() {
659af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("DTMF Keypad Button Clicked!");
660af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if ((!InCallScreen.ConfigurationHelper.isLandscape())
661af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && (!mApplication.cdmaOtaProvisionData.inOtaSpcState)) {
662af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mDialer != null) {
663af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mDialer.openDialer(true);
664af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
665af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mDialerDrawer != null) {
666af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mDialerDrawer.setVisibility(View.VISIBLE);
667af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
668af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
669af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
670af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
671af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void dismissAllOtaDialogs() {
672af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog != null) {
673af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mSpcErrorDialog.");
674af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.dismiss();
675af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = null;
676af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
677af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
678af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mOtaFailureDialog.");
679af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
680af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
681af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
682af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
683af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
684af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private int getOtaSpcDisplayTime() {
685af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime()...");
686af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpSpcTime = 1;
687af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
688af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcRunningTime = 0;
689af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcLeftTime = 0;
690af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcRunningTime = SystemClock.elapsedRealtime();
691af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcLeftTime =
692af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpOtaSpcRunningTime - mApplication.cdmaOtaProvisionData.otaSpcUptime;
69317c36a10d09fac3e2312c0bcb839e0a704f42105w            if (tmpOtaSpcLeftTime >= OTA_SPC_TIMEOUT*1000) {
694af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = 1;
695af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else {
696af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = OTA_SPC_TIMEOUT - (int)tmpOtaSpcLeftTime/1000;
697af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
698af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
699af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime(), time for SPC error notice: " + tmpSpcTime);
700af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return tmpSpcTime;
701af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
702af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
703af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
704af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize the OTA widgets for all OTA screens.
705af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
706af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void initOtaInCallScreen() {
707af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("initOtaInCallScreen()...");
708af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate = (TextView) mInCallScreen.findViewById(R.id.otaActivate);
709af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
710af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextListenProgress =
711af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaListenProgress);
712af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar =
713af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ProgressBar) mInCallScreen.findViewById(R.id.progress_large);
714af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setIndeterminate(true);
715af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail =
716af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaSuccessFailStatus);
717af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
718af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase = (View) mInCallScreen.findViewById(R.id.otaBase);
719af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress =
720af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaListenProgress);
721af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate =
722af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaActivate);
723af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess =
724af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaFailOrSuccessful);
725af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
726af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton = (Button) mInCallScreen.findViewById(R.id.otaEndButton);
727af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton.setOnClickListener(mInCallScreen);
728af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton =
729af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ToggleButton) mInCallScreen.findViewById(R.id.otaSpeakerButton);
730af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton.setOnClickListener(mInCallScreen);
731af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton =
732af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (Button) mInCallScreen.findViewById(R.id.otaActivateButton);
733af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton.setOnClickListener(mInCallScreen);
734af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCancelButton =
735af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (Button) mInCallScreen.findViewById(R.id.otaCancelButton);
736af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCancelButton.setOnClickListener(mInCallScreen);
737af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaDialogOKButton =
738af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (Button) mInCallScreen.findViewById(R.id.otaOkButton);
739af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaDialogOKButton.setOnClickListener(mInCallScreen);
740af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
741af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!InCallScreen.ConfigurationHelper.isLandscape()) {
742af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaKeypadButton =
743af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    (Button) mInCallScreen.findViewById(R.id.otaDialButton);
744af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaKeypadButton.setOnClickListener(mInCallScreen);
745af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
746af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
747af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
748af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
749af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Clear out all OTA UI widget elements. Needs to get called
750af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * when OTA call ends or InCallScreen is destroyed.
751af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
752af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void cleanOtaScreen() {
753af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA ends, cleanOtaScreen!");
754af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
755af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
756af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.isOtaCallCommitted = false;
757af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
758af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.inOtaSpcState = false;
759af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.activationCount = 0;
760af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.otaSpcUptime = 0;
761af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
762af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mInCallPanel != null) mInCallPanel.setVisibility(View.VISIBLE);
763af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mCallCard != null) mCallCard.hideCallCardElements();
764af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
765af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
766af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
767af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setVisibility(View.GONE);
768af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
769af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
770af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
771af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
772af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
773af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
774af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
775af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
776af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
777af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA information that needs to be maintained during
778af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * an OTA call when display orientation changes.
779af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
780af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaProvisionData {
781af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallCommitted;
782af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallIntentProcessed;
783af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean inOtaSpcState;
784af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int activationCount;
785af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public long otaSpcUptime;
786af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
787af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
788af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
789af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA screen configuration items read from config.xml
790af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * and used to control OTA display.
791af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
792af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaConfigData {
793af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivationScreen;
794af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowListeningScreen;
795af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivateFailTimes;
796af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaPlaySuccessFailureTone;
797af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean configComplete;
798af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaConfigData() {
799af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("CdmaOtaConfigData constructor!");
800af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivationScreen = OTA_SHOW_ACTIVATION_SCREEN_OFF;
801af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowListeningScreen = OTA_SHOW_LISTENING_SCREEN_OFF;
802af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivateFailTimes = OTA_SHOW_ACTIVATE_FAIL_COUNT_OFF;
803af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaPlaySuccessFailureTone = OTA_PLAY_SUCCESS_FAILURE_TONE_OFF;
804af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
805af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
806af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
807af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
808af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * The OTA screen state machine.
809af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
810af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaScreenState {
811af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public enum OtaScreenState {
812af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_UNDEFINED,
813af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_ACTIVATION,
814af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_LISTENING,
815af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_PROGRESS,
816af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_SUCCESS_FAILURE_DLG
817af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
818af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
819af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public OtaScreenState otaScreenState;
820af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
821af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaScreenState() {
822af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenState = OtaScreenState.OTA_STATUS_UNDEFINED;
823af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
824af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
825af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
826af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static void log(String msg) {
827af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Log.d(LOG_TAG, msg);
828af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
829839b14d460986608fe577f89f789de854dc85b58Jim Miller
830839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean isCdmaPhone() {
831839b14d460986608fe577f89f789de854dc85b58Jim Miller        return PhoneApp.getInstance().phone.getPhoneName().equals("CDMA");
832839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
833af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville}
834