| 
					
				 | 
			
			
				@@ -18,6 +18,7 @@ import android.hardware.usb.UsbInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.hardware.usb.UsbManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.hardware.usb.UsbRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.net.Uri; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.os.Build; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.os.Environment; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.os.Handler; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import android.os.Message; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -467,6 +468,7 @@ public class FirmwareUpdate extends AppCompatActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int sendLoop = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         byte addressH,addressL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String hv = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String strpidversion = "GT"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         switch(view.getId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case R.id.version:     //read version 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 bottonMode = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -500,6 +502,46 @@ public class FirmwareUpdate extends AppCompatActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 else  //GT9 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    iicRead32Bits((byte)0x01, (byte)0x00, (byte)0x14, mBytes, 23); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (int i = 10; i < 15; i++)  //Get PID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (mBytes[i] == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        int v = (mBytes[i] - 48) & 0xFF;  //ASCII码减去48 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        hv = Integer.toHexString(v); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strpidversion += hv; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (strpidversion.length() < 6) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        mShow.setText( "Null" );//输出显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strpidversion += "_"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (int i = 18; i < 22; i++)  //Get version 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            int v = mBytes[i] & 0xFF; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            hv = Integer.toHexString(v); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (hv.length() < 2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                hv = "0" + hv; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            strpidversion += hv; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (i < 21) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                strpidversion += "."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        mShow.setText(strpidversion);//输出显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     addressH = (byte)0x81; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     addressL = (byte)0x40; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     iicRead(addressH,addressL,mBytes,16); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -527,6 +569,7 @@ public class FirmwareUpdate extends AppCompatActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         mShow.setText( "Null" );//输出显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -778,6 +821,90 @@ public class FirmwareUpdate extends AppCompatActivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //发送命令,使得S818可以通过IIC向GT9的固定地址读取任意bytes的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private boolean iicRead32Bits(byte addrfirstbyte,byte addrsecondbyte,byte addrthirdbyte,byte[] wBuffer,int length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[1] = 0x0f; //7bit:0-read,1-write;other:command 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //iicByteData[2] = 0x0f; //no command 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[2] = addrfirstbyte; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[3] = addrsecondbyte; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[4] = addrthirdbyte; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[5] = 0x00; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[6] = 63;  //length 一次接收63个数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int j = 7; j < 64; j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            iicWriteData[j] = 0x00; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //int address1 = ((addrfirstbyte&0xff)<<8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //int address2 = addressLow&0xff; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //int address = address1|address2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int sendTimes = length/63 + 1;  //预计是向下取整,所以+1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[5] = (byte)(length>>8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iicByteData[6] = (byte)length;  //length 一次接收63个数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //发送读取命令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointOut, iicByteData, 0, 0x40, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (i != 0x40) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false;  //传输失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int k = 0; k < sendTimes; k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //int finalOffset = k*63; //每次只能发57bytes数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int offset = k*64; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //  if(length - (finalOffset ) < 63) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // iicByteData[6] = (byte) (length - (finalOffset));  //length 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //   else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //   { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //  iicByteData[6] = 63; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // SystemClock.sleep(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            isReceiverMessage = false;  //先关闭循环接收信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //接收数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointIn, wBuffer, offset, 0x40, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointIn, wBuffer, offset, 0x40, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //if (i != 0x40) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (i != 0x40) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // mError.setText("iicWrite Failed"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Update_log = "iicRead Failed"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // address = address + 63; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //  iicByteData[3] = (byte)(address>>8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //  iicByteData[4] = (byte)address; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //将report id从数组中去除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //byte[] temperBuffer =new byte[length]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int count1 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int k = 0; k < length; k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (k % 63 == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    count1++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                wBuffer[k] = wBuffer[k + count1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //发送命令,使得S818可以通过IIC向GT9的固定地址写任意bytes的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private  boolean iicWrite(byte addressHigh,byte addressLow,byte[] wBuffer,int offset,int length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int i; 
			 |