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

Commit 67f8e8bd authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MIDI Manager work in progress

Still to do:

Add MidiInputPort and MidiOutputPort classes
Schedule sending MIDI events in the future
Security/permissions
Reconsider interface for virtual devices
Look into performance optimizations

Change-Id: I9b7d63b196996a04be0a830efa913043da1328a8
parent 0927c43c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl \
	core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl \
	core/java/android/hardware/usb/IUsbManager.aidl \
	core/java/android/midi/IMidiListener.aidl \
	core/java/android/midi/IMidiManager.aidl \
	core/java/android/net/IConnectivityManager.aidl \
	core/java/android/net/IEthernetManager.aidl \
	core/java/android/net/IEthernetServiceListener.aidl \
+8 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ import android.media.projection.MediaProjectionManager;
import android.media.session.MediaSessionManager;
import android.media.tv.ITvInputManager;
import android.media.tv.TvInputManager;
import android.midi.IMidiManager;
import android.midi.MidiManager;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.EthernetManager;
@@ -777,6 +779,12 @@ class ContextImpl extends Context {
                IBinder b = ServiceManager.getService(APPWIDGET_SERVICE);
                return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
            }});

        registerService(MIDI_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    IBinder b = ServiceManager.getService(MIDI_SERVICE);
                    return new MidiManager(ctx, IMidiManager.Stub.asInterface(b));
                }});
    }

    static ContextImpl getImpl(Context context) {
+10 −0
Original line number Diff line number Diff line
@@ -2142,6 +2142,7 @@ public abstract class Context {
            MEDIA_SESSION_SERVICE,
            BATTERY_SERVICE,
            JOB_SCHEDULER_SERVICE,
            MIDI_SERVICE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ServiceName {}
@@ -2914,6 +2915,15 @@ public abstract class Context {
     */
    public static final String MEDIA_PROJECTION_SERVICE = "media_projection";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.midi.MidiManager} for accessing the MIDI service.
     *
     * @see #getSystemService
     * @hide
     */
    public static final String MIDI_SERVICE = "midi";

    /**
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.midi;

import android.midi.MidiDeviceInfo;

/** @hide */
oneway interface IMidiListener
{
    void onDeviceAdded(in MidiDeviceInfo device);
    void onDeviceRemoved(in MidiDeviceInfo device);
}
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.midi;

import android.hardware.usb.UsbDevice;
import android.midi.IMidiListener;
import android.midi.MidiDevice;
import android.midi.MidiDeviceInfo;
import android.os.Bundle;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;

/** @hide */
interface IMidiManager
{
    MidiDeviceInfo[] getDeviceList();

    // for device creation & removal notifications
    void registerListener(IBinder token, in IMidiListener listener);
    void unregisterListener(IBinder token, in IMidiListener listener);

    // for communicating with MIDI devices
    ParcelFileDescriptor openDevice(IBinder token, in MidiDeviceInfo device);

    // for implementing virtual MIDI devices
    MidiDevice registerVirtualDevice(IBinder token, in Bundle properties);
    void unregisterVirtualDevice(IBinder token, in MidiDeviceInfo device);

    // for use by UsbAudioManager
    void alsaDeviceAdded(int card, int device, in UsbDevice usbDevice);
    void alsaDeviceRemoved(in UsbDevice usbDevice);
}
Loading