Avoid UI freezing when reading battery capacity/status
Reading battery capacity and status could fail and end up
with timeout after 5s for some input devices, for example:
8BitDo SN30 Pro+ gamepad.
Before reading those items, it would be better to release
`mLock` so that other threads could run.
Bug: 244088945
Test: Manually verified no UI freezing when calling
`inputDevice.batteryState.capacity` or
`inputDevice.batteryState.status`
Change-Id: Ibb6b8c999b7fd4fe7fbcc57264a1fe6ad74903dc
diff --git a/services/inputflinger/reader/controller/PeripheralController.h b/services/inputflinger/reader/controller/PeripheralController.h
index b1bc8c7..ac951eb 100644
--- a/services/inputflinger/reader/controller/PeripheralController.h
+++ b/services/inputflinger/reader/controller/PeripheralController.h
@@ -31,6 +31,7 @@
explicit PeripheralController(InputDeviceContext& deviceContext);
~PeripheralController() override;
+ int32_t getEventHubId() const override;
void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
void dump(std::string& dump) override;
bool setLightColor(int32_t lightId, int32_t color) override;
@@ -43,6 +44,7 @@
private:
inline int32_t getDeviceId() { return mDeviceContext.getId(); }
inline InputDeviceContext& getDeviceContext() { return mDeviceContext; }
+ inline InputDeviceContext& getDeviceContext() const { return mDeviceContext; }
InputDeviceContext& mDeviceContext;
void configureLights();