From 84b38799cd4f44d79ecfdcaf7a5de35e0edb38e7 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Tue, 28 Sep 2021 14:44:57 -0700 Subject: [PATCH] Use PlatformProperties to read VelocityTracker strategy The VelocityTracker strategy is now going to be accessed from PlatformProperties. Update the usages in VelocityTracker. Also, dump the input-related properties in InputManager. Ideally, we would create a VelocityTracker and dump the strategy of the default-created VelocityTracker. However, that would require the following additional work: 1) Moving the VelocityTracker strategy initialization logic to native 2) Adding VelocityTracker to NativeInputManager's dump To avoid this additional work, just dump the system properties for now. Bug: 192439431 Test: run 'adb shell dumpsys input' and observe the output Output: ``` Input properties: per_window_input_rotation = false persist.input.velocitytracker.strategy = impulse Input Manager State: ``` Change-Id: I7594973f28abaf75edd39d03c952b5a057779a45 --- core/java/android/view/VelocityTracker.java | 5 +- services/core/jni/Android.bp | 2 + ...droid_server_input_InputManagerService.cpp | 59 +++++++++++-------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java index e1c4305e8747f..2b79bbfa72d40 100644 --- a/core/java/android/view/VelocityTracker.java +++ b/core/java/android/view/VelocityTracker.java @@ -19,7 +19,7 @@ package android.view; import android.annotation.IntDef; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; -import android.os.SystemProperties; +import android.sysprop.InputProperties; import android.util.ArrayMap; import android.util.Pools.SynchronizedPool; @@ -279,8 +279,7 @@ public final class VelocityTracker { // 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 = - SystemProperties.get("persist.input.velocitytracker.strategy"); + String strategyProperty = InputProperties.velocitytracker_strategy().orElse(null); if (strategyProperty == null || strategyProperty.isEmpty()) { mStrategy = strategy; } else { diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 4e4a5c35f0328..eb2c8a6b88343 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -114,6 +114,8 @@ cc_defaults { "libutils", "libui", "libvibratorservice", + "PlatformProperties", + "InputFlingerProperties", "libinput", "libinputflinger", "libinputflinger_base", diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 94b1ad18fa9f6..790acbf2cd231 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -26,30 +26,14 @@ // Log debug messages about InputDispatcherPolicy #define DEBUG_INPUT_DISPATCHER_POLICY 0 +#include #include #include #include +#include +#include #include #include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include #include #include #include @@ -57,11 +41,25 @@ #include #include #include - +#include +#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include + +#include +#include +#include #include "android_hardware_display_DisplayViewport.h" #include "android_hardware_input_InputApplicationHandle.h" @@ -69,8 +67,6 @@ #include "android_util_Binder.h" #include "com_android_server_power_PowerManagerService.h" -#include - #define INDENT " " using android::base::ParseUint; @@ -2089,11 +2085,24 @@ static void nativeReloadDeviceAliases(JNIEnv* /* env */, InputReaderConfiguration::CHANGE_DEVICE_ALIAS); } -static jstring nativeDump(JNIEnv* env, jclass /* clazz */, jlong ptr) { - NativeInputManager* im = reinterpret_cast(ptr); +static std::string dumpInputProperties() { + std::string out = "Input properties:\n"; + const bool perWindowInputRotation = + sysprop::InputFlingerProperties::per_window_input_rotation().value_or(false); + out += StringPrintf(" per_window_input_rotation = %s\n", toString(perWindowInputRotation)); + const std::string strategy = + sysprop::InputProperties::velocitytracker_strategy().value_or("default"); + out += " persist.input.velocitytracker.strategy = " + strategy + "\n"; + out += "\n"; + return out; +} - std::string dump; +static jstring nativeDump(JNIEnv* env, jclass /* clazz */, jlong ptr) { + std::string dump = dumpInputProperties(); + + NativeInputManager* im = reinterpret_cast(ptr); im->dump(dump); + return env->NewStringUTF(dump.c_str()); }