| | |
| | | import android.support.annotation.Nullable; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import android.widget.Toast; |
| | | |
| | | import com.fwupgrade.saymanss.deviceplug.IUsbDevicePlugDelegate; |
| | |
| | | if (succ_num + fail_num == tty.size()) { |
| | | Log.d(TAG, "Upgrade Finish!"); |
| | | |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("result", succ_num == tty.size()? 0 : 1); |
| | | intent.setAction("com.fwupgrade.saymanss.UPGRADE_COMPLETE"); |
| | | intent.setPackage("safeluck.drive.training"); |
| | | sendBroadcast(intent); |
| | | |
| | | intent = new Intent(); |
| | | intent.putExtra("result", succ_num == tty.size()? 0 : 1); |
| | | intent.setAction("com.fwupgrade.saymanss.UPGRADE_COMPLETE"); |
| | | intent.setPackage("demo1.tech.anyun.com.myapplication"); |
| | | sendBroadcast(intent); |
| | | sendToNewDriveTrainByBroadCast(succ_num,tty.size()); |
| | | sendToDriveTrainByBroadCast(succ_num,tty.size()); |
| | | |
| | | |
| | | |
| | | // System.exit(0); |
| | |
| | | } |
| | | } |
| | | }; |
| | | |
| | | private void sendToNewDriveTrainByBroadCast(int succ_num,int ttySize) { |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("result", succ_num == ttySize? 0 : 1); //0-成功 |
| | | intent.setAction("com.fwupgrade.saymanss.UPGRADE_COMPLETE"); |
| | | intent.setPackage("safeluck.drive.training"); |
| | | sendBroadcast(intent); |
| | | } |
| | | private void sendToDriveTrainByBroadCast(int succ_num,int ttySize) { |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("result", succ_num == ttySize? 0 : 1); |
| | | intent.setAction("com.fwupgrade.saymanss.UPGRADE_COMPLETE"); |
| | | intent.setPackage("demo1.tech.anyun.com.myapplication"); |
| | | sendBroadcast(intent); |
| | | } |
| | | |
| | | // 每次升级路径值最小的 |
| | | private void initTarget() { |
| | | ArrayList<UsbDevice> targets = UstorageDeviceInstance.getInstance().acceptOTGDeviceInfo((UsbManager) getSystemService(USB_SERVICE)); |
| | |
| | | * 获取fw列表 |
| | | */ |
| | | private void acceptFwList() { |
| | | Log.d("fwup","acceptFwList: "); |
| | | Log.d(TAG,"acceptFwList: "); |
| | | File file = new File(AppPathInfo.getFwSavePath()); |
| | | File[] files = file.listFiles(); |
| | | if (files != null && files.length > 0) { |
| | |
| | | Log.d(TAG,"permissionFinish:" + isSuccessful); |
| | | if (isSuccessful && ctrlBlock != null) { |
| | | initFwUpgrade(ctrlBlock); |
| | | }else{ |
| | | sendToDriveTrainByBroadCast(0,1); |
| | | sendToNewDriveTrainByBroadCast(0,1); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!isTarget) { |
| | | Log.d(TAG,"Not sonixCam, close"); |
| | | ctrlBlock.close(); |
| | | sendToDriveTrainByBroadCast(0,1); |
| | | sendToNewDriveTrainByBroadCast(0,1); |
| | | return; |
| | | } |
| | | |