diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-29 01:06:34 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-29 01:06:34 +0000 |
commit | ff55dacdb64406817adec20ea54ac5429d8728a7 (patch) | |
tree | 87607fc1232a441bd1d2f1e509c44546eb30b96f | |
parent | 4965ed068ab7a207d0f9cb2c122da4d9d88992ed (diff) | |
parent | 7089fbbfe5ca8b40fbc1fc41f0272642d6d427d8 (diff) | |
download | native-ff55dacdb64406817adec20ea54ac5429d8728a7.tar.gz |
Snap for 7592383 from 7089fbbfe5ca8b40fbc1fc41f0272642d6d427d8 to sc-d1-release
Change-Id: Ie147f5e42eb59ceb30ce5c363eef6233ee126071
-rw-r--r-- | cmds/atrace/atrace.rc | 13 | ||||
-rw-r--r-- | libs/input/Input.cpp | 12 | ||||
-rw-r--r-- | libs/input/tests/InputEvent_test.cpp | 22 |
3 files changed, 46 insertions, 1 deletions
diff --git a/cmds/atrace/atrace.rc b/cmds/atrace/atrace.rc index 37fc9a9356..e3c4edebbd 100644 --- a/cmds/atrace/atrace.rc +++ b/cmds/atrace/atrace.rc @@ -266,7 +266,10 @@ on late-init chmod 0666 /sys/kernel/debug/tracing/per_cpu/cpu15/trace chmod 0666 /sys/kernel/tracing/per_cpu/cpu15/trace -on post-fs-data +# Only create the tracing instance if persist.mm_events.enabled +# Attempting to remove the tracing instance after it has been created +# will likely fail with EBUSY as it would be in use by traced_probes. +on post-fs-data && property:persist.mm_events.enabled=true # Create MM Events Tracing Instance for Kmem Activity Trigger mkdir /sys/kernel/debug/tracing/instances/mm_events 0755 system system mkdir /sys/kernel/tracing/instances/mm_events 0755 system system @@ -275,10 +278,18 @@ on post-fs-data chmod 0666 /sys/kernel/debug/tracing/instances/mm_events/buffer_size_kb chmod 0666 /sys/kernel/tracing/instances/mm_events/buffer_size_kb +# Set the default buffer size to the minimum + write /sys/kernel/debug/tracing/instances/mm_events/buffer_size_kb 1 + write /sys/kernel/tracing/instances/mm_events/buffer_size_kb 1 + # Read and enable tracing chmod 0666 /sys/kernel/debug/tracing/instances/mm_events/tracing_on chmod 0666 /sys/kernel/tracing/instances/mm_events/tracing_on +# Tracing disabled by default + write /sys/kernel/debug/tracing/instances/mm_events/tracing_on 0 + write /sys/kernel/tracing/instances/mm_events/tracing_on 0 + # Read and truncate kernel trace chmod 0666 /sys/kernel/debug/tracing/instances/mm_events/trace chmod 0666 /sys/kernel/tracing/instances/mm_events/trace diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index 70ed438112..d954d23507 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -23,6 +23,7 @@ #include <limits.h> #include <string.h> +#include <android-base/properties.h> #include <android-base/stringprintf.h> #include <input/Input.h> #include <input/InputDevice.h> @@ -41,6 +42,15 @@ namespace android { namespace { +// When per-window-input-rotation is enabled, InputFlinger works in the un-rotated display +// coordinates and SurfaceFlinger includes the display rotation in the input window transforms. +bool isPerWindowInputRotationEnabled() { + static const bool PER_WINDOW_INPUT_ROTATION = + base::GetBoolProperty("persist.debug.per_window_input_rotation", false); + + return PER_WINDOW_INPUT_ROTATION; +} + float transformAngle(const ui::Transform& transform, float angleRadians) { // Construct and transform a vector oriented at the specified clockwise angle from vertical. // Coordinate system: down is increasing Y, right is increasing X. @@ -506,6 +516,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const { const PointerCoords* coords = getHistoricalRawPointerCoords(pointerIndex, historicalIndex); + if (!isPerWindowInputRotationEnabled()) return coords->getAxisValue(axis); + if (axis == AMOTION_EVENT_AXIS_X || axis == AMOTION_EVENT_AXIS_Y) { // For compatibility, convert raw coordinates into "oriented screen space". Once app // developers are educated about getRaw, we can consider removing this. diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp index 32b72ba616..3b76ddbb7c 100644 --- a/libs/input/tests/InputEvent_test.cpp +++ b/libs/input/tests/InputEvent_test.cpp @@ -17,6 +17,7 @@ #include <array> #include <math.h> +#include <android-base/properties.h> #include <attestation/HmacKeyManager.h> #include <binder/Parcel.h> #include <gtest/gtest.h> @@ -225,13 +226,34 @@ protected: static constexpr float X_OFFSET = 1; static constexpr float Y_OFFSET = 1.1; + static const std::optional<bool> INITIAL_PER_WINDOW_INPUT_ROTATION_FLAG_VALUE; + int32_t mId; ui::Transform mTransform; + void SetUp() override; + void TearDown() override; + void initializeEventWithHistory(MotionEvent* event); void assertEqualsEventWithHistory(const MotionEvent* event); }; +const std::optional<bool> MotionEventTest::INITIAL_PER_WINDOW_INPUT_ROTATION_FLAG_VALUE = + !base::GetProperty("persist.debug.per_window_input_rotation", "").empty() + ? std::optional(base::GetBoolProperty("persist.debug.per_window_input_rotation", false)) + : std::nullopt; + +void MotionEventTest::SetUp() { + // Ensure per_window_input_rotation is enabled. + base::SetProperty("persist.debug.per_window_input_rotation", "true"); +} + +void MotionEventTest::TearDown() { + const auto val = INITIAL_PER_WINDOW_INPUT_ROTATION_FLAG_VALUE.has_value() + ? (*INITIAL_PER_WINDOW_INPUT_ROTATION_FLAG_VALUE ? "true" : "false") + : ""; + base::SetProperty("persist.debug.per_window_input_rotation", val); +} void MotionEventTest::initializeEventWithHistory(MotionEvent* event) { mId = InputEvent::nextId(); |