OtaUtils.java revision 9bd141ba20a6cf6dcb745aca6c5c05a9c88f3a98
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;
86986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public Button otaNextButton;
87af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ToggleButton otaSpeakerButton;
88af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View otaCallCardBase;
89af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsFailSuccess;
90af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ProgressBar otaTextProgressBar;
91af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextSuccessFail;
92af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsActivate;
93af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsListenProgress;
94af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextActivate;
95af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextListenProgress;
96af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog spcErrorDialog;
97af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog otaFailureDialog;
98986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public TextView otaTitle;
99986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public DTMFTwelveKeyDialerView otaDtmfDialerView;
100986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public Button otaTryAgainButton;
101af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
102af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
103af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public OtaUtils(Context context,
104af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    InCallScreen inCallScreen,
105af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    ViewGroup inCallPanel,
106af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CallCard callCard,
107af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    DTMFTwelveKeyDialer dialer,
108af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    SlidingDrawer dialerDrawer) {
109af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
110af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Enter OtaUtil constructor");
111af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
112af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen = inCallScreen;
113af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext = context;
114af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallPanel = inCallPanel;
115af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mCallCard = callCard;
116af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mDialer = dialer;
117af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mDialerDrawer = dialerDrawer;
118af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication = PhoneApp.getInstance();
119af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData = new OtaWidgetData();
120af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
121af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // inflate OTA Call card and footers
122af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        ViewStub otaCallCardStub = (ViewStub) mInCallScreen.findViewById(R.id.otaCallCardStub);
123af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaCallCardStub.inflate();
124af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        readXmlSettings();
125af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        initOtaInCallScreen();
126af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
127839b14d460986608fe577f89f789de854dc85b58Jim Miller
128839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
129839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Returns true if the phone needs activation.
130839b14d460986608fe577f89f789de854dc85b58Jim Miller     *
131839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param minString the phone's MIN configuration string
132839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if phone needs activation
133839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @throws OtaConfigurationException if the string is invalid
134839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
135839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean needsActivation(String minString) throws IllegalArgumentException {
136839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (minString == null || (minString.length() < 6)) {
137839b14d460986608fe577f89f789de854dc85b58Jim Miller            throw new IllegalArgumentException();
138839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
139839b14d460986608fe577f89f789de854dc85b58Jim Miller        return (minString.equals(UNACTIVATED_MIN_VALUE)
140839b14d460986608fe577f89f789de854dc85b58Jim Miller                || minString.substring(0,6).equals(UNACTIVATED_MIN2_VALUE))
141839b14d460986608fe577f89f789de854dc85b58Jim Miller                || SystemProperties.getBoolean("test_cdma_setup", false);
142839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
143839b14d460986608fe577f89f789de854dc85b58Jim Miller
144839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
145839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Starts the OTA provisioning call.  If the MIN isn't available yet, it returns false and adds
146839b14d460986608fe577f89f789de854dc85b58Jim Miller     * an event to return the request to the calling app when it becomes available.
147839b14d460986608fe577f89f789de854dc85b58Jim Miller     *
148839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param context
149839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param handler
150839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param request
151839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if we were able to launch Ota activity or it's not required; false otherwise
152839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
153839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean maybeDoOtaCall(Context context, Handler handler, int request) {
154839b14d460986608fe577f89f789de854dc85b58Jim Miller        PhoneApp app = PhoneApp.getInstance();
155839b14d460986608fe577f89f789de854dc85b58Jim Miller        Phone phone = app.phone;
156839b14d460986608fe577f89f789de854dc85b58Jim Miller
157839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!isCdmaPhone()) {
158839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) Log.v("OtaUtils", "Can't run provisioning on a non-CDMA phone");
159839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // sanity check - a non-cdma phone doesn't need to run this
160839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
161839b14d460986608fe577f89f789de854dc85b58Jim Miller
162839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!phone.isMinInfoReady()) {
163839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("MIN is not ready. Registering to receive notification.");
164839b14d460986608fe577f89f789de854dc85b58Jim Miller            phone.registerForSubscriptionInfoReady(handler, request, null);
165839b14d460986608fe577f89f789de854dc85b58Jim Miller            return false;
166839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
167839b14d460986608fe577f89f789de854dc85b58Jim Miller
168839b14d460986608fe577f89f789de854dc85b58Jim Miller        phone.unregisterForSubscriptionInfoReady(handler);
169839b14d460986608fe577f89f789de854dc85b58Jim Miller        String min = phone.getCdmaMin();
170839b14d460986608fe577f89f789de854dc85b58Jim Miller
171839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("min_string: " + min);
172839b14d460986608fe577f89f789de854dc85b58Jim Miller
173839b14d460986608fe577f89f789de854dc85b58Jim Miller        boolean phoneNeedsActivation = false;
174839b14d460986608fe577f89f789de854dc85b58Jim Miller        try {
175839b14d460986608fe577f89f789de854dc85b58Jim Miller            phoneNeedsActivation = needsActivation(min);
176839b14d460986608fe577f89f789de854dc85b58Jim Miller        } catch (IllegalArgumentException e) {
177839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("invalid MIN string, exit");
178839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // If the MIN string is wrong, there's nothing else we can do.
179839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
180839b14d460986608fe577f89f789de854dc85b58Jim Miller
181839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("phoneNeedsActivation is set to " + phoneNeedsActivation);
182839b14d460986608fe577f89f789de854dc85b58Jim Miller
183839b14d460986608fe577f89f789de854dc85b58Jim Miller        int otaShowActivationScreen = context.getResources().getInteger(
184839b14d460986608fe577f89f789de854dc85b58Jim Miller                R.integer.OtaShowActivationScreen);
185839b14d460986608fe577f89f789de854dc85b58Jim Miller
186839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("otaShowActivationScreen: " + otaShowActivationScreen);
187839b14d460986608fe577f89f789de854dc85b58Jim Miller
188839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (phoneNeedsActivation && (otaShowActivationScreen == OTA_SHOW_ACTIVATION_SCREEN_ON)) {
189839b14d460986608fe577f89f789de854dc85b58Jim Miller            app.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
190839b14d460986608fe577f89f789de854dc85b58Jim Miller            Intent newIntent = new Intent(InCallScreen.ACTION_SHOW_ACTIVATION);
191839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setClass(context, InCallScreen.class);
192839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
193839b14d460986608fe577f89f789de854dc85b58Jim Miller            context.startActivity(newIntent);
194839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent sent.");
195839b14d460986608fe577f89f789de854dc85b58Jim Miller        } else {
196839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent NOT sent.");
197839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
198839b14d460986608fe577f89f789de854dc85b58Jim Miller        return true;
199839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
200af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
201af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void setSpeaker(boolean state) {
202af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("setSpeaker : " + state );
203af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state == PhoneUtils.isSpeakerOn(mContext)) {
204af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("no change. returning");
205af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
206af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
207af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
208af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state && mInCallScreen.isBluetoothAvailable()
209af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && mInCallScreen.isBluetoothAudioConnected()) {
210af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.disconnectBluetoothAudio();
211af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
212425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent        PhoneUtils.turnOnSpeaker(mContext, state, true);
213af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
214af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
215af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
216af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA Provision events from Framework. Possible events are:
217af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * OTA Commit Event - OTA provisioning was successful
218af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * SPC retries exceeded - SPC failure retries has exceeded, and Phone needs to
219af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     *    power down.
220af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
221af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaProvisionStatusChanged(AsyncResult r) {
222af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int OtaStatus[] = (int[]) r.result;
223af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaProvisionStatusChanged(): OtaStatus[0]" + OtaStatus[0]);
224af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
225af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaShowInProgressScreen();
226af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch(OtaStatus[0]) {
227af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED:
228af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.otaSpcUptime = SystemClock.elapsedRealtime();
229af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(OTA_SPC_TIMEOUT);
230af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                // Power.shutdown();
231af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
232af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED:
233af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.isOtaCallCommitted = true;
234af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                if (DBG) log("onOtaProvisionStatusChanged(): isOtaCallCommitted set to true");
235af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
236af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
237af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
238af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
239af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowHome() {
240af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowHome()...");
241af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
242af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
243af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        cleanOtaScreen();
244af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Intent intent = new Intent(Intent.ACTION_MAIN);
245af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.addCategory (Intent.CATEGORY_HOME);
246af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
247af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext.startActivity(intent);
248af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen.finish();
249af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
250af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
251af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
252af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
253af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show Activation Screen when phone powers up and OTA provision is
254af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * required. Also shown when activation fails and user needs
255af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * to re-attempt it. Contains ACTIVE and CANCEL buttons
256af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * which allow user to start OTA activation or cancel the activation process.
257af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
258af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowActivateScreen() {
259af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowActivationScreen()...");
260af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowActivationScreen
261af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_ACTIVATION_SCREEN_ON) {
262af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show activation screen");
263e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
264af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
265af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextActivate.setVisibility(View.VISIBLE);
266af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.VISIBLE);
267e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
268e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman                if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
269af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
270af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
271af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION;
272af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
273af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show home screen");
274af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
275af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
276af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     }
277af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
278af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
279af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Listen for Instruction" screen during OTA call. Shown when OTA Call
280af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is initiated and user needs to listen for network instructions and press
281af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * appropriate DTMF digits to proceed to the "Programming in Progress" phase.
282af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
283af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowListeningScreen() {
284af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowListeningScreen()...");
285af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowListeningScreen
286af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_LISTENING_SCREEN_ON) {
287af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show listening screen");
288e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
289af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
290af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextListenProgress.setVisibility(View.VISIBLE);
291af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_listen);
292986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                mOtaWidgetData.otaDtmfDialerView.setVisibility(View.VISIBLE);
293af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
294986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                mOtaWidgetData.otaSpeakerButton.setVisibility(View.VISIBLE);
295e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
296e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman                if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
297af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
298af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
299af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING;
300af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
301af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            // Update the state of the in-call menu items.
302af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.updateMenuItems();
303af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
304af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show progress screen");
305af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowInProgressScreen();
306af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
307af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
308af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
309af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
310af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Programming In Progress" screen during OTA call. Shown when OTA
311af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * provisioning is in progress after user has selected an option.
312af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
313af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowInProgressScreen() {
314af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowInProgressScreen()...");
315e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (!isDialerOpened()) {
316af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenInitialize();
317af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setVisibility(View.VISIBLE);
318af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_progress);
319af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextProgressBar.setVisibility(View.VISIBLE);
320af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
3219bd141ba20a6cf6dcb745aca6c5c05a9c88f3a98Jim Miller            mOtaWidgetData.otaSpeakerButton.setVisibility(View.VISIBLE);
322e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        } else {
323e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
324af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
325af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
326af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS;
327af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
328af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // Update the state of the in-call menu items.
329af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen.updateMenuItems();
330af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
331af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
332af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
333af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails.
334af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * If OTA provisioning attempts fail more than 3 times, then unsuccessful
335af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * dialog is shown. Otherwise a two-second notice is shown with unsuccessful
336af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * information. When notice expires, phone returns to activation screen.
337af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
338986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void otaShowProgramFailure(int length) {
339af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailure()...");
340af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaProvisionData.activationCount++;
341af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if ((mApplication.cdmaOtaProvisionData.activationCount <
342af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaConfigData.otaShowActivateFailTimes)
343af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && (mApplication.cdmaOtaConfigData.otaShowActivationScreen ==
344af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                OTA_SHOW_ACTIVATION_SCREEN_ON)) {
345af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): activationCount"
346af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaProvisionData.activationCount);
347af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure notice");
348af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureNotice(length);
349af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
350af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure dialog");
351af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureDialog();
352af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
353af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
354af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
355af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
356af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show either programming success dialog when OTA provisioning succeeds, or
357af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * programming failure dialog when it fails. See {@link otaShowProgramFailure}
358af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * for more details.
359af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
360af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowSuccessFailure() {
361af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure()...");
362af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaScreenInitialize();
363af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure(): isOtaCallCommitted"
364af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaProvisionData.isOtaCallCommitted);
365af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.isOtaCallCommitted) {
366af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show success dialog");
367af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramSuccessDialog();
368af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
369af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show failure dialog");
370af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailure(OTA_FAILURE_DIALOG_TIMEOUT);
371af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
372af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
373af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
374af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
375af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
376af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails more than 3
377af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * times.
378af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
379af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureDialog() {
380af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureDialog()...");
381af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
382af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
383986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_problem_with_activation);
384af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
385af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_unsuccessful);
386af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
387986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.VISIBLE);
388af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
389e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
390af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
391af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
392af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
393af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
394af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
395af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming success dialog when OTA provisioning succeeds.
396af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
397af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramSuccessDialog() {
398af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramSuccessDialog()...");
399af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
400af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
401986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_activate_success);
402af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
403af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_successful);
404af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
405986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.VISIBLE);
406af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
407e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
408af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
409af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
410af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
411af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
412af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
413af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show SPC failure notice when SPC attempts exceed 15 times.
414af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * During OTA provisioning, if SPC code is incorrect OTA provisioning will
415af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * fail. When SPC attempts are over 15, it shows SPC failure notice for one minute and
416af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * then phone will power down.
417af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
418af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowSpcErrorNotice(int length) {
419af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSpcErrorNotice()...");
420af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog == null) {
421af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.inOtaSpcState = true;
422af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            DialogInterface.OnKeyListener keyListener;
423af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            keyListener = new DialogInterface.OnKeyListener() {
424af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
425af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    log("Ignoring key events...");
426af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    return true;
427af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                }};
428af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = new AlertDialog.Builder(mInCallScreen)
429af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_spc_failure)
430af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setOnKeyListener(keyListener)
431af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
432af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.getWindow().addFlags(
433af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
434af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
435af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.show();
436af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            //close the dialer if open
437e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (isDialerOpened()) {
438af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mDialer.closeDialer(false);
439af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
440af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
441af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSpcErrorNotice(), remaining SPC noticeTime"+noticeTime);
442af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.postNewMessageDelay(InCallScreen.CLOSE_SPC_ERROR_NOTICE,noticeTime);
443af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
444af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
445af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
446af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
447af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * When SPC notice times out, force phone to power down.
448af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
449af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseSpcNotice() {
45017c36a10d09fac3e2312c0bcb839e0a704f42105w        if (DBG) log("onOtaCloseSpcNotice(), send shutdown intent");
45117c36a10d09fac3e2312c0bcb839e0a704f42105w        Intent shutdown = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
45217c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
45317c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
45417c36a10d09fac3e2312c0bcb839e0a704f42105w        mContext.startActivity(shutdown);
455af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
456af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
457af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
458af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show two-second notice when OTA provisioning fails and number of failed attempts
459af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is less then 3.
460af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
461af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureNotice(int length) {
462af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureNotice()...");
463af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog == null) {
464af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = new AlertDialog.Builder(mInCallScreen)
465af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_failure)
466af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
467af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.getWindow().addFlags(
468af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
469af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
470af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.show();
471af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
472af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
473af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.postNewMessageDelay(InCallScreen.CLOSE_OTA_FAILURE_NOTICE, noticeTime);
474af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
475af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
476af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
477af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
478af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA unsuccessful notice expiry. Dismisses the
479af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * two-second notice and shows the activation screen.
480af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
481af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseFailureNotice() {
482af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaCloseFailureNotice()...");
483af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
484af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
485af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
486af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
487af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaShowActivateScreen();
488af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
489af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
490af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
491af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize all OTA UI elements to be gone. Also set inCallPanel,
492af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * callCard and dialerDrawer to be gone. This is called before any OTA screen
493af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * gets drawn.
494af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
495af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaScreenInitialize() {
496af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaScreenInitialize()...");
497af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
498af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallPanel != null) mInCallPanel.setVisibility(View.GONE);
499af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mCallCard != null) mCallCard.hideCallCardElements();
500af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.GONE);
501af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
502986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_activate);
503af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
504af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextListenProgress.setVisibility(View.GONE);
505af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
506af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
507af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
508af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
509af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
510986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaDtmfDialerView.setVisibility(View.GONE);
511986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaSpeakerButton.setVisibility(View.GONE);
512986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.GONE);
513986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.GONE);
514af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.VISIBLE);
515af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
516af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
517af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void hideOtaScreen() {
518af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("hideOtaScreen()...");
519af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
520af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
521af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
522af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
523af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
524af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
525af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
526e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    public boolean isDialerOpened() {
527e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        return (mDialer != null && mDialer.isOpened());
528e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    }
529e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman
530af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
531af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show the appropriate OTA screen based on the current state of OTA call.
532af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Shown whenever calling screen is resumed.
533af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
534af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowProperScreen() {
535af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("otaShowProperScreen()...");
536af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallScreen.isForegroundActivity()) {
537af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("otaShowProperScreen(), OTA is foreground activity, currentstate ="
538af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaScreenState.otaScreenState);
539af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mInCallPanel != null) {
540af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mInCallPanel.setVisibility(View.GONE);
541af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
542af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaScreenState.otaScreenState
543af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION) {
544af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowActivateScreen();
545af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
546af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING) {
547af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowListeningScreen();
548af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
549af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS) {
550af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowInProgressScreen();
551af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
552af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
553af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
554af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(getOtaSpcDisplayTime());
555af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
556af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
557af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
558af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
559af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
560af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Read configuration values for each OTA screen from config.xml.
561af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * These configuration values control visibility of each screen.
562af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
563af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void readXmlSettings() {
564af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings()...");
565af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.configComplete) {
566af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
567af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
568af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
569af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.configComplete = true;
570af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivationScreen =
571af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivationScreen);
572af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivationScreen = tmpOtaShowActivationScreen;
573af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivationScreen"
574af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivationScreen);
575af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
576af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowListeningScreen =
577af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowListeningScreen);
578af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowListeningScreen = tmpOtaShowListeningScreen;
579af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowListeningScreen"
580af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowListeningScreen);
581af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
582af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivateFailTimes =
583af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivateFailTimes);
584af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivateFailTimes = tmpOtaShowActivateFailTimes;
585af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivateFailTimes"
586af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivateFailTimes);
587af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
588af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaPlaySuccessFailureTone =
589af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaPlaySuccessFailureTone);
590af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone = tmpOtaPlaySuccessFailureTone;
591af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaPlaySuccessFailureTone"
592af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone);
593af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
594af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
595af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
596af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle the click events for OTA buttons.
597af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
598af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onClickHandler(int id) {
599af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch (id) {
600af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaEndButton:
601af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaEndButton();
602af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
603af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
604af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaSpeakerButton:
605af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaSpeakerButton();
606af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
607af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
608af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaActivateButton:
609af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateButton();
610af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
611af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
612af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaCancelButton:
613af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateCancelButton();
614af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
615af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
616986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            case R.id.otaNextButton:
617986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                onClickOtaActivateNextButton();
618af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
619af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
620986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            case R.id.otaTryAgainButton:
621986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                onClickOtaTryAgainButton();
622af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
623af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
624af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            default:
625af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                if (DBG) log ("onClickHandler: received a click event for unrecognized id");
626af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
627af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
628af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
629af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
630986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void onClickOtaTryAgainButton() {
631986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Activation Try Again Clicked!");
632986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
633986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            otaShowActivateScreen();
634986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        }
635986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    }
636986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
637af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaEndButton() {
638986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Activation End Call Button Clicked!");
639af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
640af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            PhoneUtils.hangup(mApplication.phone);
641af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
642af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
643af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
644af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaSpeakerButton() {
645af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA Speaker button Clicked!");
646af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
647af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            boolean isChecked = !PhoneUtils.isSpeakerOn(mContext);
648af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            setSpeaker(isChecked);
649af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
650af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
651af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
652af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateButton() {
653af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Call Activation Clicked!");
654af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
655af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            Intent newIntent = new Intent(Intent.ACTION_CALL);
656af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            newIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, InCallScreen.OTA_NUMBER);
657af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.internalResolveIntent(newIntent);
658af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowListeningScreen();
659af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
660af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
661af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
662af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateCancelButton() {
663af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Activation Cancel Clicked!");
664af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
665af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
666af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
667af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
668af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
669986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void onClickOtaActivateNextButton() {
670986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Dialog Next Clicked!");
671af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
672af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
673af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
674af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
675af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.finish();
676af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
677af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
678af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
679af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void dismissAllOtaDialogs() {
680af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog != null) {
681af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mSpcErrorDialog.");
682af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.dismiss();
683af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = null;
684af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
685af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
686af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mOtaFailureDialog.");
687af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
688af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
689af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
690af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
691af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
692af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private int getOtaSpcDisplayTime() {
693af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime()...");
694af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpSpcTime = 1;
695af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
696af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcRunningTime = 0;
697af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcLeftTime = 0;
698af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcRunningTime = SystemClock.elapsedRealtime();
699af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcLeftTime =
700af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpOtaSpcRunningTime - mApplication.cdmaOtaProvisionData.otaSpcUptime;
70117c36a10d09fac3e2312c0bcb839e0a704f42105w            if (tmpOtaSpcLeftTime >= OTA_SPC_TIMEOUT*1000) {
702af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = 1;
703af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else {
704af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = OTA_SPC_TIMEOUT - (int)tmpOtaSpcLeftTime/1000;
705af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
706af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
707af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime(), time for SPC error notice: " + tmpSpcTime);
708af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return tmpSpcTime;
709af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
710af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
711af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
712af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize the OTA widgets for all OTA screens.
713af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
714af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void initOtaInCallScreen() {
715af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("initOtaInCallScreen()...");
716986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle = (TextView) mInCallScreen.findViewById(R.id.otaTitle);
717af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate = (TextView) mInCallScreen.findViewById(R.id.otaActivate);
718af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
719af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextListenProgress =
720af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaListenProgress);
721af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar =
722af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ProgressBar) mInCallScreen.findViewById(R.id.progress_large);
723af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setIndeterminate(true);
724af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail =
725af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaSuccessFailStatus);
726af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
727af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase = (View) mInCallScreen.findViewById(R.id.otaBase);
728af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress =
729af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaListenProgress);
730af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate =
731af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaActivate);
732af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess =
733af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaFailOrSuccessful);
734af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
735af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton = (Button) mInCallScreen.findViewById(R.id.otaEndButton);
736af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton.setOnClickListener(mInCallScreen);
737af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton =
738af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ToggleButton) mInCallScreen.findViewById(R.id.otaSpeakerButton);
739af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton.setOnClickListener(mInCallScreen);
740af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton =
741af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (Button) mInCallScreen.findViewById(R.id.otaActivateButton);
742af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton.setOnClickListener(mInCallScreen);
743986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaCancelButton = (Button) mInCallScreen.findViewById(R.id.otaCancelButton);
744af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCancelButton.setOnClickListener(mInCallScreen);
745986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton = (Button) mInCallScreen.findViewById(R.id.otaNextButton);
746986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setOnClickListener(mInCallScreen);
747986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton =
748986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                (Button) mInCallScreen.findViewById(R.id.otaTryAgainButton);
749986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setOnClickListener(mInCallScreen);
750986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
751af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
752af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!InCallScreen.ConfigurationHelper.isLandscape()) {
753986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            mOtaWidgetData.otaDtmfDialerView =
754986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                    (DTMFTwelveKeyDialerView) mInCallScreen.findViewById(R.id.otaDtmfDialer);
755986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            DTMFTwelveKeyDialer dialer;
756986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            dialer = new DTMFTwelveKeyDialer(mInCallScreen, mOtaWidgetData.otaDtmfDialerView,
757986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                    null, null);
758986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            mOtaWidgetData.otaDtmfDialerView.setDialer(dialer);
759986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            dialer.initializeDialer();
760af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
761af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
762af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
763af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
764af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Clear out all OTA UI widget elements. Needs to get called
765af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * when OTA call ends or InCallScreen is destroyed.
766af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
767af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void cleanOtaScreen() {
768af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA ends, cleanOtaScreen!");
769af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
770986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaScreenState.otaScreenState =
771986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
772986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.isOtaCallCommitted = false;
773986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
774986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.inOtaSpcState = false;
775986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.activationCount = 0;
776986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.otaSpcUptime = 0;
777986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
778986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (mInCallPanel != null) mInCallPanel.setVisibility(View.VISIBLE);
779986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (mCallCard != null) mCallCard.hideCallCardElements();
780986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (mDialerDrawer != null) mDialerDrawer.setVisibility(View.VISIBLE);
781986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
782986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
783986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextListenProgress.setVisibility(View.GONE);
784986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
785986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
786986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
787986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
788986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
789986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
790986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaDtmfDialerView.setVisibility(View.GONE);
791986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.GONE);
792986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.GONE);
793af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
794af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
795af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
796af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA information that needs to be maintained during
797af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * an OTA call when display orientation changes.
798af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
799af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaProvisionData {
800af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallCommitted;
801af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallIntentProcessed;
802af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean inOtaSpcState;
803af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int activationCount;
804af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public long otaSpcUptime;
805af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
806af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
807af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
808af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA screen configuration items read from config.xml
809af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * and used to control OTA display.
810af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
811af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaConfigData {
812af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivationScreen;
813af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowListeningScreen;
814af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivateFailTimes;
815af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaPlaySuccessFailureTone;
816af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean configComplete;
817af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaConfigData() {
818af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("CdmaOtaConfigData constructor!");
819af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivationScreen = OTA_SHOW_ACTIVATION_SCREEN_OFF;
820af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowListeningScreen = OTA_SHOW_LISTENING_SCREEN_OFF;
821af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivateFailTimes = OTA_SHOW_ACTIVATE_FAIL_COUNT_OFF;
822af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaPlaySuccessFailureTone = OTA_PLAY_SUCCESS_FAILURE_TONE_OFF;
823af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
824af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
825af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
826af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
827af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * The OTA screen state machine.
828af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
829af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaScreenState {
830af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public enum OtaScreenState {
831af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_UNDEFINED,
832af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_ACTIVATION,
833af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_LISTENING,
834af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_PROGRESS,
835af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_SUCCESS_FAILURE_DLG
836af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
837af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
838af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public OtaScreenState otaScreenState;
839af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
840af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaScreenState() {
841af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenState = OtaScreenState.OTA_STATUS_UNDEFINED;
842af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
843af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
844af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
845af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static void log(String msg) {
846af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Log.d(LOG_TAG, msg);
847af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
848839b14d460986608fe577f89f789de854dc85b58Jim Miller
849839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean isCdmaPhone() {
850839b14d460986608fe577f89f789de854dc85b58Jim Miller        return PhoneApp.getInstance().phone.getPhoneName().equals("CDMA");
851839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
852af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville}
853