app初始化的时候拷贝地图和模型到sd卡包目录下;检测到RTK配置信息主动触发上传RTK配置给RemoteService;修改FileUtil;删除单机训练和联网考试点进去上传RTK额皮质信息;收到错误码主动上传地图和车辆
6个文件已修改
139 ■■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/MainActivity.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/java/com/anyun/exam/lib/AYSdk.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -54,24 +54,7 @@
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode == Constant.FETCH_RTK_PLATFORM_INFO) {
                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未取到数据");
                }
              sendRtkConfigInfo();
            }
            if (msgCode == Constant.RTK_PLATFORM_REGISTER_STATUS) {
                try {
@@ -92,6 +75,27 @@
            }
        }
    };
    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未取到数据");
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -118,6 +122,7 @@
                MyLog.i(TAG, "RTKConfig Changed: " + (rtkConfig != null ? rtkConfig.toString() : "null"));
                mRTKConfig = rtkConfig;
                sendRtkConfigInfo();
            }
        });
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -19,6 +19,7 @@
import com.anyun.exam.lib.MyLog;
import com.anyun.exam.lib.crash.CrashHandler;
import com.anyun.im_lib.ExecutorServiceFactory;
import com.facebook.stetho.Stetho;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -86,6 +87,16 @@
            FileUtil.createdirs(getApplicationContext());
            failedProjRepository = new FailedProjRepository(this);
            rtkWorkRepository = new RTKWorkRepository(this);
            MyLog.i(TAG,"拷贝assert目录下的map" +
                    "和vechile json到包目录下");
            new Thread(new Runnable() {
                @Override
                public void run() {
                    FileUtil.copyAssertFileToSD(getApplicationContext(),Constant.MAP);
                    FileUtil.copyAssertFileToSD(getApplicationContext(),Constant.VEHICLE);
                }
            }).start();
        }
    }
@@ -144,7 +155,24 @@
                break;
            case Constant.EXAM_STATUS_REPLY:
                MyLog.d(TAG, "考试开始,需要删除上一个考试学员的数据库失败项目表");
                failedProjRepository.deleteAll();
                try {
                    failedProjRepository.deleteAll();
                    JSONObject jsonObject =new JSONObject((String)json);
                    int errCode = jsonObject.getInt("error");
                    switch (errCode){
                        case -1:
                            sendMapInfo();
                            break;
                        case -2:
                            sendVechileInfo();
                            break;
                        case -3:
                            break;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
            case Constant.RTK_PLATFORM_CONNECT_STATUS:
                String[] conn_strs = new String[2];
@@ -156,8 +184,42 @@
                WorkManager.getInstance(getApplicationContext()).enqueue(oneTimeWorkRequest);
                break;
            case Constant.FETCH_MAP_INFO:
                sendMapInfo();
                StringBuffer buffer =FileUtil.readTxtFileFromSD(this,Constant.MAP);
                break;
            case Constant.REQ_VECHILE_PROFILE:
                sendVechileInfo();
                break;
            case Constant.GPS_INFO:
                Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build();
                OneTimeWorkRequest gpsinfoWorkRequest = new OneTimeWorkRequest.Builder(GpsInfoWorker.class).setInputData(gpsData).build();
                WorkManager.getInstance(getApplicationContext()).enqueue(gpsinfoWorkRequest);
                break;
        }
    }
    private void sendVechileInfo() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                StringBuffer vebuffer =FileUtil.readTxtFileFromSD(getApplicationContext(),Constant.VEHICLE);
                if (vebuffer != null){
                    AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString());
                }else{
                    MyLog.d(TAG,String.format("车辆模型模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                }
            }
        }).start();
    }
    private void sendMapInfo(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                StringBuffer buffer =FileUtil.readTxtFileFromSD(getApplicationContext(),Constant.MAP);
                if (buffer != null){
                    AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,buffer.toString());
@@ -165,24 +227,8 @@
                    MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                }
                break;
            case Constant.REQ_VECHILE_PROFILE:
                StringBuffer vebuffer =FileUtil.readTxtFileFromSD(this,Constant.VEHICLE);
                if (vebuffer != null){
                    AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString());
                }else{
                    MyLog.d(TAG,String.format("车辆模型模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                }
                break;
            case Constant.GPS_INFO:
                Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build();
                OneTimeWorkRequest gpsinfoWorkRequest = new OneTimeWorkRequest.Builder(GpsInfoWorker.class).setInputData(gpsData).build();
                WorkManager.getInstance(getApplicationContext()).enqueue(gpsinfoWorkRequest);
                break;
        }
            }
        }).start();
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -100,8 +100,8 @@
    }
    private void sendRTKConfig2RemoteService() {
        MyLog.d(TAG,"主动推送RTKConfig");
        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
//        MyLog.d(TAG,"主动推送RTKConfig");
//        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
    }
    @Override
    public void onClick(View v) {
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -118,8 +118,8 @@
    }
    private void sendRTKConfig2RemoteService() {
        MyLog.d(TAG,"主动推送RTKConfig");
        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
//        MyLog.d(TAG,"主动推送RTKConfig");
//        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
    }
    @Override
app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java
@@ -132,7 +132,7 @@
            } catch (IOException e) {
                e.printStackTrace();
            }
            OutputStream outputStream = new FileOutputStream(  new File(context.getExternalFilesDir(null), assertfileName));
            OutputStream outputStream = new FileOutputStream(  new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(), assertfileName));
            byte[] bytes = new byte[1024];
            while ((inputStream.read(bytes))>0){
                outputStream.write(bytes);
lib/src/main/java/com/anyun/exam/lib/AYSdk.java
@@ -6,6 +6,7 @@
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
/**
@@ -83,6 +84,7 @@
    @Override
    public void sendCmd(int cmd, String s) {
        MyLog.i(TAG,"CMD="+cmd+" content:"+(!TextUtils.isEmpty(s)?s:"null"));
        SvrManager.getInstance().sendCmd(cmd,s);
    }