android5.1修改默认锁屏方式(去除锁屏)

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lcpangs/article/details/52243438

在5.1上,代码的处理方式变得不一样了,我最开始的做法是更改锁屏默认值,但是第一次刷机有效,第二次开机居然就不进去桌面了.

第一种方法:目录(不推荐):frameworks\base\packages\SystemUI\src\com\android\systemui\keyguard\KeyguardViewMediator.java

关键字:mExternallyEnabled

<span style="font-size:18px;">    /**
     * External apps (like the phone app) can tell us to disable the keygaurd.
     */
   <strong> private boolean mExternallyEnabled = true;</strong>
    /**
     * Remember if an external call to {@link #setKeyguardEnabled} with value
     * false caused us to hide the keyguard, so that we need to reshow it once
     * the keygaurd is reenabled with another call with value true.
     */
 <strong>   private boolean mNeedToReshowWhenReenabled = false;</strong>

    // cached value of whether we are showing (need to know this to quickly
    // answer whether the input should be restricted)
    private boolean mShowing;</span>

这个值是去除锁屏的,但是修改了有点问题

第二种方法(推荐)

目录:frameworks\base\packages\SettingsProvider\res\values\defaults.xml

关键字:def_lockscreen_disabled 这个值为true时是默认选择设置里面的无选项

<span style="font-size:18px;">    <bool name="def_lockscreen_disabled">true</bool>
    <bool name="def_device_provisioned">false</bool>
    <integer name="def_dock_audio_media_enabled">1</integer></span>
如果不起效果,可以在宏定义脚本加上PRODUCT_PROPERTY_OVERRIDES += ro.lockscreen.disable.default=true这个选项


下面去除设置里面的其他锁屏选项,爬代码可看出,这个布局是动态加载的(packages\apps\settings\src\com\android\settings\FingerSettings.java)


所以我们只需要把布局里面的Preference注释就可以

packages\apps\settings\res\xml\Security_settings_picker.xml

<span style="font-size:18px;"><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        android:title="@string/lock_settings_picker_title"
        android:key="lock_settings_picker">

    <PreferenceScreen
            android:key="unlock_set_off"
            android:title="@string/unlock_set_unlock_off_title"
            android:persistent="false"/>

<!--    <PreferenceScreen
            android:key="unlock_set_none"
            android:title="@string/unlock_set_unlock_none_title"
            android:persistent="false"/>

    <PreferenceScreen
            android:key="unlock_set_biometric_weak"
            android:title="@string/unlock_set_unlock_biometric_weak_title"
            android:persistent="false"/>

    <PreferenceScreen
            android:key="unlock_set_voice_weak"
            android:title="@string/unlock_set_unlock_mode_voice_weak"
            android:persistent="false"/>

    <PreferenceScreen
            android:key="unlock_set_pattern"
            android:title="@string/unlock_set_unlock_pattern_title"
            android:persistent="false"/>

    <PreferenceScreen
            android:key="unlock_set_pin"
            android:title="@string/unlock_set_unlock_pin_title"
            android:persistent="false"/>

    <PreferenceScreen
            android:key="unlock_set_password"
            android:title="@string/unlock_set_unlock_password_title"
            android:persistent="false"/>  -->

</PreferenceScreen>
</span>



展开阅读全文

没有更多推荐了,返回首页