From 8a237469ec680603b1c662dc7e67bd3ff0bbfd2a Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期六, 21 三月 2020 19:01:00 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge --- app/src/main/java/safeluck/drive/evaluation/DB/exam_status/ExamStatusOutWorker.kt | 90 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 76 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/exam_status/ExamStatusOutWorker.kt b/app/src/main/java/safeluck/drive/evaluation/DB/exam_status/ExamStatusOutWorker.kt index e1a173c..ab9f51b 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/exam_status/ExamStatusOutWorker.kt +++ b/app/src/main/java/safeluck/drive/evaluation/DB/exam_status/ExamStatusOutWorker.kt @@ -1,7 +1,10 @@ package safeluck.drive.evaluation.DB.exam_status import android.content.Context +import android.os.Environment +import android.text.TextUtils import android.util.Log +import android.widget.Toast import androidx.work.Data import androidx.work.Worker import androidx.work.WorkerParameters @@ -16,10 +19,13 @@ import safeluck.drive.evaluation.DB.WorkRoomDataBase import safeluck.drive.evaluation.DB.rtktb.RTKConfig import safeluck.drive.evaluation.DB.signalConfigdb.SingalConfig +import safeluck.drive.evaluation.app import safeluck.drive.evaluation.bean.ExamPlatformData import safeluck.drive.evaluation.bean.SignalConfigRemote import safeluck.drive.evaluation.bean.SimulateNightBean import safeluck.drive.evaluation.bean.SimulateNightBean.QuestionBean +import safeluck.drive.evaluation.util.CThreadPoolExecutor +import safeluck.drive.evaluation.util.FileUtil import safeluck.drive.evaluation.util.Utils import java.io.IOException import java.io.InputStreamReader @@ -47,22 +53,12 @@ tempQs.add(list[list.size-1])//鎻愮ず鐏厜鑰冭瘯缁撴潫 simulateNightBean.setQuestion(tempQs) AYSdk.getInstance().sendCmd(0x8012, gson.toJson(simulateNightBean)) - + sendMapInfo() + sendVehicleInfo() MyLog.i(TAG,"鏌ュ埌鐨勮�冭瘯type="+examType) ExamPlatformData.getInstance().examType = examType - val data = Data.Builder().putInt(Constant.EXAM_STATUS_TYPE,examType).build() - if (examType != safeluck.drive.evaluation.Constant.NONE_BEEN_START_EXAM) { - try { - val jsonObject = JSONObject() - jsonObject.put("exam", 1) - jsonObject.put("type", examType) - val examJson = jsonObject.toString() - AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.EXAM_STATUS, examJson) - } catch (e: JSONException) { - e.printStackTrace() - } - } + var rtk = WorkRoomDataBase.getWorkRoomDataBase(applicationContext).rtkConfigDao._getRtkConfig() if (rtk == null){ try { @@ -111,7 +107,18 @@ sendSignalConfigsToRemote(indexs) - + val data = Data.Builder().putInt(Constant.EXAM_STATUS_TYPE,examType).build() + if (examType != safeluck.drive.evaluation.Constant.NONE_BEEN_START_EXAM) { + try { + val jsonObject = JSONObject() + jsonObject.put("exam", 1) + jsonObject.put("type", examType) + val examJson = jsonObject.toString() + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.EXAM_STATUS, examJson) + } catch (e: JSONException) { + e.printStackTrace() + } + } return Result.success(data) } @@ -160,4 +167,59 @@ } } + + private fun sendMapInfo(){ + val mapPath = ExamPlatformData.getInstance().mapPath + if (!TextUtils.isEmpty(mapPath)) { + MyLog.i("璋冪敤鏇存柊Map璺緞鍚庣殑鍦板浘$mapPath") + val fileContent = FileUtil.readFile(mapPath) + if (fileContent != null) { + val str = String(fileContent) + Log.i(TAG,"鏂囦欢鍐呭锛�$str") + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_MAP_INFO, str) + } else { + MyLog.i(String.format("鏂囦欢:%s涓嶅瓨鍦�", mapPath)) + CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), "鏂囦欢锛�" + mapPath + "涓嶅瓨鍦�", Toast.LENGTH_SHORT).show() } + } + } else { + MyLog.i("璇诲彇Assert鐩綍涓嬪垵濮嬪寲鐨勫湴鍥�") + var buffer: StringBuffer? + buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.ROAD_MAP) + if (buffer != null) { + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_ROAD_MAP_INFO, buffer.toString()) + } else { + MyLog.i( String.format("鍦板浘妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) + CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("鍦板浘妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } + } + buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.MAP) + if (buffer != null) { + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_MAP_INFO, buffer.toString()) + } else { + MyLog.i( String.format("鍦板浘妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) + CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("鍦板浘妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } + } + } + } + + private fun sendVehicleInfo(){ + val carPath = ExamPlatformData.getInstance().carModelPath + if (!TextUtils.isEmpty(carPath)) { + MyLog.i("浣跨敤鏇存柊鍚庣殑Car妯″瀷鍦板浘$carPath") + val bytes = FileUtil.readFile(carPath) + if (bytes != null) { + val str = String(bytes) + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_VECHILE_PROFILE, str) + } else { + MyLog.i(String.format("鏂囦欢:%s涓嶅瓨鍦�", carPath)) + } + } else { + val vebuffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.VEHICLE) + if (vebuffer != null) { + AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_VECHILE_PROFILE, vebuffer.toString()) + } else { + MyLog.i(String.format("杞﹁締妯″瀷妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) + } + } + } + } \ No newline at end of file -- Gitblit v1.8.0