Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make android device always in wake mode?

After successful root of device. Now, I need to make device always in wake state i.e. always visibility of UI and no black screen or any daydream screens. To do so I think I've to accomplish following :

  1. No lock screen - turned off
  2. Sleep set to “never”
  3. Daydream set to “off”

What I found is all about application layer i.e. there are some applications which can do above tasks. But since my mobile is rooted I want to achieve with system files so that even if some other applications try to change above functionalities then they should not be able to do so.

like image 874
Chitrang Avatar asked Jan 06 '16 07:01

Chitrang


People also ask

How do I keep my Android screen awake?

Open Settings. Tap Display. Tap Sleep or Screen timeout. Select how long you want your Android smartphone or tablet screen to stay on before turning off due to inactivity.

How do I keep my screen wake?

Go to Control Panel > Personalization > Change Screensaver. Next to On Resume, Display Logon Screen, uncheck the box. This prevents your system from sleeping.

How do I set my Android phone to wake up?

For an effortless way to activate this, just set the screen to turn on when you pick up the phone. From Settings, search for and select Lift to wake. Tap the switch next to Lift to wake to turn this feature on.


2 Answers

  1. Activate developer mode
  2. go to Developer options
  3. turn on "Stay awake"
like image 177
Andrew Lam Avatar answered Oct 06 '22 00:10

Andrew Lam


Your main use case appears to be as follows (from your question)

Even if some other applications try to change above functionalities then they should not be able to do so

You can write a system service to trigger the PowerManager.WakeLock at regular intervals. (Source)

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();

// screen and CPU will stay awake during this section

wl.release();

To optimize the service you can also try setting the screen timeout the the maximum possible again at regular intervals so that even if changed manually it gets reset. (not sure how much max is allowed, you'll need to check with trial and error)

  /**
   * set screen off timeout
   * @param screenOffTimeout int 0~6
   */
private void setTimeout(int screenOffTimeout) {
    int time;
    switch (screenOffTimeout) {
    case 0:
        time = 15000;
        break;
    case 1:
        time = 30000;
        break;
    case 2:
        time = 60000;
        break;
    case 3:
        time = 120000;
        break;
    case 4:
        time = 600000;
        break;
    case 5:
        time = 1800000;
        break;
    default:
        time = -1;
    }
    android.provider.Settings.System.putInt(getContentResolver(),
            Settings.System.SCREEN_OFF_TIMEOUT, time);
}

(Source)

like image 30
AndroidMechanic - Viral Patel Avatar answered Oct 05 '22 23:10

AndroidMechanic - Viral Patel