Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit ff45ea84 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Sync InputDeviceSensorManager device state with InputManagerGlobal

Previously, InputDeviceSensorManager created its own thread for two
purposes:
1. To receive input devices changed callbacks, and
2. To notify events for listeners that were registered without a handler
  on which they should be notified.

The fact that the sensor manager was getting devices changed callbacks
on a separate thread meant that the callbacks would race with app
callbaks, so it was possible for apps to be notified of devices changing
before the manager was. In that case, an app that queries a newly added
device's sensors will not get the sensor even if it exists, because the
sensor manager doesn't know about the device yet.

To fix this, we no longer receive device changes on the sensor thread.
Instead, we notify the sensor manager of device changes directly from
the binder thread to keep it in sync with InputManagerGlobal.

The sensor thread will now be lazy-initialized only for case 2., where a
listener is added with a null handler.

Bug: 290254916
Test: atest InputDeviceSensorManagerTest
Change-Id: I6877a353e8cddd85f0aed5f4aa51e0e16fc364e7
parent 0e51c4b2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment