Android – 永不锁屏,开机不锁屏,删除设置中休眠时间选项
Android 绝不屏保,启动不屏保,删掉设定中休眠状态時间选择项
Android 6.0.1
Create:2016-02-29
1.Settings 删除显示屏关机选择项
packages/apps/Settings/res/xml/display_settings.xml
<!-- Hide screen sleep
<ListPreference
android:key="screen_timeout"
android:title="@string/screen_timeout"
android:summary="@string/screen_timeout_summary"
android:persistent="false"
android:entries="@array/screen_timeout_entries"
android:entryValues="@array/screen_timeout_values" /> -->
注解掉这一ListPreference
packages/apps/Settings/src/com/android/settings/DisplaySettings.java
加上if标准,要是没有寻找这一preference也不实行有关实际操作;实际能够参照被掩藏的 night_mode
mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT);
if (mScreenTimeoutPreference !=null ) {
final long currentTimeout = Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT,
FALLBACK_SCREEN_TIMEOUT_VALUE);
mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
disableUnusableTimeouts(mScreenTimeoutPreference);
updateTimeoutPreferenceDescription(currentTimeout);
}
2.严禁屏保
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<bool name="def_lockscreen_disabled">false</bool>
改成 true;即默认设置严禁屏保
frameworks/base/core/res/res/values/config.xml
<integer name="config_multiuserMaximumUsers">1</integer>
不允许多客户;即较大 用户量为1
各自编译程序frameworks/base/packages/SettingsProvider 与 frameworks/base
编译程序后push 到 system/priv-app/SettingsProvider/SettingsProvider.apk system/framework/framework.jar
删除设备中相匹配的oat文件目录。重新启动或修复系统恢复。第一次启动时,会先出現status bar,launcher要等一会才出去。
以后重新启动就可以直接进入launcher。设备会默认设置不屏保。但依然会进到sleep情况。
源代码步骤:
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
if (upgradeVersion == 54)// 版本号为54才会设定timeout
......
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) {
// See if the timeout is -1 (for "Never").
Cursor c = db.query(TABLE_SYSTEM, new String[] { "_id", "value" }, "name=? AND value=?",
new String[] { Settings.System.SCREEN_OFF_TIMEOUT, "-1" },
null, null, null);
SQLiteStatement stmt = null;
if (c.getCount() > 0) {
c.close();
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
" VALUES(?,?);");
// Set the timeout to 30 minutes in milliseconds
loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
Integer.toString(30 * 60 * 1000));
} finally {
if (stmt != null) stmt.close();
}
} else {
c.close();
}
}
......
if (SystemProperties.getBoolean("ro.lockscreen.disable.default", false) == true) {
loadSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, "1");
} else {
loadBooleanSetting(stmt, Settings.System.LOCKSCREEN_DISABLED,
R.bool.def_lockscreen_disabled);
}
timeout若是-1,则绝不屏保
载入"ro.lockscreen.disable.default",假如默认设置为true,则设定严禁屏保;不然从xml中读配备
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<integer name="def_screen_off_timeout">60000</integer>
<bool name="def_lockscreen_disabled">false</bool>`
严禁屏保默认设置为false