android 5.0
/packages/apps/Dialer
DialpadFragment.java
@Override
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();
}
......
}
SpecialCharSequenceMgr.java
private static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
private static final String MMI_IMEI_DISPLAY = "*#06#";
private static final String MMI_REGULATORY_INFO_DISPLAY = "*#07#";
public static boolean handleChars(Context context, String input, EditText textField) {
return handleChars(context, input, false, textField);
}
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 (handleIMEIDisplay(context, dialString, useSystemWindow)
|| handleRegulatoryInfoDisplay(context, dialString)
|| handlePinEntry(context, dialString)
|| handleAdnEntry(context, dialString, textField)
|| handleSecretCode(context, dialString)) {
return true;
}
return false;
}
static boolean handleIMEIDisplay(Context context, String input, boolean useSystemWindow) { =》处理:*#06#
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) {
int phoneType = telephonyManager.getPhoneType();
if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
showIMEIPanel(context, useSystemWindow, telephonyManager);
return true;
} else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
showMEIDPanel(context, useSystemWindow, telephonyManager);
return true;
}
}
return false;
}
/**
* Handles secret codes to launch arbitrary activities in the form of *#*#<code>#*#*.
* If a secret code is encountered an Intent is started with the android_secret_code://<code>
* URI.
*
* @param context the context to use
* @param input the text to check for a secret code in
* @return true if a secret code was encountered
*/
static boolean handleSecretCode(Context context, String input) { =》可以定制,比如*#*#2846579#*#*
// Secret codes are in the form *#*#<code>#*#*
int len = input.length();
if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
final Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
return false;
}
参考:
http://blog.csdn.net/fengguowuhen7871/article/details/5709568
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.2.2_r1/com/android/contacts/SpecialCharSequenceMgr.java#SpecialCharSequenceMgr