wjc
2025-05-07 8814f3f0828e6ac652a29cc9de9f971fd55bca5b
app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -1,6 +1,10 @@
package com.hdl.photovoltaic.ui;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.SystemClock;
@@ -23,13 +27,13 @@
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
import com.hdl.photovoltaic.other.HdlESLocalJsonLogic;
import com.hdl.photovoltaic.other.HdlFileLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMqttLogic;
import com.hdl.photovoltaic.other.HdlOtaLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.services.ForeService;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
@@ -84,6 +88,19 @@
        this.pushTokens();
        //获取云端脚本
        HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
//        mForegroundService= new Intent(this, ForeService.class);
//        startService();
    }
    Intent mForegroundService;
    private void startService() {
        // Android 8.0使用startForegroundService在前台启动新服务
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            startForegroundService(mForegroundService);
        } else {
            startService(mForegroundService);
        }
    }
    @Override
@@ -170,7 +187,7 @@
            HdlLogLogic.print(event.getTopic() + new Gson().toJson(event.getData()), true);
        } else if (event.getTopic().contains(ConstantManage.network_change_post)) {
//            String wifi_ssid = WifiUtils.getInstance().getCurrentConnectWifiSsid();//获取WiFi的ssid需要位置权限的
            HdlLogLogic.print("监听网络状态--->" + event.getData().toString() + "(" + event.getType() + ")", true);
            HdlLogLogic.print("监听网络状态---" + event.getData().toString() + "(" + event.getType() + ")", true);
            //第一次启动App,以及切换网络的时候更新
            if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) {
                return;
@@ -232,7 +249,7 @@
//        }
        if (TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) {
            //其实刷新token失败已通知退出登录,数据已经清空,因为等2s uni加载慢导致请求链接的时候出现token为空
            HdlLogLogic.print("返回去");
            HdlLogLogic.print("返回去---",true);
            return;
        }
        UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0);
@@ -259,7 +276,9 @@
            String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
            HdlUniLogic.getInstance().openUniMP(path, null);
        }
    }
//    /**
//     * 物理按键返回事件(包括左滑移除事件)
@@ -309,6 +328,7 @@
        HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
        //移除监听
        HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
//        stopService(mForegroundService);
    }
    /**