导航菜单

页面标题

页面副标题

Tasker v6.6.3 - MIDIHandler.java 源代码

正在查看: Tasker v6.6.3 应用的 MIDIHandler.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package net.dinglisch.android.taskerm;

import android.app.Activity;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.os.Bundle;

public class MIDIHandler extends Activity {
    public static td a(UsbManager usbManager, UsbDevice usbDevice) {
        if (usbDevice == null) {
            o7.G("MIDIHandler", "gmod: no device");
            return null;
        }
        UsbDeviceConnection openDevice = usbManager.openDevice(usbDevice);
        if (openDevice == null) {
            o7.G("MIDIHandler", "gmod: no connection ");
            return null;
        }
        int deviceClass = usbDevice.getDeviceClass();
        int deviceSubclass = usbDevice.getDeviceSubclass();
        o7.f("MIDIHandler", "gmod: device class: " + deviceClass + " subclass " + deviceSubclass);
        UsbEndpoint usbEndpoint = null;
        UsbInterface usbInterface = null;
        for (int i = 0; i < usbDevice.getInterfaceCount(); i++) {
            UsbInterface usbInterface2 = usbDevice.getInterface(i);
            int interfaceClass = usbInterface2.getInterfaceClass();
            int interfaceSubclass = usbInterface2.getInterfaceSubclass();
            o7.f("MIDIHandler", "gmod: interface " + i + " class " + interfaceClass + " subclass " + interfaceSubclass);
            if ((deviceClass == 1 && deviceSubclass == 3) || (deviceClass == 0 && interfaceClass == 1 && interfaceSubclass == 3)) {
                int i2 = 0;
                while (true) {
                    if (i2 >= usbInterface2.getEndpointCount()) {
                        break;
                    }
                    UsbEndpoint endpoint = usbInterface2.getEndpoint(i2);
                    if (endpoint.getDirection() == 0) {
                        o7.f("MIDIHandler", "gmod: using out index " + i2);
                        usbInterface = usbInterface2;
                        usbEndpoint = endpoint;
                        break;
                    }
                    i2++;
                }
            }
            if (usbEndpoint != null) {
                break;
            }
        }
        if (usbEndpoint == null) {
            o7.G("MIDIHandler", "gmod: no out endpoint found");
            return null;
        }
        o7.f("MIDIHandler", "have endpoint, create interface");
        return new td(usbDevice, openDevice, usbInterface, usbEndpoint);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        String action = getIntent().getAction();
        if (action != null && action.equals("android.hardware.usb.action.USB_DEVICE_ATTACHED")) {
            o7.f("MIDIHandler", action);
            return;
        }
        o7.k("MIDIHandler", "unexpected action " + action);
    }
}