|
@@ -1,5 +1,6 @@
|
|
|
package com.example.administrator.wingcool_gt9_apk;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
import android.app.PendingIntent;
|
|
|
import android.content.BroadcastReceiver;
|
|
@@ -20,6 +21,7 @@ import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
|
import android.net.wifi.WifiInfo;
|
|
|
import android.net.wifi.WifiManager;
|
|
|
+import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
@@ -99,6 +101,11 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
|
|
|
public static List<Activity> activityList = new LinkedList();
|
|
|
|
|
|
+ private int iProductId;
|
|
|
+ private int iVendorId;
|
|
|
+ private String strVersion;
|
|
|
+ private int iDeviceId;
|
|
|
+
|
|
|
/*
|
|
|
private Button bt_tcpstart;
|
|
|
private final static String TAG = "Main2Activity-------->";
|
|
@@ -120,8 +127,8 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
//mError.setText("");
|
|
|
//mSendMessage.setEnabled(true);
|
|
|
//String avalue = "S818 is connected";
|
|
|
-
|
|
|
- mShow.setText(R.string.connected);//????????
|
|
|
+ //mShow.setText(getResources().getString(R.string.connected));
|
|
|
+ mShow.setText("S"+Integer.toHexString(iProductId)+" "+getResources().getString(R.string.connected));//????????
|
|
|
//bt_tcpstart.setEnabled(true);
|
|
|
break;
|
|
|
case CONNECTED_FAILED://??????????????????
|
|
@@ -129,7 +136,7 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
//mError.setText("");
|
|
|
//mSendMessage.setEnabled(true);
|
|
|
|
|
|
- mShow.setText(R.string.disconnected);//????????
|
|
|
+ mShow.setText(getResources().getString(R.string.disconnected));//????????
|
|
|
break;
|
|
|
|
|
|
case RECEIVER_MESSAGE_SUCCESS://??????????????
|
|
@@ -555,10 +562,10 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
|
|
|
for (UsbDevice usbDevice : deviceList.values()) {
|
|
|
//int productId = usbDevice.getProductId();
|
|
|
- int vendorId = usbDevice.getVendorId();
|
|
|
- if (( vendorId == 0x27C0)
|
|
|
- ||(vendorId == 0x222A) //奕力的VID
|
|
|
- ||(vendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
+ iVendorId = usbDevice.getVendorId();
|
|
|
+ if ((iVendorId == 0x27C0)
|
|
|
+ ||(iVendorId == 0x222A) //奕力的VID
|
|
|
+ ||(iVendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
{
|
|
|
isS818Device = true;
|
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
@@ -601,17 +608,18 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
/**
|
|
|
* ??????????(????) , ??????????Accessory?????? , ??????PID??????Google??????2?????????????????? ,
|
|
|
*/
|
|
|
+ @SuppressLint("NewApi")
|
|
|
private void initDevice() {
|
|
|
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
|
|
|
Collection<UsbDevice> values = deviceList.values();
|
|
|
if (!values.isEmpty()) {
|
|
|
for (UsbDevice usbDevice : values) {
|
|
|
//int productId = usbDevice.getProductId();
|
|
|
- int vendorId = usbDevice.getVendorId();
|
|
|
+ iVendorId = usbDevice.getVendorId();
|
|
|
//if (productId == 0x0818 || productId == 0x0001 )
|
|
|
- if (( vendorId == 0x27C0)
|
|
|
- ||(vendorId == 0x222A) //奕力的VID
|
|
|
- ||(vendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
+ if (( iVendorId == 0x27C0)
|
|
|
+ ||(iVendorId == 0x222A) //奕力的VID
|
|
|
+ ||(iVendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
{ //0x0001是奕力的PID
|
|
|
|
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
@@ -663,6 +671,7 @@ public class GT9MainActivity extends AppCompatActivity
|
|
|
mUsbInterface = usbInterface;
|
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
|
if(null != mUsbEndpointIn){
|
|
|
+ iProductId = usbDevice.getProductId();
|
|
|
mHandler.sendEmptyMessage(CONNECTED_SUCCESS);
|
|
|
}
|
|
|
|