1

I am in process of porting Android Kitkat 4.4.2 on Freescale iMX6 based custom board. Android is working properly now but it have a requirement to keep the screen ON permanently regardless of whatever application is running.

I am browsing the AOSP code to find out which function to comment out to disable the screen timeout functionality but no success so far. Can you guys point out to the right file/function ?

So far I have tried to comment out the code inside goToSleepInternal() function in frameworks/base/services/java/com/android/server/power/PowerManagerService.java but it is not disabling the screen timeout.

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
androidFan
  • 611
  • 2
  • 19
  • 31

3 Answers3

2

For those who stumble upon this question and are looking for a solution that does not require changes in the source code:

You can change the default value of the "Keep Screen On" setting in the "Developer options" using an overlay. Simply add the following line to <...>/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml:

<bool name="def_stay_on_while_plugged_in">true</bool>
Snellius
  • 21
  • 5
1

I finally solved the issue myself.

I commented the function call to handleUserActivityTimeout() in file frameworks/base/services/java/com/android/server/power/PowerManagerService.java :

@@ -2511,7 +2511,7 @@ public final class PowerManagerService extends IPowerManager.Stub
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case MSG_USER_ACTIVITY_TIMEOUT:
-                    handleUserActivityTimeout();
+                    //handleUserActivityTimeout();
                     break;
                 case MSG_SANDMAN:
                     handleSandman();
androidFan
  • 611
  • 2
  • 19
  • 31
0

Create a launcher application and from that call the code to keep screen on as below :

How do I keep the screen on in my App?

Community
  • 1
  • 1
Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
  • Yes I have a custom Launcher so I could do that. If I start a application then will the Launcher go in background ? – androidFan Jul 02 '15 at 16:37
  • SCREEN_DIM_WAKE_LOCK was deprecated in API level 17 , http://developer.android.com/reference/android/os/PowerManager.html#SCREEN_DIM_WAKE_LOCK – androidFan Jul 02 '15 at 19:17