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

Commit 20c9e7aa authored by Jian-Syuan (Shane) Wong's avatar Jian-Syuan (Shane) Wong Committed by Android (Google) Code Review
Browse files

Merge "Trigger touch boost when the viewVisibility of ViewRootImpl changed" into main

parents a0a63b42 a113a835
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -3216,6 +3216,12 @@ public final class ViewRootImpl implements ViewParent,
                endDragResizing();
                destroyHardwareResources();
            }

            if (sToolkitSetFrameRateReadOnlyFlagValue && viewVisibility == View.VISIBLE) {
                // Boost frame rate when the viewVisibility becomes true.
                // This is mainly for lanuchers that lanuch new windows.
                boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME);
            }
        }

        // Non-visible windows can't hold accessibility focus.
@@ -3925,6 +3931,11 @@ public final class ViewRootImpl implements ViewParent,
                    focused.restoreDefaultFocus();
                }
            }

            if (sToolkitSetFrameRateReadOnlyFlagValue) {
                // Boost the frame rate when the ViewRootImpl first becomes available.
                boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME);
            }
        }

        final boolean changedVisibility = (viewVisibilityChanged || mFirst) && isViewVisible;
@@ -12159,6 +12170,22 @@ public final class ViewRootImpl implements ViewParent,
        return mPreferredFrameRate;
    }

    /**
     * Get the value of mIsFrameRateBoosting
     */
    @VisibleForTesting
    public boolean getIsFrameRateBoosting() {
        return mIsFrameRateBoosting;
    }

    private void boostFrameRate(int boostTimeOut) {
        mIsFrameRateBoosting = true;
        setPreferredFrameRateCategory(mPreferredFrameRateCategory);
        mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT);
        mHandler.sendEmptyMessageDelayed(MSG_TOUCH_BOOST_TIMEOUT,
                boostTimeOut);
    }

    @Override
    public boolean transferHostTouchGestureToEmbedded(
            @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) {
+7 −0
Original line number Diff line number Diff line
@@ -472,6 +472,7 @@ public class ViewRootImplTest {
     * Test the value of the frame rate cateogry based on the visibility of a view
     * Invsible: FRAME_RATE_CATEGORY_NO_PREFERENCE
     * Visible: FRAME_RATE_CATEGORY_NORMAL
     * Also, mIsFrameRateBoosting should be true when the visibility becomes visible
     */
    @Test
    @RequiresFlagsEnabled(FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY)
@@ -485,6 +486,7 @@ public class ViewRootImplTest {
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(),
                    FRAME_RATE_CATEGORY_NO_PREFERENCE);
        });
        sInstrumentation.waitForIdleSync();

        sInstrumentation.runOnMainSync(() -> {
            view.setVisibility(View.VISIBLE);
@@ -492,6 +494,11 @@ public class ViewRootImplTest {
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(),
                    FRAME_RATE_CATEGORY_NORMAL);
        });
        sInstrumentation.waitForIdleSync();

        sInstrumentation.runOnMainSync(() -> {
            assertEquals(viewRootImpl.getIsFrameRateBoosting(), true);
        });
    }

    /**