Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent screen sleeping

Tags:

android

adb

Android v4.2.2. I'm trying to stop the screen from going to sleep. I've tried a few things like changing the relevant settings in the db:

adb shell "sqlite3 /data/data/com.android.providers.settings/databases/settings.db  \"update system set value='-1' where name='screen_off_timeout'\";"

But that didn't work - screen just went to sleep almost immediately. If I go to the settings app there isn't an option to disable it. Instead, it ranges from 15s to 30m.

I have also tried to set the KEEP_SCREEN_ON FLAG in the application but that stops working when I switch to a new activity.

Is there anything else I can try. I was hoping a db setting would do the job. Here is my system db as it stands. Perhaps a setting I am missing and can insert?

1|volume_music|11
2|volume_ring|5
3|volume_system|7
4|volume_voice|4
5|volume_alarm|6
6|volume_notification|5
7|volume_bluetooth_sco|7
8|mode_ringer_streams_affected|174
9|mute_streams_affected|46
10|vibrate_when_ringing|0
11|dim_screen|0
13|dtmf_tone_type|0
14|hearing_aid|0
15|tty_mode|0
16|screen_brightness|102
17|screen_brightness_mode|0
18|window_animation_scale|1.0
19|transition_animation_scale|1.0
20|accelerometer_rotation|1
21|haptic_feedback_enabled|1
22|notification_light_pulse|1
23|dtmf_tone|1
24|sound_effects_enabled|1
26|lockscreen_sounds_enabled|1
27|pointer_speed|0
28|next_alarm_formatted|
29|alarm_alert|content://media/internal/audio/media/5
30|notification_sound|content://media/internal/audio/media/7
31|ringtone|content://media/internal/audio/media/9
32|volume_music_headset|10
33|volume_music_last_audible_headset|10
34|volume_music_headphone|10
35|volume_music_last_audible_headphone|10
36|time_12_24|24
37|date_format|dd-MM-yyyy
39|stay_on_while_plugged_in|1
45|screen_off_timeout|-1
like image 993
tbh1 Avatar asked Dec 02 '13 14:12

tbh1


People also ask

How do I stop my computer Screen from going to sleep?

To adjust power and sleep settings in Windows 11, select Start > Settings > System > Power & battery > Screen and sleep.

What is preventing Windows 10 from sleeping?

Peripheral Devices such as your mouse, keyboard, scanner, and network adapters can interfere with your PC power settings and prevent it from going to sleep.

How do I stop my Screen from turning off AFK?

Choose System, then Power & sleep from the right navigation menu. If you're using a laptop, click the drop-down menu under On battery power, turn off after under Screen and select Never.

How do you keep your Screen awake?

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


1 Answers

Your setting db contains default time out set by the system which is probably low so the device went to sleep immediately due to low timeout value. You can issue adb shell command to increase screen timeout.

adb shell settings put system screen_off_timeout 60000

Note: 60000 = 1 minute

You can also update setting db with the desired timeout and then push db back to device but it requires root. Above command does not require device to be rooted.

like image 94
PalFS Avatar answered Oct 04 '22 06:10

PalFS