import typing

import android.app
import android.bluetooth
import android.content
import android.os
import java
import java.chaquopy
import java.io
import java.lang
import java.util
import java.util.concurrent

class MidiDevice(java.io.Closeable):
    def close(self) -> None: ...
    def connectPorts(self, inputPort: MidiInputPort, outputPortNumber: int | java.jint | java.lang.Integer, /) -> MidiDevice.MidiConnection: ...
    def finalize(self) -> None: ...
    def getInfo(self) -> MidiDeviceInfo: ...
    def openInputPort(self, portNumber: int | java.jint | java.lang.Integer, /) -> MidiInputPort: ...
    def openOutputPort(self, portNumber: int | java.jint | java.lang.Integer, /) -> MidiOutputPort: ...
    def toString(self) -> str: ...

    class MidiConnection(java.io.Closeable):
        def close(self) -> None: ...
        def finalize(self) -> None: ...

class MidiDeviceInfo(android.os.Parcelable):
    CREATOR: typing.ClassVar[android.os.Parcelable.Creator[MidiDeviceInfo]] = ...
    PROPERTY_BLUETOOTH_DEVICE: typing.ClassVar[str] = ...
    PROPERTY_MANUFACTURER: typing.ClassVar[str] = ...
    PROPERTY_NAME: typing.ClassVar[str] = ...
    PROPERTY_PRODUCT: typing.ClassVar[str] = ...
    PROPERTY_SERIAL_NUMBER: typing.ClassVar[str] = ...
    PROPERTY_USB_DEVICE: typing.ClassVar[str] = ...
    PROPERTY_VERSION: typing.ClassVar[str] = ...
    PROTOCOL_UMP_MIDI_1_0_UP_TO_128_BITS: typing.ClassVar[int] = ...
    PROTOCOL_UMP_MIDI_1_0_UP_TO_128_BITS_AND_JRTS: typing.ClassVar[int] = ...
    PROTOCOL_UMP_MIDI_1_0_UP_TO_64_BITS: typing.ClassVar[int] = ...
    PROTOCOL_UMP_MIDI_1_0_UP_TO_64_BITS_AND_JRTS: typing.ClassVar[int] = ...
    PROTOCOL_UMP_MIDI_2_0: typing.ClassVar[int] = ...
    PROTOCOL_UMP_MIDI_2_0_AND_JRTS: typing.ClassVar[int] = ...
    PROTOCOL_UMP_USE_MIDI_CI: typing.ClassVar[int] = ...
    PROTOCOL_UNKNOWN: typing.ClassVar[int] = ...
    TYPE_BLUETOOTH: typing.ClassVar[int] = ...
    TYPE_USB: typing.ClassVar[int] = ...
    TYPE_VIRTUAL: typing.ClassVar[int] = ...
    def describeContents(self) -> int: ...
    def equals(self, o: java.lang.Object | int | bool | float | str, /) -> bool: ...
    def getDefaultProtocol(self) -> int: ...
    def getId(self) -> int: ...
    def getInputPortCount(self) -> int: ...
    def getOutputPortCount(self) -> int: ...
    def getPorts(self) -> java.chaquopy.JavaArray[MidiDeviceInfo.PortInfo]: ...
    def getProperties(self) -> android.os.Bundle: ...
    def getType(self) -> int: ...
    def hashCode(self) -> int: ...
    def isPrivate(self) -> bool: ...
    def toString(self) -> str: ...
    def writeToParcel(self, parcel: android.os.Parcel, flags: int | java.jint | java.lang.Integer, /) -> None: ...

    class PortInfo(java.lang.Object):
        TYPE_INPUT: typing.ClassVar[int] = ...
        TYPE_OUTPUT: typing.ClassVar[int] = ...
        def getName(self) -> str: ...
        def getPortNumber(self) -> int: ...
        def getType(self) -> int: ...

class MidiDeviceService(android.app.Service):
    SERVICE_INTERFACE: typing.ClassVar[str] = ...
    def __init__(self) -> None: ...
    def getDeviceInfo(self) -> MidiDeviceInfo: ...
    def getOutputPortReceivers(self) -> java.chaquopy.JavaArray[MidiReceiver]: ...
    def onBind(self, intent: android.content.Intent, /) -> android.os.IBinder: ...
    def onClose(self) -> None: ...
    def onCreate(self) -> None: ...
    def onDeviceStatusChanged(self, status: MidiDeviceStatus, /) -> None: ...
    def onGetInputPortReceivers(self) -> java.chaquopy.JavaArray[MidiReceiver]: ...

class MidiDeviceStatus(android.os.Parcelable):
    CREATOR: typing.ClassVar[android.os.Parcelable.Creator[MidiDeviceStatus]] = ...
    def describeContents(self) -> int: ...
    def getDeviceInfo(self) -> MidiDeviceInfo: ...
    def getOutputPortOpenCount(self, portNumber: int | java.jint | java.lang.Integer, /) -> int: ...
    def isInputPortOpen(self, portNumber: int | java.jint | java.lang.Integer, /) -> bool: ...
    def toString(self) -> str: ...
    def writeToParcel(self, parcel: android.os.Parcel, flags: int | java.jint | java.lang.Integer, /) -> None: ...

class MidiInputPort(MidiReceiver, java.io.Closeable):
    def close(self) -> None: ...
    def finalize(self) -> None: ...
    def getPortNumber(self) -> int: ...
    def onFlush(self) -> None: ...
    def onSend(self, msg: java.chaquopy.JavaArrayJByte, offset: int | java.jint | java.lang.Integer, count: int | java.jint | java.lang.Integer, timestamp: int | java.jlong | java.lang.Long, /) -> None: ...

class MidiManager(java.lang.Object):
    TRANSPORT_MIDI_BYTE_STREAM: typing.ClassVar[int] = ...
    TRANSPORT_UNIVERSAL_MIDI_PACKETS: typing.ClassVar[int] = ...
    def getDevices(self) -> java.chaquopy.JavaArray[MidiDeviceInfo]: ...
    def getDevicesForTransport(self, transport: int | java.jint | java.lang.Integer, /) -> java.util.Set[MidiDeviceInfo]: ...
    def openBluetoothDevice(self, bluetoothDevice: android.bluetooth.BluetoothDevice, listener: MidiManager.OnDeviceOpenedListener, handler: android.os.Handler, /) -> None: ...
    def openDevice(self, deviceInfo: MidiDeviceInfo, listener: MidiManager.OnDeviceOpenedListener, handler: android.os.Handler, /) -> None: ...
    @typing.overload
    def registerDeviceCallback(self, callback: MidiManager.DeviceCallback, handler: android.os.Handler, /) -> None: ...
    @typing.overload
    def registerDeviceCallback(self, transport: int | java.jint | java.lang.Integer, executor: java.util.concurrent.Executor, callback: MidiManager.DeviceCallback, /) -> None: ...
    def unregisterDeviceCallback(self, callback: MidiManager.DeviceCallback, /) -> None: ...

    class OnDeviceOpenedListener(java.lang.Object):
        def onDeviceOpened(self, arg1: MidiDevice, /) -> None: ...

    class DeviceCallback(java.lang.Object):
        def __init__(self) -> None: ...
        def onDeviceAdded(self, device: MidiDeviceInfo, /) -> None: ...
        def onDeviceRemoved(self, device: MidiDeviceInfo, /) -> None: ...
        def onDeviceStatusChanged(self, status: MidiDeviceStatus, /) -> None: ...

class MidiOutputPort(MidiSender, java.io.Closeable):
    def close(self) -> None: ...
    def finalize(self) -> None: ...
    def getPortNumber(self) -> int: ...
    def onConnect(self, receiver: MidiReceiver, /) -> None: ...
    def onDisconnect(self, receiver: MidiReceiver, /) -> None: ...

class MidiReceiver(java.lang.Object):
    @typing.overload
    def __init__(self) -> None: ...
    @typing.overload
    def __init__(self, maxMessageSize: int | java.jint | java.lang.Integer, /) -> None: ...
    def flush(self) -> None: ...
    def getMaxMessageSize(self) -> int: ...
    def onFlush(self) -> None: ...
    def onSend(self, arg1: java.chaquopy.JavaArrayJByte, arg2: int | java.jint | java.lang.Integer, arg3: int | java.jint | java.lang.Integer, arg4: int | java.jlong | java.lang.Long, /) -> None: ...
    @typing.overload
    def send(self, msg: java.chaquopy.JavaArrayJByte, offset: int | java.jint | java.lang.Integer, count: int | java.jint | java.lang.Integer, /) -> None: ...
    @typing.overload
    def send(self, msg: java.chaquopy.JavaArrayJByte, offset: int | java.jint | java.lang.Integer, count: int | java.jint | java.lang.Integer, timestamp: int | java.jlong | java.lang.Long, /) -> None: ...

class MidiSender(java.lang.Object):
    def __init__(self) -> None: ...
    def connect(self, receiver: MidiReceiver, /) -> None: ...
    def disconnect(self, receiver: MidiReceiver, /) -> None: ...
    def onConnect(self, arg1: MidiReceiver, /) -> None: ...
    def onDisconnect(self, arg1: MidiReceiver, /) -> None: ...

class MidiUmpDeviceService(android.app.Service):
    SERVICE_INTERFACE: typing.ClassVar[str] = ...
    def __init__(self) -> None: ...
    def getDeviceInfo(self) -> MidiDeviceInfo | None: ...
    def getOutputPortReceivers(self) -> java.util.List[MidiReceiver]: ...
    def onBind(self, intent: android.content.Intent, /) -> android.os.IBinder | None: ...
    def onClose(self) -> None: ...
    def onCreate(self) -> None: ...
    def onDeviceStatusChanged(self, status: MidiDeviceStatus, /) -> None: ...
    def onGetInputPortReceivers(self) -> java.util.List[MidiReceiver]: ...
