Search in sources :

Example 1 with MidiDeviceInfo

use of android.media.midi.MidiDeviceInfo in project platform_frameworks_base by android.

the class MidiService method addDeviceLocked.

// synchronize on mDevicesByInfo
private MidiDeviceInfo addDeviceLocked(int type, int numInputPorts, int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, boolean isPrivate, int uid) {
    int id = mNextDeviceId++;
    MidiDeviceInfo deviceInfo = new MidiDeviceInfo(type, id, numInputPorts, numOutputPorts, inputPortNames, outputPortNames, properties, isPrivate);
    if (server != null) {
        try {
            server.setDeviceInfo(deviceInfo);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException in setDeviceInfo()");
            return null;
        }
    }
    Device device = null;
    BluetoothDevice bluetoothDevice = null;
    if (type == MidiDeviceInfo.TYPE_BLUETOOTH) {
        bluetoothDevice = (BluetoothDevice) properties.getParcelable(MidiDeviceInfo.PROPERTY_BLUETOOTH_DEVICE);
        device = mBluetoothDevices.get(bluetoothDevice);
        if (device != null) {
            device.setDeviceInfo(deviceInfo);
        }
    }
    if (device == null) {
        device = new Device(server, deviceInfo, serviceInfo, uid);
    }
    mDevicesByInfo.put(deviceInfo, device);
    if (bluetoothDevice != null) {
        mBluetoothDevices.put(bluetoothDevice, device);
    }
    synchronized (mClients) {
        for (Client c : mClients.values()) {
            c.deviceAdded(device);
        }
    }
    return deviceInfo;
}
Also used : MidiDeviceInfo(android.media.midi.MidiDeviceInfo) BluetoothDevice(android.bluetooth.BluetoothDevice) BluetoothDevice(android.bluetooth.BluetoothDevice) RemoteException(android.os.RemoteException)

Example 2 with MidiDeviceInfo

use of android.media.midi.MidiDeviceInfo in project android_frameworks_base by DirtyUnicorns.

the class MidiService method getDevices.

public MidiDeviceInfo[] getDevices() {
    ArrayList<MidiDeviceInfo> deviceInfos = new ArrayList<MidiDeviceInfo>();
    int uid = Binder.getCallingUid();
    synchronized (mDevicesByInfo) {
        for (Device device : mDevicesByInfo.values()) {
            if (device.isUidAllowed(uid)) {
                deviceInfos.add(device.getDeviceInfo());
            }
        }
    }
    return deviceInfos.toArray(EMPTY_DEVICE_INFO_ARRAY);
}
Also used : MidiDeviceInfo(android.media.midi.MidiDeviceInfo) BluetoothDevice(android.bluetooth.BluetoothDevice) ArrayList(java.util.ArrayList)

Example 3 with MidiDeviceInfo

use of android.media.midi.MidiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class MidiService method addDeviceLocked.

// synchronize on mDevicesByInfo
private MidiDeviceInfo addDeviceLocked(int type, int numInputPorts, int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, boolean isPrivate, int uid) {
    int id = mNextDeviceId++;
    MidiDeviceInfo deviceInfo = new MidiDeviceInfo(type, id, numInputPorts, numOutputPorts, inputPortNames, outputPortNames, properties, isPrivate);
    if (server != null) {
        try {
            server.setDeviceInfo(deviceInfo);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException in setDeviceInfo()");
            return null;
        }
    }
    Device device = null;
    BluetoothDevice bluetoothDevice = null;
    if (type == MidiDeviceInfo.TYPE_BLUETOOTH) {
        bluetoothDevice = (BluetoothDevice) properties.getParcelable(MidiDeviceInfo.PROPERTY_BLUETOOTH_DEVICE);
        device = mBluetoothDevices.get(bluetoothDevice);
        if (device != null) {
            device.setDeviceInfo(deviceInfo);
        }
    }
    if (device == null) {
        device = new Device(server, deviceInfo, serviceInfo, uid);
    }
    mDevicesByInfo.put(deviceInfo, device);
    if (bluetoothDevice != null) {
        mBluetoothDevices.put(bluetoothDevice, device);
    }
    synchronized (mClients) {
        for (Client c : mClients.values()) {
            c.deviceAdded(device);
        }
    }
    return deviceInfo;
}
Also used : MidiDeviceInfo(android.media.midi.MidiDeviceInfo) BluetoothDevice(android.bluetooth.BluetoothDevice) BluetoothDevice(android.bluetooth.BluetoothDevice) RemoteException(android.os.RemoteException)

Example 4 with MidiDeviceInfo

use of android.media.midi.MidiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class MidiService method getDevices.

public MidiDeviceInfo[] getDevices() {
    ArrayList<MidiDeviceInfo> deviceInfos = new ArrayList<MidiDeviceInfo>();
    int uid = Binder.getCallingUid();
    synchronized (mDevicesByInfo) {
        for (Device device : mDevicesByInfo.values()) {
            if (device.isUidAllowed(uid)) {
                deviceInfos.add(device.getDeviceInfo());
            }
        }
    }
    return deviceInfos.toArray(EMPTY_DEVICE_INFO_ARRAY);
}
Also used : MidiDeviceInfo(android.media.midi.MidiDeviceInfo) BluetoothDevice(android.bluetooth.BluetoothDevice) ArrayList(java.util.ArrayList)

Example 5 with MidiDeviceInfo

use of android.media.midi.MidiDeviceInfo in project android_frameworks_base by crdroidandroid.

the class MidiService method getDevices.

public MidiDeviceInfo[] getDevices() {
    ArrayList<MidiDeviceInfo> deviceInfos = new ArrayList<MidiDeviceInfo>();
    int uid = Binder.getCallingUid();
    synchronized (mDevicesByInfo) {
        for (Device device : mDevicesByInfo.values()) {
            if (device.isUidAllowed(uid)) {
                deviceInfos.add(device.getDeviceInfo());
            }
        }
    }
    return deviceInfos.toArray(EMPTY_DEVICE_INFO_ARRAY);
}
Also used : MidiDeviceInfo(android.media.midi.MidiDeviceInfo) BluetoothDevice(android.bluetooth.BluetoothDevice) ArrayList(java.util.ArrayList)

Aggregations

BluetoothDevice (android.bluetooth.BluetoothDevice)8 MidiDeviceInfo (android.media.midi.MidiDeviceInfo)8 RemoteException (android.os.RemoteException)4 ArrayList (java.util.ArrayList)4