lizhanwei
2020-02-10 d9941fe4e30358f98c90a080dd0835fceb0213ee
app/src/main/java/safeluck/drive/evaluation/fragment/BaseDatasFragment.java
@@ -3,6 +3,8 @@
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -11,6 +13,11 @@
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
import com.anyun.exam.lib.util.ByteUtil;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.Constant;
@@ -65,14 +72,22 @@
                ((BaseSettingFragment)getParentFragment()).startBrotherFragment(SignalConfigFragment.newInstance());
                break;
            case R.id.btn_mcu_upgrade:
                StringBuffer stringBuffer = FileUtil.readMCUtFileFromSD(getContext(),"dfu.bin");
                if (stringBuffer != null){
                    AYSdk.getInstance().sendCmd(Constant.UPGRADE_MCU_CONTENT_FILE, stringBuffer.toString());
                }else{
                    MyLog.i(TAG,"mcu升级文件不存在");
                try {
                    byte[] datas =FileUtil.readLocalFile(getActivity(),"dfu.bin");
                    if (datas != null){
                        String strs = new String(datas, Charset.forName("ISO-8859-1"));
                        Log.i(TAG, "onClick: datas.legnth=="+strs.getBytes("ISO-8859-1").length);
                        AYSdk.getInstance().sendCmd(Constant.UPGRADE_MCU_CONTENT_FILE, strs);
                    }else{
                        MyLog.i(TAG,"mcu升级文件不存在");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
            default:
                break;