MidiService: clear status when device unbound

This can help prevent MIDI input ports from getting
stuck in the open position.

Bug: 210724686
Test: see bug for repro steps
Test: atest CtsMidiTestCases
Test: https://source.android.com/devices/audio/midi_test.html
Test: Check status with:  adb shell dumpsys midi
Change-Id: I9fe45eeb2d51356d114ae5a1a175e3d1f6977328
This commit is contained in:
Phil Burk
2021-12-18 19:42:34 +00:00
parent 67487b4673
commit 59a36aeb0d

View File

@@ -340,6 +340,11 @@ public class MidiService extends IMidiManager.Stub {
IBinder binder = server.asBinder();
mDevicesByServer.remove(binder);
// Clearing mDeviceStatus is needed because setDeviceStatus()
// relies on finding the device in mDevicesByServer.
// So the status can no longer be updated after we remove it.
// Then we can end up with input ports that are stuck open.
mDeviceStatus = null;
try {
server.closeDevice();