1.拨号界面输入*#06#。显示IMEI号,这是怎么出来的?

2.怎样高速的找出Android平台中的指令?

1. 在DialpadFragment中的EditText注冊一个Textchanged的监听器TextWatcher,

当EditText中的内容发生变化时会调用对应的回调函数,TextWatcher是一个接口:

public interface TextWatcher extends NoCopySpan {
public void beforeTextChanged(CharSequence s, int start,int count, int after);
public void onTextChanged(CharSequence s, int start, int before, int count);
public void afterTextChanged(Editable s);
}

在DialpadFragment中实现了该接口:

    public void afterTextChanged(Editable input) {
// When DTMF dialpad buttons are being pressed, we delay SpecialCharSequencMgr sequence,
// since some of SpecialCharSequenceMgr's behavior is too abrupt for the "touch-down"
// behavior.
if (!mDigitsFilledByIntent &&
SpecialCharSequenceMgr.handleChars(getActivity(), input.toString(), mDigits)) {
// A special sequence was entered, clear the digits
mDigits.getText().clear();
}
if (isDigitsEmpty()) {
mDigitsFilledByIntent = false;
mDigits.setCursorVisible(false);
}else {
mDigits.setCursorVisible(true);
} updateDialAndDeleteButtonEnabledState();
loadSmartDialEntries(); refreshDigitTextSize(input);
}

指令处理的主角:SpecialCharSequenceMgr.handleChars(getActivity(), input.toString(), mDigits)

看 其方法的主体:

    static boolean handleChars(Context context, String input, boolean useSystemWindow,
EditText textField) { //get rid of the separators so that the string gets parsed correctly
String dialString = PhoneNumberUtils.stripSeparators(input); if (handlePRLVersion(context, dialString)
|| handleModemTestDisplay(context, dialString)
|| handleIMEIDisplay(context, dialString, useSystemWindow)
|| handleRegulatoryInfoDisplay(context, dialString)
|| handlePinEntry(context, dialString)
|| handleAdnEntry(context, dialString, textField)
|| handleSecretCode(context, dialString)
return true;
} return false;
}

这里有个handleIMEIDisplay(context, dialString, useSystemWindow)。看其主体:

    static boolean handleIMEIDisplay(Context context, String input, boolean useSystemWindow) {
if (input.equals(MMI_IMEI_DISPLAY)) { <span style="color:#3333ff;"> //</span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#3333ff;">MMI_IMEI_DISPLAY = "*#06#"</span></span>
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
return handleMSimIMEIDisplay(context);<span style="background-color: rgb(255, 255, 255);"><span style="color:#3333ff;">//显示IMEI号</span></span>
}
int subscription = MSimTelephonyManager.getDefault().getPreferredVoiceSubscription();
int phoneType;
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
phoneType = ((MSimTelephonyManager)context.getSystemService(
Context.MSIM_TELEPHONY_SERVICE)).getCurrentPhoneType(subscription);
} else {
phoneType = ((TelephonyManager)context.getSystemService(
Context.TELEPHONY_SERVICE)).getCurrentPhoneType();
}
if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
showIMEIPanel(context, useSystemWindow);<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#3333ff;">//显示IMEI号</span></span>
return true;
} else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
showMEIDPanel(context, useSystemWindow);<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#3333ff;">//显示IMEI号</span></span>
return true;
}
} return false;
}

至此IMEI号的显示流程都呈现出来。

2.在handleChars中还有对其它指令进行处理的方法:

handleModemTestDisplay、handleRegulatoryInfoDisplay、handleSecretCode等,

当中handleSecretCode是对*#*#。

#*#* 这一类的指令进行集中处理,看源代码:

  static boolean handleSecretCode(Context context, String input) {
// Secret codes are in the form *#*#<code>#*#*
int len = input.length();
if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) { Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
} return false;
}

能够看到是发送的一个广播,广播的action是 :

public static final String SECRET_CODE_ACTION ="android.provider.Telephony.SECRET_CODE";

data是一个URI,

所以在平台里面的全部AndroidManifest.xml 文件里查找android.provider.Telephony.SECRET_CODE。

就可以找出平台中全部*#*#。。#*#* 类型的指令,如:

<receiver android:name="TestingSettingsBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="837851" />
</intent-filter>
</receiver>
     <receiver android:name="TestingSettingsBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="4636" />
</intent-filter>
</receiver>

Android指令处理流程源代码追踪的更多相关文章

  1. Android 6.0 源代码编译实践

    http://www.judymax.com/archives/1087 Android 6.0 源代码编译实践 https://mirrors.tuna.tsinghua.edu.cn/help/A ...

  2. [Android Pro] Android 打包流程

    Android 打包流程: 官网地址:http://developer.android.com/tools/building/index.html 具体的打包步骤如下: 1:生成R.java类文件:E ...

  3. Android绘制流程

    一.前言 1.1.C++界面库 MFC.WTL.DuiLib.QT.Skia.OpenGL.Android里面的画图分为2D和3D两种: 2D是由Skia 来实现的,3D部分是由OpenGL实现的. ...

  4. Android源代码下载之《Android新闻client源代码》

    介绍 Android新闻client源代码,功能上分为:新闻.关注.读报.微博.里面比較有特色的就是读报功能.真正安装报纸的排版进行读报.给人得感觉就像是在读真实的报纸.事实上即使首页的动态云标签很有 ...

  5. Android系统启动流程(一)解析init进程启动过程

    整体流程大致如下:     1.init简介 init进程是Android系统中用户空间的第一个进程,作为第一个进程,它被赋予了很多极其重要的工作职责,比如创建zygote(孵化器)和属性服务等.in ...

  6. Android系统启动流程(四)Launcher启动过程与系统启动流程

    此前的文章我们学习了init进程.Zygote进程和SyetemServer进程的启动过程,这一篇文章我们就来学习Android系统启动流程的最后一步:Launcher的启动流程,并结合本系列的前三篇 ...

  7. Android manifest 获取源代码

    /********************************************************************************* * Android manifes ...

  8. 【转】android SystemUI 流程分析

    android4 SystemUI 流程分析 什么是SystemUI? 对于Phone来说SystemUI指的是:StatusBar(状态栏).NavigationBar(导航栏).而对于Tablet ...

  9. Android 5.0 源代码结构

    本节书摘来自异步社区<深入理解Android 5 源代码>一书中的第2章,第2.2节分析Android源代码结构,作者 李骏. 网址:https://yq.aliyun.com/artic ...

随机推荐

  1. 方程式0day图形化利用工具

    最近方程式的漏洞着实活了一把,分析了下githup上面的文件目录,找到了利用文件,主要是针对windows主机的SMB.RDP协议进行攻击,因为我主要根据他们提供的payload的程序,利用这两个模块 ...

  2. bzoj1477 poj1061 青蛙的约会

    Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘记了一件很重要的事 ...

  3. python 爬虫 处理超级课程表传输的数据

    借鉴的别人的思路 http://www.oschina.net/code/snippet_2463131_53711 抓取超级课程表传输的数据 他的传输数据居然是明文的-- 现在已经把自己的课表都抓出 ...

  4. Codeforces Round #260 (Div. 2) B. Fedya and Maths

    B. Fedya and Maths time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Apache 如何反向代理tomcat并且实现Session保持

    简介 LAMT=Linux+Apache+MySQL+Tomcat: Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器: 在中小型系统和并发访问用户不是很多的场合下 ...

  6. Image.Save()发生“GDI+ 中发生一般性错误”

    从数据库中读取的图片是byte[]类型,将其转换成Image可以正常显示,但是调用image.Save()时会发生“GDI+ 中发生一般性错误”.public static System.Drawin ...

  7. Python基础教程学习(三)

    如何定义类 class ClassName(base_class[es]): "optional documentation string" static_member_decla ...

  8. CAS工作流程

    CAS3.0的工作流程: 0.app将用户转发到CAS处, 并将自己的url作为callback参数传给CAS. 1.CAS验证用户成功(authentication) 2.生成用户实体(princi ...

  9. C++中模板单例的跨SO(DLL)问题:RTTI,typeid,static,单例

    (转载请注明原创于潘多拉盒子) C++的模板可以帮助我们编写适合不同类型的模板类,给代码的复用性提供了极大的方便.近来写了一个涉及单例的C++模板类,简化下来可以归结为以下的代码: template ...

  10. Git 学习(六)分支管理

    Git 学习(六)分支管理 几乎每一种版本控制系统都支持分支.使用分支意味着你可以从开发主线上分离开来,然后不影响主线的同时继续工作.在很多版本控制系统中,这是个昂贵的过程,常常需要创建一个源代码目录 ...