| | |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0100; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0101; |
| | | import safeluck.drive.evaluation.platformMessage.PlatFormConstant; |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.PermissionManager; |
| | | import safeluck.drive.evaluation.util.SPUtils; |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | import safeluck.drive.evaluation.viewmodels.ExamPlatformModel; |
| | | import safeluck.drive.evaluation.viewmodels.MainViewModel; |
| | | import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin; |
| | |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | if (msgCode == Constant.FETCH_RTK_PLATFORM_INFO) { |
| | | sendRtkConfigInfo(); |
| | | // sendRtkConfigInfo(); |
| | | } |
| | | if (msgCode == Constant.RTK_PLATFORM_REGISTER_STATUS) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | if (msgCode == Constant.NDK_START){ |
| | | MyLog.i(TAG,"NDK_start,发送RTK配置"); |
| | | sendRtkConfigInfo(); |
| | | MyLog.i(TAG,"NDK_start"); |
| | | // sendRtkConfigInfo(); |
| | | sendMcuUprgrade(); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | private void sendRtkConfigInfo() { |
| | | if (mRTKConfig != null) { |
| | | String rtkjson = gson.toJson(mRTKConfig); |
| | | |
| | | //去除id字段 |
| | | JSONObject jsonObject = null; |
| | | try { |
| | | jsonObject = new JSONObject(rtkjson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.remove("_id"); |
| | | rtkjson = null; |
| | | rtkjson = jsonObject.toString(); |
| | | MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); |
| | | } else { |
| | | MyLog.d(TAG, "RTKConfig未取到数据"); |
| | | onlySendOnceRTKConfig = true; |
| | | } |
| | | } |
| | | // private void sendRtkConfigInfo() { |
| | | // if (mRTKConfig != null) { |
| | | // String rtkjson = gson.toJson(mRTKConfig); |
| | | // |
| | | // //去除id字段 |
| | | // JSONObject jsonObject = null; |
| | | // try { |
| | | // jsonObject = new JSONObject(rtkjson); |
| | | // } catch (JSONException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // jsonObject.remove("_id"); |
| | | // rtkjson = null; |
| | | // rtkjson = jsonObject.toString(); |
| | | // MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | // AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); |
| | | // } else { |
| | | // MyLog.d(TAG, "RTKConfig未取到数据"); |
| | | // onlySendOnceRTKConfig = true; |
| | | // } |
| | | // } |
| | | public ExamPlatformModel examPlatformModel; |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | MyLog.i(TAG, "RTKConfig Changed: " + (rtkConfig != null ? rtkConfig.toString() : "null")); |
| | | mRTKConfig = rtkConfig; |
| | | if (rtkConfig != null) |
| | | ExamPlatformData.getInstance().setPhone(rtkConfig.getPhone()); |
| | | ExamPlatformData.getInstance().setPhone(rtkConfig.getSn()); |
| | | synchronized (MainActivity.this){ |
| | | if (onlySendOnceRTKConfig){ |
| | | MyLog.i(TAG,"进入 synchronized (MainActivity.this)"); |
| | | onlySendOnceRTKConfig = false; |
| | | sendRtkConfigInfo(); |
| | | } |
| | | // if (onlySendOnceRTKConfig){ |
| | | // MyLog.i(TAG,"进入 synchronized (MainActivity.this)"); |
| | | // onlySendOnceRTKConfig = false; |
| | | // sendRtkConfigInfo(); |
| | | // } |
| | | } |
| | | |
| | | } |
| | |
| | | }else{ |
| | | JKMessage0101 jkMessage0101 = new JKMessage0101(); |
| | | jkMessage0101.phone = ExamPlatformData.getInstance().getPhone(); |
| | | jkMessage0101.des =hexPwd; |
| | | jkMessage0101.timestamp = (int) System.currentTimeMillis(); |
| | | String des = hexPwd; |
| | | int time = (int) System.currentTimeMillis(); |
| | | jkMessage0101.timestamp = time; |
| | | |
| | | |
| | | byte[] miwen = Utils.encrypt(com.anyun.im_lib.util.ByteUtil.intGetBytes(time),des); |
| | | MyLog.i(PlatFormConstant.TAG,"鉴权密文="+BytesUtils.bytesToHexString(miwen)+" time="+time); |
| | | jkMessage0101.des = BytesUtils.bytesToHexString(miwen); |
| | | |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0101); |
| | | } |
| | | } |