Android显示设置中增加“永不休眠”功能
来源:程序员人生 发布时间:2014-12-22 08:54:47 阅读次数:3654次
首先在frameworksasepackagesSettingsProvider
esvaluesdefaults.xml中设置def_screen_off_timeout为⑴,即
<integer name="def_screen_off_timeout">⑴</integer>
然后修改alpspackagesappsSettings
esvaluesarrays.xml:
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown ain a list dialog. -->
<string-array name="screen_timeout_entries">
<item>15 seconds</item>
<item>30 seconds</item>
<item>1 minute</item>
<item>2 minutes</item>
<item>10 minutes</item>
<item>30 minutes</item>
<item>never</item>
</string-array>
<!-- Do not translate. -->
<string-array name="screen_timeout_values" translatable="false">
<!-- Do not translate. -->
<item>15000</item>
<!-- Do not translate. -->
<item>30000</item>
<!-- Do not translate. -->
<item>60000</item>
<!-- Do not translate. -->
<item>120000</item>
<!-- Do not translate. -->
<item>600000</item>
<!-- Do not translate. -->
<item>1800000</item>
<item>⑴</item>
</string-array>
接着修改对照语言value文件夹下的arrays.xml, 修改screen_timeout_entries对应的翻译。不用管那个msgid,只是google用来表示是他自己的资源而已,直接添加<item >"永不休眠"</item>便可。
然后是代码的改动:
frameworks/base/services/java/com/android/server/power/PowerManagerService.java
private void updateUserActivitySummaryLocked(long now, int dirty) {
.....
//change code here ==============
Slog.d(TAG,"mScreenOffTimeoutSetting ="+mScreenOffTimeoutSetting);
//if (mUserActivitySummary != 0 ) {
if (mUserActivitySummary != 0 && mScreenOffTimeoutSetting > 0) {
//change code here end ==============
Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY_TIMEOUT);
msg.setAsynchronous(true);
mHandler.sendMessageAtTime(msg, nextTimeout);
}
转载请注明出处:周木水的CSDN博客 http://blog.csdn.net/zhoumushui
我的GitHub:周木水的GitHub https://github.com/zhoumushui
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠