Android通过输入暗码控制指定app icon的显示与隐藏

来源:互联网 发布:2018年网络dj歌曲 编辑:程序博客网 时间:2024/05/22 03:43

首先来分析下该需求,来确认所需要改动的位置.

第一,输入暗码.说明要在拨号盘进行输入操作,并且对我们设置的特定暗码(例如 *#*#111#*#*)进行相应操作.

第二,根据暗码对指定的app的ICON进行隐藏或显示操作.

于是,大致确认需要改动的两个位置,拨号盘Dialer和桌面Launcher.


一、设置暗码

首先找到该类  packages/apps/Dialer/src/com/android/dialer/SpecialCharSequenceMgr.java

SpecialCharSequenceMgr 顾名思义就是特殊字符序列管理,

在该类中,声明一个字符串变量,也就是我们的暗码.

private static final String DISPLAY_ICON = "*#*#111#*#*";

接着找到该类的入口函数handleChars()

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





未完....

原创粉丝点击