MidiDeviceService: Add getDeviceInfo() accessor method
so service implementations can access their own device info object. Change-Id: I93e0c449e72d76568d7b4c9f7f7db00a846b5a33
This commit is contained in:
@@ -55,6 +55,7 @@ abstract public class MidiDeviceService extends Service {
|
||||
|
||||
private IMidiManager mMidiManager;
|
||||
private MidiDeviceServer mServer;
|
||||
private MidiDeviceInfo mDeviceInfo;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -64,6 +65,11 @@ abstract public class MidiDeviceService extends Service {
|
||||
try {
|
||||
MidiDeviceInfo deviceInfo = mMidiManager.getServiceDeviceInfo(getPackageName(),
|
||||
this.getClass().getName());
|
||||
if (deviceInfo == null) {
|
||||
Log.e(TAG, "Could not find MidiDeviceInfo for MidiDeviceService " + this);
|
||||
return;
|
||||
}
|
||||
mDeviceInfo = deviceInfo;
|
||||
MidiReceiver[] inputPortReceivers = getInputPortReceivers();
|
||||
if (inputPortReceivers == null) {
|
||||
inputPortReceivers = new MidiReceiver[0];
|
||||
@@ -100,6 +106,14 @@ abstract public class MidiDeviceService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the {@link MidiDeviceInfo} instance for this service
|
||||
* @return our MidiDeviceInfo
|
||||
*/
|
||||
public MidiDeviceInfo getDeviceInfo() {
|
||||
return mDeviceInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
if (SERVICE_INTERFACE.equals(intent.getAction()) && mServer != null) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package android.media.midi;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
* This class contains utilities for socket communication between a
|
||||
* MidiInputPort and MidiOutputPort
|
||||
|
||||
Reference in New Issue
Block a user