编码、调试根据协议格式生成一个二维码,采用des加密、然后Base64编码,调试通过
6个文件已修改
149 ■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/util/SPUtils.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/util/Utils.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt
@@ -63,7 +63,6 @@
            getMap(sn, "yard")
            getMap(sn, "car")
            MyLog.i(PlatFormConstant.TAG,"重置TCP连接")
            IMSClientBootstrap.getInstance().resetConnect();
        }
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java
@@ -407,4 +407,29 @@
    public String getCoachID() {
        return coachID;
    }
    /**
     * 返回学员是否签到,true-已经签到
     */
    public boolean IsStuSign() {
        isStuSign =  (boolean) SPUtils.get(app.getAppContext(),SPUtils.STU_SIGN_STATUS,false);
        return isStuSign;
    }
    public void setStuSign(boolean flag){
        isStuSign = flag;
        SPUtils.put(app.getAppContext(),SPUtils.STU_SIGN_STATUS,flag);
    }
    private boolean isStuSign;
    /**
     * 返回教练是否签到,true-已经签到
     */
    public boolean IsCoachSign() {
        isCoachSign =  (boolean) SPUtils.get(app.getAppContext(),SPUtils.Coach_SIGN_STATUS,false);
        return isCoachSign;
    }
    public void setCoachSign(boolean flag){
        isCoachSign = flag;
        SPUtils.put(app.getAppContext(),SPUtils.Coach_SIGN_STATUS,flag);
    }
    private boolean isCoachSign;
}
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -12,6 +12,7 @@
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -21,12 +22,10 @@
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.work.OneTimeWorkRequest;
@@ -34,11 +33,11 @@
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -48,8 +47,6 @@
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.DB.Student;
import safeluck.drive.evaluation.DB.WokViewModel;
import safeluck.drive.evaluation.DB.appstatusdb.AppStatus;
import safeluck.drive.evaluation.DB.appstatusdb.AppStatusViewModel;
import safeluck.drive.evaluation.DB.exam_status.ExamStatusInitWorker;
import safeluck.drive.evaluation.DB.exam_status.ExamStatusViewModel;
import safeluck.drive.evaluation.DB.failitems.FailedProjViewModel;
@@ -60,22 +57,16 @@
import safeluck.drive.evaluation.DB.exam_status.ExamStatus;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.ScoreBean;
import safeluck.drive.evaluation.bean.SimulateNightBean;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.customview.ArrowView;
import safeluck.drive.evaluation.customview.HouseView;
import safeluck.drive.evaluation.customview.LoadProgressDialog;
import safeluck.drive.evaluation.customview.QRCodeDialog;
import safeluck.drive.evaluation.customview.SelectDialog;
import safeluck.drive.evaluation.httpmodule.RetrofitCreator;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.JKMessage0201;
import safeluck.drive.evaluation.platformMessage.JKMessage0202;
import safeluck.drive.evaluation.platformMessage.JKMessage0204;
import safeluck.drive.evaluation.platformMessage.PlatFormConstant;
import safeluck.drive.evaluation.util.Utils;
import safeluck.drive.evaluation.viewmodels.TimeViewModel;
/**
 * 联网训练UI
@@ -536,6 +527,7 @@
        btn_ids.add(R.id.btn_10);
        view.findViewById(R.id.iv_head).setOnClickListener(this);
        view.findViewById(R.id.iv_coach_head).setOnClickListener(this);
        ((TextView)view.findViewById(R.id.tv_score_tip)).setText("当前考试得分");
        av_curve = view.findViewById(R.id.av3);
        av_park = view.findViewById(R.id.av2);
@@ -580,7 +572,6 @@
    }
private LoadProgressDialog loadProgressDialog;
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
@@ -634,16 +625,38 @@
                break;
            case R.id.iv_head:
                MyLog.i(PlatFormConstant.HTTPTAG,"签到");
                loadProgressDialog = LoadProgressDialog.newInstance("请稍后...");
                loadProgressDialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.Dialog_FullScreen);
                loadProgressDialog.showNow(getFragmentManager(),"loadingdiaolog");
                MyLog.i(TAG,"学员签到");
                if (ExamPlatformData.getInstance().IsStuSign()){
                    ExamPlatformData.getInstance().setStuSign(false);
                    qrcode(1,false);
                }else{
                    ExamPlatformData.getInstance().setStuSign(true);
                    qrcode(1,true);
                }
                break;
            case R.id.iv_coach_head:
                MyLog.i(PlatFormConstant.HTTPTAG,"教练签到");
                if (ExamPlatformData.getInstance().IsCoachSign()){
                    ExamPlatformData.getInstance().setCoachSign(false);
                    qrcode(0,false);
                }else{
                    ExamPlatformData.getInstance().setCoachSign(true);
                    qrcode(0,true);
                }
                //从服务器获取用于生成签到二维码的url
                break;
        }
    }
    private void qrcode(int type,boolean isSign) {
        content = "87,"+String.valueOf(type)+ ","+ExamPlatformData.getInstance().getPhone()
                +(isSign?",signin":",signout");
        Log.i(TAG,String.format("二维码内容:%s",content));
        byte[] bytes = Utils.qrencrypt(content.getBytes(),"safeluck");
        String str = Base64.encodeToString(bytes,Base64.DEFAULT);
        Log.i(TAG,"base64加密后的字符串="+str);
        QRCodeDialog qrCodeDialog = QRCodeDialog.newInstance(str);
        qrCodeDialog.show(getFragmentManager(),"qrdialog" );
    }
    private void sendJK0202(int type) {
        final JKMessage0202 jkMessage0202 = new JKMessage0202();
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -21,6 +21,7 @@
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -41,6 +42,7 @@
import org.json.JSONException;
import org.json.JSONObject;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -62,19 +64,16 @@
import safeluck.drive.evaluation.adapter.ScoreAdapter;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.ScoreBean;
import safeluck.drive.evaluation.bean.SimulateNightBean;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.customview.ArrowView;
import safeluck.drive.evaluation.customview.HouseView;
import safeluck.drive.evaluation.customview.LoadProgressDialog;
import safeluck.drive.evaluation.customview.QRCodeDialog;
import safeluck.drive.evaluation.customview.SelectDialog;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.JKMessage0201;
import safeluck.drive.evaluation.platformMessage.JKMessage0202;
import safeluck.drive.evaluation.util.DimenUtil;
import safeluck.drive.evaluation.platformMessage.PlatFormConstant;
import safeluck.drive.evaluation.util.Utils;
import safeluck.drive.evaluation.viewmodels.TimeViewModel;
/**单机训练UI
 * MyApplication2
@@ -107,7 +106,7 @@
    private TextView tv_speed,tv_total_score,tv_name
            ,tv_start_time,tv_coach_name;
    private double speed=0.0;
    private ImageView iv_head;
    private ImageView iv_head,iv_coach_head;
    WokViewModel wokViewModel;
    private int currTotalScore = 100;
@@ -117,7 +116,6 @@
    String icson;//返回的ic卡信息 json
    private String content;//用以生成二维码的内容
    private LoadProgressDialog loadProgressDialog;
private List<Integer> btn_ids = new ArrayList<Integer>();
@@ -517,6 +515,7 @@
        view.findViewById(R.id.iv_head).setOnClickListener(this);
        view.findViewById(R.id.iv_coach_head).setOnClickListener(this);
        av_curve = view.findViewById(R.id.av3);
        av_park = view.findViewById(R.id.av2);
        av_podao = view.findViewById(R.id.av1);
@@ -610,14 +609,39 @@
                }
                break;
            case R.id.iv_head:
                MyLog.i(TAG,"签到,获取身份证物理卡号");
                loadProgressDialog = LoadProgressDialog.newInstance("请稍后...");
                loadProgressDialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.Dialog_FullScreen);
                loadProgressDialog.showNow(getFragmentManager(),"loadingdiaolog");
                MyLog.i(TAG,"学员签到");
                if (ExamPlatformData.getInstance().IsStuSign()){
                    ExamPlatformData.getInstance().setStuSign(false);
                    qrcode(1,false);
                }else{
                    ExamPlatformData.getInstance().setStuSign(true);
                    qrcode(1,true);
                }
                break;
            case R.id.iv_coach_head:
                MyLog.i(PlatFormConstant.HTTPTAG,"教练签到");
                if (ExamPlatformData.getInstance().IsCoachSign()){
                    ExamPlatformData.getInstance().setCoachSign(false);
                    qrcode(0,false);
                }else{
                    ExamPlatformData.getInstance().setCoachSign(true);
                    qrcode(0,true);
                }
                break;
        }
    }
    private void qrcode(int type,boolean isSign) {
        content = "87,"+String.valueOf(type)+ ","+ExamPlatformData.getInstance().getPhone()
                +(isSign?",signin":",signout");
        Log.i(TAG,String.format("二维码内容:%s",content));
        byte[] bytes = Utils.qrencrypt(content.getBytes(Charset.forName("utf-8")),"safeluck");
        String str = Base64.encodeToString(bytes,Base64.DEFAULT);
        QRCodeDialog qrCodeDialog = QRCodeDialog.newInstance(str);
        qrCodeDialog.show(getFragmentManager(),"qrdialog" );
    }
    private void sendJK0202(int type) {
        final JKMessage0202 jkMessage0202 = new JKMessage0202();
app/src/main/java/safeluck/drive/evaluation/util/SPUtils.java
@@ -23,6 +23,8 @@
    public static final String TRAIN_MODE = "training_mode";
    public static final String FAIL_PROJ_SNS = "failed_projs_sns";
    public static final String ROAD_MAP_PATH = "road_map_path";
    public static final String STU_SIGN_STATUS = "stu_sign_";
    public static final String Coach_SIGN_STATUS = "coach_sign_";
    /**
     * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
app/src/main/java/safeluck/drive/evaluation/util/Utils.java
@@ -14,6 +14,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -34,6 +35,7 @@
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import safeluck.drive.evaluation.bean.Point;
@@ -275,6 +277,30 @@
            e.printStackTrace();
        }
        return null;
    }    /**
     * 二维码加密
     * @param datasource byte[]
     * @param password String
     * @return byte[]
     */
    public static  byte[] qrencrypt(byte[] datasource, String password) {
        try{
            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            DESKeySpec desKeySpec = new DESKeySpec(password.getBytes());
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            SecretKey securekey = keyFactory.generateSecret(desKeySpec);
            IvParameterSpec desKey = new IvParameterSpec(password.getBytes());
            //创建一个密匙工厂,然后用它把DESKeySpec转换成
            //Cipher对象实际完成加密操作
            //用密匙初始化Cipher对象
            cipher.init(Cipher.ENCRYPT_MODE, securekey, desKey);
            //现在,获取数据并加密
            //正式执行加密操作
            return cipher.doFinal(datasource);
        }catch(Throwable e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 解密