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

相关推荐
呆呆虫1210 分钟前
用 orjson 加速 SerpBase 响应解析:基准对比与注意事项
开发语言·php
wflynn12 分钟前
GitHub 今日推荐|Edge0:让大号 MoE 模型在一台 Mac 上流式跑起来
python·开源·github
2601_9679801130 分钟前
python之用scapy分层解析pcap报文(Ethernet帧、IP数据包、TCP数据包、UDP数据包、Raw数据包)
python·scapy·pcap·协议分析·网络数据包
心疼你的一切37 分钟前
Python自动发邮件实战定时发报表
大数据·开发语言·python
Wang's Blog2 小时前
Java 项目实战:交友项目 - 用户体系集成总结
java·开发语言·交友
中科三方2 小时前
IPv6检测常见问题:AAAA记录检测不通过是什么原因?
开发语言·php
卡提西亚2 小时前
FastAPI基础入门
python·fastapi
fanruitian3 小时前
python 机器学习 ML LinearRegression KNN KMeans
python·机器学习·kmeans
鱼宵3 小时前
取集合第一个元素,Java 为什么要写三种写法?
java·windows·python·java21
卷无止境3 小时前
给AI装上一双眼睛:快速构建代码验证器的思路与落地方案
后端·python