| | |
| | | import android.hardware.usb.UsbManager; |
| | | import android.os.Handler; |
| | | import android.os.IBinder; |
| | | import android.os.Looper; |
| | | import android.os.Message; |
| | | import android.os.RemoteException; |
| | | import android.os.SystemClock; |
| | |
| | | |
| | | } |
| | | }; |
| | | |
| | | |
| | | @Nullable |
| | | @Override |
| | | public IBinder onBind(Intent intent) { |
| | |
| | | initData(); |
| | | initDeviceSDK(); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private HashMap<String, Integer> tty = new HashMap<>(); |
| | | |
| | | private final Handler mHander = new Handler() { |
| | | |
| | | private final Handler mHander = new Handler(Looper.getMainLooper()) { |
| | | @Override |
| | | public void dispatchMessage(Message msg) { |
| | | switch (msg.what) { |
| | |
| | | break; |
| | | |
| | | case USB_DEVICE_DETACHED: |
| | | Toast.makeText(FwUpgradeService.this, "USB设备已拔出,等待设备插入", Toast.LENGTH_SHORT).show(); |
| | | |
| | | boolean isSuccessful1 = (boolean) msg.obj; |
| | | if (isSuccessful1) { |
| | | Toast.makeText(FwUpgradeService.this, "USB设备权限申请成功", Toast.LENGTH_SHORT).show(); |
| | | } else { |
| | | Log.i(TAG,"发送失败结果广播给驾培"); |
| | | sendToDriveTrainByBroadCast(0,1); |
| | | sendToNewDriveTrainByBroadCast(0,1); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case USB_DEVICE_OPEN: |
| | |
| | | * UstorageDeviceSDK初始化. |
| | | */ |
| | | private void initDeviceSDK() { |
| | | UstorageDeviceInstance.getInstance().tryAttcheDeviceHandle(FwUpgradeService.this, FwUpgradeService.this); |
| | | int ret = UstorageDeviceInstance.getInstance().tryAttcheDeviceHandle(FwUpgradeService.this, FwUpgradeService.this); |
| | | Log.i(TAG,"initDeviceSDk,ret="+ret); |
| | | if (ret==1){ |
| | | Message message = Message.obtain(); |
| | | message.obj = false; |
| | | message.what = USB_DEVICE_DETACHED; |
| | | mHander.sendMessageDelayed(message,1000); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |