在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>
本文介绍了两种去除Android设备锁屏的方法。第一种方法涉及修改SystemUI源代码中的KeyguardViewMediator类,但存在不稳定的问题。第二种推荐方法是通过修改SettingsProvider中的defaults.xml文件,并可进一步禁用特定锁屏选项。
1112

被折叠的 条评论
为什么被折叠?



