diff options
author | Phil Burk <philburk@google.com> | 2015-09-03 14:37:03 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2015-10-13 15:40:03 +0000 |
commit | 977fe03b36a7783f9cee8497efe550a69b128473 (patch) | |
tree | d4b796103d255c84b0cde4ca0e0410cc6b8b1bf1 /services | |
parent | c024de3c946c18e8e4799eb8d372fdec3146f8cf (diff) | |
download | frameworks_base-977fe03b36a7783f9cee8497efe550a69b128473.zip frameworks_base-977fe03b36a7783f9cee8497efe550a69b128473.tar.gz frameworks_base-977fe03b36a7783f9cee8497efe550a69b128473.tar.bz2 |
BLE-MIDI: change binding for BluetoothMidiService
Add a remote call addBluetoothDevice() using AIDL.
This was needed because onBind() is only called once.
Bug: 23219556
Bug: 23760886
Change-Id: Id7554ca55d596352d11dbd6ae3e403138a29c864
Signed-off-by: Phil Burk <philburk@google.com>
(cherry picked from commit 7cd06c0b9e087a555d2c5dd4cab5b7eac8497526)
Diffstat (limited to 'services')
-rw-r--r-- | services/midi/java/com/android/server/midi/MidiService.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/services/midi/java/com/android/server/midi/MidiService.java b/services/midi/java/com/android/server/midi/MidiService.java index 701e07f..c6d5a7e 100644 --- a/services/midi/java/com/android/server/midi/MidiService.java +++ b/services/midi/java/com/android/server/midi/MidiService.java @@ -27,6 +27,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.XmlResourceParser; +import android.media.midi.IBluetoothMidiService; import android.media.midi.IMidiDeviceListener; import android.media.midi.IMidiDeviceOpenCallback; import android.media.midi.IMidiDeviceServer; @@ -394,7 +395,20 @@ public class MidiService extends IMidiManager.Stub { mServiceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { - IMidiDeviceServer server = IMidiDeviceServer.Stub.asInterface(service); + IMidiDeviceServer server = null; + if (mBluetoothDevice != null) { + IBluetoothMidiService mBluetoothMidiService = IBluetoothMidiService.Stub.asInterface(service); + try { + // We need to explicitly add the device in a separate method + // because onBind() is only called once. + IBinder deviceBinder = mBluetoothMidiService.addBluetoothDevice(mBluetoothDevice); + server = IMidiDeviceServer.Stub.asInterface(deviceBinder); + } catch(RemoteException e) { + Log.e(TAG, "Could not call addBluetoothDevice()", e); + } + } else { + server = IMidiDeviceServer.Stub.asInterface(service); + } setDeviceServer(server); } @@ -411,7 +425,6 @@ public class MidiService extends IMidiManager.Stub { intent.setComponent(new ComponentName( MidiManager.BLUETOOTH_MIDI_SERVICE_PACKAGE, MidiManager.BLUETOOTH_MIDI_SERVICE_CLASS)); - intent.putExtra("device", mBluetoothDevice); } else { intent = new Intent(MidiDeviceService.SERVICE_INTERFACE); intent.setComponent( |