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;
205c0517ae3c17505ffd466be79ab0026b7fe6c959Wink Savilleimport com.android.phone.OtaUtils.CdmaOtaInCallScreenUiState.State;
21af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
22af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.app.AlertDialog;
2313660626500d047d4a3a097e832bb175e1c4f894Freeman Ngimport android.app.PendingIntent;
2413660626500d047d4a3a097e832bb175e1c4f894Freeman Ngimport android.app.PendingIntent.CanceledException;
2513660626500d047d4a3a097e832bb175e1c4f894Freeman Ngimport android.content.ActivityNotFoundException;
26af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.Context;
27af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.DialogInterface;
28af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.content.Intent;
29839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.content.pm.ResolveInfo;
30af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.AsyncResult;
31839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.os.Handler;
32839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.os.Message;
33af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.SystemClock;
34af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.os.SystemProperties;
35839b14d460986608fe577f89f789de854dc85b58Jim Millerimport android.provider.Settings;
36af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
37af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.util.Log;
38af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.KeyEvent;
39af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.View;
40af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.ViewGroup;
41af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.ViewStub;
42af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.view.WindowManager;
43af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
44af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.Button;
459e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Millerimport android.widget.ScrollView;
46af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.ToggleButton;
47af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.ProgressBar;
48af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savilleimport android.widget.TextView;
49af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
50af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville/**
51af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville * Handles all OTA Call related logic and UI functionality.
52e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown * The InCallScreen interacts with this class to perform an OTA Call.
53e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown *
54e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown * OTA is a CDMA-specific feature:
55e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown *   OTA or OTASP == Over The Air service provisioning
56e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown *   SPC == Service Programming Code
57e31831f42ffa08456ef0d5d1461ddc70b9d1fcfeDavid Brown *   TODO: Include pointer to more detailed documentation.
58af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville */
59af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Savillepublic class OtaUtils {
60af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static final String LOG_TAG = "OtaUtils";
61839b14d460986608fe577f89f789de854dc85b58Jim Miller    private static final String UNACTIVATED_MIN2_VALUE = "000000";
62839b14d460986608fe577f89f789de854dc85b58Jim Miller    private static final String UNACTIVATED_MIN_VALUE = "1111110111";
635c0517ae3c17505ffd466be79ab0026b7fe6c959Wink Saville    private static final boolean DBG = (PhoneApp.DBG_LEVEL >= 1);
64af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
65af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATION_SCREEN_OFF = 0;
66af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATION_SCREEN_ON = 1;
67af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_LISTENING_SCREEN_OFF =0;
68af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_LISTENING_SCREEN_ON =1;
69af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATE_FAIL_COUNT_OFF = 0;
70af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_SHOW_ACTIVATE_FAIL_COUNT_THREE = 3;
71af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_PLAY_SUCCESS_FAILURE_TONE_OFF = 0;
72af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static final int OTA_PLAY_SUCCESS_FAILURE_TONE_ON = 1;
73af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
7417c36a10d09fac3e2312c0bcb839e0a704f42105w    // SPC Timeout is 60 seconds
7517c36a10d09fac3e2312c0bcb839e0a704f42105w    public final int OTA_SPC_TIMEOUT = 60;
76af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public final int OTA_FAILURE_DIALOG_TIMEOUT = 2;
77af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
78af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private InCallScreen mInCallScreen;
79af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private Context mContext;
80af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private PhoneApp mApplication;
81af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private OtaWidgetData mOtaWidgetData;
82af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private ViewGroup mInCallPanel;
83af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private CallCard mCallCard;
842f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
852f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // The DTMFTwelveKeyDialer instance owned by the InCallScreen, which
862f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // the InCallScreen passes in to our constructor.
87af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private DTMFTwelveKeyDialer mDialer;
882f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    //
892f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // The DTMFTwelveKeyDialer instance that we create ourselves in
902f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // initOtaInCallScreen(), and attach to the DTMFTwelveKeyDialerView
912f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // ("otaDtmfDialerView") that comes from otacall_card.xml.
922f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    private DTMFTwelveKeyDialer mOtaCallCardDtmfDialer;
932f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // TODO: we ought to share a single DTMFTwelveKeyDialer instance for
942f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown    // both these uses, but see bug 2432289 for related issues.
952f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
9657a38778e8c9f58b24cea1062e451934cadc4b3dJim Miller    private static boolean mIsWizardMode = true;
97af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
98af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
99af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * OtaWidgetData class represent all OTA UI elements
100af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
101af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private class OtaWidgetData {
102af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaEndButton;
103af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public Button otaActivateButton;
10413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        public Button otaSkipButton;
105986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public Button otaNextButton;
106af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ToggleButton otaSpeakerButton;
107af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View otaCallCardBase;
108af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsFailSuccess;
109af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public ProgressBar otaTextProgressBar;
110af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextSuccessFail;
111af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsActivate;
112af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public View callCardOtaButtonsListenProgress;
113af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextActivate;
114af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public TextView otaTextListenProgress;
1159e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller        public ScrollView otaTextListenProgressContainer;
116af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog spcErrorDialog;
117af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public AlertDialog otaFailureDialog;
11813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        public AlertDialog otaSkipConfirmationDialog;
119986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public TextView otaTitle;
120986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public DTMFTwelveKeyDialerView otaDtmfDialerView;
121986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        public Button otaTryAgainButton;
122af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
123af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
124af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public OtaUtils(Context context,
125af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    InCallScreen inCallScreen,
126af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    ViewGroup inCallPanel,
127af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CallCard callCard,
1288df5c508da2c836b841ee24120fa7c5cc92df387David Brown                    DTMFTwelveKeyDialer dialer) {
129af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
130af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Enter OtaUtil constructor");
131af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
132af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen = inCallScreen;
133af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext = context;
134af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallPanel = inCallPanel;
135af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mCallCard = callCard;
136af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mDialer = dialer;
137af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication = PhoneApp.getInstance();
138af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData = new OtaWidgetData();
139af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
140af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // inflate OTA Call card and footers
141af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        ViewStub otaCallCardStub = (ViewStub) mInCallScreen.findViewById(R.id.otaCallCardStub);
142af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaCallCardStub.inflate();
143af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        readXmlSettings();
144af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        initOtaInCallScreen();
145af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
146a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent
147839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
148839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Returns true if the phone needs activation.
149a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent     *
150839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param minString the phone's MIN configuration string
151839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if phone needs activation
152839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @throws OtaConfigurationException if the string is invalid
153839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
154839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean needsActivation(String minString) throws IllegalArgumentException {
155839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (minString == null || (minString.length() < 6)) {
156839b14d460986608fe577f89f789de854dc85b58Jim Miller            throw new IllegalArgumentException();
157839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
158a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent        return (minString.equals(UNACTIVATED_MIN_VALUE)
159839b14d460986608fe577f89f789de854dc85b58Jim Miller                || minString.substring(0,6).equals(UNACTIVATED_MIN2_VALUE))
160839b14d460986608fe577f89f789de854dc85b58Jim Miller                || SystemProperties.getBoolean("test_cdma_setup", false);
161839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
162a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent
163839b14d460986608fe577f89f789de854dc85b58Jim Miller    /**
164839b14d460986608fe577f89f789de854dc85b58Jim Miller     * Starts the OTA provisioning call.  If the MIN isn't available yet, it returns false and adds
165a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent     * an event to return the request to the calling app when it becomes available.
166a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent     *
167839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param context
168839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param handler
169839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @param request
170839b14d460986608fe577f89f789de854dc85b58Jim Miller     * @return true if we were able to launch Ota activity or it's not required; false otherwise
171839b14d460986608fe577f89f789de854dc85b58Jim Miller     */
172839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean maybeDoOtaCall(Context context, Handler handler, int request) {
17313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
174839b14d460986608fe577f89f789de854dc85b58Jim Miller        PhoneApp app = PhoneApp.getInstance();
175839b14d460986608fe577f89f789de854dc85b58Jim Miller        Phone phone = app.phone;
176839b14d460986608fe577f89f789de854dc85b58Jim Miller
177839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!isCdmaPhone()) {
178839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) Log.v("OtaUtils", "Can't run provisioning on a non-CDMA phone");
179839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // sanity check - a non-cdma phone doesn't need to run this
180839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
181839b14d460986608fe577f89f789de854dc85b58Jim Miller
182839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (!phone.isMinInfoReady()) {
183839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("MIN is not ready. Registering to receive notification.");
184839b14d460986608fe577f89f789de854dc85b58Jim Miller            phone.registerForSubscriptionInfoReady(handler, request, null);
185839b14d460986608fe577f89f789de854dc85b58Jim Miller            return false;
186839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
187839b14d460986608fe577f89f789de854dc85b58Jim Miller
188839b14d460986608fe577f89f789de854dc85b58Jim Miller        phone.unregisterForSubscriptionInfoReady(handler);
189839b14d460986608fe577f89f789de854dc85b58Jim Miller        String min = phone.getCdmaMin();
190839b14d460986608fe577f89f789de854dc85b58Jim Miller
191839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("min_string: " + min);
192839b14d460986608fe577f89f789de854dc85b58Jim Miller
193839b14d460986608fe577f89f789de854dc85b58Jim Miller        boolean phoneNeedsActivation = false;
194839b14d460986608fe577f89f789de854dc85b58Jim Miller        try {
195839b14d460986608fe577f89f789de854dc85b58Jim Miller            phoneNeedsActivation = needsActivation(min);
196839b14d460986608fe577f89f789de854dc85b58Jim Miller        } catch (IllegalArgumentException e) {
197839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("invalid MIN string, exit");
198839b14d460986608fe577f89f789de854dc85b58Jim Miller            return true; // If the MIN string is wrong, there's nothing else we can do.
199839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
200839b14d460986608fe577f89f789de854dc85b58Jim Miller
201839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("phoneNeedsActivation is set to " + phoneNeedsActivation);
202a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent
203839b14d460986608fe577f89f789de854dc85b58Jim Miller        int otaShowActivationScreen = context.getResources().getInteger(
204839b14d460986608fe577f89f789de854dc85b58Jim Miller                R.integer.OtaShowActivationScreen);
205839b14d460986608fe577f89f789de854dc85b58Jim Miller
206839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (DBG) log("otaShowActivationScreen: " + otaShowActivationScreen);
207839b14d460986608fe577f89f789de854dc85b58Jim Miller
208839b14d460986608fe577f89f789de854dc85b58Jim Miller        if (phoneNeedsActivation && (otaShowActivationScreen == OTA_SHOW_ACTIVATION_SCREEN_ON)) {
209839b14d460986608fe577f89f789de854dc85b58Jim Miller            app.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
210839b14d460986608fe577f89f789de854dc85b58Jim Miller            Intent newIntent = new Intent(InCallScreen.ACTION_SHOW_ACTIVATION);
211839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setClass(context, InCallScreen.class);
212839b14d460986608fe577f89f789de854dc85b58Jim Miller            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
21357a38778e8c9f58b24cea1062e451934cadc4b3dJim Miller            mIsWizardMode = false;
214839b14d460986608fe577f89f789de854dc85b58Jim Miller            context.startActivity(newIntent);
215839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent sent.");
216839b14d460986608fe577f89f789de854dc85b58Jim Miller        } else {
217839b14d460986608fe577f89f789de854dc85b58Jim Miller            if (DBG) log("activation intent NOT sent.");
218839b14d460986608fe577f89f789de854dc85b58Jim Miller        }
219839b14d460986608fe577f89f789de854dc85b58Jim Miller        return true;
220839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
221af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
222af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void setSpeaker(boolean state) {
223af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("setSpeaker : " + state );
224af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state == PhoneUtils.isSpeakerOn(mContext)) {
225af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("no change. returning");
226af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
227af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
228af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
229af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (state && mInCallScreen.isBluetoothAvailable()
230af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && mInCallScreen.isBluetoothAudioConnected()) {
231af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.disconnectBluetoothAudio();
232af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
233425b8e3c9846d5e0e76466604b35cad8856d79deEric Laurent        PhoneUtils.turnOnSpeaker(mContext, state, true);
234af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
235af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
236af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
237af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA Provision events from Framework. Possible events are:
238af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * OTA Commit Event - OTA provisioning was successful
239af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * SPC retries exceeded - SPC failure retries has exceeded, and Phone needs to
240af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     *    power down.
241af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
242af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaProvisionStatusChanged(AsyncResult r) {
243af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int OtaStatus[] = (int[]) r.result;
244af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaProvisionStatusChanged(): OtaStatus[0]" + OtaStatus[0]);
245af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
246af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch(OtaStatus[0]) {
247af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED:
24865336771f727928a14d1d8fe175390ef7a06f71dWink Saville                otaShowInProgressScreen();
249af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.otaSpcUptime = SystemClock.elapsedRealtime();
250af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(OTA_SPC_TIMEOUT);
25165336771f727928a14d1d8fe175390ef7a06f71dWink Saville                if (DBG) log("onOtaProvisionStatusChanged(): RETRIES EXCEEDED");
252af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                // Power.shutdown();
253af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
25465336771f727928a14d1d8fe175390ef7a06f71dWink Saville
255af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED:
25665336771f727928a14d1d8fe175390ef7a06f71dWink Saville                otaShowInProgressScreen();
257af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaProvisionData.isOtaCallCommitted = true;
25865336771f727928a14d1d8fe175390ef7a06f71dWink Saville                if (DBG) log("onOtaProvisionStatusChanged(): DONE, isOtaCallCommitted set to true");
25965336771f727928a14d1d8fe175390ef7a06f71dWink Saville                break;
26065336771f727928a14d1d8fe175390ef7a06f71dWink Saville
26165336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED:
26265336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED:
26365336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_SSD_UPDATED:
26465336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED:
26565336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED:
26665336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED:
26765336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED:
26865336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED:
26965336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED:
27065336771f727928a14d1d8fe175390ef7a06f71dWink Saville            case Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED:
27165336771f727928a14d1d8fe175390ef7a06f71dWink Saville                if (DBG) log("onOtaProvisionStatusChanged(): change to ProgressScreen");
27265336771f727928a14d1d8fe175390ef7a06f71dWink Saville                otaShowInProgressScreen();
27365336771f727928a14d1d8fe175390ef7a06f71dWink Saville                break;
27465336771f727928a14d1d8fe175390ef7a06f71dWink Saville
27565336771f727928a14d1d8fe175390ef7a06f71dWink Saville            default:
27665336771f727928a14d1d8fe175390ef7a06f71dWink Saville                if (DBG) log("onOtaProvisionStatusChanged(): Ignoring OtaStatus " + OtaStatus[0]);
277af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
278af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
279af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
280af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
281af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowHome() {
282af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowHome()...");
283af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
284af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
2854a5a966f0d43e04d336be1b94182346399a931f6Wink Saville        mInCallScreen.endInCallScreenSession();
286af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Intent intent = new Intent(Intent.ACTION_MAIN);
287af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.addCategory (Intent.CATEGORY_HOME);
288af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
289af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mContext.startActivity(intent);
290af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
291af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
292af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
29313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng    private void otaSkipActivation() {
29413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        if (DBG) log("otaSkipActivation()...");
29513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
29613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        PhoneApp app = PhoneApp.getInstance();
29713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        if (app != null && app.cdmaOtaInCallScreenUiState.reportSkipPendingIntent != null) {
29813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            try {
29913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                app.cdmaOtaInCallScreenUiState.reportSkipPendingIntent.send();
30013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            } catch (CanceledException e) {
30113660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                // should never happen because no code cancels the pending intent right now,
30213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                // but if it does, the user will simply be returned to the initial setup screen
30313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            }
30413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        }
30513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
30613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mInCallScreen.finish();
30713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        return;
30813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng    }
30913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
31013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng    private void otaPerformActivation() {
31113660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        if (DBG) log("otaPerformActivation()...");
31213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
31313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            Intent newIntent = new Intent(Intent.ACTION_CALL);
31413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            newIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, InCallScreen.OTA_NUMBER);
31513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            mInCallScreen.internalResolveIntent(newIntent);
31613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            otaShowListeningScreen();
31713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        }
31813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        return;
31913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng    }
32013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
321af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
322af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show Activation Screen when phone powers up and OTA provision is
323af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * required. Also shown when activation fails and user needs
32413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng     * to re-attempt it. Contains ACTIVATE and SKIP buttons
32513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng     * which allow user to start OTA activation or skip the activation process.
326af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
327af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowActivateScreen() {
328af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowActivationScreen()...");
329af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowActivationScreen
330af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_ACTIVATION_SCREEN_ON) {
331af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show activation screen");
332e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
333af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
33413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                mOtaWidgetData.otaSkipButton.setVisibility(mIsWizardMode ?
33557a38778e8c9f58b24cea1062e451934cadc4b3dJim Miller                        View.VISIBLE : View.INVISIBLE);
336af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextActivate.setVisibility(View.VISIBLE);
337af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.VISIBLE);
338e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
3398df5c508da2c836b841ee24120fa7c5cc92df387David Brown                mDialer.setHandleVisible(true);
340af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
341af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
342af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION;
343af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
344af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowActivationScreen(): show home screen");
345af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
346af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
347af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     }
348af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
349af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
350af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Listen for Instruction" screen during OTA call. Shown when OTA Call
351af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is initiated and user needs to listen for network instructions and press
352af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * appropriate DTMF digits to proceed to the "Programming in Progress" phase.
353af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
354af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowListeningScreen() {
355af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowListeningScreen()...");
356af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.otaShowListeningScreen
357af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                == OTA_SHOW_LISTENING_SCREEN_ON) {
358af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show listening screen");
359e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (!isDialerOpened()) {
360af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaScreenInitialize();
3619e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller                mOtaWidgetData.otaTextListenProgressContainer.setVisibility(View.VISIBLE);
362af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_listen);
363986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                mOtaWidgetData.otaDtmfDialerView.setVisibility(View.VISIBLE);
364af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
365986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                mOtaWidgetData.otaSpeakerButton.setVisibility(View.VISIBLE);
366a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                boolean speakerOn = PhoneUtils.isSpeakerOn(mContext);
367a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                mOtaWidgetData.otaSpeakerButton.setChecked(speakerOn);
368e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            } else {
3698df5c508da2c836b841ee24120fa7c5cc92df387David Brown                mDialer.setHandleVisible(true);
370af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
371af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
372af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING;
373af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
374af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            // Update the state of the in-call menu items.
375af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mInCallScreen.updateMenuItems();
376af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
377af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowListeningScreen(): show progress screen");
378af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowInProgressScreen();
379af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
380af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
381af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
382af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
383af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show "Programming In Progress" screen during OTA call. Shown when OTA
384af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * provisioning is in progress after user has selected an option.
385af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
386af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowInProgressScreen() {
387af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowInProgressScreen()...");
388e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (!isDialerOpened()) {
389af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenInitialize();
3909e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller            mOtaWidgetData.otaTextListenProgressContainer.setVisibility(View.VISIBLE);
391af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextListenProgress.setText(R.string.ota_progress);
392af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaTextProgressBar.setVisibility(View.VISIBLE);
393af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.VISIBLE);
3949bd141ba20a6cf6dcb745aca6c5c05a9c88f3a98Jim Miller            mOtaWidgetData.otaSpeakerButton.setVisibility(View.VISIBLE);
395a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent            boolean speakerOn = PhoneUtils.isSpeakerOn(mContext);
396a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent            mOtaWidgetData.otaSpeakerButton.setChecked(speakerOn);
397e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        } else {
3988df5c508da2c836b841ee24120fa7c5cc92df387David Brown            mDialer.setHandleVisible(true);
399af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
400af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
401af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS;
402af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
403af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        // Update the state of the in-call menu items.
404af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mInCallScreen.updateMenuItems();
405af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
406af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
407af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
408af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails.
409af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * If OTA provisioning attempts fail more than 3 times, then unsuccessful
410af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * dialog is shown. Otherwise a two-second notice is shown with unsuccessful
411af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * information. When notice expires, phone returns to activation screen.
412af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
413986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void otaShowProgramFailure(int length) {
414af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailure()...");
415af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaProvisionData.activationCount++;
416af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if ((mApplication.cdmaOtaProvisionData.activationCount <
417af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mApplication.cdmaOtaConfigData.otaShowActivateFailTimes)
418af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                && (mApplication.cdmaOtaConfigData.otaShowActivationScreen ==
419af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                OTA_SHOW_ACTIVATION_SCREEN_ON)) {
420af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): activationCount"
421af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaProvisionData.activationCount);
422af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure notice");
423af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureNotice(length);
424af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
425af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowProgramFailure(): show failure dialog");
426af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailureDialog();
427af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
428af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
429af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
430af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
431af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show either programming success dialog when OTA provisioning succeeds, or
432af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * programming failure dialog when it fails. See {@link otaShowProgramFailure}
433af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * for more details.
434af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
435af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowSuccessFailure() {
436af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure()...");
437af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaScreenInitialize();
438af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSuccessFailure(): isOtaCallCommitted"
439af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaProvisionData.isOtaCallCommitted);
440af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.isOtaCallCommitted) {
441af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show success dialog");
442af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramSuccessDialog();
443af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        } else {
444af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("OtaShowSuccessFailure(), show failure dialog");
445af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowProgramFailure(OTA_FAILURE_DIALOG_TIMEOUT);
446af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
447af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return;
448af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
449af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
450af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
451af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming failure dialog when OTA provisioning fails more than 3
452af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * times.
453af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
454af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureDialog() {
455af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureDialog()...");
456af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
457af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
458986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_problem_with_activation);
459af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
460af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_unsuccessful);
461af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
462986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.VISIBLE);
463af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
464e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
465af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
466af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
467af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
468af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
469af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
470af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show programming success dialog when OTA provisioning succeeds.
471af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
472af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramSuccessDialog() {
473af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramSuccessDialog()...");
474af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaScreenState.otaScreenState =
475af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG;
476986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_activate_success);
477af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.VISIBLE);
478af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setText(R.string.ota_successful);
479af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.VISIBLE);
480986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.VISIBLE);
481af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        //close the dialer if open
482e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        if (isDialerOpened()) {
483af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mDialer.closeDialer(false);
484af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
485af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
486af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
487af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
488af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show SPC failure notice when SPC attempts exceed 15 times.
489af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * During OTA provisioning, if SPC code is incorrect OTA provisioning will
490af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * fail. When SPC attempts are over 15, it shows SPC failure notice for one minute and
491af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * then phone will power down.
492af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
493af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowSpcErrorNotice(int length) {
494af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowSpcErrorNotice()...");
495af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog == null) {
496af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaProvisionData.inOtaSpcState = true;
497af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            DialogInterface.OnKeyListener keyListener;
498af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            keyListener = new DialogInterface.OnKeyListener() {
499af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
500af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    log("Ignoring key events...");
501af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    return true;
502af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                }};
503af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = new AlertDialog.Builder(mInCallScreen)
504af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_spc_failure)
505af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setOnKeyListener(keyListener)
506af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
507af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.getWindow().addFlags(
508af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
509af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
510af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.show();
511af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            //close the dialer if open
512e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman            if (isDialerOpened()) {
513af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mDialer.closeDialer(false);
514af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
515af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
516325cc2ced6f1ff5fb1708abfcc5e9c73ac0cd962David Brown            if (DBG) log("OtaShowSpcErrorNotice(), remaining SPC noticeTime" + noticeTime);
517325cc2ced6f1ff5fb1708abfcc5e9c73ac0cd962David Brown            mInCallScreen.requestCloseSpcErrorNotice(noticeTime);
518af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
519af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
520af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
521af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
522af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * When SPC notice times out, force phone to power down.
523af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
524af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseSpcNotice() {
52517c36a10d09fac3e2312c0bcb839e0a704f42105w        if (DBG) log("onOtaCloseSpcNotice(), send shutdown intent");
52617c36a10d09fac3e2312c0bcb839e0a704f42105w        Intent shutdown = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
52717c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
52817c36a10d09fac3e2312c0bcb839e0a704f42105w        shutdown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
52917c36a10d09fac3e2312c0bcb839e0a704f42105w        mContext.startActivity(shutdown);
530af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
531af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
532af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
533af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show two-second notice when OTA provisioning fails and number of failed attempts
534af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * is less then 3.
535af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
536af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaShowProgramFailureNotice(int length) {
537af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaShowProgramFailureNotice()...");
538af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog == null) {
539af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = new AlertDialog.Builder(mInCallScreen)
540af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .setMessage(R.string.ota_failure)
541af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    .create();
542af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.getWindow().addFlags(
543af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
544af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
545af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.show();
546af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
547af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long noticeTime = length*1000;
548325cc2ced6f1ff5fb1708abfcc5e9c73ac0cd962David Brown            mInCallScreen.requestCloseOtaFailureNotice(noticeTime);
549af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
550af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
551af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
552af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
553af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle OTA unsuccessful notice expiry. Dismisses the
554af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * two-second notice and shows the activation screen.
555af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
556af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onOtaCloseFailureNotice() {
557af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("onOtaCloseFailureNotice()...");
558af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
559af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
560af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
561af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
562af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        otaShowActivateScreen();
563af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
564af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
565af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
566af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize all OTA UI elements to be gone. Also set inCallPanel,
5678df5c508da2c836b841ee24120fa7c5cc92df387David Brown     * callCard and the dialpad handle to be gone. This is called before any OTA screen
568af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * gets drawn.
569af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
570af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void otaScreenInitialize() {
571af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OtaScreenInitialize()...");
572af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
573af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallPanel != null) mInCallPanel.setVisibility(View.GONE);
574af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mCallCard != null) mCallCard.hideCallCardElements();
5758df5c508da2c836b841ee24120fa7c5cc92df387David Brown        mDialer.setHandleVisible(false);
576af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
577986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle.setText(R.string.ota_title_activate);
578af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
5799e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller        mOtaWidgetData.otaTextListenProgressContainer.setVisibility(View.GONE);
580af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
581af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
582af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
583af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
584af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
585986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaDtmfDialerView.setVisibility(View.GONE);
586986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaSpeakerButton.setVisibility(View.GONE);
587986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.GONE);
588986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.GONE);
589af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.VISIBLE);
59013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mOtaWidgetData.otaSkipButton.setVisibility(View.VISIBLE);
591af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
592af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
593af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void hideOtaScreen() {
594af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("hideOtaScreen()...");
595af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
596af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
597af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
598af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
599af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
600af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
601af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
602e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    public boolean isDialerOpened() {
603e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman        return (mDialer != null && mDialer.isOpened());
604e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman    }
605e4a6da04f5ed72f8be2e578b91d041493277e248Paul Berman
606af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
607af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Show the appropriate OTA screen based on the current state of OTA call.
608af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Shown whenever calling screen is resumed.
609af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
610af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void otaShowProperScreen() {
611af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("otaShowProperScreen()...");
612af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mInCallScreen.isForegroundActivity()) {
613af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("otaShowProperScreen(), OTA is foreground activity, currentstate ="
614af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    + mApplication.cdmaOtaScreenState.otaScreenState);
615af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mInCallPanel != null) {
616af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mInCallPanel.setVisibility(View.GONE);
617af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
618af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaScreenState.otaScreenState
619af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION) {
620af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowActivateScreen();
621af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
622af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_LISTENING) {
623af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowListeningScreen();
624af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else if (mApplication.cdmaOtaScreenState.otaScreenState
625af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    == CdmaOtaScreenState.OtaScreenState.OTA_STATUS_PROGRESS) {
626af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowInProgressScreen();
627af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
628af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
629af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
630af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                otaShowSpcErrorNotice(getOtaSpcDisplayTime());
631af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
632af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
633af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
634af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
635af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
636af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Read configuration values for each OTA screen from config.xml.
637af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * These configuration values control visibility of each screen.
638af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
639af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void readXmlSettings() {
640af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings()...");
641af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaConfigData.configComplete) {
642af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            return;
643af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
644af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
645af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.configComplete = true;
646af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivationScreen =
647af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivationScreen);
648af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivationScreen = tmpOtaShowActivationScreen;
649af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivationScreen"
650af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivationScreen);
651af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
652af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowListeningScreen =
653af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowListeningScreen);
654af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowListeningScreen = tmpOtaShowListeningScreen;
655af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowListeningScreen"
656af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowListeningScreen);
657af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
658af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaShowActivateFailTimes =
659af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaShowActivateFailTimes);
660af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaShowActivateFailTimes = tmpOtaShowActivateFailTimes;
661af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaShowActivateFailTimes"
662af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaShowActivateFailTimes);
663af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
664af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpOtaPlaySuccessFailureTone =
665af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                mContext.getResources().getInteger(R.integer.OtaPlaySuccessFailureTone);
666af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone = tmpOtaPlaySuccessFailureTone;
667af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("readXmlSettings(), otaPlaySuccessFailureTone"
668af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                + mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone);
669af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
670af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
671af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
672af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Handle the click events for OTA buttons.
673af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
674af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void onClickHandler(int id) {
675af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        switch (id) {
676af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaEndButton:
677af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaEndButton();
678af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
679af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
680af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaSpeakerButton:
681af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaSpeakerButton();
682af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
683af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
684af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            case R.id.otaActivateButton:
685af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                onClickOtaActivateButton();
686af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
687af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
68813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            case R.id.otaSkipButton:
68913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                onClickOtaActivateSkipButton();
690af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
691af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
692986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            case R.id.otaNextButton:
693986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                onClickOtaActivateNextButton();
694af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
695af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
696986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            case R.id.otaTryAgainButton:
697986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                onClickOtaTryAgainButton();
698af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
699af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
700af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            default:
701af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                if (DBG) log ("onClickHandler: received a click event for unrecognized id");
702af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                break;
703af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
704af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
705af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
706986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void onClickOtaTryAgainButton() {
707986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Activation Try Again Clicked!");
708986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
709986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller            otaShowActivateScreen();
710986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        }
711986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    }
712986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
713af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaEndButton() {
714986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Activation End Call Button Clicked!");
715af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
716a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent            if (PhoneUtils.hangup(mApplication.phone) == false) {
717a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                // If something went wrong when placing the OTA call,
718a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                // the screen is not updated by the call disconnect
719a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                // handler and we have to do it here
720a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                setSpeaker(false);
721a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent                mInCallScreen.handleOtaCallEnd();
722a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent            }
723af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
724af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
725af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
726af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaSpeakerButton() {
727af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA Speaker button Clicked!");
728af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
729af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            boolean isChecked = !PhoneUtils.isSpeakerOn(mContext);
730af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            setSpeaker(isChecked);
731af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
732af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
733af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
734af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void onClickOtaActivateButton() {
735af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("Call Activation Clicked!");
73613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        otaPerformActivation();
737af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
738af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
73913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng    private void onClickOtaActivateSkipButton() {
74013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        if (DBG) log("Activation Skip Clicked!");
74113660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        DialogInterface.OnKeyListener keyListener;
74213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        keyListener = new DialogInterface.OnKeyListener() {
74313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            public boolean onKey(DialogInterface dialog, int keyCode,
74413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    KeyEvent event) {
74513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                if (DBG) log("Ignoring key events...");
74613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                return true;
74713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng            }
74813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        };
74913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mOtaWidgetData.otaSkipConfirmationDialog = new AlertDialog.Builder(mInCallScreen)
75013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .setTitle(R.string.ota_skip_activation_dialog_title)
75113660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .setMessage(R.string.ota_skip_activation_dialog_message)
75213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .setPositiveButton(
75313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    R.string.ota_skip_activation_dialog_skip_label,
75413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    new AlertDialog.OnClickListener() {
75513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                        public void onClick(DialogInterface dialog, int which) {
75613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                            otaSkipActivation();
75713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                        }
75813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    })
75913660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .setNegativeButton(
76013660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    R.string.ota_skip_activation_dialog_continue_label,
76113660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    new AlertDialog.OnClickListener() {
76213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                        public void onClick(DialogInterface dialog, int which) {
76313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                            otaPerformActivation();
76413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                        }
76513660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                    })
76613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .setOnKeyListener(keyListener)
76713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng                .create();
76813660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mOtaWidgetData.otaSkipConfirmationDialog.show();
769af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
770af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
771986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller    private void onClickOtaActivateNextButton() {
772986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (DBG) log("Dialog Next Clicked!");
773af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (!mApplication.cdmaOtaProvisionData.inOtaSpcState) {
774af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mApplication.cdmaOtaScreenState.otaScreenState =
775af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                    CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
776af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowHome();
777af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
778af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
779af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
780af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public void dismissAllOtaDialogs() {
781af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.spcErrorDialog != null) {
782af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mSpcErrorDialog.");
783af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog.dismiss();
784af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.spcErrorDialog = null;
785af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
786af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mOtaWidgetData.otaFailureDialog != null) {
787af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("- DISMISSING mOtaFailureDialog.");
788af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog.dismiss();
789af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            mOtaWidgetData.otaFailureDialog = null;
790af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
791af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
792af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
793af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private int getOtaSpcDisplayTime() {
794af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime()...");
795af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        int tmpSpcTime = 1;
796af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (mApplication.cdmaOtaProvisionData.inOtaSpcState) {
797af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcRunningTime = 0;
798af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            long tmpOtaSpcLeftTime = 0;
799af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcRunningTime = SystemClock.elapsedRealtime();
800af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            tmpOtaSpcLeftTime =
801af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpOtaSpcRunningTime - mApplication.cdmaOtaProvisionData.otaSpcUptime;
80217c36a10d09fac3e2312c0bcb839e0a704f42105w            if (tmpOtaSpcLeftTime >= OTA_SPC_TIMEOUT*1000) {
803af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = 1;
804af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            } else {
805af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                tmpSpcTime = OTA_SPC_TIMEOUT - (int)tmpOtaSpcLeftTime/1000;
806af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            }
807af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
808af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("getOtaSpcDisplayTime(), time for SPC error notice: " + tmpSpcTime);
809af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        return tmpSpcTime;
810af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
811af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
812af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
813af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Initialize the OTA widgets for all OTA screens.
814af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
815af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private void initOtaInCallScreen() {
816af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("initOtaInCallScreen()...");
817986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTitle = (TextView) mInCallScreen.findViewById(R.id.otaTitle);
818af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate = (TextView) mInCallScreen.findViewById(R.id.otaActivate);
819af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
8209e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller        mOtaWidgetData.otaTextListenProgressContainer =
8219e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller                (ScrollView) mInCallScreen.findViewById(R.id.otaListenProgressContainer);
822af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextListenProgress =
823af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaListenProgress);
824af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar =
825af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ProgressBar) mInCallScreen.findViewById(R.id.progress_large);
826af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextProgressBar.setIndeterminate(true);
827af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaTextSuccessFail =
828af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (TextView) mInCallScreen.findViewById(R.id.otaSuccessFailStatus);
829af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
830af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaCallCardBase = (View) mInCallScreen.findViewById(R.id.otaBase);
831af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsListenProgress =
832af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaListenProgress);
833af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsActivate =
834af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaActivate);
835af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.callCardOtaButtonsFailSuccess =
836af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (View) mInCallScreen.findViewById(R.id.callCardOtaFailOrSuccessful);
837af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
838af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton = (Button) mInCallScreen.findViewById(R.id.otaEndButton);
839af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaEndButton.setOnClickListener(mInCallScreen);
840af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton =
841af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (ToggleButton) mInCallScreen.findViewById(R.id.otaSpeakerButton);
842af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaSpeakerButton.setOnClickListener(mInCallScreen);
843af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton =
844af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville                (Button) mInCallScreen.findViewById(R.id.otaActivateButton);
845af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        mOtaWidgetData.otaActivateButton.setOnClickListener(mInCallScreen);
84613660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mOtaWidgetData.otaSkipButton = (Button) mInCallScreen.findViewById(R.id.otaSkipButton);
84713660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        mOtaWidgetData.otaSkipButton.setOnClickListener(mInCallScreen);
848986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton = (Button) mInCallScreen.findViewById(R.id.otaNextButton);
849986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setOnClickListener(mInCallScreen);
850986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton =
851986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                (Button) mInCallScreen.findViewById(R.id.otaTryAgainButton);
852986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setOnClickListener(mInCallScreen);
853a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent
854dfa83d531cdb88513f09e913424b7a16628b37d3David Brown        mOtaWidgetData.otaDtmfDialerView =
855dfa83d531cdb88513f09e913424b7a16628b37d3David Brown                (DTMFTwelveKeyDialerView) mInCallScreen.findViewById(R.id.otaDtmfDialer);
856dfa83d531cdb88513f09e913424b7a16628b37d3David Brown        // Sanity-check: the otaDtmfDialer widget should *always* be present.
857dfa83d531cdb88513f09e913424b7a16628b37d3David Brown        if (mOtaWidgetData.otaDtmfDialerView == null) {
858dfa83d531cdb88513f09e913424b7a16628b37d3David Brown            Log.e(LOG_TAG, "onCreate: couldn't find otaDtmfDialer", new IllegalStateException());
859af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
8602f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
8612f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
8622f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // Create a new DTMFTwelveKeyDialer instance purely for use by the
8632f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // DTMFTwelveKeyDialerView ("otaDtmfDialerView") that comes from
8642f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // otacall_card.xml.
8652f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // (But note that mDialer is a separate DTMFTwelveKeyDialer
8662f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // instance, that belongs to the InCallScreen.  This is confusing;
8672f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // see the TODO comment above.)
8682f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        mOtaCallCardDtmfDialer = new DTMFTwelveKeyDialer(mInCallScreen,
8692f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown                                                         mOtaWidgetData.otaDtmfDialerView,
8702f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown                                                         null /* no SlidingDrawer used here */);
8712f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
8722f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // Initialize the new DTMFTwelveKeyDialer instance.  This is
8732f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // needed to play local DTMF tones.
8742f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        mOtaCallCardDtmfDialer.startDialerSession();
8752f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
8762f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        mOtaWidgetData.otaDtmfDialerView.setDialer(mOtaCallCardDtmfDialer);
877af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
878af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
879af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
880af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Clear out all OTA UI widget elements. Needs to get called
881af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * when OTA call ends or InCallScreen is destroyed.
8824a5a966f0d43e04d336be1b94182346399a931f6Wink Saville     * @param disableSpeaker parameter control whether Speaker should be turned off.
883af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
8844a5a966f0d43e04d336be1b94182346399a931f6Wink Saville    public void cleanOtaScreen(boolean disableSpeaker) {
885af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        if (DBG) log("OTA ends, cleanOtaScreen!");
886af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
887986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaScreenState.otaScreenState =
888986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller                CdmaOtaScreenState.OtaScreenState.OTA_STATUS_UNDEFINED;
889986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.isOtaCallCommitted = false;
890986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.isOtaCallIntentProcessed = false;
891986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.inOtaSpcState = false;
892986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.activationCount = 0;
893986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mApplication.cdmaOtaProvisionData.otaSpcUptime = 0;
8945c0517ae3c17505ffd466be79ab0026b7fe6c959Wink Saville        mApplication.cdmaOtaInCallScreenUiState.state = State.UNDEFINED;
895986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
896986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (mInCallPanel != null) mInCallPanel.setVisibility(View.VISIBLE);
897986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        if (mCallCard != null) mCallCard.hideCallCardElements();
8988df5c508da2c836b841ee24120fa7c5cc92df387David Brown        mDialer.setHandleVisible(true);
899986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller
9002f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // Free resources from the DTMFTwelveKeyDialer instance we created
9012f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        // in initOtaInCallScreen().
9022f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        if (mOtaCallCardDtmfDialer != null) {
9032f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown            mOtaCallCardDtmfDialer.stopDialerSession();
9042f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown        }
9052f22a9001166458ef4b04f6142b6d6a480af1c9dDavid Brown
906986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextActivate.setVisibility(View.GONE);
9079e9d66682248d0d9d0514b906f4c0a5ee7b9f7d3Jim Miller        mOtaWidgetData.otaTextListenProgressContainer.setVisibility(View.GONE);
908986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextProgressBar.setVisibility(View.GONE);
909986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTextSuccessFail.setVisibility(View.GONE);
910986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsActivate.setVisibility(View.GONE);
911986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsListenProgress.setVisibility(View.GONE);
912986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.callCardOtaButtonsFailSuccess.setVisibility(View.GONE);
913986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaCallCardBase.setVisibility(View.GONE);
914986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaDtmfDialerView.setVisibility(View.GONE);
915986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaNextButton.setVisibility(View.GONE);
916986d2f46bd9572b563b89627fa60a9ea0853a91fJim Miller        mOtaWidgetData.otaTryAgainButton.setVisibility(View.GONE);
917a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent
918a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent        // turn off the speaker in case it was turned on
919a44a437fae34920b0ecbf66400ac50e10e5ae49eEric Laurent        // but the OTA call could not be completed
9204a5a966f0d43e04d336be1b94182346399a931f6Wink Saville        if (disableSpeaker) {
9214a5a966f0d43e04d336be1b94182346399a931f6Wink Saville            setSpeaker(false);
9224a5a966f0d43e04d336be1b94182346399a931f6Wink Saville        }
923af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
924af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
925af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
926af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA information that needs to be maintained during
927af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * an OTA call when display orientation changes.
928af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
929af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaProvisionData {
930af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallCommitted;
931af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean isOtaCallIntentProcessed;
932af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean inOtaSpcState;
933af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int activationCount;
934af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public long otaSpcUptime;
935af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
936af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
937af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
938af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * Defines OTA screen configuration items read from config.xml
939af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * and used to control OTA display.
940af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
941af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaConfigData {
942af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivationScreen;
943af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowListeningScreen;
944af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaShowActivateFailTimes;
945af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public int otaPlaySuccessFailureTone;
946af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public boolean configComplete;
947af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaConfigData() {
948af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            if (DBG) log("CdmaOtaConfigData constructor!");
949af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivationScreen = OTA_SHOW_ACTIVATION_SCREEN_OFF;
950af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowListeningScreen = OTA_SHOW_LISTENING_SCREEN_OFF;
951af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaShowActivateFailTimes = OTA_SHOW_ACTIVATE_FAIL_COUNT_OFF;
952af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaPlaySuccessFailureTone = OTA_PLAY_SUCCESS_FAILURE_TONE_OFF;
953af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
954af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
955af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
956af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    /**
957f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     * The state of the OTA InCallScreen UI.
958f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     */
959f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    public static class CdmaOtaInCallScreenUiState {
960f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        public enum State {
961f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville            UNDEFINED,
962f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville            NORMAL,
963f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville            ENDED
964f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        }
965f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville
966f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        public State state;
967f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville
968f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        public CdmaOtaInCallScreenUiState() {
969f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville            if (DBG) log("CdmaOtaInCallScreenState: constructor init to UNDEFINED");
970f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville            state = CdmaOtaInCallScreenUiState.State.UNDEFINED;
971f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        }
97213660626500d047d4a3a097e832bb175e1c4f894Freeman Ng
97313660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        // the pending intent used to report when the user skips ota provisioning
97413660626500d047d4a3a097e832bb175e1c4f894Freeman Ng        public PendingIntent reportSkipPendingIntent;
975f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    }
976f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville
977f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    /**
978f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     * Save the Ota InCallScreen UI state
979f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     */
980f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    public void setCdmaOtaInCallScreenUiState(CdmaOtaInCallScreenUiState.State state) {
981f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        if (DBG) log("setCdmaOtaInCallScreenState: " + state);
982f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        mApplication.cdmaOtaInCallScreenUiState.state = state;
983f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    }
984f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville
985f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    /**
986f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     * Get the Ota InCallScreen UI state
987f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville     */
988f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    public CdmaOtaInCallScreenUiState.State getCdmaOtaInCallScreenUiState() {
989f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        if (DBG) log("getCdmaOtaInCallScreenState: " + mApplication.cdmaOtaInCallScreenUiState.state);
990f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville        return mApplication.cdmaOtaInCallScreenUiState.state;
991f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    }
992f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville
993f6eb7893215a875863e1e0200e4aa3174137f76cWink Saville    /**
994af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     * The OTA screen state machine.
995af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville     */
996af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    public static class CdmaOtaScreenState {
997af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public enum OtaScreenState {
998af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_UNDEFINED,
999af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_ACTIVATION,
1000af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_LISTENING,
1001af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_PROGRESS,
1002af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            OTA_STATUS_SUCCESS_FAILURE_DLG
1003af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
1004af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
1005af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public OtaScreenState otaScreenState;
1006af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
1007af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        public CdmaOtaScreenState() {
1008af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville            otaScreenState = OtaScreenState.OTA_STATUS_UNDEFINED;
1009af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        }
1010af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
1011af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville
1012af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    private static void log(String msg) {
1013af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville        Log.d(LOG_TAG, msg);
1014af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville    }
1015839b14d460986608fe577f89f789de854dc85b58Jim Miller
1016839b14d460986608fe577f89f789de854dc85b58Jim Miller    public static boolean isCdmaPhone() {
101779b9f6e30e8402b103f1ec3ed9dda1fcad2b1cd5Tammo Spalink        return (PhoneApp.getInstance().phone.getPhoneType() == Phone.PHONE_TYPE_CDMA);
1018839b14d460986608fe577f89f789de854dc85b58Jim Miller    }
1019af684393e2c6d0c051b9d5a189c2cd1de2506831Wink Saville}
1020