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

相关推荐
paopaokaka_luck25 分钟前
基于springboot3+vue3的企业考勤管理系统(部门树递归、Echarts图形化分析)
开发语言·spring boot·学习·echarts·mybatis·需求分析·代码规范
张小凡vip1 小时前
python--爬虫--成熟的爬虫框架Scrapy
爬虫·python·scrapy
Pluchon1 小时前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
梦雨生生2 小时前
java开发工具(学习第一天)
java·开发语言·学习
不瘦80斤不改名2 小时前
01-vibe-coding-起源与本质
人工智能·python
夜雪一千2 小时前
如何对新闻数据进行模糊去重
python
啊啊啊啊啊!!!!3 小时前
【c++】stack和queue的接口使用以及底层实现
开发语言·c++
oyguyteggytrrwwwrt4 小时前
3dgs渲染部分详细注释
python
松仔log4 小时前
Java中级——组合和继承
android·java·开发语言
天天爱吃肉82186 小时前
【重磅发布:拿下新超仁达代理权 】
大数据·人工智能·python·功能测试·汽车