diff options
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/flags/refresh_rate_flags.aconfig | 8 | ||||
| -rw-r--r-- | core/tests/coretests/src/android/view/ViewFrameRateTest.java | 62 |
3 files changed, 76 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 0ca442d66e6f..733ecadf4951 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -118,6 +118,7 @@ import static android.view.flags.Flags.disableDrawWakeLock; import static android.view.flags.Flags.sensitiveContentAppProtection; import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix; import static android.view.flags.Flags.toolkitFrameRateFunctionEnablingReadOnly; +import static android.view.flags.Flags.toolkitFrameRateTouchBoost25q1; import static android.view.flags.Flags.toolkitFrameRateTypingReadOnly; import static android.view.flags.Flags.toolkitFrameRateVelocityMappingReadOnly; import static android.view.flags.Flags.toolkitFrameRateViewEnablingReadOnly; @@ -13045,6 +13046,11 @@ public final class ViewRootImpl implements ViewParent, boolean desiredAction = motionEventAction != MotionEvent.ACTION_OUTSIDE; boolean undesiredType = windowType == TYPE_INPUT_METHOD && sToolkitFrameRateTypingReadOnlyFlagValue; + + // don't suppress touch boost for TYPE_INPUT_METHOD in ViewRootImpl + if (toolkitFrameRateTouchBoost25q1()) { + return desiredAction && shouldEnableDvrr() && getFrameRateBoostOnTouchEnabled(); + } // use toolkitSetFrameRate flag to gate the change return desiredAction && !undesiredType && shouldEnableDvrr() && getFrameRateBoostOnTouchEnabled(); diff --git a/core/java/android/view/flags/refresh_rate_flags.aconfig b/core/java/android/view/flags/refresh_rate_flags.aconfig index 7b049278731d..c31df73fbeae 100644 --- a/core/java/android/view/flags/refresh_rate_flags.aconfig +++ b/core/java/android/view/flags/refresh_rate_flags.aconfig @@ -119,4 +119,12 @@ flag { description: "Feature flag to enable the fix for applyLegacyAnimation for VRR V QPR2" bug: "335874198" is_fixed_read_only: true +} + +flag { + name: "toolkit_frame_rate_touch_boost_25q1" + namespace: "toolkit" + description: "Feature flag to not suppress touch boost for specific windowTypes in VRR V QPR2" + bug: "335874198" + is_exported: true }
\ No newline at end of file diff --git a/core/tests/coretests/src/android/view/ViewFrameRateTest.java b/core/tests/coretests/src/android/view/ViewFrameRateTest.java index c98142357d69..483ebc2c8649 100644 --- a/core/tests/coretests/src/android/view/ViewFrameRateTest.java +++ b/core/tests/coretests/src/android/view/ViewFrameRateTest.java @@ -24,6 +24,7 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY; +import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_TOUCH_BOOST_25Q1; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY; import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY; import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API; @@ -118,6 +119,67 @@ public class ViewFrameRateTest { } @Test + @RequiresFlagsEnabled(FLAG_TOOLKIT_FRAME_RATE_TOUCH_BOOST_25Q1) + public void shouldNotSuppressTouchBoost() throws Throwable { + if (!ViewProperties.vrr_enabled().orElse(true)) { + return; + } + + mActivityRule.runOnUiThread(() -> { + ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); + layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; + layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; + mMovingView.setLayoutParams(layoutParams); + mMovingView.setOnClickListener((v) -> {}); + }); + waitForFrameRateCategoryToSettle(); + + int[] position = new int[2]; + mActivityRule.runOnUiThread(() -> { + mMovingView.getLocationOnScreen(position); + position[0] += mMovingView.getWidth() / 2; + position[1] += mMovingView.getHeight() / 2; + }); + final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + + // update the window type to TYPE_INPUT_METHOD + int windowType = mViewRoot.mWindowAttributes.type; + final WindowManager.LayoutParams attrs = mViewRoot.mWindowAttributes; + attrs.type = TYPE_INPUT_METHOD; + instrumentation.runOnMainSync(() -> { + mViewRoot.setLayoutParams(attrs, false); + }); + instrumentation.waitForIdleSync(); + + final WindowManager.LayoutParams newAttrs = mViewRoot.mWindowAttributes; + assertTrue(newAttrs.type == TYPE_INPUT_METHOD); + + long now = SystemClock.uptimeMillis(); + MotionEvent down = MotionEvent.obtain( + now, // downTime + now, // eventTime + MotionEvent.ACTION_DOWN, // action + position[0], // x + position[1], // y + 0 // metaState + ); + down.setSource(InputDevice.SOURCE_TOUCHSCREEN); + instrumentation.sendPointerSync(down); + down.recycle(); + + // should have touch boost + assertTrue(mViewRoot.getIsTouchBoosting()); + + // Reset the window type back to the original one. + newAttrs.type = windowType; + instrumentation.runOnMainSync(() -> { + mViewRoot.setLayoutParams(newAttrs, false); + }); + instrumentation.waitForIdleSync(); + assertTrue(mViewRoot.mWindowAttributes.type == windowType); + } + + @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY) public void inputMethodWithContentMoves() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { |