码迷,mamicode.com
首页 > 移动开发 > 详细

Android显示设置中增加“永不休眠”功能

时间:2014-11-28 18:19:22      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:android   永不休眠   显示   设置   


首先在frameworks\base\packages\SettingsProvider\res\values\defaults.xml中设置def_screen_off_timeout为-1,即
<integer name="def_screen_off_timeout">-1</integer>
然后修改alps\packages\apps\Settings\res\values\arrays.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>-1</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


 

Android显示设置中增加“永不休眠”功能

标签:android   永不休眠   显示   设置   

原文地址:http://blog.csdn.net/zhoumushui/article/details/41577725

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!