Android 去掉运营商STK对话框提示

STK

SIM Card Tool Kit

Android 去掉运营商STK对话框提示_第1张图片

Android 去掉运营商STK对话框提示_第2张图片

相关代码位置:

vendor\mediatek\proprietary\packages\apps\Stk1\src\com\android\stk\StkAppService.java

case DISPLAY_TEXT:
            CatLog.d(LOG_TAG, "[handleCmd][DISPLAY_TEXT] +");
            if (isBusyOnCall() == true) {
                CatLog.d(LOG_TAG, "[Handle Command][DISPLAY_TEXT][Can not handle currently]");
                CatResponseMessage resMsg = new CatResponseMessage(mStkContext[slotId].mCurrentCmd);
                resMsg.setResultCode(ResultCode.TERMINAL_CRNTLY_UNABLE_TO_PROCESS);
                additionalInfo = new byte[1];
                additionalInfo[0] = (byte) 0x02;
                resMsg.setAdditionalInfo(additionalInfo);
                mStkService[slotId].onCmdResponse(resMsg);
                return;
            }
            TextMessage msg = cmdMsg.geTextMessage();
            mStkContext[slotId].responseNeeded = msg.responseNeeded;
            if (mStkContext[slotId].responseNeeded == false) {
                //Immediate response
                CatLog.d(LOG_TAG, "[Handle Command][DISPLAY_TEXT][Should immediatly response]");
                CatResponseMessage resMsg = new CatResponseMessage(mStkContext[slotId].mCurrentCmd);
                  resMsg.setResultCode(ResultCode.OK);
                mStkService[slotId].onCmdResponse(resMsg);
            } else {
            }
            // TODO: get the carrier name from the SIM
            msg.title = "";
            String optr = SystemProperties.get("ro.operator.optr");
            if (optr != null && "OP02".equals(optr)) {
                 int resId = R.string.app_name;
                 if (slotId == PhoneConstants.SIM_ID_1) {
                     if (SystemProperties.get("ro.mtk_gemini_support").equals("1") == true) {
                         /* GEMINI or GEMINI+ project */
                         resId = R.string.appI_name;
                     } else {
                         /* Single card project */
                         resId = R.string.app_name;
                     }
                 } else if (slotId == PhoneConstants.SIM_ID_2){
                     resId = R.string.appII_name;
                 }
                 msg.title = getResources().getString(resId);
            }
            byte[] target = {0x0d, 0x0a};
            String strTarget = new String(target);
            String strLine = System.getProperty("line.separator");
            String strText = msg.text.replaceAll(strTarget, strLine);
            msg.text = strText;

            launchTextDialog(slotId);
            break;

之所以显示这个对话框,是因为SIM卡上报DISPLAY TEXT命令,然后STK应用的StkAppService服务显示这个通知:

    private void launchTextDialog(int slotId) {
        CatLog.d(LOG_TAG, "launchTextDialog, slotId: " + slotId +
                ", mDelayToCheckTime: " + mStkContext[slotId].mDelayToCheckTime);
        if (canShowTextDialog(mStkContext[slotId].mCurrentCmd.geTextMessage(), slotId) == false) {
            if (0 >= DELAY_TO_CHECK_IDLE_TIME || DELAY_TO_CHECK_NUM <= mStkContext[slotId].mDelayToCheckTime) {
                mStkContext[slotId].mDelayToCheckTime = 0;
                CatLog.d(LOG_TAG, "launchTextDialog responseNeeded: " +
                mStkContext[slotId].responseNeeded);
                if (mStkContext[slotId].responseNeeded) {
                    sendOkMessage(slotId);
                }
                // reset mStkContext[].responseNeeded
                if (!mStkContext[slotId].responseNeeded) {
                    mStkContext[slotId].responseNeeded = true;
                }
                handleDelayedCmd(slotId);
            } else {
                mStkContext[slotId].mDelayToCheckTime++;
                delayToCheckIdle(slotId);
            }
            return;
        }
        mStkContext[slotId].mDelayToCheckTime = 0;

        Intent newIntent = new Intent();
        String targetActivity = STK_DIALOG_ACTIVITY_NAME;
        int action = getFlagActivityNoUserAction(InitiatedByUserAction.unknown, slotId);
        String uriString = STK_DIALOG_URI + System.currentTimeMillis();
        //Set unique URI to create a new instance of activity for different slotId.
        Uri uriData = Uri.parse(uriString);
        if (newIntent != null) {
            newIntent.setClassName(PACKAGE_NAME, targetActivity);
            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                | getFlagActivityNoUserAction(InitiatedByUserAction.unknown, slotId));
            newIntent.setData(uriData);
            newIntent.putExtra("TEXT", mStkContext[slotId].mCurrentCmd.geTextMessage());
            newIntent.putExtra(SLOT_ID, slotId);
            newIntent.putExtra(STK_SOURCE_KEY, mStkAppSourceKey);
            startActivity(newIntent);
        }
    }

找到了显示的地方,去掉也就不是难题了。

你可能感兴趣的:(Android)