Android screen-off timer set as 2 seconds

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Android screen-off timer set as 2 seconds

522 Views
MarkDing
Contributor I

1. I tried to reproduce this issue by blow actions:

a. Power up Android, input Screen-off timer to 2 seconds in console.

$ sqlite3 /data/data/com.android.providers.settings/databases/settings.db sqlite> update system set value="2000" where name="screen_off_timeout"; sqlite> .quit 

b. Unlock the screen and wait for suspend message, about 6 seconds, I can see suspend message output from console. It shows what I see is exactly same as customer’s.

2. Locate the reason.

In “frameworks/base/services/java/com/android/server/PowerManagerService.java”, function private void setTimeoutLocked(long now, final long originalTimeoutOverride, int nextState), we can see below code. For nextState = SCREEN_BRIGHT, it will wait for mKeylightDelay and then enter next state.

switch (nextState) {     case SCREEN_BRIGHT:         when = now + mKeylightDelay;         break;     case SCREEN_DIM:         if (mDimDelay >= 0) {             when = now + mDimDelay;             break;         } else {             Slog.w(TAG, "mDimDelay=" + mDimDelay + " while trying to dim");         }     case SCREEN_OFF:         synchronized (mLocks) {             when = now + mScreenOffDelay;         }         break;     default:         when = now;         break;     } 

I checked code, mKeylightDelay get its value “LONG_KEYLIGHT_DELAY” in function private void setScreenOffTimeoutsLocked(). And we can see macro definition in this file.

    // time since last state: time since last event:     // The short keylight delay comes from secure settings; this is the default.     private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 6000; // t+6 sec     private static final int MEDIUM_KEYLIGHT_DELAY = 15000;       // t+15 sec     private static final int LONG_KEYLIGHT_DELAY = 6000;        // t+6 sec     private static final int LONG_DIM_TIME = 7000;              // t+N-5 sec 

From above definition, we can see that is Android default design method, and we know why we will wait 6 seconds to enter suspend mode even we set screen-off timer as 2 seconds.

3. Solution.

a. We should keep minimum screen-off timer as 6 seconds, just following Android default design method.
b. I tried to modify the macro definition like below, and have a test, it can enter into suspend mode within 2 seconds. However, user experience is not good. Because 2 seconds is too short, e-reader panel response is slow, it is very easy to enter suspend mode, we have to wakeup it frequency.

    // time since last state: time since last event:     // The short keylight delay comes from secure settings; this is the default.     private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 1000; // t+6 sec     private static final int MEDIUM_KEYLIGHT_DELAY = 9000;       // t+15 sec     private static final int LONG_KEYLIGHT_DELAY = 1000;        // t+6 sec     private static final int LONG_DIM_TIME = 2000;              // t+N-5 sec 

Please tradeoff it.

Tags (1)
0 Kudos
0 Replies