diff options
| -rw-r--r-- | libs/nativewindow/rust/Android.bp | 12 | ||||
| -rw-r--r-- | libs/nativewindow/rust/src/lib.rs | 3 | ||||
| -rw-r--r-- | services/inputflinger/reader/mapper/TouchInputMapper.cpp | 43 | ||||
| -rw-r--r-- | services/inputflinger/reader/mapper/TouchInputMapper.h | 22 | ||||
| -rw-r--r-- | services/inputflinger/reader/mapper/TouchpadInputMapper.cpp | 2 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 161 | ||||
| -rw-r--r-- | services/surfaceflinger/Scheduler/EventThread.cpp | 12 | ||||
| -rw-r--r-- | services/surfaceflinger/Scheduler/EventThread.h | 8 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 24 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/EventThreadTest.cpp | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/mock/MockEventThread.h | 2 |
11 files changed, 88 insertions, 203 deletions
diff --git a/libs/nativewindow/rust/Android.bp b/libs/nativewindow/rust/Android.bp index a3df4820ba..97740dbcd8 100644 --- a/libs/nativewindow/rust/Android.bp +++ b/libs/nativewindow/rust/Android.bp @@ -54,6 +54,10 @@ rust_bindgen { }, min_sdk_version: "VanillaIceCream", vendor_available: true, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], } rust_library { @@ -78,6 +82,10 @@ rust_library { }, min_sdk_version: "VanillaIceCream", vendor_available: true, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], } rust_test { @@ -116,6 +124,10 @@ rust_library { }, min_sdk_version: "VanillaIceCream", vendor_available: true, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], } rust_test { diff --git a/libs/nativewindow/rust/src/lib.rs b/libs/nativewindow/rust/src/lib.rs index 22ad83463c..dc3f51f7fd 100644 --- a/libs/nativewindow/rust/src/lib.rs +++ b/libs/nativewindow/rust/src/lib.rs @@ -16,7 +16,8 @@ extern crate nativewindow_bindgen as ffi; -pub mod surface; +mod surface; +pub use surface::Surface; pub use ffi::{AHardwareBuffer_Format, AHardwareBuffer_UsageFlags}; diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index 7d27d4a9ce..8d915996f7 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -20,8 +20,24 @@ #include "TouchInputMapper.h" +#include <algorithm> +#include <cinttypes> +#include <cmath> +#include <cstddef> +#include <tuple> + +#include <math.h> + +#include <android-base/stringprintf.h> +#include <android/input.h> #include <ftl/enum.h> #include <input/PrintTools.h> +#include <input/PropertyMap.h> +#include <input/VirtualKeyMap.h> +#include <linux/input-event-codes.h> +#include <log/log_main.h> +#include <math/vec2.h> +#include <ui/FloatRect.h> #include "CursorButtonAccumulator.h" #include "CursorScrollAccumulator.h" @@ -147,20 +163,6 @@ void TouchInputMapper::populateDeviceInfo(InputDeviceInfo& info) { info.addMotionRange(mOrientedRanges.y); info.addMotionRange(mOrientedRanges.pressure); - if (mDeviceMode == DeviceMode::UNSCALED && mSource == AINPUT_SOURCE_TOUCHPAD) { - // Populate RELATIVE_X and RELATIVE_Y motion ranges for touchpad capture mode. - // - // RELATIVE_X and RELATIVE_Y motion ranges should be the largest possible relative - // motion, i.e. the hardware dimensions, as the finger could move completely across the - // touchpad in one sample cycle. - const InputDeviceInfo::MotionRange& x = mOrientedRanges.x; - const InputDeviceInfo::MotionRange& y = mOrientedRanges.y; - info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat, x.fuzz, - x.resolution); - info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat, y.fuzz, - y.resolution); - } - if (mOrientedRanges.size) { info.addMotionRange(*mOrientedRanges.size); } @@ -531,7 +533,7 @@ bool TouchInputMapper::hasExternalStylus() const { * 4. Otherwise, use a non-display viewport. */ std::optional<DisplayViewport> TouchInputMapper::findViewport() { - if (mParameters.hasAssociatedDisplay && mDeviceMode != DeviceMode::UNSCALED) { + if (mParameters.hasAssociatedDisplay) { if (getDeviceContext().getAssociatedViewport()) { return getDeviceContext().getAssociatedViewport(); } @@ -939,8 +941,10 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) mSource = AINPUT_SOURCE_TOUCH_NAVIGATION; mDeviceMode = DeviceMode::NAVIGATION; } else { - mSource = AINPUT_SOURCE_TOUCHPAD; - mDeviceMode = DeviceMode::UNSCALED; + ALOGW("Touch device '%s' has invalid parameters or configuration. The device will be " + "inoperable.", + getDeviceName().c_str()); + mDeviceMode = DeviceMode::DISABLED; } const std::optional<DisplayViewport> newViewportOpt = findViewport(); @@ -1884,8 +1888,7 @@ std::list<NotifyArgs> TouchInputMapper::consumeRawTouches(nsecs_t when, nsecs_t } if (!mCurrentRawState.rawPointerData.hoveringIdBits.isEmpty() && - mCurrentRawState.rawPointerData.touchingIdBits.isEmpty() && - mDeviceMode != DeviceMode::UNSCALED) { + mCurrentRawState.rawPointerData.touchingIdBits.isEmpty()) { // We have hovering pointers, and there are no touching pointers. bool hoveringPointersInFrame = false; auto hoveringIds = mCurrentRawState.rawPointerData.hoveringIdBits; @@ -1912,7 +1915,7 @@ std::list<NotifyArgs> TouchInputMapper::consumeRawTouches(nsecs_t when, nsecs_t // Skip checking whether the pointer is inside the physical frame if the device is in // unscaled or pointer mode. if (!isPointInsidePhysicalFrame(pointer.x, pointer.y) && - mDeviceMode != DeviceMode::UNSCALED && mDeviceMode != DeviceMode::POINTER) { + mDeviceMode != DeviceMode::POINTER) { // If exactly one pointer went down, check for virtual key hit. // Otherwise, we will drop the entire stroke. if (mCurrentRawState.rawPointerData.touchingIdBits.count() == 1) { diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h index 4b39e4099c..8451675944 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchInputMapper.h @@ -16,17 +16,38 @@ #pragma once +#include <array> +#include <climits> +#include <limits> +#include <list> +#include <memory> #include <optional> #include <string> +#include <utility> +#include <vector> #include <stdint.h> +#include <gui/constants.h> +#include <input/DisplayViewport.h> +#include <input/Input.h> +#include <input/InputDevice.h> +#include <input/VelocityControl.h> +#include <input/VelocityTracker.h> +#include <ui/Rect.h> #include <ui/Rotation.h> +#include <ui/Size.h> +#include <ui/Transform.h> +#include <utils/BitSet.h> +#include <utils/Timers.h> #include "CursorButtonAccumulator.h" #include "CursorScrollAccumulator.h" #include "EventHub.h" #include "InputMapper.h" #include "InputReaderBase.h" +#include "NotifyArgs.h" +#include "PointerControllerInterface.h" +#include "StylusState.h" #include "TouchButtonAccumulator.h" namespace android { @@ -195,7 +216,6 @@ protected: enum class DeviceMode { DISABLED, // input is disabled DIRECT, // direct mapping (touchscreen) - UNSCALED, // unscaled mapping (e.g. captured touchpad) NAVIGATION, // unscaled mapping with assist gesture (touch navigation) POINTER, // pointer mapping (e.g. uncaptured touchpad, drawing tablet) diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index 721cdfdfb0..f558ba1196 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -185,6 +185,7 @@ private: static AStatsManager_PullAtomCallbackReturn pullAtomCallback(int32_t atomTag, AStatsEventList* outEventList, void* cookie) { + ALOGI("Received pull request for touchpad usage atom"); LOG_ALWAYS_FATAL_IF(atomTag != android::util::TOUCHPAD_USAGE); MetricsAccumulator& accumulator = MetricsAccumulator::getInstance(); accumulator.produceAtomsAndReset(*outEventList); @@ -192,6 +193,7 @@ private: } void produceAtomsAndReset(AStatsEventList& outEventList) { + ALOGI("Acquiring lock for touchpad usage metrics..."); std::scoped_lock lock(mLock); produceAtomsLocked(outEventList); resetCountersLocked(); diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 1d46c9a1e2..367bc70a1c 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -9790,163 +9790,13 @@ TEST_F(MultiTouchInputMapperTest_ExternalDevice, Viewports_Fallback) { ASSERT_EQ(SECONDARY_DISPLAY_ID, motionArgs.displayId); } -TEST_F(MultiTouchInputMapperTest, Process_TouchpadCapture) { - // we need a pointer controller for mouse mode of touchpad (start pointer at 0,0) +TEST_F(MultiTouchInputMapperTest, Process_TouchpadPointer) { std::shared_ptr<FakePointerController> fakePointerController = std::make_shared<FakePointerController>(); fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1); fakePointerController->setPosition(0, 0); - // prepare device and capture - prepareDisplay(ui::ROTATION_0); - prepareAxes(POSITION | ID | SLOT); - mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0); - mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0); - mFakePolicy->setPointerCapture(/*window=*/sp<BBinder>::make()); - mFakePolicy->setPointerController(fakePointerController); - MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>(); - - // captured touchpad should be a touchpad source - NotifyDeviceResetArgs resetArgs; - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs)); - ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper.getSources()); - - InputDeviceInfo deviceInfo = mDevice->getDeviceInfo(); - - const InputDeviceInfo::MotionRange* relRangeX = - deviceInfo.getMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, AINPUT_SOURCE_TOUCHPAD); - ASSERT_NE(relRangeX, nullptr); - ASSERT_EQ(relRangeX->min, -(RAW_X_MAX - RAW_X_MIN)); - ASSERT_EQ(relRangeX->max, RAW_X_MAX - RAW_X_MIN); - const InputDeviceInfo::MotionRange* relRangeY = - deviceInfo.getMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, AINPUT_SOURCE_TOUCHPAD); - ASSERT_NE(relRangeY, nullptr); - ASSERT_EQ(relRangeY->min, -(RAW_Y_MAX - RAW_Y_MIN)); - ASSERT_EQ(relRangeY->max, RAW_Y_MAX - RAW_Y_MIN); - - // run captured pointer tests - note that this is unscaled, so input listener events should be - // identical to what the hardware sends (accounting for any - // calibration). - // FINGER 0 DOWN - processSlot(mapper, 0); - processId(mapper, 1); - processPosition(mapper, 100 + RAW_X_MIN, 100 + RAW_Y_MIN); - processKey(mapper, BTN_TOUCH, 1); - processSync(mapper); - - // expect coord[0] to contain initial location of touch 0 - NotifyMotionArgs args; - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action); - ASSERT_EQ(1U, args.getPointerCount()); - ASSERT_EQ(0, args.pointerProperties[0].id); - ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, args.source); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[0], 100, 100, 1, 0, 0, 0, 0, 0, 0, 0)); - - // FINGER 1 DOWN - processSlot(mapper, 1); - processId(mapper, 2); - processPosition(mapper, 560 + RAW_X_MIN, 154 + RAW_Y_MIN); - processSync(mapper); - - // expect coord[0] to contain previous location, coord[1] to contain new touch 1 location - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(ACTION_POINTER_1_DOWN, args.action); - ASSERT_EQ(2U, args.getPointerCount()); - ASSERT_EQ(0, args.pointerProperties[0].id); - ASSERT_EQ(1, args.pointerProperties[1].id); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[0], 100, 100, 1, 0, 0, 0, 0, 0, 0, 0)); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[1], 560, 154, 1, 0, 0, 0, 0, 0, 0, 0)); - - // FINGER 1 MOVE - processPosition(mapper, 540 + RAW_X_MIN, 690 + RAW_Y_MIN); - processSync(mapper); - - // expect coord[0] to contain previous location, coord[1] to contain new touch 1 location - // from move - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[0], 100, 100, 1, 0, 0, 0, 0, 0, 0, 0)); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[1], 540, 690, 1, 0, 0, 0, 0, 0, 0, 0)); - - // FINGER 0 MOVE - processSlot(mapper, 0); - processPosition(mapper, 50 + RAW_X_MIN, 800 + RAW_Y_MIN); - processSync(mapper); - - // expect coord[0] to contain new touch 0 location, coord[1] to contain previous location - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[0], 50, 800, 1, 0, 0, 0, 0, 0, 0, 0)); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[1], 540, 690, 1, 0, 0, 0, 0, 0, 0, 0)); - - // BUTTON DOWN - processKey(mapper, BTN_LEFT, 1); - processSync(mapper); - - // touchinputmapper design sends a move before button press - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_BUTTON_PRESS, args.action); - - // BUTTON UP - processKey(mapper, BTN_LEFT, 0); - processSync(mapper); - - // touchinputmapper design sends a move after button release - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_BUTTON_RELEASE, args.action); - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); - - // FINGER 0 UP - processId(mapper, -1); - processSync(mapper); - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | 0x0000, args.action); - - // FINGER 1 MOVE - processSlot(mapper, 1); - processPosition(mapper, 320 + RAW_X_MIN, 900 + RAW_Y_MIN); - processSync(mapper); - - // expect coord[0] to contain new location of touch 1, and properties[0].id to contain 1 - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); - ASSERT_EQ(1U, args.getPointerCount()); - ASSERT_EQ(1, args.pointerProperties[0].id); - ASSERT_NO_FATAL_FAILURE( - assertPointerCoords(args.pointerCoords[0], 320, 900, 1, 0, 0, 0, 0, 0, 0, 0)); - - // FINGER 1 UP - processId(mapper, -1); - processKey(mapper, BTN_TOUCH, 0); - processSync(mapper); - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); - ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action); - - // non captured touchpad should be a mouse source - mFakePolicy->setPointerCapture(/*window=*/nullptr); - configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE); - ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs)); - ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources()); -} - -TEST_F(MultiTouchInputMapperTest, Process_UnCapturedTouchpadPointer) { - std::shared_ptr<FakePointerController> fakePointerController = - std::make_shared<FakePointerController>(); - fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1); - fakePointerController->setPosition(0, 0); - - // prepare device and capture + // prepare device prepareDisplay(ui::ROTATION_0); prepareAxes(POSITION | ID | SLOT); mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0); @@ -10004,7 +9854,7 @@ TEST_F(MultiTouchInputMapperTest, Process_UnCapturedTouchpadPointer) { ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action); } -TEST_F(MultiTouchInputMapperTest, WhenCapturedAndNotCaptured_GetSources) { +TEST_F(MultiTouchInputMapperTest, Touchpad_GetSources) { std::shared_ptr<FakePointerController> fakePointerController = std::make_shared<FakePointerController>(); @@ -10017,11 +9867,6 @@ TEST_F(MultiTouchInputMapperTest, WhenCapturedAndNotCaptured_GetSources) { // uncaptured touchpad should be a pointer device ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources()); - - // captured touchpad should be a touchpad device - mFakePolicy->setPointerCapture(/*window=*/sp<BBinder>::make()); - configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE); - ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper.getSources()); } // --- BluetoothMultiTouchInputMapperTest --- diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index 96eccf290f..6b654499a2 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -235,7 +235,8 @@ binder::Status EventThreadConnection::getLatestVsyncEventData( ParcelableVsyncEventData* outVsyncEventData) { ATRACE_CALL(); outVsyncEventData->vsync = - mEventThread->getLatestVsyncEventData(sp<EventThreadConnection>::fromExisting(this)); + mEventThread->getLatestVsyncEventData(sp<EventThreadConnection>::fromExisting(this), + systemTime()); return binder::Status::ok(); } @@ -387,8 +388,8 @@ void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection) } } -VsyncEventData EventThread::getLatestVsyncEventData( - const sp<EventThreadConnection>& connection) const { +VsyncEventData EventThread::getLatestVsyncEventData(const sp<EventThreadConnection>& connection, + nsecs_t now) const { // Resync so that the vsync is accurate with hardware. getLatestVsyncEventData is an alternate // way to get vsync data (instead of posting callbacks to Choreographer). mCallback.resync(); @@ -399,11 +400,10 @@ VsyncEventData EventThread::getLatestVsyncEventData( const auto [presentTime, deadline] = [&]() -> std::pair<nsecs_t, nsecs_t> { std::lock_guard<std::mutex> lock(mMutex); const auto vsyncTime = mVsyncSchedule->getTracker().nextAnticipatedVSyncTimeFrom( - systemTime() + mWorkDuration.get().count() + mReadyDuration.count()); + now + mWorkDuration.get().count() + mReadyDuration.count()); return {vsyncTime, vsyncTime - mReadyDuration.count()}; }(); - generateFrameTimeline(vsyncEventData, frameInterval.ns(), systemTime(SYSTEM_TIME_MONOTONIC), - presentTime, deadline); + generateFrameTimeline(vsyncEventData, frameInterval.ns(), now, presentTime, deadline); if (FlagManager::getInstance().vrr_config()) { mCallback.onExpectedPresentTimePosted(TimePoint::fromNs(presentTime)); } diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h index 90e61a984b..f772126349 100644 --- a/services/surfaceflinger/Scheduler/EventThread.h +++ b/services/surfaceflinger/Scheduler/EventThread.h @@ -127,8 +127,8 @@ public: virtual void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) = 0; // Requests the next vsync. If resetIdleTimer is set to true, it resets the idle timer. virtual void requestNextVsync(const sp<EventThreadConnection>& connection) = 0; - virtual VsyncEventData getLatestVsyncEventData( - const sp<EventThreadConnection>& connection) const = 0; + virtual VsyncEventData getLatestVsyncEventData(const sp<EventThreadConnection>& connection, + nsecs_t now) const = 0; virtual void onNewVsyncSchedule(std::shared_ptr<scheduler::VsyncSchedule>) = 0; @@ -160,8 +160,8 @@ public: status_t registerDisplayEventConnection(const sp<EventThreadConnection>& connection) override; void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) override; void requestNextVsync(const sp<EventThreadConnection>& connection) override; - VsyncEventData getLatestVsyncEventData( - const sp<EventThreadConnection>& connection) const override; + VsyncEventData getLatestVsyncEventData(const sp<EventThreadConnection>& connection, + nsecs_t now) const override; void enableSyntheticVsync(bool) override; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 7b313c3c99..a6a0ca6d6e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -5252,17 +5252,19 @@ bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelin desiredPresentTime, isAutoTimestamp, postTime, transactionId); } - if ((flags & eAnimation) && resolvedState.state.surface) { - if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) { - const auto layerProps = scheduler::LayerProps{ - .visible = layer->isVisible(), - .bounds = layer->getBounds(), - .transform = layer->getTransform(), - .setFrameRateVote = layer->getFrameRateForLayerTree(), - .frameRateSelectionPriority = layer->getFrameRateSelectionPriority(), - .isFrontBuffered = layer->isFrontBuffered(), - }; - layer->recordLayerHistoryAnimationTx(layerProps, now); + if (!mLayerLifecycleManagerEnabled) { + if ((flags & eAnimation) && resolvedState.state.surface) { + if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) { + const auto layerProps = scheduler::LayerProps{ + .visible = layer->isVisible(), + .bounds = layer->getBounds(), + .transform = layer->getTransform(), + .setFrameRateVote = layer->getFrameRateForLayerTree(), + .frameRateSelectionPriority = layer->getFrameRateSelectionPriority(), + .isFrontBuffered = layer->isFrontBuffered(), + }; + layer->recordLayerHistoryAnimationTx(layerProps, now); + } } } } diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp index 3eabe1f362..625d2e68d8 100644 --- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp +++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp @@ -493,7 +493,7 @@ TEST_F(EventThreadTest, getLatestVsyncEventData) { EXPECT_CALL(mockTracker, nextAnticipatedVSyncTimeFrom(_, _)) .WillOnce(Return(preferredExpectedPresentationTime)); - VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection); + VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection, now); // Check EventThread immediately requested a resync. EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value()); diff --git a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h index e2b0ed1df9..8dd1a34ec4 100644 --- a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h +++ b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h @@ -55,7 +55,7 @@ public: (override)); MOCK_METHOD(void, requestNextVsync, (const sp<android::EventThreadConnection>&), (override)); MOCK_METHOD(VsyncEventData, getLatestVsyncEventData, - (const sp<android::EventThreadConnection>&), (const, override)); + (const sp<android::EventThreadConnection>&, nsecs_t), (const, override)); MOCK_METHOD(void, requestLatestConfig, (const sp<android::EventThreadConnection>&)); MOCK_METHOD(void, pauseVsyncCallback, (bool)); MOCK_METHOD(void, onNewVsyncSchedule, (std::shared_ptr<scheduler::VsyncSchedule>), (override)); |