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

Commit 6d0488d8 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Get velocitytracker strategy from InputManager

We are already caching this value inside InputManager, so let's just use
it directly from there.

We can't get this value reliably from ViewConfiguration because we dont
have a UI context. We can't use the application context because it would
create strict mode violations.

Bug: 233112584
Test: atest BinderTests#testSwitchToOverview
Test: atest android.view.cts.VelocityTrackerTest
Change-Id: I86595fb133c298b5dd1098b58b8743bb16a2e24b
parent 5f7c816d
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package android.view;

import android.annotation.IntDef;
import android.app.ActivityThread;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.input.InputManager;
import android.os.Build;
import android.util.ArrayMap;
import android.util.Pools.SynchronizedPool;
@@ -278,9 +278,7 @@ public final class VelocityTracker {
    private VelocityTracker(@VelocityTrackerStrategy int strategy) {
        // If user has not selected a specific strategy
        if (strategy == VELOCITY_TRACKER_STRATEGY_DEFAULT) {
            final String strategyProperty = ViewConfiguration.get(
                    ActivityThread.currentActivityThread().getApplication())
                    .getVelocityTrackerStrategy();
            final String strategyProperty = InputManager.getInstance().getVelocityTrackerStrategy();
            // Check if user specified strategy by overriding system property.
            if (strategyProperty == null || strategyProperty.isEmpty()) {
                mStrategy = strategy;
+0 −13
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
@@ -353,7 +352,6 @@ public class ViewConfiguration {
    private final int mSmartSelectionInitializedTimeout;
    private final int mSmartSelectionInitializingTimeout;
    private final boolean mPreferKeepClearForFocusEnabled;
    private final String mVelocityTrackerStrategy;

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915)
    private boolean sHasPermanentMenuKey;
@@ -401,7 +399,6 @@ public class ViewConfiguration {
        mSmartSelectionInitializedTimeout = SMART_SELECTION_INITIALIZED_TIMEOUT_IN_MILLISECOND;
        mSmartSelectionInitializingTimeout = SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND;
        mPreferKeepClearForFocusEnabled = false;
        mVelocityTrackerStrategy = InputManager.getInstance().getVelocityTrackerStrategy();
    }

    /**
@@ -520,16 +517,6 @@ public class ViewConfiguration {
                com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis);
        mPreferKeepClearForFocusEnabled = res.getBoolean(
                com.android.internal.R.bool.config_preferKeepClearForFocus);

        mVelocityTrackerStrategy = InputManager.getInstance().getVelocityTrackerStrategy();
    }

    /**
     * Get the current VelocityTracker strategy
     * @hide
     */
    public String getVelocityTrackerStrategy() {
        return mVelocityTrackerStrategy;
    }

    /**