diff options
| -rw-r--r-- | apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java | 278 | ||||
| -rw-r--r-- | core/java/android/companion/virtual/flags/flags.aconfig | 8 | ||||
| -rw-r--r-- | core/java/android/view/ViewConfiguration.java | 231 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 37 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 11 |
5 files changed, 66 insertions, 499 deletions
diff --git a/apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java b/apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java index 8e3ed6d9931c..7a7250b9e910 100644 --- a/apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java +++ b/apct-tests/perftests/core/src/android/view/ViewConfigurationPerfTest.java @@ -19,27 +19,24 @@ 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.test.filters.LargeTest; -import androidx.test.runner.AndroidJUnit4; +import androidx.benchmark.BenchmarkState; +import androidx.benchmark.junit4.BenchmarkRule; +import androidx.test.filters.SmallTest; import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; -@LargeTest -@RunWith(AndroidJUnit4.class) +@SmallTest public class ViewConfigurationPerfTest { @Rule - public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + public final BenchmarkRule mBenchmarkRule = new BenchmarkRule(); private final Context mContext = getInstrumentation().getTargetContext(); @Test public void testGet_newViewConfiguration() { - final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); while (state.keepRunning()) { state.pauseTiming(); @@ -53,7 +50,7 @@ public class ViewConfigurationPerfTest { @Test public void testGet_cachedViewConfiguration() { - final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final BenchmarkState state = mBenchmarkRule.getState(); // Do `get` once to make sure there's something cached. ViewConfiguration.get(mContext); @@ -61,265 +58,4 @@ 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(); - } - } } diff --git a/core/java/android/companion/virtual/flags/flags.aconfig b/core/java/android/companion/virtual/flags/flags.aconfig index c3dc257e6535..fcdb02ab5da2 100644 --- a/core/java/android/companion/virtual/flags/flags.aconfig +++ b/core/java/android/companion/virtual/flags/flags.aconfig @@ -125,11 +125,3 @@ 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" -} diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 2895bf3f846a..9e97a8eb58aa 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -21,9 +21,7 @@ import android.annotation.NonNull; import android.annotation.TestApi; import android.annotation.UiContext; import android.app.Activity; -import android.app.ActivityThread; import android.app.AppGlobals; -import android.app.Application; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Configuration; @@ -41,13 +39,14 @@ import android.util.SparseArray; import android.util.TypedValue; import android.view.flags.Flags; -import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; /** * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. */ public class ViewConfiguration { + private static final String TAG = "ViewConfiguration"; + /** * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in * dips @@ -350,8 +349,6 @@ public class ViewConfiguration { */ private static final int SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND = 500; - private static ResourceCache sResourceCache = new ResourceCache(); - private final boolean mConstructedWithContext; private final int mEdgeSlop; private final int mFadingEdgeLength; @@ -377,6 +374,7 @@ public class ViewConfiguration { private final int mOverscrollDistance; private final int mOverflingDistance; private final boolean mViewTouchScreenHapticScrollFeedbackEnabled; + @UnsupportedAppUsage private final boolean mFadingMarqueeEnabled; private final long mGlobalActionsKeyTimeout; private final float mVerticalScrollFactor; @@ -470,12 +468,14 @@ public class ViewConfiguration { mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f); mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f); - mScrollbarSize = res.getDimensionPixelSize(R.dimen.config_scrollbarSize); + mScrollbarSize = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_scrollbarSize); mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f); mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f); final TypedValue multiplierValue = new TypedValue(); - res.getValue(R.dimen.config_ambiguousGestureMultiplier, + res.getValue( + com.android.internal.R.dimen.config_ambiguousGestureMultiplier, multiplierValue, true /*resolveRefs*/); mAmbiguousGestureMultiplier = Math.max(1.0f, multiplierValue.getFloat()); @@ -488,7 +488,8 @@ public class ViewConfiguration { mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f); if (!sHasPermanentMenuKeySet) { - final int configVal = res.getInteger(R.integer.config_overrideHasPermanentMenuKey); + final int configVal = res.getInteger( + com.android.internal.R.integer.config_overrideHasPermanentMenuKey); switch (configVal) { default: @@ -515,27 +516,32 @@ public class ViewConfiguration { } } - mFadingMarqueeEnabled = res.getBoolean(R.bool.config_ui_enableFadingMarquee); - mTouchSlop = res.getDimensionPixelSize(R.dimen.config_viewConfigurationTouchSlop); + mFadingMarqueeEnabled = res.getBoolean( + com.android.internal.R.bool.config_ui_enableFadingMarquee); + mTouchSlop = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewConfigurationTouchSlop); mHandwritingSlop = res.getDimensionPixelSize( - R.dimen.config_viewConfigurationHandwritingSlop); - mHoverSlop = res.getDimensionPixelSize(R.dimen.config_viewConfigurationHoverSlop); + com.android.internal.R.dimen.config_viewConfigurationHandwritingSlop); + mHoverSlop = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewConfigurationHoverSlop); mMinScrollbarTouchTarget = res.getDimensionPixelSize( - R.dimen.config_minScrollbarTouchTarget); + com.android.internal.R.dimen.config_minScrollbarTouchTarget); mPagingTouchSlop = mTouchSlop * 2; mDoubleTapTouchSlop = mTouchSlop; mHandwritingGestureLineMargin = res.getDimensionPixelSize( - R.dimen.config_viewConfigurationHandwritingGestureLineMargin); + com.android.internal.R.dimen.config_viewConfigurationHandwritingGestureLineMargin); - mMinimumFlingVelocity = res.getDimensionPixelSize(R.dimen.config_viewMinFlingVelocity); - mMaximumFlingVelocity = res.getDimensionPixelSize(R.dimen.config_viewMaxFlingVelocity); + mMinimumFlingVelocity = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewMinFlingVelocity); + mMaximumFlingVelocity = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_viewMaxFlingVelocity); int configMinRotaryEncoderFlingVelocity = res.getDimensionPixelSize( - R.dimen.config_viewMinRotaryEncoderFlingVelocity); + com.android.internal.R.dimen.config_viewMinRotaryEncoderFlingVelocity); int configMaxRotaryEncoderFlingVelocity = res.getDimensionPixelSize( - R.dimen.config_viewMaxRotaryEncoderFlingVelocity); + com.android.internal.R.dimen.config_viewMaxRotaryEncoderFlingVelocity); if (configMinRotaryEncoderFlingVelocity < 0 || configMaxRotaryEncoderFlingVelocity < 0) { mMinimumRotaryEncoderFlingVelocity = NO_FLING_MIN_VELOCITY; mMaximumRotaryEncoderFlingVelocity = NO_FLING_MAX_VELOCITY; @@ -545,7 +551,8 @@ public class ViewConfiguration { } int configRotaryEncoderHapticScrollFeedbackTickIntervalPixels = - res.getDimensionPixelSize(R.dimen + res.getDimensionPixelSize( + com.android.internal.R.dimen .config_rotaryEncoderAxisScrollTickInterval); mRotaryEncoderHapticScrollFeedbackTickIntervalPixels = configRotaryEncoderHapticScrollFeedbackTickIntervalPixels > 0 @@ -553,31 +560,41 @@ public class ViewConfiguration { : NO_HAPTIC_SCROLL_TICK_INTERVAL; mRotaryEncoderHapticScrollFeedbackEnabled = - res.getBoolean(R.bool + res.getBoolean( + com.android.internal.R.bool .config_viewRotaryEncoderHapticScrollFedbackEnabled); - mGlobalActionsKeyTimeout = res.getInteger(R.integer.config_globalActionsKeyTimeout); + mGlobalActionsKeyTimeout = res.getInteger( + com.android.internal.R.integer.config_globalActionsKeyTimeout); - mHorizontalScrollFactor = res.getDimensionPixelSize(R.dimen.config_horizontalScrollFactor); - mVerticalScrollFactor = res.getDimensionPixelSize(R.dimen.config_verticalScrollFactor); + mHorizontalScrollFactor = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_horizontalScrollFactor); + mVerticalScrollFactor = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_verticalScrollFactor); mShowMenuShortcutsWhenKeyboardPresent = res.getBoolean( - R.bool.config_showMenuShortcutsWhenKeyboardPresent); + com.android.internal.R.bool.config_showMenuShortcutsWhenKeyboardPresent); - mMinScalingSpan = res.getDimensionPixelSize(R.dimen.config_minScalingSpan); + mMinScalingSpan = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_minScalingSpan); - mScreenshotChordKeyTimeout = res.getInteger(R.integer.config_screenshotChordKeyTimeout); + mScreenshotChordKeyTimeout = res.getInteger( + com.android.internal.R.integer.config_screenshotChordKeyTimeout); mSmartSelectionInitializedTimeout = res.getInteger( - R.integer.config_smartSelectionInitializedTimeoutMillis); + com.android.internal.R.integer.config_smartSelectionInitializedTimeoutMillis); mSmartSelectionInitializingTimeout = res.getInteger( - R.integer.config_smartSelectionInitializingTimeoutMillis); - mPreferKeepClearForFocusEnabled = res.getBoolean(R.bool.config_preferKeepClearForFocus); + com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis); + mPreferKeepClearForFocusEnabled = res.getBoolean( + com.android.internal.R.bool.config_preferKeepClearForFocus); mViewBasedRotaryEncoderScrollHapticsEnabledConfig = - res.getBoolean(R.bool.config_viewBasedRotaryEncoderHapticsEnabled); + res.getBoolean( + com.android.internal.R.bool.config_viewBasedRotaryEncoderHapticsEnabled); mViewTouchScreenHapticScrollFeedbackEnabled = Flags.enableScrollFeedbackForTouch() - ? res.getBoolean(R.bool.config_viewTouchScreenHapticScrollFeedbackEnabled) + ? res.getBoolean( + com.android.internal.R.bool + .config_viewTouchScreenHapticScrollFeedbackEnabled) : false; } @@ -615,7 +632,6 @@ public class ViewConfiguration { @VisibleForTesting public static void resetCacheForTesting() { sConfigurations.clear(); - sResourceCache = new ResourceCache(); } /** @@ -691,7 +707,7 @@ public class ViewConfiguration { * components. */ public static int getPressedStateDuration() { - return sResourceCache.getPressedStateDuration(); + return PRESSED_STATE_DURATION; } /** @@ -736,7 +752,7 @@ public class ViewConfiguration { * considered to be a tap. */ public static int getTapTimeout() { - return sResourceCache.getTapTimeout(); + return TAP_TIMEOUT; } /** @@ -745,7 +761,7 @@ public class ViewConfiguration { * considered to be a tap. */ public static int getJumpTapTimeout() { - return sResourceCache.getJumpTapTimeout(); + return JUMP_TAP_TIMEOUT; } /** @@ -754,7 +770,7 @@ public class ViewConfiguration { * double-tap. */ public static int getDoubleTapTimeout() { - return sResourceCache.getDoubleTapTimeout(); + return DOUBLE_TAP_TIMEOUT; } /** @@ -766,7 +782,7 @@ public class ViewConfiguration { */ @UnsupportedAppUsage public static int getDoubleTapMinTime() { - return sResourceCache.getDoubleTapMinTime(); + return DOUBLE_TAP_MIN_TIME; } /** @@ -776,7 +792,7 @@ public class ViewConfiguration { * @hide */ public static int getHoverTapTimeout() { - return sResourceCache.getHoverTapTimeout(); + return HOVER_TAP_TIMEOUT; } /** @@ -787,7 +803,7 @@ public class ViewConfiguration { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static int getHoverTapSlop() { - return sResourceCache.getHoverTapSlop(); + return HOVER_TAP_SLOP; } /** @@ -1028,7 +1044,7 @@ public class ViewConfiguration { * in milliseconds. */ public static long getZoomControlsTimeout() { - return sResourceCache.getZoomControlsTimeout(); + return ZOOM_CONTROLS_TIMEOUT; } /** @@ -1097,14 +1113,14 @@ public class ViewConfiguration { * friction. */ public static float getScrollFriction() { - return sResourceCache.getScrollFriction(); + return SCROLL_FRICTION; } /** * @return the default duration in milliseconds for {@link ActionMode#hide(long)}. */ public static long getDefaultActionModeHideDuration() { - return sResourceCache.getDefaultActionModeHideDuration(); + return ACTION_MODE_HIDE_DURATION_DEFAULT; } /** @@ -1455,137 +1471,8 @@ public class ViewConfiguration { return HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT; } - private static int getDisplayDensity(Context context) { + private static final int getDisplayDensity(Context context) { final DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return (int) (100.0f * metrics.density); } - - /** - * Fetches resource values statically and caches them locally for fast lookup. Note that these - * values will not be updated during the lifetime of a process, even if resource overlays are - * applied. - */ - private static final class ResourceCache { - - private int mPressedStateDuration = -1; - private int mTapTimeout = -1; - private int mJumpTapTimeout = -1; - private int mDoubleTapTimeout = -1; - private int mDoubleTapMinTime = -1; - private int mHoverTapTimeout = -1; - private int mHoverTapSlop = -1; - private long mZoomControlsTimeout = -1L; - private float mScrollFriction = -1f; - private long mDefaultActionModeHideDuration = -1L; - - public int getPressedStateDuration() { - if (mPressedStateDuration < 0) { - Resources resources = getCurrentResources(); - mPressedStateDuration = resources != null - ? resources.getInteger(R.integer.config_pressedStateDurationMillis) - : PRESSED_STATE_DURATION; - } - return mPressedStateDuration; - } - - public int getTapTimeout() { - if (mTapTimeout < 0) { - Resources resources = getCurrentResources(); - mTapTimeout = resources != null - ? resources.getInteger(R.integer.config_tapTimeoutMillis) - : TAP_TIMEOUT; - } - return mTapTimeout; - } - - public int getJumpTapTimeout() { - if (mJumpTapTimeout < 0) { - Resources resources = getCurrentResources(); - mJumpTapTimeout = resources != null - ? resources.getInteger(R.integer.config_jumpTapTimeoutMillis) - : JUMP_TAP_TIMEOUT; - } - return mJumpTapTimeout; - } - - public int getDoubleTapTimeout() { - if (mDoubleTapTimeout < 0) { - Resources resources = getCurrentResources(); - mDoubleTapTimeout = resources != null - ? resources.getInteger(R.integer.config_doubleTapTimeoutMillis) - : DOUBLE_TAP_TIMEOUT; - } - return mDoubleTapTimeout; - } - - public int getDoubleTapMinTime() { - if (mDoubleTapMinTime < 0) { - Resources resources = getCurrentResources(); - mDoubleTapMinTime = resources != null - ? resources.getInteger(R.integer.config_doubleTapMinTimeMillis) - : DOUBLE_TAP_MIN_TIME; - } - return mDoubleTapMinTime; - } - - public int getHoverTapTimeout() { - if (mHoverTapTimeout < 0) { - Resources resources = getCurrentResources(); - mHoverTapTimeout = resources != null - ? resources.getInteger(R.integer.config_hoverTapTimeoutMillis) - : HOVER_TAP_TIMEOUT; - } - return mHoverTapTimeout; - } - - public int getHoverTapSlop() { - if (mHoverTapSlop < 0) { - Resources resources = getCurrentResources(); - mHoverTapSlop = resources != null - ? resources.getDimensionPixelSize(R.dimen.config_hoverTapSlop) - : HOVER_TAP_SLOP; - } - return mHoverTapSlop; - } - - public long getZoomControlsTimeout() { - if (mZoomControlsTimeout < 0) { - Resources resources = getCurrentResources(); - mZoomControlsTimeout = resources != null - ? resources.getInteger(R.integer.config_zoomControlsTimeoutMillis) - : ZOOM_CONTROLS_TIMEOUT; - } - return mZoomControlsTimeout; - } - - public float getScrollFriction() { - if (mScrollFriction < 0) { - Resources resources = getCurrentResources(); - mScrollFriction = resources != null - ? resources.getFloat(R.dimen.config_scrollFriction) - : SCROLL_FRICTION; - } - return mScrollFriction; - } - - public long getDefaultActionModeHideDuration() { - if (mDefaultActionModeHideDuration < 0) { - Resources resources = getCurrentResources(); - mDefaultActionModeHideDuration = resources != null - ? resources.getInteger(R.integer.config_defaultActionModeHideDurationMillis) - : ACTION_MODE_HIDE_DURATION_DEFAULT; - } - return mDefaultActionModeHideDuration; - } - - private static Resources getCurrentResources() { - if (!android.companion.virtualdevice.flags.Flags - .migrateViewconfigurationConstantsToResources()) { - return null; - } - Application application = ActivityThread.currentApplication(); - Context context = application != null ? application.getApplicationContext() : null; - return context != null ? context.getResources() : null; - } - } } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 6d57427ce221..b3581d98face 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3061,43 +3061,6 @@ {@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> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index b80d1297f9d3..9393aa4b6086 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -4155,17 +4155,6 @@ <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" /> |