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

Commit bd327537 authored by Glenn Kasten's avatar Glenn Kasten Committed by android-build-merger
Browse files

Merge "BLE-MIDI: change binding for BluetoothMidiService"

am: 5831944a

* commit '5831944a':
  BLE-MIDI: change binding for BluetoothMidiService
parents d8a85004 5831944a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -348,6 +348,7 @@ LOCAL_SRC_FILES += \
	media/java/android/media/IRingtonePlayer.aidl \
	media/java/android/media/IVolumeController.aidl \
	media/java/android/media/audiopolicy/IAudioPolicyCallback.aidl \
	media/java/android/media/midi/IBluetoothMidiService.aidl \
	media/java/android/media/midi/IMidiDeviceListener.aidl \
	media/java/android/media/midi/IMidiDeviceOpenCallback.aidl \
	media/java/android/media/midi/IMidiDeviceServer.aidl \
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.midi;

import android.bluetooth.BluetoothDevice;
import android.os.IBinder;

/** @hide */
interface IBluetoothMidiService
{
    IBinder addBluetoothDevice(in BluetoothDevice bluetoothDevice);
}
+2 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_SRC_FILES += \
      $(call all-java-files-under,src)

LOCAL_PACKAGE_NAME := BluetoothMidiService
LOCAL_CERTIFICATE := platform
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

    <application
        android:label="@string/app_name">
        <service android:name="BluetoothMidiService"
        <service android:name=".BluetoothMidiService"
            android:permission="android.permission.BIND_MIDI_DEVICE_SERVICE">
            <intent-filter>
                <action android:name="android.media.midi.BluetoothMidiService" />
+15 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.bluetoothmidiservice;
import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.media.midi.IBluetoothMidiService;
import android.media.midi.MidiManager;
import android.os.IBinder;
import android.util.Log;
@@ -34,25 +35,31 @@ public class BluetoothMidiService extends Service {

    @Override
    public IBinder onBind(Intent intent) {
        if (MidiManager.BLUETOOTH_MIDI_SERVICE_INTENT.equals(intent.getAction())) {
            BluetoothDevice bluetoothDevice = (BluetoothDevice)intent.getParcelableExtra("device");
            if (bluetoothDevice == null) {
                Log.e(TAG, "no BluetoothDevice in onBind intent");
                return null;
        // Return the interface
        return mBinder;
    }


    private final IBluetoothMidiService.Stub mBinder = new IBluetoothMidiService.Stub() {

        public IBinder addBluetoothDevice(BluetoothDevice bluetoothDevice) {
            BluetoothMidiDevice device;
            if (bluetoothDevice == null) {
                Log.e(TAG, "no BluetoothDevice in addBluetoothDevice()");
                return null;
            }
            synchronized (mDeviceServerMap) {
                device = mDeviceServerMap.get(bluetoothDevice);
                if (device == null) {
                    device = new BluetoothMidiDevice(this, bluetoothDevice, this);
                    device = new BluetoothMidiDevice(BluetoothMidiService.this,
                            bluetoothDevice, BluetoothMidiService.this);
                    mDeviceServerMap.put(bluetoothDevice, device);
                }
            }
            return device.getBinder();
        }
        return null;
    }

    };

    void deviceClosed(BluetoothDevice device) {
        synchronized (mDeviceServerMap) {
Loading