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

相关推荐
闻道且行之1 小时前
TurboOCR:基于PP-OCRv6的极速Windows离线OCR工具,深度解析3.4GB依赖背后的技术架构
c++·人工智能·python·qt·机器学习·ocr
许彰午2 小时前
95_Python内存管理与垃圾回收
开发语言·python
多加点辣也没关系3 小时前
JavaScript|第13章:原始类型的方法
开发语言·javascript·ecmascript
এ慕ོ冬℘゜3 小时前
深入理解 JavaScript 事件体系:Window、鼠标与键盘事件详解
开发语言·javascript·okhttp
骄阳如火3 小时前
Python 性能深度剖析:从“被诟病的慢”到“Rust 重塑”的拐点
python
满怀冰雪3 小时前
03-第一个 Paddle 程序:Tensor 创建、计算与设备管理
人工智能·python·paddle
CClaris4 小时前
大模型量化从0到1(九):用 llama.cpp 把模型转成 GGUF 并跑本地推理
人工智能·pytorch·python·深度学习·llama
学编程的小虎4 小时前
SenseVoice微调
人工智能·python·自然语言处理
诸葛说抛光4 小时前
国内大型汽车改装展览会定展 佛山改装 佛山汽车赛事
python·汽车
chouchuang4 小时前
day-030-综合练习-笔记管理器
开发语言·笔记·python