Loading apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java +271 −7 Original line number Diff line number Diff line Loading @@ -19,24 +19,27 @@ package android.view; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import android.content.Context; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import androidx.benchmark.BenchmarkState; import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.SmallTest; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @SmallTest @LargeTest @RunWith(AndroidJUnit4.class) public class ViewConfigurationPerfTest { @Rule public final BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); private final Context mContext = getInstrumentation().getTargetContext(); @Test public void testGet_newViewConfiguration() { final BenchmarkState state = mBenchmarkRule.getState(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); Loading @@ -50,7 +53,7 @@ public class ViewConfigurationPerfTest { @Test public void testGet_cachedViewConfiguration() { final BenchmarkState state = mBenchmarkRule.getState(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure there's something cached. ViewConfiguration.get(mContext); Loading @@ -58,4 +61,265 @@ public class ViewConfigurationPerfTest { ViewConfiguration.get(mContext); } } @Test public void testGetPressedStateDuration_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getPressedStateDuration(); } } @Test public void testGetPressedStateDuration_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getPressedStateDuration(); while (state.keepRunning()) { ViewConfiguration.getPressedStateDuration(); } } @Test public void testGetTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getTapTimeout(); } } @Test public void testGetTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getTapTimeout(); } } @Test public void testGetJumpTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getJumpTapTimeout(); } } @Test public void testGetJumpTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getJumpTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getJumpTapTimeout(); } } @Test public void testGetDoubleTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDoubleTapTimeout(); } } @Test public void testGetDoubleTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDoubleTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getDoubleTapTimeout(); } } @Test public void testGetDoubleTapMinTime_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDoubleTapMinTime(); } } @Test public void testGetDoubleTapMinTime_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDoubleTapMinTime(); while (state.keepRunning()) { ViewConfiguration.getDoubleTapMinTime(); } } @Test public void testGetZoomControlsTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getZoomControlsTimeout(); } } @Test public void testGetZoomControlsTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getZoomControlsTimeout(); while (state.keepRunning()) { ViewConfiguration.getZoomControlsTimeout(); } } @Test public void testGetLongPressTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getLongPressTimeout(); } } @Test public void testGetMultiPressTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getMultiPressTimeout(); } } @Test public void testGetKeyRepeatTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getKeyRepeatTimeout(); } } @Test public void testGetKeyRepeatDelay() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getKeyRepeatDelay(); } } @Test public void testGetHoverTapSlop_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getHoverTapSlop(); } } @Test public void testGetHoverTapSlop_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getHoverTapSlop(); while (state.keepRunning()) { ViewConfiguration.getHoverTapSlop(); } } @Test public void testGetScrollFriction_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getScrollFriction(); } } @Test public void testGetScrollFriction_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getScrollFriction(); while (state.keepRunning()) { ViewConfiguration.getScrollFriction(); } } @Test public void testGetDefaultActionModeHideDuration_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDefaultActionModeHideDuration(); } } @Test public void testGetDefaultActionModeHideDuration_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDefaultActionModeHideDuration(); while (state.keepRunning()) { ViewConfiguration.getDefaultActionModeHideDuration(); } } } core/java/android/companion/virtual/flags/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -125,3 +125,11 @@ flag { description: "Show virtual devices in Settings" bug: "338974320" } flag { name: "migrate_viewconfiguration_constants_to_resources" namespace: "virtual_devices" description: "Use resources instead of constants in ViewConfiguration" is_fixed_read_only: true bug: "370928384" } core/java/android/view/ViewConfiguration.java +172 −59 File changed.Preview size limit exceeded, changes collapsed. Show changes core/res/res/values/config.xml +37 −0 Original line number Diff line number Diff line Loading @@ -3061,6 +3061,43 @@ {@link MotionEvent#ACTION_SCROLL} event. --> <dimen name="config_scrollFactor">64dp</dimen> <!-- Duration in milliseconds of the pressed state in child components. --> <integer name="config_pressedStateDurationMillis">64</integer> <!-- Duration in milliseconds we will wait to see if a touch event is a tap or a scroll. If the user does not move within this interval, it is considered to be a tap. --> <integer name="config_tapTimeoutMillis">100</integer> <!-- Duration in milliseconds we will wait to see if a touch event is a jump tap. If the user does not move within this interval, it is considered to be a tap. --> <integer name="config_jumpTapTimeoutMillis">500</integer> <!-- Duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered a double-tap. --> <integer name="config_doubleTapTimeoutMillis">300</integer> <!-- Minimum duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered a double-tap. --> <integer name="config_doubleTapMinTimeMillis">40</integer> <!-- Maximum duration in milliseconds between a touch pad touch and release for a given touch to be considered a tap (click) as opposed to a hover movement gesture. --> <integer name="config_hoverTapTimeoutMillis">150</integer> <!-- The amount of time in milliseconds that the zoom controls should be displayed on the screen. --> <integer name="config_zoomControlsTimeoutMillis">3000</integer> <!-- Default duration in milliseconds for {@link ActionMode#hide(long)}. --> <integer name="config_defaultActionModeHideDurationMillis">2000</integer> <!-- Maximum distance in pixels that a touch pad touch can move before being released for it to be considered a tap (click) as opposed to a hover movement gesture. --> <dimen name="config_hoverTapSlop">20px</dimen> <!-- The amount of friction applied to scrolls and flings. --> <item name="config_scrollFriction" format="float" type="dimen">0.015</item> <!-- Maximum number of grid columns permitted in the ResolverActivity used for picking activities to handle an intent. --> <integer name="config_maxResolverActivityColumns">3</integer> Loading core/res/res/values/symbols.xml +11 −0 Original line number Diff line number Diff line Loading @@ -4153,6 +4153,17 @@ <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamilyMedium" /> <java-symbol type="integer" name="config_pressedStateDurationMillis" /> <java-symbol type="integer" name="config_tapTimeoutMillis" /> <java-symbol type="integer" name="config_jumpTapTimeoutMillis" /> <java-symbol type="integer" name="config_doubleTapTimeoutMillis" /> <java-symbol type="integer" name="config_doubleTapMinTimeMillis" /> <java-symbol type="integer" name="config_hoverTapTimeoutMillis" /> <java-symbol type="integer" name="config_zoomControlsTimeoutMillis" /> <java-symbol type="integer" name="config_defaultActionModeHideDurationMillis" /> <java-symbol type="dimen" name="config_hoverTapSlop" /> <java-symbol type="dimen" name="config_scrollFriction" /> <java-symbol type="drawable" name="stat_sys_vitals" /> <java-symbol type="color" name="text_color_primary" /> Loading Loading
apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java +271 −7 Original line number Diff line number Diff line Loading @@ -19,24 +19,27 @@ package android.view; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import android.content.Context; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import androidx.benchmark.BenchmarkState; import androidx.benchmark.junit4.BenchmarkRule; import androidx.test.filters.SmallTest; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @SmallTest @LargeTest @RunWith(AndroidJUnit4.class) public class ViewConfigurationPerfTest { @Rule public final BenchmarkRule mBenchmarkRule = new BenchmarkRule(); public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); private final Context mContext = getInstrumentation().getTargetContext(); @Test public void testGet_newViewConfiguration() { final BenchmarkState state = mBenchmarkRule.getState(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); Loading @@ -50,7 +53,7 @@ public class ViewConfigurationPerfTest { @Test public void testGet_cachedViewConfiguration() { final BenchmarkState state = mBenchmarkRule.getState(); final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure there's something cached. ViewConfiguration.get(mContext); Loading @@ -58,4 +61,265 @@ public class ViewConfigurationPerfTest { ViewConfiguration.get(mContext); } } @Test public void testGetPressedStateDuration_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getPressedStateDuration(); } } @Test public void testGetPressedStateDuration_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getPressedStateDuration(); while (state.keepRunning()) { ViewConfiguration.getPressedStateDuration(); } } @Test public void testGetTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getTapTimeout(); } } @Test public void testGetTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getTapTimeout(); } } @Test public void testGetJumpTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getJumpTapTimeout(); } } @Test public void testGetJumpTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getJumpTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getJumpTapTimeout(); } } @Test public void testGetDoubleTapTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDoubleTapTimeout(); } } @Test public void testGetDoubleTapTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDoubleTapTimeout(); while (state.keepRunning()) { ViewConfiguration.getDoubleTapTimeout(); } } @Test public void testGetDoubleTapMinTime_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDoubleTapMinTime(); } } @Test public void testGetDoubleTapMinTime_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDoubleTapMinTime(); while (state.keepRunning()) { ViewConfiguration.getDoubleTapMinTime(); } } @Test public void testGetZoomControlsTimeout_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getZoomControlsTimeout(); } } @Test public void testGetZoomControlsTimeout_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getZoomControlsTimeout(); while (state.keepRunning()) { ViewConfiguration.getZoomControlsTimeout(); } } @Test public void testGetLongPressTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getLongPressTimeout(); } } @Test public void testGetMultiPressTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getMultiPressTimeout(); } } @Test public void testGetKeyRepeatTimeout() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getKeyRepeatTimeout(); } } @Test public void testGetKeyRepeatDelay() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { ViewConfiguration.getKeyRepeatDelay(); } } @Test public void testGetHoverTapSlop_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getHoverTapSlop(); } } @Test public void testGetHoverTapSlop_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getHoverTapSlop(); while (state.keepRunning()) { ViewConfiguration.getHoverTapSlop(); } } @Test public void testGetScrollFriction_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getScrollFriction(); } } @Test public void testGetScrollFriction_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getScrollFriction(); while (state.keepRunning()) { ViewConfiguration.getScrollFriction(); } } @Test public void testGetDefaultActionModeHideDuration_unCached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { state.pauseTiming(); // Reset any caches. ViewConfiguration.resetCacheForTesting(); state.resumeTiming(); ViewConfiguration.getDefaultActionModeHideDuration(); } } @Test public void testGetDefaultActionModeHideDuration_cached() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); // Do `get` once to make sure the value gets cached. ViewConfiguration.getDefaultActionModeHideDuration(); while (state.keepRunning()) { ViewConfiguration.getDefaultActionModeHideDuration(); } } }
core/java/android/companion/virtual/flags/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -125,3 +125,11 @@ flag { description: "Show virtual devices in Settings" bug: "338974320" } flag { name: "migrate_viewconfiguration_constants_to_resources" namespace: "virtual_devices" description: "Use resources instead of constants in ViewConfiguration" is_fixed_read_only: true bug: "370928384" }
core/java/android/view/ViewConfiguration.java +172 −59 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/res/res/values/config.xml +37 −0 Original line number Diff line number Diff line Loading @@ -3061,6 +3061,43 @@ {@link MotionEvent#ACTION_SCROLL} event. --> <dimen name="config_scrollFactor">64dp</dimen> <!-- Duration in milliseconds of the pressed state in child components. --> <integer name="config_pressedStateDurationMillis">64</integer> <!-- Duration in milliseconds we will wait to see if a touch event is a tap or a scroll. If the user does not move within this interval, it is considered to be a tap. --> <integer name="config_tapTimeoutMillis">100</integer> <!-- Duration in milliseconds we will wait to see if a touch event is a jump tap. If the user does not move within this interval, it is considered to be a tap. --> <integer name="config_jumpTapTimeoutMillis">500</integer> <!-- Duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered a double-tap. --> <integer name="config_doubleTapTimeoutMillis">300</integer> <!-- Minimum duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered a double-tap. --> <integer name="config_doubleTapMinTimeMillis">40</integer> <!-- Maximum duration in milliseconds between a touch pad touch and release for a given touch to be considered a tap (click) as opposed to a hover movement gesture. --> <integer name="config_hoverTapTimeoutMillis">150</integer> <!-- The amount of time in milliseconds that the zoom controls should be displayed on the screen. --> <integer name="config_zoomControlsTimeoutMillis">3000</integer> <!-- Default duration in milliseconds for {@link ActionMode#hide(long)}. --> <integer name="config_defaultActionModeHideDurationMillis">2000</integer> <!-- Maximum distance in pixels that a touch pad touch can move before being released for it to be considered a tap (click) as opposed to a hover movement gesture. --> <dimen name="config_hoverTapSlop">20px</dimen> <!-- The amount of friction applied to scrolls and flings. --> <item name="config_scrollFriction" format="float" type="dimen">0.015</item> <!-- Maximum number of grid columns permitted in the ResolverActivity used for picking activities to handle an intent. --> <integer name="config_maxResolverActivityColumns">3</integer> Loading
core/res/res/values/symbols.xml +11 −0 Original line number Diff line number Diff line Loading @@ -4153,6 +4153,17 @@ <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamilyMedium" /> <java-symbol type="integer" name="config_pressedStateDurationMillis" /> <java-symbol type="integer" name="config_tapTimeoutMillis" /> <java-symbol type="integer" name="config_jumpTapTimeoutMillis" /> <java-symbol type="integer" name="config_doubleTapTimeoutMillis" /> <java-symbol type="integer" name="config_doubleTapMinTimeMillis" /> <java-symbol type="integer" name="config_hoverTapTimeoutMillis" /> <java-symbol type="integer" name="config_zoomControlsTimeoutMillis" /> <java-symbol type="integer" name="config_defaultActionModeHideDurationMillis" /> <java-symbol type="dimen" name="config_hoverTapSlop" /> <java-symbol type="dimen" name="config_scrollFriction" /> <java-symbol type="drawable" name="stat_sys_vitals" /> <java-symbol type="color" name="text_color_primary" /> Loading