summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjhonboy121 <alfredmathew05@gmail.com>2022-03-18 16:09:21 +0530
committeralk3pInjection <webmaster@raspii.tech>2022-05-07 00:20:58 +0800
commit10dba017b3e6fe6bb413fc6ab142e48496624796 (patch)
tree9d965533c2281081746561673f177b91bd9d136b
parent28e446bccda7890303ad97f84825a6bb70caffef (diff)
BluetoothControllerImpl: Synchronize mConnectedDevices access in getBatteryLevel()
E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: com.android.systemui, PID: 2245 E AndroidRuntime: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 E AndroidRuntime: at java.util.ArrayList.get(ArrayList.java:437) E AndroidRuntime: at com.android.systemui.statusbar.policy.BluetoothControllerImpl.getBatteryLevel(BluetoothControllerImpl.java:329) E AndroidRuntime: at com.android.systemui.statusbar.policy.BluetoothControllerImpl.updateBattery(BluetoothControllerImpl.java:335) E AndroidRuntime: at com.android.systemui.statusbar.policy.BluetoothControllerImpl.updateConnected(BluetoothControllerImpl.java:282) E AndroidRuntime: at com.android.systemui.statusbar.policy.BluetoothControllerImpl.onDeviceAttributesChanged(BluetoothControllerImpl.java:379) E AndroidRuntime: at com.android.settingslib.bluetooth.CachedBluetoothDevice.dispatchAttributesChanged(CachedBluetoothDevice.java:904) E AndroidRuntime: at com.android.settingslib.bluetooth.CachedBluetoothDevice.lambda$refresh$0(CachedBluetoothDevice.java:612) E AndroidRuntime: at com.android.settingslib.bluetooth.CachedBluetoothDevice.$r8$lambda$4IYXIWE9azg2QshMjGh5evIGUmg(Unknown Source:0) E AndroidRuntime: at com.android.settingslib.bluetooth.CachedBluetoothDevice$$ExternalSyntheticLambda1.run(Unknown Source:2) E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938) E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7871) E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:550) E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) Change-Id: I036ffeb434ddbd7f2abfcfe950414319458f455b Signed-off-by: jhonboy121 <alfredmathew05@gmail.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
index 28268e1d9f63..de9b28580603 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
@@ -325,8 +325,10 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
@Override
public int getBatteryLevel() {
- if (!mConnectedDevices.isEmpty()) {
- return mConnectedDevices.get(0).getBatteryLevel();
+ synchronized (mConnectedDevices) {
+ if (!mConnectedDevices.isEmpty()) {
+ return mConnectedDevices.get(0).getBatteryLevel();
+ }
}
return -1;
}