| | |
| | | import androidx.lifecycle.ViewModelProviders; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.work.Data; |
| | | import androidx.work.OneTimeWorkRequest; |
| | | import androidx.work.WorkInfo; |
| | | import androidx.work.WorkManager; |
| | | |
| | | import com.anyun.exam.lib.AYSdk; |
| | |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.SPUtils; |
| | | import safeluck.drive.evaluation.worker.MCUUpgradeWorker; |
| | | |
| | | /** |
| | | * 设置所有参数 |
| | |
| | | case R.id.btn_mcu_upgrade: |
| | | |
| | | |
| | | |
| | | try { |
| | | byte[] datas = FileUtil.readLocalFile(getActivity(),"dfu.bin"); |
| | | if (datas != null){ |
| | | Log.i(TAG, ByteUtil.byte2hex(datas)); |
| | | |
| | | String strs = new String(datas, Charset.forName("ISO-8859-1")); |
| | | Log.i(TAG, "onClick: datas.legnth=="+strs.getBytes("ISO-8859-1").length); |
| | | AYSdk.getInstance().sendCmd(Constant.UPGRADE_MCU_CONTENT_FILE, strs); |
| | | }else{ |
| | | MyLog.i(TAG,"mcu升级文件不存在"); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | OneTimeWorkRequest mcuUpgradeWorkReq = OneTimeWorkRequest.from(MCUUpgradeWorker.class); |
| | | WorkManager.getInstance(_mActivity.getApplicationContext()).enqueue(mcuUpgradeWorkReq); |
| | | WorkManager.getInstance(_mActivity.getApplicationContext()).getWorkInfoByIdLiveData(mcuUpgradeWorkReq.getId()) |
| | | .observe(this, new Observer<WorkInfo>() { |
| | | @Override |
| | | public void onChanged(WorkInfo workInfo) { |
| | | if (workInfo.getState()== WorkInfo.State.FAILED){ |
| | | Data data = workInfo.getOutputData(); |
| | | String str = data.getString(Constant.MCU_UPGRADE_FAIL_RESASON); |
| | | Toast.makeText(_mActivity, str, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | }); |
| | | break; |
| | | case R.id.btn_save_platform: |
| | | Toast.makeText(_mActivity, "保存成功", Toast.LENGTH_SHORT).show(); |