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

Commit ad82a0fe authored by Phil Burk's avatar Phil Burk
Browse files

MidiService: synchronize mDeviceConnections

Try to prevent a NullPointerException caused
by scanning the array while devices were being removed
by another thread.

Bug: 193278370
Test: atest CtsMidiTestCases
Change-Id: I8560cf6f39654037d5ccdc0f6922fa8bdb719c2f
parent e850823d
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -350,11 +350,13 @@ public class MidiService extends IMidiManager.Stub {
            }
            }


            if (mDeviceConnections != null) {
            if (mDeviceConnections != null) {
                synchronized (mDeviceConnections) {
                    for (DeviceConnection connection : mDeviceConnections) {
                    for (DeviceConnection connection : mDeviceConnections) {
                        connection.notifyClient(server);
                        connection.notifyClient(server);
                    }
                    }
                }
                }
            }
            }
        }


        public MidiDeviceInfo getDeviceInfo() {
        public MidiDeviceInfo getDeviceInfo() {
            return mDeviceInfo;
            return mDeviceInfo;