Android顯示設定中增加“永不休眠”功能,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