项目中需要让Android板开机就进入桌面并且永不休眠。项目使用的是广和通的SC806Android开发板,msm8909平台。
配置永不休眠
diff
diff文件放前面,可以直接apply进去!
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index 64378d7ba7..3ee1079fb5 100644
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -18,7 +18,8 @@
-->
<resources>
<bool name="def_dim_screen">true</bool>
- <integer name="def_screen_off_timeout">60000</integer>
+ <!-- <integer name="def_screen_off_timeout">60000</integer> -->
+ <integer name="def_screen_off_timeout">-1</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/services/core/java/com/android/server/power/PowerManagerService.java b/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
index 7528a749b6..ff6ca47b87 100644
--- a/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
@@ -1830,6 +1830,7 @@ public final class PowerManagerService extends SystemService
}
private int getScreenOffTimeoutLocked(int sleepTimeout) {
+ int nosleep;
int timeout = mScreenOffTimeoutSetting;
if (isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked()) {
timeout = Math.min(timeout, mMaximumScreenOffTimeoutFromDeviceAdmin);
@@ -1840,6 +1841,11 @@ public final class PowerManagerService extends SystemService
if (sleepTimeout >= 0) {
timeout = Math.min(timeout, sleepTimeout);
}
+ nosleep = mScreenOffTimeoutSetting;
+ if(nosleep == 0) {
+ nosleep = mMaximumScreenOffTimeoutFromDeviceAdmin ;
+ return Math.max(nosleep, mMaximumScreenOffTimeoutFromDeviceAdmin);
+ }
return Math.max(timeout, mMinimumScreenOffTimeoutConfig);
}
diff --git a/packages/apps/Settings/res/values/arrays.xml b/packages/apps/Settings/res/values/arrays.xml
index c10057b423..f50595f501 100755
--- a/packages/apps/Settings/res/values/arrays.xml
+++ b/packages/apps/Settings/res/values/arrays.xml
@@ -46,6 +46,7 @@
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown in a list dialog. -->
<string-array name="screen_timeout_entries">
+ <item>Never</item>
<item>15 seconds</item>
<item>30 seconds</item>
<item>1 minute</item>
@@ -57,6 +58,8 @@
<!-- Do not translate. -->
<string-array name="screen_timeout_values" translatable="false">
+ <!-- Do not translate. -->
+ <item>0</item>
<!-- Do not translate. -->
<item>15000</item>
<!-- Do not translate. -->
详细说明
Setting UI
首先修改setting -> display -> sleep 菜单数组,增加Never选项
文件路径:packages/apps/Settings/res/values/arrays.xml
新增如下两行:
<item>Never</item>
-----------------------------------------------
<!-- Do not translate. -->
<item>0</item>
关闭息屏功能
文件路径:frameworks/base/packages/SettingsProvider/res/values/defaults.xml
修改def_screen_off_timeout
的值为 -1
<!-- <integer name="def_screen_off_timeout">60000</integer> -->
<integer name="def_screen_off_timeout">-1</integer>
更改电源管理方案
文件路径:frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
在getScreenOffTimeoutLocked
方法中添加如下语句:
private int getScreenOffTimeoutLocked(int sleepTimeout) {
int nosleep; // 新增
int timeout = mScreenOffTimeoutSetting;
if (isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked()) {
timeout = Math.min(timeout, mMaximumScreenOffTimeoutFromDeviceAdmin);
}
if (mUserActivityTimeoutOverrideFromWindowManager >= 0) {
timeout = (int)Math.min(timeout, mUserActivityTimeoutOverrideFromWindowManager);
}
if (sleepTimeout >= 0) {
timeout = Math.min(timeout, sleepTimeout);
}
// 新增判断开始
nosleep = mScreenOffTimeoutSetting;
if(nosleep == 0) {
nosleep = mMaximumScreenOffTimeoutFromDeviceAdmin ;
return Math.max(nosleep, mMaximumScreenOffTimeoutFromDeviceAdmin);
}
// 新增判断结束
return Math.max(timeout, mMinimumScreenOffTimeoutConfig);
}
private int getScreenDimDurationLocked(int screenOffTimeout) {
return Math.min(mMaximumScreenDimDurationConfig,
(int)(screenOffTimeout * mMaximumScreenDimRatioConfig));
}
标签:xml,msm8909,int,res,休眠,Setting,timeout,packages,Math
From: https://www.cnblogs.com/klelee/p/disable_sleep.html