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
Merged-In: Ibb6b8c999b7fd4fe7fbcc57264a1fe6ad74903dc
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 728020e..b3a24af 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -32,8 +32,6 @@
#include "InputReaderContext.h"
namespace android {
-// TODO b/180733860 support multiple battery in API and remove this.
-constexpr int32_t DEFAULT_BATTERY_ID = 1;
class PeripheralController;
class PeripheralControllerInterface;
@@ -100,8 +98,7 @@
void disableSensor(InputDeviceSensorType sensorType);
void flushSensor(InputDeviceSensorType sensorType);
- std::optional<int32_t> getBatteryCapacity();
- std::optional<int32_t> getBatteryStatus();
+ std::optional<int32_t> getBatteryEventHubId() const;
bool setLightColor(int32_t lightId, int32_t color);
bool setLightPlayerId(int32_t lightId, int32_t playerId);