19d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project/*
29d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
379085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville *
49d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); you may not
59d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * use this file except in compliance with the License. You may obtain a copy of
69d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * the License at
779085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville *
89d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0
979085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville *
109d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * See the License for the specific language governing permissions and
149d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * limitations under the License.
159d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project */
169d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
179d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectpackage com.android.stk;
189d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
199d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.app.Activity;
209d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.content.Context;
219d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.content.Intent;
229d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.graphics.drawable.BitmapDrawable;
239d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.os.Bundle;
249d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.os.Handler;
259d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.os.Message;
269d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.text.Editable;
279d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.text.InputFilter;
28ee36b6f73ef8df4cd9d785ae3464bd0e09ed7a33duho.roimport android.text.InputType;
299d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.text.TextWatcher;
309d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.text.method.PasswordTransformationMethod;
319d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.view.KeyEvent;
329d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.view.MenuItem;
339d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.view.View;
349d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.view.Window;
359d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.widget.Button;
369d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.widget.TextView;
379d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.widget.EditText;
389d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectimport android.widget.TextView.BufferType;
39e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Savilleimport com.android.internal.telephony.cat.CatLog;
40d41f1d98d7bf42e9e867819593ad79f685604796Alex Yakavenkaimport com.android.internal.telephony.cat.FontSize;
41d41f1d98d7bf42e9e867819593ad79f685604796Alex Yakavenkaimport com.android.internal.telephony.cat.Input;
429d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
439d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project/**
449d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project * Display a request for a text input a long with a text edit form.
459d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project */
469d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Projectpublic class StkInputActivity extends Activity implements View.OnClickListener,
479d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        TextWatcher {
489d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
499d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    // Members
509d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private int mState;
519d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private Context mContext;
529d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private EditText mTextIn = null;
539d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private TextView mPromptView = null;
549d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private View mYesNoLayout = null;
559d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private View mNormalLayout = null;
569d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
579d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    // Constants
58e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private static final String className = new Object(){}.getClass().getEnclosingClass().getName();
59e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private static final String LOG_TAG = className.substring(className.lastIndexOf('.') + 1);
60e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
61e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private Input mStkInput = null;
62e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private boolean mAcceptUsersInput = true;
63e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    // Constants
649d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private static final int STATE_TEXT = 1;
659d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private static final int STATE_YES_NO = 2;
669d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
679d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    static final String YES_STR_RESPONSE = "YES";
689d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    static final String NO_STR_RESPONSE = "NO";
699d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
709d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    // Font size factor values.
719d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    static final float NORMAL_FONT_FACTOR = 1;
729d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    static final float LARGE_FONT_FACTOR = 2;
739d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    static final float SMALL_FONT_FACTOR = (1 / 2);
749d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
7579085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville    // message id for time out
769d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private static final int MSG_ID_TIMEOUT = 1;
77e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private StkAppService appService = StkAppService.getInstance();
78e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
79e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private boolean mIsResponseSent = false;
80e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private int mSlotId = -1;
81e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    Activity mInstance = null;
829d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
839d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    Handler mTimeoutHandler = new Handler() {
849d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        @Override
859d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        public void handleMessage(Message msg) {
869d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            switch(msg.what) {
879d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            case MSG_ID_TIMEOUT:
88e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                CatLog.d(LOG_TAG, "Msg timeout.");
89e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                mAcceptUsersInput = false;
90e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                appService.getStkContext(mSlotId).setPendingActivityInstance(mInstance);
919d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                sendResponse(StkAppService.RES_ID_TIMEOUT);
929d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                break;
939d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            }
949d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
959d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    };
969d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
979d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    // Click listener to handle buttons press..
989d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void onClick(View v) {
999d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        String input = null;
100e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (!mAcceptUsersInput) {
101e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "mAcceptUsersInput:false");
102e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return;
103e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
1049d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1059d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        switch (v.getId()) {
1069d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case R.id.button_ok:
1079d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            // Check that text entered is valid .
1089d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            if (!verfiyTypedText()) {
109e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                CatLog.d(LOG_TAG, "handleClick, invalid text");
1109d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                return;
1119d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            }
112e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
1139d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            input = mTextIn.getText().toString();
1149d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            break;
1159d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Yes/No layout buttons.
1169d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case R.id.button_yes:
117e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
1189d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            input = YES_STR_RESPONSE;
1199d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            break;
1209d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case R.id.button_no:
121e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
1229d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            input = NO_STR_RESPONSE;
1239d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            break;
1249d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
125e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "handleClick, ready to response");
12603be6676b5797d70ad30374c16589300f63438c0Preeti Ahuja        cancelTimeOut();
127e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        appService.getStkContext(mSlotId).setPendingActivityInstance(this);
1289d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        sendResponse(StkAppService.RES_ID_INPUT, input, false);
1299d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
1309d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1319d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
1329d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void onCreate(Bundle icicle) {
1339d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onCreate(icicle);
1349d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
135e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onCreate - mIsResponseSent[" + mIsResponseSent + "]");
136e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
1379d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Set the layout for this activity.
138e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        requestWindowFeature(Window.FEATURE_LEFT_ICON);
1399d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        setContentView(R.layout.stk_input);
1409d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1419d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Initialize members
1429d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mTextIn = (EditText) this.findViewById(R.id.in_text);
1439d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mPromptView = (TextView) this.findViewById(R.id.prompt);
144e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        mInstance = this;
1459d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Set buttons listeners.
14679085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville        Button okButton = (Button) findViewById(R.id.button_ok);
1479d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        Button yesButton = (Button) findViewById(R.id.button_yes);
1489d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        Button noButton = (Button) findViewById(R.id.button_no);
1499d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1509d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        okButton.setOnClickListener(this);
1519d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        yesButton.setOnClickListener(this);
1529d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        noButton.setOnClickListener(this);
1539d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1549d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mYesNoLayout = findViewById(R.id.yes_no_layout);
1559d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mNormalLayout = findViewById(R.id.normal_layout);
156e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        initFromIntent(getIntent());
1579d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mContext = getBaseContext();
158e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        mAcceptUsersInput = true;
1599d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
1609d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1619d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
1629d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    protected void onPostCreate(Bundle savedInstanceState) {
1639d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onPostCreate(savedInstanceState);
1649d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1659d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mTextIn.addTextChangedListener(this);
1669d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
1679d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1689d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
1699d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void onResume() {
1709d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onResume();
171e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onResume - mIsResponseSent[" + mIsResponseSent +
172e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                "], slot id: " + mSlotId);
1739d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        startTimeOut();
174e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        appService.getStkContext(mSlotId).setPendingActivityInstance(null);
175cba2996aa661e04e591a7ecb48369cc9289a3bf6hoonsung.park        if (mIsResponseSent) {
176cba2996aa661e04e591a7ecb48369cc9289a3bf6hoonsung.park            cancelTimeOut();
177cba2996aa661e04e591a7ecb48369cc9289a3bf6hoonsung.park            finish();
178cba2996aa661e04e591a7ecb48369cc9289a3bf6hoonsung.park        }
1799d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
1809d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
1819d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
1829d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void onPause() {
1839d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onPause();
184e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onPause - mIsResponseSent[" + mIsResponseSent + "]");
185e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    }
1869d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
187e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    @Override
188e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    public void onStop() {
189e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        super.onStop();
190e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onStop - mIsResponseSent[" + mIsResponseSent + "]");
191e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (mIsResponseSent) {
192e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            cancelTimeOut();
193e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            finish();
194e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        } else {
195e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            appService.getStkContext(mSlotId).setPendingActivityInstance(this);
196e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
197e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    }
198e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
199e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    @Override
200e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    public void onDestroy() {
201e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        super.onDestroy();
202e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onDestroy - before Send End Session mIsResponseSent[" +
203e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                mIsResponseSent + " , " + mSlotId + "]");
204e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        //If the input activity is finished by stkappservice
205e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        //when receiving OP_LAUNCH_APP from the other SIM, we can not send TR here
206e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        //, since the input cmd is waiting user to process.
207e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (!mIsResponseSent && !appService.isInputPending(mSlotId)) {
208e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "handleDestroy - Send End Session");
209e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            sendResponse(StkAppService.RES_ID_END_SESSION);
210e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
2119d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        cancelTimeOut();
2129d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2139d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2149d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
2159d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public boolean onKeyDown(int keyCode, KeyEvent event) {
216e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (!mAcceptUsersInput) {
217e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "mAcceptUsersInput:false");
218e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return true;
219e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
220e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
2219d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        switch (keyCode) {
2229d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case KeyEvent.KEYCODE_BACK:
223e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "onKeyDown - KEYCODE_BACK");
224e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
22503be6676b5797d70ad30374c16589300f63438c0Preeti Ahuja            cancelTimeOut();
226e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            appService.getStkContext(mSlotId).setPendingActivityInstance(this);
2279d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            sendResponse(StkAppService.RES_ID_BACKWARD, null, false);
228e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return true;
2299d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
2309d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return super.onKeyDown(keyCode, event);
2319d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2329d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
233e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    void sendResponse(int resId) {
2349d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        sendResponse(resId, null, false);
2359d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2369d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
237e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    void sendResponse(int resId, String input, boolean help) {
238e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (mSlotId == -1) {
239e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "slot id is invalid");
240e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return;
241e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
242e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
243e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (StkAppService.getInstance() == null) {
244e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "StkAppService is null, Ignore response: id is " + resId);
245e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return;
246e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
247e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
248bde7f03b500d003a377b54166aeb7bb6b799a430Cuihtlauac ALVARADO        CatLog.d(LOG_TAG, "sendResponse resID[" + resId + "] input[*****] help["
249bde7f03b500d003a377b54166aeb7bb6b799a430Cuihtlauac ALVARADO                + help + "]");
250e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        mIsResponseSent = true;
2519d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        Bundle args = new Bundle();
2529d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        args.putInt(StkAppService.OPCODE, StkAppService.OP_RESPONSE);
253e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        args.putInt(StkAppService.SLOT_ID, mSlotId);
2549d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        args.putInt(StkAppService.RES_ID, resId);
2559d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        if (input != null) {
2569d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            args.putString(StkAppService.INPUT, input);
2579d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
2589d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        args.putBoolean(StkAppService.HELP, help);
2599d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mContext.startService(new Intent(mContext, StkAppService.class)
2609d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                .putExtras(args));
2619d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2629d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2639d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
2649d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public boolean onCreateOptionsMenu(android.view.Menu menu) {
2659d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onCreateOptionsMenu(menu);
2669d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        menu.add(android.view.Menu.NONE, StkApp.MENU_ID_END_SESSION, 1,
2679d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                R.string.menu_end_session);
2689d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        menu.add(0, StkApp.MENU_ID_HELP, 2, R.string.help);
2699d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2709d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return true;
2719d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2729d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2739d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
2749d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public boolean onPrepareOptionsMenu(android.view.Menu menu) {
2759d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        super.onPrepareOptionsMenu(menu);
2769d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        menu.findItem(StkApp.MENU_ID_END_SESSION).setVisible(true);
2779d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        menu.findItem(StkApp.MENU_ID_HELP).setVisible(mStkInput.helpAvailable);
2789d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2799d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return true;
2809d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
2819d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
2829d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    @Override
2839d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public boolean onOptionsItemSelected(MenuItem item) {
284e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (!mAcceptUsersInput) {
285e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "mAcceptUsersInput:false");
286e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            return true;
287e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
2889d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        switch (item.getItemId()) {
2899d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case StkApp.MENU_ID_END_SESSION:
290e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
291e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            cancelTimeOut();
2929d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            sendResponse(StkAppService.RES_ID_END_SESSION);
2939d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            finish();
2949d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            return true;
2959d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case StkApp.MENU_ID_HELP:
296e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mAcceptUsersInput = false;
297e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            cancelTimeOut();
2989d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            sendResponse(StkAppService.RES_ID_INPUT, "", true);
2999d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            finish();
3009d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            return true;
3019d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
3029d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return super.onOptionsItemSelected(item);
3039d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3049d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
305e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    @Override
306e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    protected void onSaveInstanceState(Bundle outState) {
307e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onSaveInstanceState: " + mSlotId);
308e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        outState.putBoolean("ACCEPT_USERS_INPUT", mAcceptUsersInput);
309e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    }
310e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
311e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    @Override
312e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    protected void onRestoreInstanceState(Bundle savedInstanceState) {
313e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "onRestoreInstanceState: " + mSlotId);
314e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        mAcceptUsersInput = savedInstanceState.getBoolean("ACCEPT_USERS_INPUT");
315e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    }
316e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
3179d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void beforeTextChanged(CharSequence s, int start, int count,
3189d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            int after) {
3199d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3209d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3219d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void onTextChanged(CharSequence s, int start, int before, int count) {
3229d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Reset timeout.
3239d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        startTimeOut();
3249d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3259d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3269d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    public void afterTextChanged(Editable s) {
3279d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3289d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3299d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private boolean verfiyTypedText() {
3309d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // If not enough input was typed in stay on the edit screen.
3319d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        if (mTextIn.getText().length() < mStkInput.minLen) {
3329d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            return false;
3339d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
3349d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3359d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return true;
3369d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3379d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3389d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private void cancelTimeOut() {
3399d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mTimeoutHandler.removeMessages(MSG_ID_TIMEOUT);
3409d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3419d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3429d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private void startTimeOut() {
343c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa        int duration = StkApp.calculateDurationInMilis(mStkInput.duration);
344c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa
345c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa        if (duration <= 0) {
346c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa            duration = StkApp.UI_TIMEOUT;
347c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa        }
3489d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        cancelTimeOut();
3499d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mTimeoutHandler.sendMessageDelayed(mTimeoutHandler
350c7c3a46ff0191ceaf086d80800665c5be0022dc3Abhishek Adappa                .obtainMessage(MSG_ID_TIMEOUT), duration);
3519d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
3529d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3539d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private void configInputDisplay() {
3549d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        TextView numOfCharsView = (TextView) findViewById(R.id.num_of_chars);
3559d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        TextView inTypeView = (TextView) findViewById(R.id.input_type);
3569d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3579d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        int inTypeId = R.string.alphabet;
3589d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3599d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // set the prompt.
3609d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        mPromptView.setText(mStkInput.text);
3619d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
36279085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville        // Set input type (alphabet/digit) info close to the InText form.
3639d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        if (mStkInput.digitOnly) {
3649d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            mTextIn.setKeyListener(StkDigitsKeyListener.getInstance());
3659d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            inTypeId = R.string.digits;
3669d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
3679d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        inTypeView.setText(inTypeId);
3689d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3699d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        if (mStkInput.icon != null) {
3709d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            setFeatureDrawable(Window.FEATURE_LEFT_ICON, new BitmapDrawable(
3719d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                    mStkInput.icon));
3729d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
3739d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3749d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        // Handle specific global and text attributes.
3759d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        switch (mState) {
37679085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville        case STATE_TEXT:
3779d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            int maxLen = mStkInput.maxLen;
3789d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            int minLen = mStkInput.minLen;
3799d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            mTextIn.setFilters(new InputFilter[] {new InputFilter.LengthFilter(
3809d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                    maxLen)});
38179085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville
3829d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            // Set number of chars info.
3839d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            String lengthLimit = String.valueOf(minLen);
3849d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            if (maxLen != minLen) {
3859d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                lengthLimit = minLen + " - " + maxLen;
3869d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            }
3879d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            numOfCharsView.setText(lengthLimit);
3889d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
3899d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            if (!mStkInput.echo) {
390ee36b6f73ef8df4cd9d785ae3464bd0e09ed7a33duho.ro                mTextIn.setInputType(InputType.TYPE_CLASS_NUMBER
391ee36b6f73ef8df4cd9d785ae3464bd0e09ed7a33duho.ro                                     | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
3929d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            }
3939d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            // Set default text if present.
3949d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            if (mStkInput.defaultText != null) {
3959d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                mTextIn.setText(mStkInput.defaultText);
3969d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            } else {
3979d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                // make sure the text is cleared
3989d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project                mTextIn.setText("", BufferType.EDITABLE);
3999d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            }
4009d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
4019d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            break;
4029d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        case STATE_YES_NO:
4039d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            // Set display mode - normal / yes-no layout
4049d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            mYesNoLayout.setVisibility(View.VISIBLE);
4059d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            mNormalLayout.setVisibility(View.GONE);
4069d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            break;
4079d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        }
4089d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
4099d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
4109d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    private float getFontSizeFactor(FontSize size) {
41179085fcc5b4e54cc374e8720644ce4c1dc0004beWink Saville        final float[] fontSizes =
4129d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project            {NORMAL_FONT_FACTOR, LARGE_FONT_FACTOR, SMALL_FONT_FACTOR};
4139d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project
4149d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project        return fontSizes[size.ordinal()];
4159d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project    }
416e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville
417e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    private void initFromIntent(Intent intent) {
418e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        // Get the calling intent type: text/key, and setup the
419e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        // display parameters.
420e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        CatLog.d(LOG_TAG, "initFromIntent - slot id: " + mSlotId);
421e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        if (intent != null) {
422e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mStkInput = intent.getParcelableExtra("INPUT");
423e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            mSlotId = intent.getIntExtra(StkAppService.SLOT_ID, -1);
424e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            CatLog.d(LOG_TAG, "onCreate - slot id: " + mSlotId);
425e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            if (mStkInput == null) {
426e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                finish();
427e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            } else {
428e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                mState = mStkInput.yesNo ? STATE_YES_NO :
429e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                        STATE_TEXT;
430e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville                configInputDisplay();
431e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            }
432e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        } else {
433e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville            finish();
434e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville        }
435e68857da85f6fb0964da9d58a7cbfcc0348065c6Wink Saville    }
4369d9730aecb72e830ef12d66ce6e084d8ae0928f2The Android Open Source Project}
437