Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e5d33ef authored by Jeff Brown's avatar Jeff Brown
Browse files

Don't request traversals when updating display brightness.

Setting the display state and brightness does not require a surface
flinger transaction so don't schedule traversals unnecessarily.
They may still be scheduled as a side-effect of other operations
but only when needed.

Bug: 21296696
Change-Id: Ie264254ea1972c37319e5e5a06163d47f6689c22
parent fe4ad335
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -346,6 +346,8 @@ public final class DisplayManagerService extends SystemService {
        synchronized (mTempDisplayStateWorkQueue) {
            try {
                // Update the display state within the lock.
                // Note that we do not need to schedule traversals here although it
                // may happen as a side-effect of displays changing state.
                synchronized (mSyncRoot) {
                    if (mGlobalDisplayState == state
                            && mGlobalDisplayBrightness == brightness) {
@@ -357,8 +359,7 @@ public final class DisplayManagerService extends SystemService {
                            + ", brightness=" + brightness + ")");
                    mGlobalDisplayState = state;
                    mGlobalDisplayBrightness = brightness;
                    updateGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
                    scheduleTraversalLocked(false);
                    applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
                }

                // Setting the display power state can take hundreds of milliseconds
@@ -715,6 +716,7 @@ public final class DisplayManagerService extends SystemService {
            handleDisplayDeviceRemovedLocked(device);
        }
    }

    private void handleDisplayDeviceRemovedLocked(DisplayDevice device) {
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        if (!mDisplayDevices.remove(device)) {
@@ -729,7 +731,7 @@ public final class DisplayManagerService extends SystemService {
        scheduleTraversalLocked(false);
    }

    private void updateGlobalDisplayStateLocked(List<Runnable> workQueue) {
    private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) {
        final int count = mDisplayDevices.size();
        for (int i = 0; i < count; i++) {
            DisplayDevice device = mDisplayDevices.get(i);