mac
2023-12-06 d830fef6a2bc2ab061e6ac2b423c4a49dda3cf21
app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -1,10 +1,12 @@
package com.hdl.photovoltaic.ui;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import android.Manifest;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Bundle;
@@ -74,6 +76,7 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        setNotificationBarBackgroundColor(CustomColor.blue);
        //初始化
        initView();
        //初始化界面监听器
@@ -83,7 +86,7 @@
        //初始化mqtt客户端
        initMqttClient();
//        dddd();
    }
@@ -315,12 +318,14 @@
        } else if (event.getTopic().contains(HdlOtaLogic.localDownloadProgress)) {
            //下载云端驱动或者固件文件,自己计算进度条上报到uni那边
            HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
            uniCallBackBaseBean.setType(HdlOtaLogic.localDownloadProgress);
            uniCallBackBaseBean.setType(event.getType());
            uniCallBackBaseBean.setData(event.getData());
            HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL, uniCallBackBaseBean);
            HdlLogLogic.print(((HdlOtaLogic.Progress) event.getData()).step + "", false);
            HdlLogLogic.print("进度:" + ((HdlOtaLogic.Progress) event.getData()).step + "", false);
        }
    }
    /**
@@ -354,7 +359,76 @@
    }
    private void dddd() {
//        String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName("036F6C1B", "V01.01.02");
//        String data = HdlFileLogic.getInstance().readFile(drivePathFileName);
//        String md5 = HDLMD5Utils.encodeMD5(data);//网关驱动需要
//        Log.e("", md5);
//        HdlOtaLogic.getInstance().getDeviceDriverDownloadFile("http://192.168.16.135:49152/storage/emulated/0/Android/data/com.hdl.photovoltaic/files/Documents/upgrade/drive/036F6C1B_V01.01.02.zip", new CloudCallBeak<ResponseBody>() {
//            @Override
//            public void onSuccess(ResponseBody responseBody) {
//
//                HdlOtaLogic.getInstance().disposeDownLoadFile(drivePathFileName, responseBody, md5);
//
////                //本地升级驱动文件路径
////
////                String data = HdlFileLogic.getInstance().readFile(drivePathFileName);
////                String md5 = HDLMD5Utils.encodeMD5(data);//网关驱动需要
//            }
//
//            @Override
//            public void onFailure(HDLException e) {
//
//            }
//        });
//        HdlOtaLogic.getInstance().getNewGatewayDrivers("036F6C1B", "A000", new CloudCallBeak<CloudGatewayDriversBean>() {
//            @Override
//            public void onSuccess(CloudGatewayDriversBean obj) {
//
//            }
//
//            @Override
//            public void onFailure(HDLException e) {
//
//            }
//        });
//        dowlao();
        HdlOtaLogic.getInstance().startLocalService(new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
            }
            @Override
            public void onServiceDisconnected(ComponentName name) {
            }
        });
    }
    void dowlao() {
        HdlOtaLogic.getInstance().getDeviceUpgradeDownloadFile("http://hdl-hz-test.oss-cn-hangzhou.aliyuncs.com/20/2023/11/1834a1d0-d2a7-4b6f-9877-6f2722e9b7bc.hdlipk_sec", new CloudCallBeak<ResponseBody>() {
            @Override
            public void onSuccess(ResponseBody responseBody) {
                String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName("036F6C1B", "V01.01.02");
                HdlOtaLogic.getInstance().disposeDownLoadFile(drivePathFileName, responseBody, "84cd8e62d4311c90508313f0e5965dbb", HdlOtaLogic.driver_type);
//                HdlFileLogic.getInstance().writeFile(drivePathFileName, bytes);//写入新文件
                HdlLogLogic.print("写入新驱动文件到内存成功.", false);
            }
            @Override
            public void onFailure(HDLException e) {
                HdlLogLogic.print("下载驱动文件到内存失败.", false);
            }
        });
    }
}