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

Commit 2fea7634 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Do not invalidate isInteractive cache on power group events.

ag/29700291 fixed a bug with the cache invalidation as it didn't take
into account individual power group wakefulness changes. However, it
also invalidated the cache for any power group event, which was
unnecessary - when a power group is added, changed or removed, the
cache should be invalidated only if the global wakefulness has
changed. So reverting that part of the CL.

Fix: 372215504
Test: presubmit
Flag: EXEMPT bugfix
Change-Id: I52a135a02008ac50c403715729960b9887a581c7
parent 6242f19b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2332,6 +2332,8 @@ public final class PowerManagerService extends SystemService
        Trace.traceBegin(Trace.TRACE_TAG_POWER, traceMethodName);
        try {
            // Phase 2: Handle wakefulness change and bookkeeping.
            // Under lock, invalidate before set ensures caches won't return stale values.
            mInjector.invalidateIsInteractiveCaches();
            mWakefulnessRaw = newWakefulness;
            mWakefulnessChanging = true;
            mDirty |= DIRTY_WAKEFULNESS;
@@ -2429,7 +2431,6 @@ public final class PowerManagerService extends SystemService
    void onPowerGroupEventLocked(int event, PowerGroup powerGroup) {
        mWakefulnessChanging = true;
        mDirty |= DIRTY_WAKEFULNESS;
        mInjector.invalidateIsInteractiveCaches();
        final int groupId = powerGroup.getGroupId();
        if (event == DisplayGroupPowerChangeListener.DISPLAY_GROUP_REMOVED) {
            mPowerGroups.delete(groupId);
+2 −4
Original line number Diff line number Diff line
@@ -2705,12 +2705,11 @@ public class PowerManagerServiceTest {
        verify(mInvalidateInteractiveCachesMock).call();

        listener.get().onDisplayGroupAdded(nonDefaultDisplayGroupId);
        verify(mInvalidateInteractiveCachesMock, times(2)).call();

        mService.setWakefulnessLocked(Display.DEFAULT_DISPLAY_GROUP, WAKEFULNESS_ASLEEP,
                mClock.now(), 0, PowerManager.GO_TO_SLEEP_REASON_APPLICATION, 0, null, null);

        verify(mInvalidateInteractiveCachesMock, times(3)).call();
        verify(mInvalidateInteractiveCachesMock, times(2)).call();
    }

    @Test
@@ -2732,12 +2731,11 @@ public class PowerManagerServiceTest {
        verify(mInvalidateInteractiveCachesMock).call();

        listener.get().onDisplayGroupAdded(nonDefaultDisplayGroupId);
        verify(mInvalidateInteractiveCachesMock, times(2)).call();

        mService.setWakefulnessLocked(nonDefaultDisplayGroupId, WAKEFULNESS_ASLEEP, mClock.now(),
                0, PowerManager.GO_TO_SLEEP_REASON_APPLICATION, 0, null, null);

        verify(mInvalidateInteractiveCachesMock, times(3)).call();
        verify(mInvalidateInteractiveCachesMock, times(2)).call();
    }

    @Test