| | |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKConfigUpdateWorker; |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel; |
| | | import safeluck.drive.evaluation.DB.signalConfigdb.SignalConfigViewModel; |
| | | import safeluck.drive.evaluation.bean.AbsInitialData; |
| | | import safeluck.drive.evaluation.bean.ExamPlatformData; |
| | | import safeluck.drive.evaluation.bean.SignalConfigRemote; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0101; |
| | | import safeluck.drive.evaluation.platformMessage.PlatFormConstant; |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.DataInitKt; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.PermissionManager; |
| | | import safeluck.drive.evaluation.util.SPUtils; |
| | |
| | | break; |
| | | case 1: |
| | | des ="蓝牙打开"; |
| | | |
| | | break; |
| | | case 2: |
| | | des ="蓝牙未连接"; |
| | | break; |
| | | case 3: |
| | | authMapViewmodel.setAuthValue(3); |
| | | //需要延迟再发送,因为发送蓝牙已连接在前,收到sn在后,所以延迟发送3 ,可以取得sn |
| | | scheduledExecutorService.schedule(()->{ authMapViewmodel.setAuthValue(3);},1,TimeUnit.SECONDS); |
| | | des ="蓝牙连接"; |
| | | String mac = jsonObject.getString("bluetooth_addr"); |
| | | SPUtils.put(getApplicationContext(),SPUtils.BLUETOOTH_MAC,mac); |
| | |
| | | if (integer.intValue() == Constant.BLUETOOTH_CONNECT){ |
| | | MyLog.i(TAG,"Bluetooth connected,auth permission and sn != null"); |
| | | String sn = ExamPlatformData.getInstance().getMcuSN(); |
| | | MyLog.i(TAG,"权限允许,获得到的sn="+sn); |
| | | Data data = new Data.Builder().putString(safeluck.drive.evaluation.DB.Constant.RTK_CONFIG_UPDATE_JSON,sn).build(); |
| | | OneTimeWorkRequest rtkConfigUpdateWorker= new OneTimeWorkRequest.Builder(RTKConfigUpdateWorker.class).setInputData(data).build(); |
| | | WorkManager.getInstance(getApplicationContext()).enqueue(rtkConfigUpdateWorker); |
| | | if (!TextUtils.isEmpty(sn)){ |
| | | |
| | | MyLog.i(TAG,"权限允许,蓝牙已连接,获得到的sn="+sn); |
| | | AbsInitialData.getInstance().sendInitialData(); |
| | | }else{ |
| | | MyLog.i(TAG,"权限允许,蓝牙已连接,获得到的sn=null,不能发送初始数据"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | |
| | | private void setSDAuthAndSendJudgeArg() { |
| | | ExamPlatformData.getInstance().setCanWriteSD(true); |
| | | //只要app不销毁(重启)只会请求一次,但是确保PERMISSIONS最后一个元素是writeSD |
| | | CThreadPoolExecutor.runInBackground(()->{ |
| | | MyLog.i(TAG,"权限允许,开始发送配置参数"); |
| | | sendJudgeArgs(); |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void sendJudgeArgs() { |
| | | FileUtil.createdirs(getApplicationContext()); |
| | | File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+getPackageName()); |
| | | |
| | | List<String> names = ExamPlatformData.getRulesettingFilesName(); |
| | | for (int i = 0; i < names.size(); i++) { |
| | | File settFile = new File(dir,names.get(i)); |
| | | if (settFile.exists() ){ |
| | | Log.i(TAG,settFile.getName()+"存在不复制"); |
| | | }else{ |
| | | Log.i(TAG,settFile.getName()+"不存在,复制..."); |
| | | FileUtil.copyAssertFileToSD(getApplicationContext(),names.get(i)); |
| | | } |
| | | } |
| | | |
| | | if (dir.exists()){ |
| | | File[] files = dir.listFiles(); |
| | | for (int i = 0; i < files.length; i++) { |
| | | Log.i(TAG,files[i].getName()); |
| | | if (names.contains(files[i].getName())){ |
| | | |
| | | |
| | | byte[] buffer = FileUtil.readFile(files[i].getAbsolutePath()); |
| | | AYSdk.getInstance().sendCmd(Constant.ID_judge_args,new String(buffer).trim()); |
| | | }else{ |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |