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 :
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.
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.
Go to Control Panel > Personalization > Change Screensaver. Next to On Resume, Display Logon Screen, uncheck the box. This prevents your system from sleeping.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With