【Settings】设置何时启动屏保

设置在何时开启Daydream
界面中设置在上下文菜单中点击when to dream
【Settings】设置何时启动屏保_第1张图片
Daydream部分的源码路径:packages\apps\Settings\src\com\android\settings
DreamSettings.java

onCreateOptionsMenu(Menu menu, MenuInflater inflater)中

// create "when to dream" overflow menu item
        MenuItem whenToDream = createMenuItem(menu,
                R.string.screensaver_settings_when_to_dream,
                MenuItem.SHOW_AS_ACTION_NEVER,
                isEnabled,
                new Runnable() {
                    @Override
                    public void run() {
                        showDialog(DIALOG_WHEN_TO_DREAM);
                    }});

查看onCreateDialog()方法

    @Override
    public Dialog onCreateDialog(int dialogId) {
        logd("onCreateDialog(%s)", dialogId);
        if (dialogId == DIALOG_WHEN_TO_DREAM)
            return createWhenToDreamDialog();
        return super.onCreateDialog(dialogId);
    }

调用了createWhenToDreamDialog()
【Settings】设置何时启动屏保_第2张图片
设置单选项时由变量initialSelection决定。
将initialSelection的值改为我们所需的位置,注释掉原有代码

Settings的push路径 system/priv-app/Settings,重启成功

你可能感兴趣的:(源码,android)