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


 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。