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

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

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

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

  1. public interface TextWatcher extends NoCopySpan {
  2. public void beforeTextChanged(CharSequence s, int start,int count, int after);
  3. public void onTextChanged(CharSequence s, int start, int before, int count);
  4. public void afterTextChanged(Editable s);
  5. }

在DialpadFragment中实现了该接口:

  1. public void afterTextChanged(Editable input) {
  2. // When DTMF dialpad buttons are being pressed, we delay SpecialCharSequencMgr sequence,
  3. // since some of SpecialCharSequenceMgr's behavior is too abrupt for the "touch-down"
  4. // behavior.
  5. if (!mDigitsFilledByIntent &&
  6. SpecialCharSequenceMgr.handleChars(getActivity(), input.toString(), mDigits)) {
  7. // A special sequence was entered, clear the digits
  8. mDigits.getText().clear();
  9. }
  10. if (isDigitsEmpty()) {
  11. mDigitsFilledByIntent = false;
  12. mDigits.setCursorVisible(false);
  13. }else {
  14. mDigits.setCursorVisible(true);
  15. }
  16.  
  17. updateDialAndDeleteButtonEnabledState();
  18. loadSmartDialEntries();
  19.  
  20. refreshDigitTextSize(input);
  21. }

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

看 其方法的主体:

  1. static boolean handleChars(Context context, String input, boolean useSystemWindow,
  2. EditText textField) {
  3.  
  4. //get rid of the separators so that the string gets parsed correctly
  5. String dialString = PhoneNumberUtils.stripSeparators(input);
  6.  
  7. if (handlePRLVersion(context, dialString)
  8. || handleModemTestDisplay(context, dialString)
  9. || handleIMEIDisplay(context, dialString, useSystemWindow)
  10. || handleRegulatoryInfoDisplay(context, dialString)
  11. || handlePinEntry(context, dialString)
  12. || handleAdnEntry(context, dialString, textField)
  13. || handleSecretCode(context, dialString)
  14. return true;
  15. }
  16.  
  17. return false;
  18. }

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

  1. static boolean handleIMEIDisplay(Context context, String input, boolean useSystemWindow) {
  2. 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>
  3. if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
  4. return handleMSimIMEIDisplay(context);<span style="background-color: rgb(255, 255, 255);"><span style="color:#3333ff;">//显示IMEI号</span></span>
  5. }
  6. int subscription = MSimTelephonyManager.getDefault().getPreferredVoiceSubscription();
  7. int phoneType;
  8. if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
  9. phoneType = ((MSimTelephonyManager)context.getSystemService(
  10. Context.MSIM_TELEPHONY_SERVICE)).getCurrentPhoneType(subscription);
  11. } else {
  12. phoneType = ((TelephonyManager)context.getSystemService(
  13. Context.TELEPHONY_SERVICE)).getCurrentPhoneType();
  14. }
  15. if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
  16. showIMEIPanel(context, useSystemWindow);<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#3333ff;">//显示IMEI号</span></span>
  17. return true;
  18. } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
  19. showMEIDPanel(context, useSystemWindow);<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#3333ff;">//显示IMEI号</span></span>
  20. return true;
  21. }
  22. }
  23.  
  24. return false;
  25. }

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

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

handleModemTestDisplay、handleRegulatoryInfoDisplay、handleSecretCode等,

当中handleSecretCode是对*#*#。

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

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

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

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

data是一个URI,

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

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

  1. <receiver android:name="TestingSettingsBroadcastReceiver">
  2. <intent-filter>
  3. <action android:name="android.provider.Telephony.SECRET_CODE" />
  4. <data android:scheme="android_secret_code" android:host="837851" />
  5. </intent-filter>
  6. </receiver>
  1. <receiver android:name="TestingSettingsBroadcastReceiver">
  2. <intent-filter>
  3. <action android:name="android.provider.Telephony.SECRET_CODE" />
  4. <data android:scheme="android_secret_code" android:host="4636" />
  5. </intent-filter>
  6. </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. BZOJ.2194.快速傅立叶之二(FFT 卷积)

    题目链接 \(Descripiton\) 给定\(A[\ ],B[\ ]\),求\[C[k]=\sum_{i=k}^{n-1}A[i]*B[i-k]\ (0\leq k<n)\] \(Solut ...

  2. Android之安全机制

    根据android四大框架来解说安全机制 代码安全 java不同于C/C++,java是解释性语言,存在代码被反编译的隐患: 默认混淆器为proguard,最新版本为4.7: proguard还可用来 ...

  3. 【bzoj2005】 [Noi2010]能量采集 数学结论(gcd)

    [bzoj2005] [Noi2010]能量采集 Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...

  4. HDU 3161 Iterated Difference 暴力

    Iterated Difference Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. ROS知识(9)----NodeHandle命令空间问题

    一直被NodleHandle的构造函数的命名空间搞混淆了.例如: ros::NodeHandle node_private("~/"); ros::NodeHandle node_ ...

  6. Asky极简教程:零基础1小时学编程,已更新前8节

    Asky极简架构 开源Asky极简架构.超轻量级.高并发.水平扩展.微服务架构 <Asky极简教程:零基础1小时学编程>开源教程 零基础入门,从零开始全程演示,如何开发一个大型互联网系统, ...

  7. Spring <context:annotation-config/> 解说(转)

    在基于主机方式配置Spring的配置文件中,你可能会见到<context:annotation-config/>这样一条配置,他的作用是式地向 Spring 容器注册 AutowiredA ...

  8. FolderSync Instant sync 即时同步

    Folderpairs - Edit folderpair - Sync options - Instant sync  Select this for instant sync on change. ...

  9. C#多线程编程之:lock使用注意事项

    1.避免锁定public类型对象. 如果实例可以被公共访问,将出现lock(this)问题. 如有一个类MyClass,该类有一个Method方法通过lock(this)来实现互斥: 1 public ...

  10. MVC使用Entity Framework Code First,用漂亮表格显示1对多关系

    部门和职员是1对多关系.用一个表格列出所有部门,并且在每行显示该部门下的所有职员名称.如下: 部门和职员的Model: using System.Collections.Generic; namesp ...