| | |
| | | private static final int UPGRADE_FAIL = 3; |
| | | private static final int UPGRADE_SUCCESS = 4; |
| | | |
| | | |
| | | private CameraInfo mCamInfo = null; |
| | | private static final String TAG = FwUpgradeService.class.getCanonicalName(); |
| | | private IFwAidlInterface.Stub mBinder = new IFwAidlInterface.Stub() { |
| | |
| | | super.onCreate(); |
| | | Log.i(TAG,"onCreate"); |
| | | initTarget(); |
| | | |
| | | initData(); |
| | | initDeviceSDK(); |
| | | UStorageTestModule.getInstance().initUStorageDeviceModuleWithVirtualDisk(AppPathInfo.getLogPath()); |
| | |
| | | |
| | | case USB_DEVICE_DETACHED: |
| | | |
| | | 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); |
| | | int count = (int) msg.obj; |
| | | Log.i(TAG,"count="+count); |
| | | if (count<2) { |
| | | tty.clear(); |
| | | initTarget(); |
| | | int ret = UstorageDeviceInstance.getInstance().tryAgain(FwUpgradeService.this); |
| | | if (ret==1){ |
| | | Log.i(TAG,"发送失败结果广播给驾培"); |
| | | sendToDriveTrainByBroadCast(0,1); |
| | | sendToNewDriveTrainByBroadCast(0,1); |
| | | } |
| | | } |
| | | |
| | | break; |
| | |
| | | int errCode = msg.arg1; |
| | | int succ_num = 0, fail_num = 0; |
| | | |
| | | Log.d("fwup","Upgrade result:" + devName + ", errCode: " + errCode); |
| | | Log.d("fwup","Upgrade result:" + devName + ", errCode: " + errCode+".ttySize="+tty.size()); |
| | | |
| | | if (tty.containsKey(devName)) { |
| | | tty.put(devName, errCode == 0? UPGRADE_SUCCESS:UPGRADE_FAIL); |
| | |
| | | for (UsbDevice usbDevice: targets) { |
| | | if (usbDevice.getDeviceName().compareTo(min) < 0) { |
| | | min = usbDevice.getDeviceName(); |
| | | |
| | | } |
| | | } |
| | | Log.i(TAG,"min="+min); |
| | | tty.put(min, UPGRADE_PRESET); |
| | | } |
| | | |
| | |
| | | * UstorageDeviceSDK初始化. |
| | | */ |
| | | private void initDeviceSDK() { |
| | | int count = 0 ; |
| | | int ret = UstorageDeviceInstance.getInstance().tryAttcheDeviceHandle(FwUpgradeService.this, FwUpgradeService.this); |
| | | Log.i(TAG,"initDeviceSDk,ret="+ret); |
| | | if (ret==1){ |
| | | |
| | | ++count; |
| | | Log.i(TAG,"再次的初始化"); |
| | | Message message = Message.obtain(); |
| | | message.obj = false; |
| | | message.obj = count; |
| | | message.what = USB_DEVICE_DETACHED; |
| | | mHander.sendMessageDelayed(message,1000); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | String serial = ctrlBlock.getSerial(); |
| | | |
| | | Log.d(TAG,"sonixCamInit " + String.format("vendorId:%d productId:%d fileDescriptor:%d busNum:%d devNum:%d usbfsName:%s devName:%s serial:%s", vendorId, productId, fileDescriptor, busNum, devNum, usbfsName, devName, serial)); |
| | | Log.d(TAG,"sonixCamInit " + String.format("vendorId:%d productId:%d fileDescriptor:%d busNum:%d devNum:%d usbfsName:%s devName:%s serial:%s,tty.size=%d", vendorId, productId, fileDescriptor, busNum, devNum, usbfsName, devName, serial,tty.size())); |
| | | |
| | | |
| | | if (tty.containsKey(devName) && tty.get(devName) == 0) { |
| | |
| | | tty.put(devName, 1); |
| | | } |
| | | |
| | | |
| | | |
| | | if (!isTarget) { |
| | | |
| | | Log.d(TAG,"Not sonixCam, close"); |
| | | ctrlBlock.close(); |
| | | sendToDriveTrainByBroadCast(0,1); |
| | | sendToNewDriveTrainByBroadCast(0,1); |
| | | |
| | | return; |
| | | } |
| | | |
| | | Log.d(TAG,"Is sonixCam, upgrade!"); |
| | | |
| | | Message msg = Message.obtain(); |
| | | //msg.obj = errCode == 0; |
| | | msg.obj = new CameraInfo(vendorId, productId, fileDescriptor, busNum, devNum, usbfsName, devName); |