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

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

MidiManager: use ConcurrentHashMap



So that adding and removing device listeners is thread-safe.

Bug: 22909752
Change-Id: I1369ab53c865b54e6e5eb8ea3e8d437fdd1d7197
Signed-off-by: default avatarPhil Burk <philburk@google.com>
parent b83b5fa6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * This class is the public application interface to the MIDI service.
@@ -61,8 +61,8 @@ public final class MidiManager {
    private final IMidiManager mService;
    private final IBinder mToken = new Binder();

    private HashMap<DeviceCallback,DeviceListener> mDeviceListeners =
        new HashMap<DeviceCallback,DeviceListener>();
    private ConcurrentHashMap<DeviceCallback,DeviceListener> mDeviceListeners =
        new ConcurrentHashMap<DeviceCallback,DeviceListener>();

    // Binder stub for receiving device notifications from MidiService
    private class DeviceListener extends IMidiDeviceListener.Stub {