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
Loading
Please register or sign in to comment