Commit 91450a62 authored by Anthony Zhang's avatar Anthony Zhang Committed by Commit Bot

Notify newly added observer of existing devices

Newly added observers are not currently notified of existing
devices. If ScanDevices() is called before all observers are
registered then some observers will miss device events.

Bug: 70595920
Test: Observers receive OnDeviceEvent() correctly when registered
Change-Id: Ia04b894773ac676409e2d6d12b31e3b3801eb140
Reviewed-on: https://chromium-review.googlesource.com/841424Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Anthony Zhang <antz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526039}
parent 2af7b4b8
......@@ -46,6 +46,11 @@ void DeviceManagerManual::ScanDevices(DeviceEventObserver* observer) {
void DeviceManagerManual::AddObserver(DeviceEventObserver* observer) {
observers_.AddObserver(observer);
// Notify the new observer about existing devices.
for (const auto& path : devices_) {
DeviceEvent event(DeviceEvent::INPUT, DeviceEvent::ADD, path);
observer->OnDeviceEvent(event);
}
}
void DeviceManagerManual::RemoveObserver(DeviceEventObserver* observer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment