android14修改默认锁屏方式为无

android14修改默认休眠时间为永不休眠后,依然会很快就会息屏进入休眠。后面发现系统默认的锁屏方式为滑动解锁。开机后出现的就是滑动解锁的界面。解锁后或者设置系统锁屏方式为无以后,就不会再休眠了。

系统中frameworks/base/packages/SettingsProvider/res/values/defaults.xml修改<bool name="def_lockscreen_disabled">true</bool>来禁止锁屏,系统默认还是不能够让锁屏方式变成无的。

查找系统设置锁屏方式的代码packages\apps\Settings\src\com\android\settings\password\ChooseLockGeneric.java:

找到里面更新选项的函数:

private void updateCurrentPreference() {

String currentKey = getKeyForCurrent();

Preference preference = findPreference(currentKey);

if (preference != null) {

preference.setSummary(R.string.current_screen_lock);

}

}

上面代码可知获取当前锁屏方式有getKeyForCurrent函数获取。

private String getKeyForCurrent() {

final int credentialOwner = UserManager.get(getContext())

.getCredentialOwnerProfile(mUserId);

if (mLockPatternUtils.isLockScreenDisabled(credentialOwner)) {

return ScreenLockType.NONE.preferenceKey;

}

ScreenLockType lock =

ScreenLockType.fromQuality(

mLockPatternUtils.getKeyguardStoredPasswordQuality(credentialOwner));

return lock != null ? lock.preferenceKey : null;

}

上面函数可知,如果mLockPatternUtils.isLockScreenDisabled(credentialOwner)返回true就返回锁屏方式为无。

isLockScreenDisabled函数在frameworks\base\core\java\com\android\internal\widget\LockPatternUtils.java文件中:

public boolean isLockScreenDisabled(int userId) {

if (isSecure(userId)) {

return false;

}

boolean disabledByDefault = mContext.getResources().getBoolean(

com.android.internal.R.bool.config_disableLockscreenByDefault);

UserInfo userInfo = getUserManager().getUserInfo(userId);

boolean isDemoUser = UserManager.isDeviceInDemoMode(mContext) && userInfo != null

&& userInfo.isDemo();

return getBoolean(DISABLE_LOCKSCREEN_KEY, false, userId)

|| disabledByDefault

|| isDemoUser;

}

上面函数可知,只要getBoolean(DISABLE_LOCKSCREEN_KEY, false, userId)、disabledByDefault、isDemoUser三个其中一个为true就可以返回true。我们还看到disabledByDefault,顾名思义就是默认值了,这个值由com.android.internal.R.bool.config_disableLockscreenByDefault决定,这个值位于frameworks\base\core\res\res\values\config.xml中的config_disableLockscreenByDefault。

<!-- Is the lock-screen disabled for new users by default -->

<bool name="config_disableLockscreenByDefault">false</bool>

config_disableLockscreenByDefault为true,则默认关闭锁屏,isLockScreenDisabled返回true,系统就会默认锁屏方式为无。

相关推荐
新缸中之脑几秒前
Moltbook 帖子精选
开发语言·php
xyq202411 分钟前
jQuery Mobile 表单选择
开发语言
Sagittarius_A*13 分钟前
形态学与多尺度处理:计算机视觉中图像形状与尺度的基础处理框架【计算机视觉】
图像处理·人工智能·python·opencv·计算机视觉
m0_5613596715 分钟前
使用PyQt5创建现代化的桌面应用程序
jvm·数据库·python
2301_7903009616 分钟前
用Python实现自动化的Web测试(Selenium)
jvm·数据库·python
青岑CTF16 分钟前
攻防世界-Web_php_include-胎教版wp
开发语言·安全·web安全·网络安全·php
雾岛听蓝24 分钟前
C++11 列表初始化与右值引用核心解析
开发语言·c++·经验分享
自可乐26 分钟前
LangGraph从入门到精通:构建智能Agent的完整指南
人工智能·python·机器学习
m0_5613596728 分钟前
使用Docker容器化你的Python应用
jvm·数据库·python
小北方城市网34 分钟前
Spring Boot 多数据源与事务管理实战:主从分离、动态切换与事务一致性
java·开发语言·jvm·数据库·mysql·oracle·mybatis