Skip to content

Commit 32dafe2

Browse files
author
Jeff Brown
committed
Reduce screen on/off latency.
Reduce latency of screen on/off and improve how it is synchronized with backlight changes. Screen state changes are no longer posted to vsync which should save time. What's more, the state change occurs on a separate thread so we no longer run the risk of blocking the Looper for a long time while waiting for the screen to turn on or off. Bug: 7382919 Bug: 7139924 Change-Id: I375950d1b07e22fcb94efb82892fd817e2f780dc
1 parent 9bef329 commit 32dafe2

File tree

4 files changed

+218
-201
lines changed

4 files changed

+218
-201
lines changed

services/java/com/android/server/power/DisplayPowerController.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import android.hardware.SensorManager;
3131
import android.hardware.SystemSensorManager;
3232
import android.hardware.display.DisplayManager;
33-
import android.os.AsyncTask;
3433
import android.os.Handler;
3534
import android.os.Looper;
3635
import android.os.Message;
@@ -44,7 +43,6 @@
4443
import android.view.Display;
4544

4645
import java.io.PrintWriter;
47-
import java.util.concurrent.Executor;
4846

4947
/**
5048
* Controls the power state of the display.
@@ -161,9 +159,6 @@ final class DisplayPowerController {
161159
// Notifier for sending asynchronous notifications.
162160
private final Notifier mNotifier;
163161

164-
// A suspend blocker.
165-
private final SuspendBlocker mSuspendBlocker;
166-
167162
// The display blanker.
168163
private final DisplayBlanker mDisplayBlanker;
169164

@@ -339,12 +334,11 @@ final class DisplayPowerController {
339334
* Creates the display power controller.
340335
*/
341336
public DisplayPowerController(Looper looper, Context context, Notifier notifier,
342-
LightsService lights, TwilightService twilight, SuspendBlocker suspendBlocker,
337+
LightsService lights, TwilightService twilight,
343338
DisplayBlanker displayBlanker,
344339
Callbacks callbacks, Handler callbackHandler) {
345340
mHandler = new DisplayControllerHandler(looper);
346341
mNotifier = notifier;
347-
mSuspendBlocker = suspendBlocker;
348342
mDisplayBlanker = displayBlanker;
349343
mCallbacks = callbacks;
350344
mCallbackHandler = callbackHandler;
@@ -513,14 +507,10 @@ private void sendUpdatePowerStateLocked() {
513507
}
514508

515509
private void initialize() {
516-
final Executor executor = AsyncTask.THREAD_POOL_EXECUTOR;
517510
Display display = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
518511
mPowerState = new DisplayPowerState(
519-
new ElectronBeam(display),
520-
new PhotonicModulator(executor,
521-
mLights.getLight(LightsService.LIGHT_ID_BACKLIGHT),
522-
mSuspendBlocker),
523-
mDisplayBlanker);
512+
new ElectronBeam(display), mDisplayBlanker,
513+
mLights.getLight(LightsService.LIGHT_ID_BACKLIGHT));
524514

525515
mElectronBeamOnAnimator = ObjectAnimator.ofFloat(
526516
mPowerState, DisplayPowerState.ELECTRON_BEAM_LEVEL, 0.0f, 1.0f);

0 commit comments

Comments
 (0)