Stk APP中广播来源
2017-11-19 12:49
92 查看
总体框架: Stk的核心是1个服务,3个广播接收器
一,1个服务(StkAppService.java)
二,3个广播接收器(BootCompletedReceiver,StkCmdReceiver,StkIntentReceiver)
前面两个Receiver是AOSP原生的,为静态Reciver;最后一般是各个手机厂商订制开发新增,名字可能不同,具体实作也不同。
1,BootCompletedReceiver
注册:
实作:
2,StkCmdReceiver
注册:
实作:
广播来源:在StkCmdReceiver中注册的广播主要是来自Framework UICC,包括:
AppInterface.CAT_CMD_ACTION:
AppInterface.CAT_SESSION_END_ACTION:
AppInterface.CAT_ICC_STATUS_CHANGE:
AppInterface.CAT_ALPHA_NOTIFY_ACTION:
Intent.ACTION_LOCALE_CHANGED(略)
Intent.ACTION_SCREEN_OFF(略)
3,StkIntentReceiver(略)
一,1个服务(StkAppService.java)
二,3个广播接收器(BootCompletedReceiver,StkCmdReceiver,StkIntentReceiver)
前面两个Receiver是AOSP原生的,为静态Reciver;最后一般是各个手机厂商订制开发新增,名字可能不同,具体实作也不同。
1,BootCompletedReceiver
注册:
<receiver android:name="com.android.stk.BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.USER_INITIALIZE" /> </intent-filter> </receiver>
实作:
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) { return; } // make sure the app icon is removed every time the device boots. if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { Bundle args = new Bundle(); args.putInt(StkAppService.OPCODE, StkAppService.OP_BOOT_COMPLETED); context.startService(new Intent(context, StkAppService.class) .putExtras(args)); CatLog.d(LOG_TAG, "[ACTION_BOOT_COMPLETED]"); } else if(action.equals(Intent.ACTION_USER_INITIALIZE)) { // TODO: http://b/25155491 if (!android.os.Process.myUserHandle().isSystem()) { //Disable package for all secondary users. Package is only required for device //owner. context.getPackageManager().setApplicationEnabledSetting(context.getPackageName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); return; } } }
2,StkCmdReceiver
注册:
<receiver android:name="com.android.stk.StkCmdReceiver"> <intent-filter> <action android:name= "com.android.internal.stk.command" /> <action android:name= "com.android.internal.stk.session_end" /> <action android:name= "com.android.internal.stk.icc_status_change" /> <action android:name= "com.android.internal.stk.alpha_notify" /> <action android:name= "android.intent.action.LOCALE_CHANGED" /> <action android:name= "org.codeaurora.action.stk.idle_screen"/> </intent-filter> </receiver>
实作:
public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) { return; } if (action.equals(AppInterface.CAT_CMD_ACTION)) { handleAction(context, intent, StkAppService.OP_CMD); } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) { handleAction(context, intent, StkAppService.OP_END_SESSION); } else if (action.equals(AppInterface.CAT_ICC_STATUS_CHANGE)) { handleAction(context, intent, StkAppService.OP_CARD_STATUS_CHANGED); } else if (action.equals(Intent.ACTION_LOCALE_CHANGED)) { handleLocaleChange(context); } else if (action.equals(AppInterface.CAT_ALPHA_NOTIFY_ACTION)) { handleAction(context, intent, StkAppService.OP_ALPHA_NOTIFY); } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { handleIdleScreen(context); } }
广播来源:在StkCmdReceiver中注册的广播主要是来自Framework UICC,包括:
AppInterface.CAT_CMD_ACTION:
CatService.java private void broadcastCatCmdIntent(CatCmdMessage cmdMsg) { Intent intent = new Intent(AppInterface.CAT_CMD_ACTION); intent.putExtra("STK CMD", cmdMsg); intent.putExtra("SLOT_ID", mSlotId); intent.setComponent(AppInterface.getDefaultSTKApplication()); CatLog.d(this, "Sending CmdMsg: " + cmdMsg+ " on slotid:" + mSlotId); mContext.sendBroadcast(intent, AppInterface.STK_PERMISSION); }
AppInterface.CAT_SESSION_END_ACTION:
CatService.java private void handleSessionEnd() { CatLog.d(this, "SESSION END on "+ mSlotId); mCurrntCmd = mMenuCmd; Intent intent = new Intent(AppInterface.CAT_SESSION_END_ACTION); intent.putExtra("SLOT_ID", mSlotId); intent.setComponent(AppInterface.getDefaultSTKApplication()); mContext.sendBroadcast(intent, AppInterface.STK_PERMISSION); }
AppInterface.CAT_ICC_STATUS_CHANGE:
CatService.java private void broadcastCardStateAndIccRefreshResp(CardState cardState, IccRefreshResponse iccRefreshState) { Intent intent = new Intent(AppInterface.CAT_ICC_STATUS_CHANGE); boolean cardPresent = (cardState == CardState.CARDSTATE_PRESENT); if (iccRefreshState != null) { //This case is when MSG_ID_ICC_REFRESH is received. intent.putExtra(AppInterface.REFRESH_RESULT, iccRefreshState.refreshResult); CatLog.d(this, "Sending IccResult with Result: " + iccRefreshState.refreshResult); } // This sends an intent with CARD_ABSENT (0 - false) /CARD_PRESENT (1 - true). intent.putExtra(AppInterface.CARD_STATUS, cardPresent); intent.setComponent(AppInterface.getDefaultSTKApplication()); CatLog.d(this, "Sending Card Status: " + cardState + " " + "cardPresent: " + cardPresent); mContext.sendBroadcast(intent, AppInterface.STK_PERMISSION); }
AppInterface.CAT_ALPHA_NOTIFY_ACTION:
CatService.java private void broadcastAlphaMessage(String alphaString) { CatLog.d(this, "Broadcasting CAT Alpha message from card: " + alphaString); Intent intent = new Intent(AppInterface.CAT_ALPHA_NOTIFY_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.putExtra(AppInterface.ALPHA_STRING, alphaString); intent.putExtra("SLOT_ID", mSlotId); intent.setComponent(AppInterface.getDefaultSTKApplication()); mContext.sendBroadcast(intent, AppInterface.STK_PERMISSION); }
Intent.ACTION_LOCALE_CHANGED(略)
Intent.ACTION_SCREEN_OFF(略)
3,StkIntentReceiver(略)
相关文章推荐
- MacOS Sierra允许安装任何来源App
- android中两个app之间利用广播互相监听
- Activity基类广播退出APP
- android 如何通过服务或广播来开启APP,而不是直接点图标
- Android中如何做到自定义的广播只能有指定的app接收
- Android-接受来自Appwidget的广播、更新Appwidget控件的状态
- 进入一个APP时对手机网络判断(使用广播和不使用广播)
- app微信支付宝支付后台的插件模式+回调通过spring广播处理后续业务(已亲测可用)
- 开机广播如何解决App无法收到android开机广播
- 如何解决App无法收到android开机广播
- AppWidget,及其与广播的相关处理
- Android开发之接受来自Appwidget的广播、更新Appwidget控件的状态
- 使用AppWidget进行广播更新
- app版本更新和下载,通知栏实时进度(使用服务和广播)
- android自定义广播实现app完全退出
- 在一次也没有打开app的情况下能否接受到系统广播
- android自定义广播实现app完全退出
- Mac中允许任何来源的app安装
- Android平台好友点击微信分享的内容后跳转来源App的实现方案研究
- 如何让自己的广播只让指定的 app 接收?