Loading core/java/android/view/VelocityTracker.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,10 +16,17 @@ package android.view; import static android.Manifest.permission.READ_DEVICE_CONFIG; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.provider.DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT; import android.annotation.IntDef; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.sysprop.InputProperties; import android.os.Process; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.util.ArrayMap; import android.util.Pools.SynchronizedPool; Loading Loading @@ -171,6 +178,9 @@ public final class VelocityTracker { }) public @interface VelocityTrackerStrategy {} // Feature flag name for the strategy to be used in VelocityTracker private static final String VELOCITYTRACKER_STRATEGY = "velocitytracker_strategy"; private long mPtr; @VelocityTrackerStrategy private final int mStrategy; Loading Loading @@ -275,11 +285,22 @@ public final class VelocityTracker { return mStrategy; } @Nullable // Read the VelocityTracker strategy property from DeviceConfig private static String readStrategyProperty() { if (PermissionManager.checkPermission( READ_DEVICE_CONFIG, Process.myPid(), Process.myUid()) == PERMISSION_GRANTED) { return DeviceConfig.getProperty(NAMESPACE_INPUT_NATIVE_BOOT, VELOCITYTRACKER_STRATEGY); } // The process using VelocityTracker can't read the config. return null; } private VelocityTracker(@VelocityTrackerStrategy int strategy) { // If user has not selected a specific strategy if (strategy == VELOCITY_TRACKER_STRATEGY_DEFAULT) { // Check if user specified strategy by overriding system property. String strategyProperty = InputProperties.velocitytracker_strategy().orElse(null); final String strategyProperty = readStrategyProperty(); if (strategyProperty == null || strategyProperty.isEmpty()) { mStrategy = strategy; } else { Loading services/core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,7 @@ cc_defaults { "android.system.suspend.control-V1-cpp", "android.system.suspend.control.internal-cpp", "android.system.suspend-V1-ndk", "server_configurable_flags", "service.incremental", ], Loading services/core/jni/com_android_server_input_InputManagerService.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #include <nativehelper/ScopedLocalRef.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <nativehelper/ScopedUtfChars.h> #include <server_configurable_flags/get_flags.h> #include <ui/Region.h> #include <utils/Log.h> #include <utils/Looper.h> Loading Loading @@ -87,6 +88,13 @@ namespace android { // where the speed ranges from -7 to + 7 and is supplied by the user. static const float POINTER_SPEED_EXPONENT = 1.0f / 4; // Category (=namespace) name for the input settings that are applied at boot time static const char* INPUT_NATIVE_BOOT = "input_native_boot"; /** * Feature flag name. This flag determines which VelocityTracker strategy is used by default. */ static const char* VELOCITYTRACKER_STRATEGY = "velocitytracker_strategy"; static struct { jclass clazz; jmethodID notifyConfigurationChanged; Loading Loading @@ -2125,8 +2133,10 @@ static void nativeReloadDeviceAliases(JNIEnv* /* env */, static std::string dumpInputProperties() { std::string out = "Input properties:\n"; const std::string strategy = sysprop::InputProperties::velocitytracker_strategy().value_or("default"); out += " persist.input.velocitytracker.strategy = " + strategy + "\n"; server_configurable_flags::GetServerConfigurableFlag(INPUT_NATIVE_BOOT, VELOCITYTRACKER_STRATEGY, "default"); out += " velocitytracker_strategy (flag value) = " + strategy + "\n"; out += "\n"; return out; } Loading Loading
core/java/android/view/VelocityTracker.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,10 +16,17 @@ package android.view; import static android.Manifest.permission.READ_DEVICE_CONFIG; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.provider.DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT; import android.annotation.IntDef; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.sysprop.InputProperties; import android.os.Process; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.util.ArrayMap; import android.util.Pools.SynchronizedPool; Loading Loading @@ -171,6 +178,9 @@ public final class VelocityTracker { }) public @interface VelocityTrackerStrategy {} // Feature flag name for the strategy to be used in VelocityTracker private static final String VELOCITYTRACKER_STRATEGY = "velocitytracker_strategy"; private long mPtr; @VelocityTrackerStrategy private final int mStrategy; Loading Loading @@ -275,11 +285,22 @@ public final class VelocityTracker { return mStrategy; } @Nullable // Read the VelocityTracker strategy property from DeviceConfig private static String readStrategyProperty() { if (PermissionManager.checkPermission( READ_DEVICE_CONFIG, Process.myPid(), Process.myUid()) == PERMISSION_GRANTED) { return DeviceConfig.getProperty(NAMESPACE_INPUT_NATIVE_BOOT, VELOCITYTRACKER_STRATEGY); } // The process using VelocityTracker can't read the config. return null; } private VelocityTracker(@VelocityTrackerStrategy int strategy) { // If user has not selected a specific strategy if (strategy == VELOCITY_TRACKER_STRATEGY_DEFAULT) { // Check if user specified strategy by overriding system property. String strategyProperty = InputProperties.velocitytracker_strategy().orElse(null); final String strategyProperty = readStrategyProperty(); if (strategyProperty == null || strategyProperty.isEmpty()) { mStrategy = strategy; } else { Loading
services/core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,7 @@ cc_defaults { "android.system.suspend.control-V1-cpp", "android.system.suspend.control.internal-cpp", "android.system.suspend-V1-ndk", "server_configurable_flags", "service.incremental", ], Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #include <nativehelper/ScopedLocalRef.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <nativehelper/ScopedUtfChars.h> #include <server_configurable_flags/get_flags.h> #include <ui/Region.h> #include <utils/Log.h> #include <utils/Looper.h> Loading Loading @@ -87,6 +88,13 @@ namespace android { // where the speed ranges from -7 to + 7 and is supplied by the user. static const float POINTER_SPEED_EXPONENT = 1.0f / 4; // Category (=namespace) name for the input settings that are applied at boot time static const char* INPUT_NATIVE_BOOT = "input_native_boot"; /** * Feature flag name. This flag determines which VelocityTracker strategy is used by default. */ static const char* VELOCITYTRACKER_STRATEGY = "velocitytracker_strategy"; static struct { jclass clazz; jmethodID notifyConfigurationChanged; Loading Loading @@ -2125,8 +2133,10 @@ static void nativeReloadDeviceAliases(JNIEnv* /* env */, static std::string dumpInputProperties() { std::string out = "Input properties:\n"; const std::string strategy = sysprop::InputProperties::velocitytracker_strategy().value_or("default"); out += " persist.input.velocitytracker.strategy = " + strategy + "\n"; server_configurable_flags::GetServerConfigurableFlag(INPUT_NATIVE_BOOT, VELOCITYTRACKER_STRATEGY, "default"); out += " velocitytracker_strategy (flag value) = " + strategy + "\n"; out += "\n"; return out; } Loading