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,系统就会默认锁屏方式为无。

相关推荐
IVEN_6 小时前
只会Python皮毛?深入理解这几点,轻松进阶全栈开发
python·全栈
Ray Liang7 小时前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
AI攻城狮7 小时前
如何给 AI Agent 做"断舍离":OpenClaw Session 自动清理实践
python
千寻girling7 小时前
一份不可多得的 《 Python 》语言教程
人工智能·后端·python
AI攻城狮10 小时前
用 Playwright 实现博客一键发布到稀土掘金
python·自动化运维
曲幽11 小时前
FastAPI分布式系统实战:拆解分布式系统中常见问题及解决方案
redis·python·fastapi·web·httpx·lock·asyncio
孟健1 天前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞1 天前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽1 天前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers