Loading data/etc/Android.bp +12 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,12 @@ prebuilt_etc { defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.opengles.deqp.level-2022-03-01.prebuilt.xml", src: "android.software.opengles.deqp.level-2022-03-01.xml", defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.sip.voip.prebuilt.xml", src: "android.software.sip.voip.xml", Loading @@ -244,6 +250,12 @@ prebuilt_etc { defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.vulkan.deqp.level-2022-03-01.prebuilt.xml", src: "android.software.vulkan.deqp.level-2022-03-01.xml", defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "aosp_excluded_hardware.prebuilt.xml", src: "aosp_excluded_hardware.xml", Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +18 −6 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ namespace android { // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; // --- CursorMotionAccumulator --- CursorMotionAccumulator::CursorMotionAccumulator() { Loading Loading @@ -154,8 +157,9 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* mHWheelScale = 1.0f; } if ((!changes && config->pointerCaptureRequest.enable) || (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE)) { const bool configurePointerCapture = (!changes && config->pointerCaptureRequest.enable) || (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE); if (configurePointerCapture) { if (config->pointerCaptureRequest.enable) { if (mParameters.mode == Parameters::MODE_POINTER) { mParameters.mode = Parameters::MODE_POINTER_RELATIVE; Loading @@ -180,11 +184,19 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* } } if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED) || configurePointerCapture) { if (config->pointerCaptureRequest.enable) { // Disable any acceleration or scaling when Pointer Capture is enabled. mPointerVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); } else { mPointerVelocityControl.setParameters(config->pointerVelocityControlParameters); mWheelXVelocityControl.setParameters(config->wheelVelocityControlParameters); mWheelYVelocityControl.setParameters(config->wheelVelocityControlParameters); } } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { mOrientation = DISPLAY_ORIENTATION_0; Loading services/inputflinger/tests/InputReader_test.cpp +57 −1 Original line number Diff line number Diff line Loading @@ -375,6 +375,11 @@ public: float getPointerGestureMovementSpeedRatio() { return mConfig.pointerGestureMovementSpeedRatio; } void setVelocityControlParams(const VelocityControlParameters& params) { mConfig.pointerVelocityControlParameters = params; mConfig.wheelVelocityControlParameters = params; } private: uint32_t mNextPointerCaptureSequenceNumber = 0; Loading Loading @@ -2949,7 +2954,10 @@ protected: } void configureDevice(uint32_t changes) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & (InputReaderConfiguration::CHANGE_DISPLAY_INFO | InputReaderConfiguration::CHANGE_POINTER_CAPTURE))) { mReader->requestRefreshConfiguration(changes); mReader->loopOnce(); } Loading Loading @@ -4842,6 +4850,54 @@ TEST_F(CursorInputMapperTest, Process_PointerCapture) { ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } /** * When Pointer Capture is enabled, we expect to report unprocessed relative movements, so any * pointer acceleration or speed processing should not be applied. */ TEST_F(CursorInputMapperTest, PointerCaptureDisablesVelocityProcessing) { addConfigurationProperty("cursor.mode", "pointer"); const VelocityControlParameters testParams(5.f /*scale*/, 0.f /*low threshold*/, 100.f /*high threshold*/, 10.f /*acceleration*/); mFakePolicy->setVelocityControlParams(testParams); CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>(); NotifyDeviceResetArgs resetArgs; ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs)); ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime); ASSERT_EQ(DEVICE_ID, resetArgs.deviceId); NotifyMotionArgs args; // Move and verify scale is applied. process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10); process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); ASSERT_EQ(AINPUT_SOURCE_MOUSE, args.source); ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, args.action); const float relX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X); const float relY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y); ASSERT_GT(relX, 10); ASSERT_GT(relY, 20); // Enable Pointer Capture mFakePolicy->setPointerCapture(true); configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE); NotifyPointerCaptureChangedArgs captureArgs; ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyCaptureWasCalled(&captureArgs)); ASSERT_TRUE(captureArgs.request.enable); // Move and verify scale is not applied. process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10); process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); ASSERT_EQ(AINPUT_SOURCE_MOUSE_RELATIVE, args.source); ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); ASSERT_EQ(10, args.pointerCoords[0].getX()); ASSERT_EQ(20, args.pointerCoords[0].getY()); } TEST_F(CursorInputMapperTest, Process_ShouldHandleDisplayId) { CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>(); Loading services/surfaceflinger/SurfaceFlinger.cpp +12 −12 Original line number Diff line number Diff line Loading @@ -2730,12 +2730,12 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { } const auto displayId = info->id; const auto it = mPhysicalDisplayTokens.find(displayId); const auto token = mPhysicalDisplayTokens.get(displayId); if (event.connection == hal::Connection::CONNECTED) { auto [supportedModes, activeMode] = loadDisplayModes(displayId); if (it == mPhysicalDisplayTokens.end()) { if (!token) { ALOGV("Creating display %s", to_string(displayId).c_str()); DisplayDeviceState state; Loading @@ -2750,14 +2750,13 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { sp<IBinder> token = new BBinder(); mCurrentState.displays.add(token, state); mPhysicalDisplayTokens.emplace(displayId, std::move(token)); mPhysicalDisplayTokens.try_emplace(displayId, std::move(token)); mInterceptor->saveDisplayCreation(state); } else { ALOGV("Recreating display %s", to_string(displayId).c_str()); const auto token = it->second; auto& state = mCurrentState.displays.editValueFor(token); state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId auto& state = mCurrentState.displays.editValueFor(token->get()); state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId. state.physical->supportedModes = std::move(supportedModes); state.physical->activeMode = std::move(activeMode); if (getHwComposer().updatesDeviceProductInfoOnHotplugReconnect()) { Loading @@ -2767,13 +2766,13 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { } else { ALOGV("Removing display %s", to_string(displayId).c_str()); const ssize_t index = mCurrentState.displays.indexOfKey(it->second); if (index >= 0) { if (const ssize_t index = mCurrentState.displays.indexOfKey(token->get()); index >= 0) { const DisplayDeviceState& state = mCurrentState.displays.valueAt(index); mInterceptor->saveDisplayDeletion(state.sequenceId); mCurrentState.displays.removeItemsAt(index); } mPhysicalDisplayTokens.erase(it); mPhysicalDisplayTokens.erase(displayId); } processDisplayChangesLocked(); Loading Loading @@ -2954,15 +2953,16 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken, } LOG_FATAL_IF(!displaySurface); const auto display = setupNewDisplayDeviceInternal(displayToken, std::move(compositionDisplay), state, displaySurface, producer); mDisplays.emplace(displayToken, display); auto display = setupNewDisplayDeviceInternal(displayToken, std::move(compositionDisplay), state, displaySurface, producer); if (display->isPrimary()) { initScheduler(display); } if (!state.isVirtual()) { dispatchDisplayHotplugEvent(display->getPhysicalId(), true); } mDisplays.try_emplace(displayToken, std::move(display)); } void SurfaceFlinger::processDisplayRemoved(const wp<IBinder>& displayToken) { Loading services/surfaceflinger/SurfaceFlinger.h +15 −12 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <android/gui/DisplayState.h> #include <cutils/atomic.h> #include <cutils/compiler.h> #include <ftl/small_map.h> #include <gui/BufferQueue.h> #include <gui/FrameTimestamps.h> #include <gui/ISurfaceComposer.h> Loading Loading @@ -905,8 +906,8 @@ private: } sp<DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& displayToken) REQUIRES(mStateLock) { const auto it = mDisplays.find(displayToken); return it == mDisplays.end() ? nullptr : it->second; const sp<DisplayDevice> nullDisplay; return mDisplays.get(displayToken).value_or(std::cref(nullDisplay)); } sp<const DisplayDevice> getDisplayDeviceLocked(PhysicalDisplayId id) const Loading Loading @@ -1051,8 +1052,8 @@ private: */ sp<IBinder> getPhysicalDisplayTokenLocked(PhysicalDisplayId displayId) const REQUIRES(mStateLock) { const auto it = mPhysicalDisplayTokens.find(displayId); return it != mPhysicalDisplayTokens.end() ? it->second : nullptr; const sp<IBinder> nullToken; return mPhysicalDisplayTokens.get(displayId).value_or(std::cref(nullToken)); } std::optional<PhysicalDisplayId> getPhysicalDisplayIdLocked( Loading Loading @@ -1247,10 +1248,14 @@ private: std::vector<HotplugEvent> mPendingHotplugEvents GUARDED_BY(mStateLock); // this may only be written from the main thread with mStateLock held // it may be read from other threads with mStateLock held std::map<wp<IBinder>, sp<DisplayDevice>> mDisplays GUARDED_BY(mStateLock); std::unordered_map<PhysicalDisplayId, sp<IBinder>> mPhysicalDisplayTokens // Displays are composited in `mDisplays` order. Internal displays are inserted at boot and // never removed, so take precedence over external and virtual displays. // // The static capacities were chosen to exceed a typical number of physical/virtual displays. // // May be read from any thread, but must only be written from the main thread. ftl::SmallMap<wp<IBinder>, const sp<DisplayDevice>, 5> mDisplays GUARDED_BY(mStateLock); ftl::SmallMap<PhysicalDisplayId, const sp<IBinder>, 3> mPhysicalDisplayTokens GUARDED_BY(mStateLock); struct { Loading Loading @@ -1423,10 +1428,8 @@ private: std::atomic<ui::Transform::RotationFlags> mActiveDisplayTransformHint; bool isRefreshRateOverlayEnabled() const REQUIRES(mStateLock) { return std::any_of(mDisplays.begin(), mDisplays.end(), [](std::pair<wp<IBinder>, sp<DisplayDevice>> display) { return display.second->isRefreshRateOverlayEnabled(); }); return hasDisplay( [](const auto& display) { return display.isRefreshRateOverlayEnabled(); }); } wp<IBinder> mActiveDisplayToken GUARDED_BY(mStateLock); Loading Loading
data/etc/Android.bp +12 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,12 @@ prebuilt_etc { defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.opengles.deqp.level-2022-03-01.prebuilt.xml", src: "android.software.opengles.deqp.level-2022-03-01.xml", defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.sip.voip.prebuilt.xml", src: "android.software.sip.voip.xml", Loading @@ -244,6 +250,12 @@ prebuilt_etc { defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "android.software.vulkan.deqp.level-2022-03-01.prebuilt.xml", src: "android.software.vulkan.deqp.level-2022-03-01.xml", defaults: ["frameworks_native_data_etc_defaults"], } prebuilt_etc { name: "aosp_excluded_hardware.prebuilt.xml", src: "aosp_excluded_hardware.xml", Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +18 −6 Original line number Diff line number Diff line Loading @@ -27,6 +27,9 @@ namespace android { // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; // --- CursorMotionAccumulator --- CursorMotionAccumulator::CursorMotionAccumulator() { Loading Loading @@ -154,8 +157,9 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* mHWheelScale = 1.0f; } if ((!changes && config->pointerCaptureRequest.enable) || (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE)) { const bool configurePointerCapture = (!changes && config->pointerCaptureRequest.enable) || (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE); if (configurePointerCapture) { if (config->pointerCaptureRequest.enable) { if (mParameters.mode == Parameters::MODE_POINTER) { mParameters.mode = Parameters::MODE_POINTER_RELATIVE; Loading @@ -180,11 +184,19 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* } } if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED) || configurePointerCapture) { if (config->pointerCaptureRequest.enable) { // Disable any acceleration or scaling when Pointer Capture is enabled. mPointerVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS); } else { mPointerVelocityControl.setParameters(config->pointerVelocityControlParameters); mWheelXVelocityControl.setParameters(config->wheelVelocityControlParameters); mWheelYVelocityControl.setParameters(config->wheelVelocityControlParameters); } } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { mOrientation = DISPLAY_ORIENTATION_0; Loading
services/inputflinger/tests/InputReader_test.cpp +57 −1 Original line number Diff line number Diff line Loading @@ -375,6 +375,11 @@ public: float getPointerGestureMovementSpeedRatio() { return mConfig.pointerGestureMovementSpeedRatio; } void setVelocityControlParams(const VelocityControlParameters& params) { mConfig.pointerVelocityControlParameters = params; mConfig.wheelVelocityControlParameters = params; } private: uint32_t mNextPointerCaptureSequenceNumber = 0; Loading Loading @@ -2949,7 +2954,10 @@ protected: } void configureDevice(uint32_t changes) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & (InputReaderConfiguration::CHANGE_DISPLAY_INFO | InputReaderConfiguration::CHANGE_POINTER_CAPTURE))) { mReader->requestRefreshConfiguration(changes); mReader->loopOnce(); } Loading Loading @@ -4842,6 +4850,54 @@ TEST_F(CursorInputMapperTest, Process_PointerCapture) { ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } /** * When Pointer Capture is enabled, we expect to report unprocessed relative movements, so any * pointer acceleration or speed processing should not be applied. */ TEST_F(CursorInputMapperTest, PointerCaptureDisablesVelocityProcessing) { addConfigurationProperty("cursor.mode", "pointer"); const VelocityControlParameters testParams(5.f /*scale*/, 0.f /*low threshold*/, 100.f /*high threshold*/, 10.f /*acceleration*/); mFakePolicy->setVelocityControlParams(testParams); CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>(); NotifyDeviceResetArgs resetArgs; ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs)); ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime); ASSERT_EQ(DEVICE_ID, resetArgs.deviceId); NotifyMotionArgs args; // Move and verify scale is applied. process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10); process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); ASSERT_EQ(AINPUT_SOURCE_MOUSE, args.source); ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, args.action); const float relX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X); const float relY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y); ASSERT_GT(relX, 10); ASSERT_GT(relY, 20); // Enable Pointer Capture mFakePolicy->setPointerCapture(true); configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE); NotifyPointerCaptureChangedArgs captureArgs; ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyCaptureWasCalled(&captureArgs)); ASSERT_TRUE(captureArgs.request.enable); // Move and verify scale is not applied. process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10); process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args)); ASSERT_EQ(AINPUT_SOURCE_MOUSE_RELATIVE, args.source); ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action); ASSERT_EQ(10, args.pointerCoords[0].getX()); ASSERT_EQ(20, args.pointerCoords[0].getY()); } TEST_F(CursorInputMapperTest, Process_ShouldHandleDisplayId) { CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>(); Loading
services/surfaceflinger/SurfaceFlinger.cpp +12 −12 Original line number Diff line number Diff line Loading @@ -2730,12 +2730,12 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { } const auto displayId = info->id; const auto it = mPhysicalDisplayTokens.find(displayId); const auto token = mPhysicalDisplayTokens.get(displayId); if (event.connection == hal::Connection::CONNECTED) { auto [supportedModes, activeMode] = loadDisplayModes(displayId); if (it == mPhysicalDisplayTokens.end()) { if (!token) { ALOGV("Creating display %s", to_string(displayId).c_str()); DisplayDeviceState state; Loading @@ -2750,14 +2750,13 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { sp<IBinder> token = new BBinder(); mCurrentState.displays.add(token, state); mPhysicalDisplayTokens.emplace(displayId, std::move(token)); mPhysicalDisplayTokens.try_emplace(displayId, std::move(token)); mInterceptor->saveDisplayCreation(state); } else { ALOGV("Recreating display %s", to_string(displayId).c_str()); const auto token = it->second; auto& state = mCurrentState.displays.editValueFor(token); state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId auto& state = mCurrentState.displays.editValueFor(token->get()); state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId. state.physical->supportedModes = std::move(supportedModes); state.physical->activeMode = std::move(activeMode); if (getHwComposer().updatesDeviceProductInfoOnHotplugReconnect()) { Loading @@ -2767,13 +2766,13 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { } else { ALOGV("Removing display %s", to_string(displayId).c_str()); const ssize_t index = mCurrentState.displays.indexOfKey(it->second); if (index >= 0) { if (const ssize_t index = mCurrentState.displays.indexOfKey(token->get()); index >= 0) { const DisplayDeviceState& state = mCurrentState.displays.valueAt(index); mInterceptor->saveDisplayDeletion(state.sequenceId); mCurrentState.displays.removeItemsAt(index); } mPhysicalDisplayTokens.erase(it); mPhysicalDisplayTokens.erase(displayId); } processDisplayChangesLocked(); Loading Loading @@ -2954,15 +2953,16 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken, } LOG_FATAL_IF(!displaySurface); const auto display = setupNewDisplayDeviceInternal(displayToken, std::move(compositionDisplay), state, displaySurface, producer); mDisplays.emplace(displayToken, display); auto display = setupNewDisplayDeviceInternal(displayToken, std::move(compositionDisplay), state, displaySurface, producer); if (display->isPrimary()) { initScheduler(display); } if (!state.isVirtual()) { dispatchDisplayHotplugEvent(display->getPhysicalId(), true); } mDisplays.try_emplace(displayToken, std::move(display)); } void SurfaceFlinger::processDisplayRemoved(const wp<IBinder>& displayToken) { Loading
services/surfaceflinger/SurfaceFlinger.h +15 −12 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <android/gui/DisplayState.h> #include <cutils/atomic.h> #include <cutils/compiler.h> #include <ftl/small_map.h> #include <gui/BufferQueue.h> #include <gui/FrameTimestamps.h> #include <gui/ISurfaceComposer.h> Loading Loading @@ -905,8 +906,8 @@ private: } sp<DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& displayToken) REQUIRES(mStateLock) { const auto it = mDisplays.find(displayToken); return it == mDisplays.end() ? nullptr : it->second; const sp<DisplayDevice> nullDisplay; return mDisplays.get(displayToken).value_or(std::cref(nullDisplay)); } sp<const DisplayDevice> getDisplayDeviceLocked(PhysicalDisplayId id) const Loading Loading @@ -1051,8 +1052,8 @@ private: */ sp<IBinder> getPhysicalDisplayTokenLocked(PhysicalDisplayId displayId) const REQUIRES(mStateLock) { const auto it = mPhysicalDisplayTokens.find(displayId); return it != mPhysicalDisplayTokens.end() ? it->second : nullptr; const sp<IBinder> nullToken; return mPhysicalDisplayTokens.get(displayId).value_or(std::cref(nullToken)); } std::optional<PhysicalDisplayId> getPhysicalDisplayIdLocked( Loading Loading @@ -1247,10 +1248,14 @@ private: std::vector<HotplugEvent> mPendingHotplugEvents GUARDED_BY(mStateLock); // this may only be written from the main thread with mStateLock held // it may be read from other threads with mStateLock held std::map<wp<IBinder>, sp<DisplayDevice>> mDisplays GUARDED_BY(mStateLock); std::unordered_map<PhysicalDisplayId, sp<IBinder>> mPhysicalDisplayTokens // Displays are composited in `mDisplays` order. Internal displays are inserted at boot and // never removed, so take precedence over external and virtual displays. // // The static capacities were chosen to exceed a typical number of physical/virtual displays. // // May be read from any thread, but must only be written from the main thread. ftl::SmallMap<wp<IBinder>, const sp<DisplayDevice>, 5> mDisplays GUARDED_BY(mStateLock); ftl::SmallMap<PhysicalDisplayId, const sp<IBinder>, 3> mPhysicalDisplayTokens GUARDED_BY(mStateLock); struct { Loading Loading @@ -1423,10 +1428,8 @@ private: std::atomic<ui::Transform::RotationFlags> mActiveDisplayTransformHint; bool isRefreshRateOverlayEnabled() const REQUIRES(mStateLock) { return std::any_of(mDisplays.begin(), mDisplays.end(), [](std::pair<wp<IBinder>, sp<DisplayDevice>> display) { return display.second->isRefreshRateOverlayEnabled(); }); return hasDisplay( [](const auto& display) { return display.isRefreshRateOverlayEnabled(); }); } wp<IBinder> mActiveDisplayToken GUARDED_BY(mStateLock); Loading