android开发笔记之拨号界面输入特定指令进行特定操作

来源:互联网 发布:qt tcp客户端接收数据 编辑:程序博客网 时间:2024/05/16 06:50

        在android手机的 拨号界面,我们常常输入特定指令进行特定操作,如输入*#06#,可以查看IMEI号等,那么我们也可以自定义相应的特定指令,对应用户相应的操作:

        我们查看源码:输入*#06#,可以查看IMEI号是如何实现,我们自定义相应的一个特定指令,实现相对应的操作。

     SpecialCharSequenceMgrProxy.java (packages\apps\contacts\src\com\mediatek\contacts)

1.定义特定的命令:

    private static final String MMI_IMEI_DISPLAY = "*#06#";    private static final String MMI_IMEI_EDIT = "*#328#*";//added by Wuyh 2013-10-16    private static final String MMI_VERNO_NUM = "*#0000#";//add by lvmingfei for verno number in 2013-12-10    private static final String MMI_HARDWARE_NUM = "*#8818#"; //add by wangxianming for Hardware number in 2014-01-09    private static final String ADN_PHONE_NUMBER_COLUMN_NAME = "number";    private static final String ADN_NAME_COLUMN_NAME = "name";    private static final String ADN_INDEX_COLUMN_NAME = "index";


2.处理输入特定指令的逻辑代码:

    static boolean handleChars(Context context, String input, boolean useSystemWindow,            EditText textField) {        Log.d(TAG, "handleChars() dialString:" + input);        if (SlotUtils.isGeminiEnabled()) {            String dialString = PhoneNumberUtils.stripSeparators(input);            if (handleIMEIDisplay(context, dialString, useSystemWindow)///HY:zhangshenghua CIT @{                || handleCIT(context, dialString)    //added by xuaping@hongyucom, at 2013-06-21.                || handleSAR(context, dialString)  //added by chencheng@hongyucom            ///@}                || handlePinEntry(context, dialString)                    || handleAdnEntry(context, dialString, textField)                    || handleIMEIEdit(context, dialString, useSystemWindow) //added by Wuyh 2013-10-16                    || handleShowVernoNumber(context, dialString, useSystemWindow) //added by lvmingfei 2013-12-10                    || handleShowHardWareNumber(context, dialString, useSystemWindow) //add by wangxianming for Hardware number in 2014-01-09                    || handleVIPFunctionPassword(context, dialString, useSystemWindow) //add by wangxianming for vipFunction password in 2014-03-12                    || handleSecretCode(context, dialString)) {                return true;            }            return false;        } else {            return SpecialCharSequenceMgr.handleChars(context, input, useSystemWindow, textField);        }    }


3.相对应的特别操作逻辑代码:

    static boolean handleIMEIDisplay(Context context, String input, boolean useSystemWindow) {        if (SlotUtils.isGeminiEnabled()) {           if (input.equals(MMI_IMEI_DISPLAY)) {                showIMEIPanel(context, useSystemWindow);                return true;            }            return false;        } else {            return SpecialCharSequenceMgr.handleIMEIDisplay(context, input,                    useSystemWindow);        }    }


0 0
原创粉丝点击