Android OS Forum banner
1 - 3 of 3 Posts

37 Posts
Ever thought the lockscreen wasn't shown long enough after waking the screen up to see the time, song/artist name, notifications, etc before it turned back off? We can fix that. This is NOT the normal screen timeout or the keyguard delay time for activating the lockscreen once the screen turns off. This IS the amount of time the screen will stay on and show the lockscreen after pressing the power button to wake up your device.

  • device must be rooted
  • deodexed ROM
  • Android SDK Tools and Platform-tools for Windows or Mac & Linux
Important Info:
  • I am not responsible for your phone or any damage/problems but I will try and help if any issues do occur
  • This has been tested on a few different CM7-based ROMs for the Eris and should work for any ROM that has a deodexed android.policy.jar
  • To be safe, make a NAND backup before attempting
Let's get started!
To skip to the guide, see post #2 for Windows or post #3 for Mac & Linux.

Want to learn the background of what we're changing? Then keep on reading...
The value we are interested in is defined in the source file called
    /**<br />
     * The default amount of time we stay awake (used for all key input)<br />
     */<br />
    protected static final int AWAKE_INTERVAL_DEFAULT_MS = 5000;<br />
<br />
<br />
    /**<br />
     * The default amount of time we stay awake (used for all key input) when<br />
     * the keyboard is open<br />
     */<br />
    protected static final int AWAKE_INTERVAL_DEFAULT_KEYBOARD_OPEN_MS = 10000;
Notice how there are actually two variables used to control the amount of time to stay awake. The second of which is only used when the hardware keyboard is open for devices that have one. We also see that the values are set in milliseconds(ms) with the default being 5000ms(5s) unless a hardware keyboard is open where the default is 10s. The pokeWakelock methods first determine whether the keyboard is open or not and then, based on the result, sends the appropriate variable's value to a handler to implement the timeout itself:
    public void pokeWakelock() {<br />
        pokeWakelock(mKeyboardOpen ?<br />
    }<br />
<br />
    public void pokeWakelock(int holdMs) {<br />
        synchronized (this) {<br />
            if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")");<br />
            mWakeLock.acquire();<br />
            mHandler.removeMessages(TIMEOUT);<br />
            mWakelockSequence++;<br />
            Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0);<br />
            mHandler.sendMessageDelayed(msg, holdMs);<br />
        }<br />
It would be nice if we could change the default values where the variables are defined but it turns out that we need to modify them where they are used. This is because the /system/framework/android.policy.jar package is already built/compiled...meaning the defined variable values have been stored in memory and at usage time are loaded into a register. As you will see in the guide, we must change the value when it's loaded into a register. For us, that means inside the pokeWakeLock method. We're now ready to give it a go.

* thetornado for asking the question which led to this
* Daneshm90 for APK Manager
* Don Ho for Notepad++

37 Posts
Discussion Starter · #2 ·
  • download APK Manager and extract it to you preferred location
    • this guide will use C:\apk_manager_4.9
  • run C:\apk_manager_4.9\Script.bat
    • select option 0 to adb pull
      • where = /system/framework/android.policy.jar
      • stored name = android.policy.jar
      • current project = y
    • select option 9 to decompile
  • minimize Script.bat window
  • use Notepad++(or your preferred editor) to open:
    • find ".method public pokeWakelock()V" NOT ".method public pokeWakelock(I)V"
    • inside the method, find the two lines starting with "const/16 v#" followed by a hex value(0x####)
      • the second(0x1388=5000ms=5s) is the default timeout unless a hardware keyboard is open, in which case the first(0x2710=10000ms=10s) is used
      • the values are 16-bit signed integers so the highest either can be set is 0x7FFF=32767ms=32.767s (Your screen will not wake up if set higher)
      • use this dec->hex convertor to determine the hex equivalent of your desired ms timeout
    • modify the hex values to your liking, save the file, and close Notepad++
  • return to the Script.bat window
    • select option 11 to compile
      • system apk = y
      • additional files = n
    • select option 8 to adb push
      • where&name = /system/framework/android.policy.jar
    • select option 24 to quit
  • open a command prompt to run these commands:
    adb shell chmod 644 /system/framework/android.policy.jar<br />
    adb reboot recovery
  • in recovery,wipe dalvik-cache & cache, then reboot
1 - 3 of 3 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.