1. Dial-up interface input * #06 #, show IMEI number, how did this come out?
2. How to quickly find the instructions in the Android platform?
1. Register a TextChanged listener Textwatcher in Dialpadfragment EditText,
When the content in EditText is changed, the corresponding callback function is called, and Textwatcher is an interface:
Public interface Textwatcher extends Nocopyspan {public void beforetextchanged (charsequence s, int start,int count, I NT after); public void ontextchanged (charsequence s, int start, int before, int count); public void aftertextchanged (Editable s);}
This interface is implemented in Dialpadfragment:
public void aftertextchanged (Editable input) { //when DTMF dialpad buttons is being pressed, we delay SPECIALCHARSEQ Uencmgr sequence, //Since some of specialcharsequencemgr ' s behavior are too abrupt for the "touch-down" //Behavio R. 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); }
Instruction processing protagonist: Specialcharsequencemgr.handlechars (Getactivity (), input.tostring (), mdigits)
Look at the body of the method:
Static Boolean Handlechars (context context, String input, Boolean usesystemwindow, EditText textField) { //get Rid of the separators so, the string gets parsed correctly string dialstring = Phonenumberutils.stripseparators (in put); 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; }
Here is a handleimeidisplay (context, dialstring, Usesystemwindow), looking at its main body:
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 (). ismultisimenable D ()) {return Handlemsimimeidisplay (context); <span style= "Background-color:rgb (255, 255, 255);" ><span style= "color: #3333ff;" >//display IMEI number </span></span>} int subscription = Msimtelephonymanager.getdefault (). GETPR Eferredvoicesubscription (); int phonetype; if (Msimtelephonymanager.getdefault (). ismultisimenabled ()) {Phonetype = ((Msimtelephonymanager) context.get Systemservice (Context.msim_telephony_service)). Getcurrentphonetype (subscription); } else { Phonetype = ((Telephonymanager) Context.getsystemservice (Context.telephony_service)). Getcur Rentphonetype (); } if (Phonetype = = telephonymanager.phone_type_gsm) {Showimeipanel (context, Usesystemwindow); <s Pan style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "color: #3333ff;" >//display IMEI number </span></span> return true; } else if (Phonetype = = TELEPHONYMANAGER.PHONE_TYPE_CDMA) {Showmeidpanel (context, Usesystemwindow); <spa N style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "color: #3333ff;" >//display IMEI number </span></span> return true; }} return false; }
The display process for the IMEI number is presented here.
2. There are also methods for handling other instructions in Handlechars:
Handlemodemtestdisplay, Handleregulatoryinfodisplay, Handlesecretcode, etc.,
One of the Handlesecretcode is to *#*#. #*#* This kind of instruction to focus on processing, see the Source:
Static Boolean Handlesecretcode (context context, String input) { //Secret codes is in the form *#*#<code>#*#*< C2/>int len = Input.length (); if (Len > 8 && input.startswith ("*#*#") && input.endswith ("#*#*")) { Intent Intent = new Intent (Tel Ephonyintents.secret_code_action, uri.parse ("android_secret_code://" + input.substring (4, len-4))); Context.sendbroadcast (intent); return true; } return false; }
You can see that a broadcast is sent, and the action of the broadcast is:
public static final String secret_code_action = "Android.provider.Telephony.SECRET_CODE";
Data is a URI,
So find Android.provider.Telephony.SECRET_CODE in all the Androidmanifest.xml files inside the platform,
You can find all the *#*# in the platform. #*#* types of directives, such as:
<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>