正在查看: Tasker v6.6.3 应用的 USBHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.6.3 应用的 USBHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package net.dinglisch.android.taskerm;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.text.TextUtils;
import java.io.File;
import java.util.Map;
import java.util.Set;
public class USBHandler extends Activity {
private static final String[] r;
private static final com.joaomgcd.taskerm.util.o7[] s;
private static final int[] i = {65520, 254, 1, 10, 2, 13, 11, 65522, 65521, 3, 8, 239, 0, 5, 7, 6, 255, 14, 224};
private static final String[] q = {"subsystem", "power", "driver", "usb_device", "ep_", "statistics"};
private static int[] t = {2131891148, 2131891035, 2131891036, 2131891037, 2131891038, 2131891039, 2131891040, 2131891041, 2131891042, 2131891043, 2131891044, 2131891052, 2131891045, 2131891046, 2131891047, 2131891048, 2131891049, 2131891050, 2131891051};
private static long u = 0;
class a extends com.joaomgcd.taskerm.util.o7 {
final Context d;
public a(String str, String str2, int i) {
super("USBFileObserver", str, str2);
this.d = i;
}
@Override
public void b(int i, String str) {
if (i != 32768) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - USBHandler.u > 1500) {
Intent intent = new Intent(this.d, (Class<?>) ReceiverStaticInternal.class);
intent.setAction(i == 512 ? "android.hardware.usb.action.USB_DEVICE_DETACHED" : "android.hardware.usb.action.USB_DEVICE_ATTACHED");
MonitorService.E9(this.d, intent, -1);
USBHandler.u = currentTimeMillis;
}
}
}
}
static {
String[] strArr = {"/storage/emulated", "/dev/input", "/sys/bus/usb/devices", "/dev/usb", "/dev/bus/usb"};
r = strArr;
s = new com.joaomgcd.taskerm.util.o7[strArr.length];
}
private static void c(Set<Integer> set, File file, int i2, String str) {
set.add(Integer.valueOf(i2));
o7.f("USBHandler", "addDevice: " + str + " from: " + file + ": added " + i2);
}
public static int d(int i2) {
int i3 = 0;
while (true) {
int[] iArr = i;
if (i3 >= iArr.length) {
o7.G("USBHandler", "cti: unknown device class: " + i2);
return 239;
}
if (iArr[i3] == i2) {
return i3;
}
i3++;
}
}
public static String[] e(Resources resources) {
return oh.s(resources, t);
}
public static void f(Context context, Set<Integer> set) {
g(context, set);
h(set);
set.remove(9);
}
public static void g(Context context, Set<Integer> set) {
UsbManager usbManager = (UsbManager) gi.d(context, "usb", "USBHandler", "gcca");
if (usbManager == null) {
return;
}
for (UsbDevice usbDevice : usbManager.getDeviceList().values()) {
int deviceClass = usbDevice.getDeviceClass();
o7.f("USBHandler", "gca: dclass: " + deviceClass);
c(set, null, deviceClass, "gca");
for (int i2 = 0; i2 < usbDevice.getInterfaceCount(); i2++) {
int interfaceClass = usbDevice.getInterface(i2).getInterfaceClass();
o7.f("USBHandler", "gca: iface " + i2 + " class " + interfaceClass);
c(set, null, interfaceClass, "gca");
}
}
}
public static void h(Set<Integer> set) {
File file = new File("/sys/bus/usb/devices");
if (file.exists()) {
i(file, set, 0);
} else {
o7.f("USBHandler", "no dir: /sys/bus/usb/devices");
}
}
public static void i(File file, Set<Integer> set, int i2) {
if (l(file.getName(), q)) {
return;
}
File[] listFiles = file.listFiles();
if (pp.r(listFiles)) {
return;
}
for (File file2 : listFiles) {
if (!file2.isDirectory()) {
String name = file2.getName();
boolean equals = name.equals("bInterfaceClass");
if (equals || name.equals("bDeviceClass")) {
String X = pp.X(file2);
if (!TextUtils.isEmpty(X)) {
Integer D1 = pp.D1(X.trim());
if (D1 == null) {
o7.G("USBHandler", "gccldd: non-integer contents: " + file2);
} else if (D1.intValue() == 3 && equals) {
int n = n(file);
if (n == 2) {
c(set, file2, 65521, "gla_mouse");
} else if (n == 1) {
c(set, file2, 65522, "gla_key");
} else {
c(set, file2, 3, "gla_hid");
}
} else if (D1.intValue() != 0) {
c(set, file2, D1.intValue(), "gla_default");
}
}
}
} else if (i2 <= 4) {
i(file2, set, i2 + 1);
}
}
}
public static UsbDevice j(UsbManager usbManager, int i2, int i3) {
if (usbManager == null) {
o7.G("USBHandler", "getDeviceWithClass: no manager ");
return null;
}
for (Map.Entry<String, UsbDevice> entry : usbManager.getDeviceList().entrySet()) {
String key = entry.getKey();
UsbDevice value = entry.getValue();
int deviceClass = value.getDeviceClass();
int deviceSubclass = value.getDeviceSubclass();
o7.f("USBHandler", "gdwc: device: " + key + " class " + deviceClass + " sub " + value.getDeviceSubclass());
if (deviceClass == 0) {
for (int i4 = 0; i4 < value.getInterfaceCount(); i4++) {
UsbInterface usbInterface = value.getInterface(i4);
int interfaceClass = usbInterface.getInterfaceClass();
int interfaceSubclass = usbInterface.getInterfaceSubclass();
o7.f("USBHandler", "gdwc: test interface " + i4 + " class " + interfaceClass + " sub " + interfaceSubclass);
if (interfaceClass == i2 && interfaceSubclass == i3) {
o7.f("USBHandler", "gdwc: match interface");
return value;
}
}
} else if (deviceClass == i2 && deviceSubclass == i3) {
o7.f("USBHandler", "gdwc: match device");
return value;
}
}
return null;
}
public static UsbManager k(Context context) {
return (UsbManager) gi.d(context, "usb", "USBHandler", "getMan");
}
private static boolean l(String str, String[] strArr) {
for (String str2 : strArr) {
if (str.startsWith(str2)) {
return true;
}
}
return false;
}
public static int m(int i2) {
return i[i2];
}
private static int n(File file) {
String X;
File file2 = new File(file, "bInterfaceProtocol");
if (file2.exists() && (X = pp.X(file2)) != null) {
Integer E3 = pp.E3(X.trim());
if (E3 != null) {
return E3.intValue();
}
o7.f("USBHandler", "bad protocol file contents " + file + ": " + X);
}
return -1;
}
public static void o(Context context, boolean z) {
int i2 = 0;
int i3 = 0;
while (true) {
com.joaomgcd.taskerm.util.o7[] o7VarArr = s;
if (i3 >= o7VarArr.length) {
break;
}
com.joaomgcd.taskerm.util.o7 o7Var = o7VarArr[i3];
if (o7Var != null) {
o7Var.d();
o7VarArr[i3] = null;
}
i3++;
}
if (!z) {
return;
}
while (true) {
String[] strArr = r;
if (i2 >= strArr.length) {
return;
}
if (new File(strArr[i2]).exists()) {
o7.f("USBHandler", "add monitor for " + strArr[i2]);
com.joaomgcd.taskerm.util.o7[] o7VarArr2 = s;
a aVar = new a(strArr[i2], 768, context);
o7VarArr2[i2] = aVar;
aVar.c();
}
i2++;
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Intent intent = getIntent();
String action = intent.getAction();
if (action.equals("android.hardware.usb.action.USB_DEVICE_ATTACHED")) {
o7.f("USBHandler", action);
MonitorService.E9(this, intent, -1);
} else {
if (action.equals("android.hardware.usb.action.USB_DEVICE_DETACHED")) {
MonitorService.E9(this, intent, -1);
return;
}
o7.k("USBHandler", "unexpected action " + action);
}
}
}