android stk分析,[Android][Framework] 从一个小问题了解STK加载内容的方式

STK就是SIMToolKit。

问题如图,STK一个case的输入框,不应该能输入+:

STK.png?raw=true

这个界面从哪来的?

实际上,我们插入SIM卡,手机就会显示SimToolKit,打开就能看到一些和运营商相关的菜单。换了不同的卡菜单也会变。所以大概可以猜到,SIM卡里写有一些配置文件,STK会解析这些文件。

项目原因,正好可以拿到一些配置文件,如图:

STKfile.png?raw=true

通过Smartstation把配置文件写到模拟SIM卡中,然后插卡交给STK读取处理这些信息。

阅读Java文件,找到出问题的case代码:

case 30021:

GetInput getinput21 = new GetInput("Enter 67#*+.digits, SMS default alphabet, Terminal to hide text, packing required, help information available,\"+\" can not input.",4,8);

getinput21.digitsOnly();

getinput21.noEcho();

getinput21.textString().packed();

getinput21.helpInformationAvailable(true);

super.pch.sendCommand(getinput21.toByteArray());

super.state = 0;

break;

从文件可以知道,输入框是个GetInput对象。

输入对象配置了digitsOnly,noEcho,packed等属性。

怎么处理配置文件?

有了配置文件,插SIM卡到手机,STK会处理这些数据。

在OpenGrok上搜索代码,可以找到输入部分,在STK的packages/apps/Stk/src/com/android/stk/StkInputActivity.java文件中。

下面看一下configInputDisplay方法,配置输入显示。

private void configInputDisplay() {

TextView numOfCharsView = (TextView) findViewById(R.id.num_of_chars);

TextView inTypeView = (TextView) findViewById(R.id.input_type);

int inTypeId = R.string.alphabet;

// set the prompt.

mPromptView.setText(mStkInput.text);

// Set input type (alphabet/digit) info close to the InText form.

if (mStkInput.digitOnly) {

mTextIn.setKeyListener(StkDigitsKeyListener.getInstance());

inTypeId = R.string.digits;

}

inTypeView.setText(inTypeId);

if (mStkInput.icon != null) {

setFeatureDrawable(Window.FEATURE_LEFT_ICON, new BitmapDrawable(

mStkInput.icon));

}

// Handle specific global and text attributes.

switch (mState) {

case STATE_TEXT:

int maxLen = mStkInput.maxLen;

int minLen = mStkInput.minLen;

mTextIn.setFilters(new InputFilter[] {new InputFilter.LengthFilter(

maxLen)});

// Set number of chars info.

String lengthLimit = String.valueOf(minLen);

if (maxLen != minLen) {

lengthLimit = minLen + " - " + maxLen;

}

numOfCharsView.setText(lengthLimit);

if (!mStkInput.echo) {

mTextIn.setInputType(InputType.TYPE_CLASS_NUMBER

| InputType.TYPE_NUMBER_VARIATION_PASSWORD);

}

// Set default text if present.

if (mStkInput.defaultText != null) {

mTextIn.setText(mStkInput.defaultText);

} else {

// make sure the text is cleared

mTextIn.setText("", BufferType.EDITABLE);

}

break;

case STATE_YES_NO:

// Set display mode - normal / yes-no layout

mYesNoLayout.setVisibility(View.VISIBLE);

mNormalLayout.setVisibility(View.GONE);

break;

}

}

代码中出现mStkInput.digitOnly这样的判断,可以推断mStkInput就是和配置文件里的GetInput对象。

mStkInput来自frameworks/opt/telephony/src/java/com/android/internal/telephony/cat/Input.java

定义如下:

Input() {

text = "";

defaultText = null;

icon = null;

minLen = 0;

maxLen = 1;

ucs2 = false;

packed = false;

digitOnly = false;

echo = false;

yesNo = false;

helpAvailable = false;

duration = null;

iconSelfExplanatory = false;

}

回到前面的class,因为STK file里有说明getinput21.digitsOnly();,所以会进入下面逻辑:

// Set input type (alphabet/digit) info close to the InText form.

if (mStkInput.digitOnly) {

mTextIn.setKeyListener(StkDigitsKeyListener.getInstance());

inTypeId = R.string.digits;

}

这里mTextIn是一个EditText,setKeyListener就是过滤字符的作用。

/**

* For entering dates in a text field.

*/

public class StkDigitsKeyListener extends NumberKeyListener {

@Override

protected char[] getAcceptedChars() {

return CHARACTERS;

}

public int getInputType() {

return EditorInfo.TYPE_CLASS_PHONE;

}

public static StkDigitsKeyListener getInstance() {

if (sInstance != null) {

return sInstance;

}

sInstance = new StkDigitsKeyListener();

return sInstance;

}

/**

* The characters that are used.

*

* @see KeyEvent#getMatch

* @see #getAcceptedChars

*/

public static final char[] CHARACTERS = new char[] {

'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '#', '+'};

private static StkDigitsKeyListener sInstance;

}

可以看到,CHARACTERS定义了可以输入的字符,其中包含’+’。如果不需要’+’,把这里的声明修改掉就OK

其实我也不做Tele,但通过这个过程,可以大概了解一些STK相关的原理。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
STK(Systems Tool Kit)是一种通用的软件工具,用于模拟和分析航天器在空间环境中的运行。在STK中,抵近分析是一项重要的功能,用于模拟和分析卫星或航天器与其他天体之间的距离和相对运动。 抵近分析可以帮助我们了解两个天体之间的最短距离、相遇时间和相对速度等关键参数。通过STK的图形界面,我们可以加载卫星的轨道、星座、行星、恒星等对象,并在三维场景中模拟它们的运动。 在进行抵近分析之前,我们首先需要在STK中创建卫星或天体的模型,并设置其轨道参数、初始位置和速度等参数。然后,我们可以选择一个感兴趣的天体对象,并将其作为目标进行分析。 在抵近分析过程中,STK会自动生成相对距离和速度的图表,以及相关的时间信息。这些信息可用于评估目标天体与其他天体之间的接近程度和可能的碰撞风险。此外,STK还提供了各种筛选和查询功能,使我们能够进一步细化抵近分析的结果。 除了用于天体碰撞风险评估,抵近分析还可以应用于其他领域。例如,当两个卫星处于相近轨道时,可以使用抵近分析来评估它们之间的通信干扰和频谱资源共享情况。此外,抵近分析还可以用于舰船避碰、无人机避障等应用场景中。 总而言之,STK的抵近分析功能可以帮助我们模拟和分析天体之间的距离和相对运动。利用这一功能,我们可以评估天体之间的碰撞风险、通信干扰等问题,为航天器和卫星的运行提供决策支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值