.class Lcom/a/j; .super Ljava/lang/Object; # interfaces .implements Lcom/a/c$e; .implements Ljava/lang/Runnable; # static fields .field private static j:Lcom/a/j; # instance fields .field private a:Landroid/hardware/usb/UsbManager; .field private b:Landroid/content/Context; .field private c:Lcom/a/c$b; .field private d:Lcom/a/c$d; .field private e:Landroid/hardware/usb/UsbAccessory; .field private f:Ljava/io/FileInputStream; .field private g:Ljava/io/FileOutputStream; .field private h:Landroid/os/ParcelFileDescriptor; .field private i:Z .field private k:Landroid/content/BroadcastReceiver; # direct methods .method constructor ()V .locals 1 invoke-direct {p0}, Ljava/lang/Object;->()V new-instance v0, Lcom/a/j$1; invoke-direct {v0, p0}, Lcom/a/j$1;->(Lcom/a/j;)V iput-object v0, p0, Lcom/a/j;->k:Landroid/content/BroadcastReceiver; return-void .end method .method static synthetic a(Lcom/a/j;)Lcom/a/c$b; .locals 1 iget-object v0, p0, Lcom/a/j;->c:Lcom/a/c$b; return-object v0 .end method .method public static a()Lcom/a/j; .locals 1 sget-object v0, Lcom/a/j;->j:Lcom/a/j; if-nez v0, :cond_0 new-instance v0, Lcom/a/j; invoke-direct {v0}, Lcom/a/j;->()V sput-object v0, Lcom/a/j;->j:Lcom/a/j; :cond_0 sget-object v0, Lcom/a/j;->j:Lcom/a/j; return-object v0 .end method .method private a([BZ)V .locals 5 iget-object v0, p0, Lcom/a/j;->c:Lcom/a/c$b; invoke-interface {v0}, Lcom/a/c$b;->a()Ljava/lang/String; move-result-object v0 invoke-virtual {v0}, Ljava/lang/String;->getBytes()[B move-result-object v1 const/4 v2, 0x0 const/16 v3, 0xc array-length v4, v1 invoke-static {v1, v2, p1, v3, v4}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V const/4 v2, 0x2 const v3, 0x27afe2d8 array-length v1, v1 invoke-static {p1, v2, v3, v1}, Lcom/a/l;->a([BBII)I move-result v1 invoke-virtual {p0, p1, v1}, Lcom/a/j;->a([BI)V const-string v1, "UsbDeviceTransfer" new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;->()V const-string v3, "write snoop response:" invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v0 const-string v2, " ,first= " invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v0 invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder; move-result-object v0 invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v0 invoke-static {v1, v0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I return-void .end method .method private a(Landroid/hardware/usb/UsbAccessory;)Z .locals 4 const/4 v1, 0x1 const/4 v0, 0x0 iget-object v2, p0, Lcom/a/j;->c:Lcom/a/c$b; invoke-interface {v2, p1}, Lcom/a/c$b;->a(Landroid/hardware/usb/UsbAccessory;)Z move-result v2 if-nez v2, :cond_0 :goto_0 return v0 :cond_0 iget-object v2, p0, Lcom/a/j;->a:Landroid/hardware/usb/UsbManager; invoke-virtual {v2, p1}, Landroid/hardware/usb/UsbManager;->hasPermission(Landroid/hardware/usb/UsbAccessory;)Z move-result v2 if-nez v2, :cond_1 iget-object v1, p0, Lcom/a/j;->b:Landroid/content/Context; new-instance v2, Landroid/content/Intent; const-string v3, "com.tcp2usb.usbdevice.USB_PERMISSION" invoke-direct {v2, v3}, Landroid/content/Intent;->(Ljava/lang/String;)V invoke-static {v1, v0, v2, v0}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent; move-result-object v1 iget-object v2, p0, Lcom/a/j;->a:Landroid/hardware/usb/UsbManager; invoke-virtual {v2, p1, v1}, Landroid/hardware/usb/UsbManager;->requestPermission(Landroid/hardware/usb/UsbAccessory;Landroid/app/PendingIntent;)V goto :goto_0 :cond_1 monitor-enter p0 :try_start_0 iget-object v2, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; if-eqz v2, :cond_2 iget-object v2, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-virtual {v2, p1}, Landroid/hardware/usb/UsbAccessory;->equals(Ljava/lang/Object;)Z move-result v2 if-eqz v2, :cond_2 monitor-exit p0 move v0, v1 goto :goto_0 :cond_2 iget-object v2, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-direct {p0, v2}, Lcom/a/j;->b(Landroid/hardware/usb/UsbAccessory;)V iget-object v2, p0, Lcom/a/j;->a:Landroid/hardware/usb/UsbManager; invoke-virtual {v2, p1}, Landroid/hardware/usb/UsbManager;->openAccessory(Landroid/hardware/usb/UsbAccessory;)Landroid/os/ParcelFileDescriptor; move-result-object v2 iput-object v2, p0, Lcom/a/j;->h:Landroid/os/ParcelFileDescriptor; iget-object v2, p0, Lcom/a/j;->h:Landroid/os/ParcelFileDescriptor; if-nez v2, :cond_3 const-string v1, "UsbDeviceTransfer" new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;->()V const-string v3, "can\'t open accessroy:" invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v2 invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I monitor-exit p0 goto :goto_0 :catchall_0 move-exception v0 monitor-exit p0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 throw v0 :cond_3 :try_start_1 iget-object v0, p0, Lcom/a/j;->h:Landroid/os/ParcelFileDescriptor; invoke-virtual {v0}, Landroid/os/ParcelFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor; move-result-object v0 new-instance v2, Ljava/io/FileOutputStream; invoke-direct {v2, v0}, Ljava/io/FileOutputStream;->(Ljava/io/FileDescriptor;)V iput-object v2, p0, Lcom/a/j;->g:Ljava/io/FileOutputStream; new-instance v2, Ljava/io/FileInputStream; invoke-direct {v2, v0}, Ljava/io/FileInputStream;->(Ljava/io/FileDescriptor;)V iput-object v2, p0, Lcom/a/j;->f:Ljava/io/FileInputStream; iget-object v0, p0, Lcom/a/j;->d:Lcom/a/c$d; invoke-interface {v0}, Lcom/a/c$d;->b()V iget-object v0, p0, Lcom/a/j;->c:Lcom/a/c$b; invoke-virtual {p1}, Landroid/hardware/usb/UsbAccessory;->getVersion()Ljava/lang/String; move-result-object v2 const/16 v3, 0x64 invoke-interface {v0, v2, v3}, Lcom/a/c$b;->a(Ljava/lang/String;I)V iput-object p1, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; const/4 v0, 0x1 iput-boolean v0, p0, Lcom/a/j;->i:Z new-instance v0, Ljava/lang/Thread; const-string v2, "ReadLoop" invoke-direct {v0, p0, v2}, Ljava/lang/Thread;->(Ljava/lang/Runnable;Ljava/lang/String;)V invoke-virtual {v0}, Ljava/lang/Thread;->start()V const-string v0, "UsbDeviceTransfer" new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;->()V const-string v3, "open accessory OK:" invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 iget-object v3, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v2 invoke-static {v0, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I monitor-exit p0 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 move v0, v1 goto/16 :goto_0 .end method .method static synthetic a(Lcom/a/j;Landroid/hardware/usb/UsbAccessory;)Z .locals 1 invoke-direct {p0, p1}, Lcom/a/j;->a(Landroid/hardware/usb/UsbAccessory;)Z move-result v0 return v0 .end method .method private b(Landroid/hardware/usb/UsbAccessory;)V .locals 3 if-nez p1, :cond_1 :cond_0 :goto_0 return-void :cond_1 iget-object v0, p0, Lcom/a/j;->c:Lcom/a/c$b; invoke-interface {v0, p1}, Lcom/a/c$b;->a(Landroid/hardware/usb/UsbAccessory;)Z move-result v0 if-eqz v0, :cond_0 iget-object v0, p0, Lcom/a/j;->d:Lcom/a/c$d; invoke-interface {v0}, Lcom/a/c$d;->b()V monitor-enter p0 :try_start_0 invoke-virtual {p1}, Landroid/hardware/usb/UsbAccessory;->getVersion()Ljava/lang/String; move-result-object v0 const/4 v1, 0x0 iput-object v1, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; iget-object v1, p0, Lcom/a/j;->h:Landroid/os/ParcelFileDescriptor; invoke-static {v1}, Lcom/a/e;->a(Landroid/os/ParcelFileDescriptor;)V const/4 v1, 0x0 iput-object v1, p0, Lcom/a/j;->h:Landroid/os/ParcelFileDescriptor; const/4 v1, 0x0 iput-object v1, p0, Lcom/a/j;->g:Ljava/io/FileOutputStream; :goto_1 iget-boolean v1, p0, Lcom/a/j;->i:Z :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 if-eqz v1, :cond_2 :try_start_1 const-string v1, "UsbDeviceTransfer" const-string v2, "wait thread to exit..." invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I invoke-virtual {p0}, Ljava/lang/Object;->wait()V const-string v1, "UsbDeviceTransfer" const-string v2, "wait thread to exit done" invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I :try_end_1 .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0 .catchall {:try_start_1 .. :try_end_1} :catchall_0 goto :goto_1 :catch_0 move-exception v1 goto :goto_1 :cond_2 const/4 v1, 0x0 :try_start_2 iput-object v1, p0, Lcom/a/j;->f:Ljava/io/FileInputStream; iget-object v1, p0, Lcom/a/j;->c:Lcom/a/c$b; const/4 v2, 0x0 invoke-interface {v1, v0, v2}, Lcom/a/c$b;->a(Ljava/lang/String;I)V const-string v0, "UsbDeviceTransfer" const-string v1, "close accessory OK" invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I monitor-exit p0 goto :goto_0 :catchall_0 move-exception v0 monitor-exit p0 :try_end_2 .catchall {:try_start_2 .. :try_end_2} :catchall_0 throw v0 .end method .method static synthetic b(Lcom/a/j;Landroid/hardware/usb/UsbAccessory;)V .locals 0 invoke-direct {p0, p1}, Lcom/a/j;->b(Landroid/hardware/usb/UsbAccessory;)V return-void .end method # virtual methods .method public a(Landroid/content/Context;)V .locals 2 invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context; move-result-object v0 iput-object v0, p0, Lcom/a/j;->b:Landroid/content/Context; iget-object v0, p0, Lcom/a/j;->b:Landroid/content/Context; const-string v1, "usb" invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object; move-result-object v0 check-cast v0, Landroid/hardware/usb/UsbManager; iput-object v0, p0, Lcom/a/j;->a:Landroid/hardware/usb/UsbManager; return-void .end method .method public a([BI)V .locals 2 monitor-enter p0 :try_start_0 iget-object v0, p0, Lcom/a/j;->g:Ljava/io/FileOutputStream; const/4 v1, 0x0 invoke-virtual {v0, p1, v1, p2}, Ljava/io/FileOutputStream;->write([BII)V monitor-exit p0 return-void :catchall_0 move-exception v0 monitor-exit p0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 throw v0 .end method .method public run()V .locals 7 const/4 v2, 0x1 const/4 v1, 0x0 const-string v0, "UsbDeviceTransfer" const-string v3, "usb readLoop enter" invoke-static {v0, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I const/16 v0, 0x4000 new-array v3, v0, [B new-instance v4, Lcom/a/m; invoke-direct {v4}, Lcom/a/m;->()V new-instance v5, Lcom/a/l; invoke-direct {v5}, Lcom/a/l;->()V iput-object v3, v5, Lcom/a/l;->d:[B iget-object v0, p0, Lcom/a/j;->d:Lcom/a/c$d; invoke-interface {v0}, Lcom/a/c$d;->b()V const/4 v0, 0x0 :try_start_0 invoke-direct {p0, v3, v0}, Lcom/a/j;->a([BZ)V move v0, v2 :cond_0 iget-object v6, p0, Lcom/a/j;->f:Ljava/io/FileInputStream; invoke-virtual {v6, v3}, Ljava/io/FileInputStream;->read([B)I move-result v6 if-gtz v6, :cond_1 const-string v0, "UsbDeviceTransfer" new-instance v1, Ljava/lang/StringBuilder; invoke-direct {v1}, Ljava/lang/StringBuilder;->()V const-string v2, "usb read return " invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v1 invoke-virtual {v1, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder; move-result-object v1 invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v1 invoke-static {v0, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I :try_end_0 .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 .catchall {:try_start_0 .. :try_end_0} :catchall_2 monitor-enter p0 :try_start_1 const-string v0, "UsbDeviceTransfer" const-string v1, "usb read thread will exit" invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I const/4 v0, 0x0 iput-boolean v0, p0, Lcom/a/j;->i:Z invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V iget-object v0, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-direct {p0, v0}, Lcom/a/j;->b(Landroid/hardware/usb/UsbAccessory;)V monitor-exit p0 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_1 :goto_0 const-string v0, "UsbDeviceTransfer" const-string v1, "usb readLoop exited" invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I return-void :cond_1 :try_start_2 invoke-virtual {v4, v3, v6}, Lcom/a/m;->a([BI)V :goto_1 const/4 v6, 0x0 invoke-virtual {v4, v6, v5}, Lcom/a/m;->a(ZLcom/a/l;)Z move-result v6 if-eqz v6, :cond_0 iget-byte v6, v5, Lcom/a/l;->a:B if-eq v6, v2, :cond_2 if-eqz v0, :cond_3 :cond_2 iget-object v6, p0, Lcom/a/j;->d:Lcom/a/c$d; invoke-interface {v6}, Lcom/a/c$d;->b()V invoke-direct {p0, v3, v0}, Lcom/a/j;->a([BZ)V :goto_2 move v0, v1 goto :goto_1 :cond_3 iget-object v0, p0, Lcom/a/j;->d:Lcom/a/c$d; invoke-interface {v0, v5}, Lcom/a/c$d;->a(Lcom/a/l;)V :try_end_2 .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0 .catchall {:try_start_2 .. :try_end_2} :catchall_2 goto :goto_2 :catch_0 move-exception v0 :try_start_3 const-string v1, "UsbDeviceTransfer" new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;->()V const-string v3, "usb readLoop error:" invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; move-result-object v0 invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v0 invoke-static {v1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I :try_end_3 .catchall {:try_start_3 .. :try_end_3} :catchall_2 monitor-enter p0 :try_start_4 const-string v0, "UsbDeviceTransfer" const-string v1, "usb read thread will exit" invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I const/4 v0, 0x0 iput-boolean v0, p0, Lcom/a/j;->i:Z invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V iget-object v0, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-direct {p0, v0}, Lcom/a/j;->b(Landroid/hardware/usb/UsbAccessory;)V monitor-exit p0 goto :goto_0 :catchall_0 move-exception v0 monitor-exit p0 :try_end_4 .catchall {:try_start_4 .. :try_end_4} :catchall_0 throw v0 :catchall_1 move-exception v0 :try_start_5 monitor-exit p0 :try_end_5 .catchall {:try_start_5 .. :try_end_5} :catchall_1 throw v0 :catchall_2 move-exception v0 monitor-enter p0 :try_start_6 const-string v1, "UsbDeviceTransfer" const-string v2, "usb read thread will exit" invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I const/4 v1, 0x0 iput-boolean v1, p0, Lcom/a/j;->i:Z invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V iget-object v1, p0, Lcom/a/j;->e:Landroid/hardware/usb/UsbAccessory; invoke-direct {p0, v1}, Lcom/a/j;->b(Landroid/hardware/usb/UsbAccessory;)V monitor-exit p0 :try_end_6 .catchall {:try_start_6 .. :try_end_6} :catchall_3 throw v0 :catchall_3 move-exception v0 :try_start_7 monitor-exit p0 :try_end_7 .catchall {:try_start_7 .. :try_end_7} :catchall_3 throw v0 .end method