Android系统取消开机锁屏功能和永不熄屏
- 源码
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
private void upgradeScreenTimeout(SQLiteDatabase db) {
// Change screen timeout to current default
db.beginTransaction();
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)"
+ " VALUES(?,?);");
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (stmt != null)
stmt.close();
}
}
private void loadSystemSettings(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
R.bool.def_dim_screen);
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
···
}
···
}
frameworks/base/packages/SystemUI/AndroidManifest.xml
//锁屏服务
<service
android:name=".keyguard.KeyguardService"
android:exported="true"
android:enabled="@bool/config_enableKeyguardService" />
- 实现
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index a8c05e1..a6b9f1c 100755
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -18,7 +18,7 @@
-->
<resources>
<bool name="def_dim_screen">true</bool>
- <integer name="def_screen_off_timeout">60000</integer>
+ <integer name="def_screen_off_timeout">2147483647</integer>
<integer name="def_sleep_timeout">-1</integer>
<bool name="def_airplane_mode_on">false</bool>
<bool name="def_theater_mode_on">false</bool>
diff --git a/frameworks/base/packages/SystemUI/res/values/config.xml b/frameworks/base/packages/SystemUI/res/values/config.xml
index 0c018d7..4436a9d 100755
--- a/frameworks/base/packages/SystemUI/res/values/config.xml
+++ b/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -224,7 +224,7 @@
<item name="recents_layout_unfocused_range_max" format="float" type="integer">2.5</item>
<!-- Whether to enable KeyguardService or not -->
- <bool name="config_enableKeyguardService">true</bool>
+ <bool name="config_enableKeyguardService">false</bool>
<!-- The maximum count of notifications on Keyguard. The rest will be collapsed in an overflow
card. -->
- 通过adb命令获取休眠时间
#获取屏幕休眠时间
C:\Users\Admin>adb shell settings get system screen_off_timeout
60000
#休眠时间修改为最大值,最大值就是永不休眠
C:\Users\Admin>adb shell settings put system screen_off_timeout 2147483647