/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.stk;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.telephony.TelephonyManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.telephony.cat.AppInterface;
import com.android.internal.telephony.cat.Menu;
import com.android.internal.telephony.cat.Item;
import com.android.internal.telephony.cat.Input;
import com.android.internal.telephony.cat.ResultCode;
import com.android.internal.telephony.cat.CatCmdMessage;
import com.android.internal.telephony.cat.CatCmdMessage.BrowserSettings;
import com.android.internal.telephony.cat.CatLog;
import com.android.internal.telephony.cat.CatResponseMessage;
import com.android.internal.telephony.cat.TextMessage;
import java.util.LinkedList;
/**
* SIM toolkit application level service. Interacts with Telephopny messages,
* application's launch and user input from STK UI elements.
*
*/
public class StkAppService extends Service implements Runnable {
// members
private volatile Looper mServiceLooper;
private volatile ServiceHandler mServiceHandler;
private AppInterface mStkService;
private Context mContext = null;
private CatCmdMessage mMainCmd = null;
private CatCmdMessage mCurrentCmd = null;
private Menu mCurrentMenu = null;
private String lastSelectedItem = null;
private boolean mMenuIsVisibile = false;
private boolean responseNeeded = true;
private boolean mCmdInProgress = false;
private NotificationManager mNotificationManager = null;
private LinkedList<DelayedCmd> mCmdsQ = null;
private boolean launchBrowser = false;
private BrowserSettings mBrowserSettings = null;
static StkAppService sInstance = null;
// Used for setting FLAG_ACTIVITY_NO_USER_ACTION when
// creating an intent.
private enum InitiatedByUserAction {
yes, // The action was started via a user initiated action
unknown, // Not known for sure if user initated the action
}
// constants
static final String OPCODE = "op";
static final String CMD_MSG = "cmd message";
static final String RES_ID = "response id";
static final String MENU_SELECTION = "menu selection";
static final String INPUT = "input";
static final String HELP = "help";
static final String CONFIRMATION = "confirm";
// operations ids for different service functionality.
static final int OP_CMD = 1;
static final int OP_RESPONSE = 2;
static final int OP_LAUNCH_APP = 3;
static final int OP_END_SESSION = 4;
static final int OP_BOOT_COMPLETED = 5;
private static final int OP_DELAYED_MSG = 6;
// Response ids
static final int RES_ID_MENU_SELECTION = 11;
static final int RES_ID_INPUT = 12;
static final int RES_ID_CONFIRM = 13;
static final int RES_ID_DONE = 14;
static final int RES_ID_TIMEOUT = 20;
static final int RES_ID_BACKWARD = 21;
static final int RES_ID_END_SESSION = 22;
static final int RES_ID_EXIT = 23;
private static final String PACKAGE_NAME = "com.android.stk";
private static final String MENU_ACTIVITY_NAME =
PACKAGE_NAME + ".StkMenuActivity";
private static final String INPUT_ACTIVITY_NAME =
PACKAGE_NAME + ".StkInputActivity";
// Notification id used to display Idle Mode text in NotificationManager.
private static final int STK_NOTIFICATION_ID = 333;
// Inner class used for queuing telephony messages (proactive commands,
// session end) while the service is busy processing a previous message.
private class DelayedCmd {
// members
int id;
CatCmdMessage msg;
DelayedCmd(int id, CatCmdMessage msg) {
this.id = id;
this.msg = msg;
}
}
@Override
public void onCreate() {
// Initialize members
mStkService = com.android.internal.telephony.cat.CatService
.getInstance();
// NOTE mStkService is a singleton and continues to exist even if the GSMPhone is disposed
// after the radio technology change from GSM to CDMA so the PHONE_TYPE_CDMA check is
// needed. In case of switching back from CDMA to GSM the GSMPhone constructor updates
// the instance. (TODO: test).
if ((mStkService == null)
&& (TelephonyManager.getDefault().getPhoneType()
!= TelephonyManager.PHONE_TYPE_CDMA)) {
CatLog.d(this, " Unable to get Service handle");
return;
}
mCmdsQ = new LinkedList<DelayedCmd>();
Thread serviceThread = new Thread(null, this, "Stk App Service");
serviceThread.start();
mContext = getBaseContext();
mNotificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
sInstance = this;
}
@Override
public void onStart(Intent intent, int startId) {
waitForLooper();
// onStart() method can be passed a null intent
// TODO: replace onStart() with onStartCommand()
if (intent == null) {
return;
}
Bundle args = intent.getExtras();
if (args == null) {
return;
}
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = args.getInt(OPCODE);
switch(msg.arg1) {
case OP_CMD:
msg.obj = args.getParcelable(CMD_MSG);
break;
case OP_RESPONSE:
msg.obj = args;
/* falls through */
case OP_LAUNCH_APP:
case OP_END_SESSION:
case OP_BOOT_COMPLETED:
break;
default:
return;
}
mServiceHandler.sendMessage(msg);
}
@Override
public void onDestroy() {
waitForLooper();
mServiceLooper.quit();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public void run() {
Looper.prepare();
mServiceLooper = Looper.myLooper();
mServiceHandler = new ServiceHandler();
Looper.loop();
}
/*
* Package api used by StkMenuActivity to indicate if its on the foreground.
*/
void indicateMenuVisibility(boolean visibility) {
mMenuIsVisibile = visibility;
}
/*
* Package api used by StkMenuActivity to get its Menu parameter.
*/
Menu getMenu() {
return mCurrentMenu;
}
/*
* Package api used by UI Activities and Dialogs to communicate directly
* with the service to deliver state information and parameters.
*/
static StkAppService getInstance() {
return sInstance;
}
private void waitForLooper() {
while (mServiceHandler == null) {
synchronized (this) {
try {
没有合适的资源?快使用搜索试试~ 我知道了~
Android应用源码之Stk.zip项目安卓应用源码下载
共79个文件
xml:58个
java:13个
png:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 116 浏览量
2022-03-08
08:22:59
上传
评论
收藏 128KB ZIP 举报
温馨提示
Android应用源码之Stk.zip项目安卓应用源码下载Android应用源码之Stk.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之Stk.zip (79个子文件)
Android应用源码之Stk
Android应用源码之Stk
Stk
.git
HEAD 41B
index 7KB
AndroidManifest.xml 3KB
res
values-lv
strings.xml 2KB
values-el
strings.xml 2KB
values-sr
strings.xml 2KB
values-tl
strings.xml 2KB
values-sl
strings.xml 2KB
values-sv
strings.xml 2KB
values-sk
strings.xml 2KB
values-es-rUS
strings.xml 2KB
values-iw
strings.xml 2KB
layout
stk_msg_dialog.xml 3KB
stk_event_msg.xml 1KB
stk_menu_item.xml 2KB
stk_tone_dialog.xml 1KB
stk_title.xml 3KB
stk_input.xml 4KB
stk_menu_list.xml 2KB
values-th
strings.xml 2KB
values-fr
strings.xml 2KB
values-zh-rTW
strings.xml 2KB
values-nl
strings.xml 2KB
values-cs
strings.xml 2KB
values-vi
strings.xml 2KB
values-hi
strings.xml 2KB
values-hr
strings.xml 2KB
values-af
strings.xml 2KB
values-ms
strings.xml 2KB
values-uk
strings.xml 2KB
values-ko
strings.xml 2KB
drawable-mdpi
ic_launcher_sim_toolkit.png 3KB
values-ja
strings.xml 2KB
values-it
strings.xml 2KB
values-pl
strings.xml 2KB
values-en-rGB
strings.xml 2KB
values-pt-rPT
strings.xml 2KB
values-ar
strings.xml 2KB
xml
stk_settings.xml 1KB
values-nb
strings.xml 2KB
values-in
strings.xml 2KB
values-hu
strings.xml 2KB
values-tr
strings.xml 2KB
values-am
strings.xml 2KB
values-ru
strings.xml 2KB
drawable-hdpi
ic_launcher_sim_toolkit.png 5KB
values-es
strings.xml 2KB
values-zh-rCN
strings.xml 2KB
values-de
strings.xml 2KB
values-sw
strings.xml 2KB
values-ro
strings.xml 2KB
values-bg
strings.xml 2KB
values-rm
strings.xml 2KB
values
strings.xml 2KB
colors.xml 798B
values-fa
strings.xml 2KB
values-da
strings.xml 2KB
values-pt
strings.xml 2KB
values-fi
strings.xml 2KB
values-lt
strings.xml 2KB
values-zu
strings.xml 2KB
values-ca
strings.xml 2KB
src
com
android
stk
StkAppService.java 28KB
StkApp.java 2KB
StkLauncherActivity.java 1KB
BootCompletedReceiver.java 1KB
StkDigitsKeyListener.java 2KB
StkAppInstaller.java 2KB
StkInputActivity.java 10KB
StkMenuAdapter.java 2KB
TonePlayer.java 3KB
ToneDialog.java 4KB
StkDialogActivity.java 5KB
StkMenuActivity.java 10KB
StkCmdReceiver.java 2KB
CleanSpec.mk 2KB
NOTICE 10KB
MODULE_LICENSE_APACHE2 0B
Android.mk 269B
共 79 条
- 1
资源评论
- shengsheng19832022-05-15用户下载后在一定时间内未进行评价,系统默认好评。
yxkfw
- 粉丝: 76
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功