The simplest way is to leverage the adb shell
to run settings put global theater_mode_on
.
settings put global theater_mode_on 1
will turn on theater modesettings put global theater_mode_on 0
will turn off theater mode
And the following is the java code to turn on theater mode.
Process su = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(su.getOutputStream()); os.writeBytes("settings put global theater_mode_on 1\n"); os.flush(); os.close();
So we can automated the theater mode through scripts.
Notice that the total time to get it effective is about 2 seconds, and it will pop up a long toast, followed by the dark screen. The whole takes around 10 seconds. Afterwards, if ambient mode is on, the device will get into ambient mode.