第一种方法:目录(不推荐):frameworks\base\packages\SystemUI\src\com\Android\systemui\keyguard\KeyguardViewMediator.Java
<bool name="def_lockscreen_disabled">true</bool>
(1)
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<integer name="def_screen_off_timeout">60000</integer>
60000改成想要的时间如果是不锁为-1
第二种方法:
packages\apps\settings\res\xml\Security_settings_picker.xml
<!-- <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"/> -->
第三种方法:
KeyguardManager manager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock keyguardLock = manager.newKeyguardLock(lockTag);
keyguardLock.disableKeyguard();
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
第四种方法:
让系统一启动我们就禁用锁屏的功能,很简单,我们只要把系统锁 屏 功能的的初始默认开关给改以下就可以了,如下找到这个类:
/frameworks/base/packages/SystemUI/src/com/android/systemui/keyguard
private boolean mExternallyEnabled = true;
mExternallyEnabled是用来管理是否开启屏幕锁的关键。默认值是打开屏锁,根据注释可以知道他是希望应用程序来修改这个
值,我们可以把这个值改成false就可以了。