From 30e96788f05f5ce28b58d991051c79e9c952c824 Mon Sep 17 00:00:00 2001 From: 562935844@qq.com Date: 星期三, 28 十二月 2022 14:51:34 +0800 Subject: [PATCH] 修改入网认证流程 --- HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java | 61 +++++++++++++++++++----------- 1 files changed, 39 insertions(+), 22 deletions(-) diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java index 5fb4298..bfe3d60 100644 --- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java +++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java @@ -3,7 +3,9 @@ import android.text.TextUtils; import com.hdl.sdk.common.config.TopicConstant; +import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.SPUtils; +import com.hdl.sdk.connect.bean.request.AuthenticateRequest; import com.hdl.sdk.connect.bean.response.GatewaySearchBean; @@ -21,28 +23,33 @@ private String localSecret;//鏈湴鍔犲瘑瀵嗛挜 private String gatewayId; private String ipAddress; - private boolean isLocalEncrypt;//缃戝叧鏄惁闇�瑕佸姞瀵嗛�氳 private GatewaySearchBean currentGateway;//褰撳墠缃戝叧 + + private AuthenticateRequest.AuthenticateDeviceInfoBean deviceInfoBean;//褰撳墠璁惧鍩烘湰淇℃伅 /** * instance */ - private volatile static HDLLinkConfig instance; + private static final HDLLinkConfig instance=new HDLLinkConfig(); + private HDLLinkConfig() + { + loadConfig(); + } /** * getInstance * * @return AuthenticateConfig */ - public static synchronized HDLLinkConfig getInstance() { - if (instance == null) { - synchronized (HDLLinkConfig.class) { - if (instance == null) { - instance = new HDLLinkConfig(); - instance.loadConfig(); - } - } - } + public static HDLLinkConfig getInstance() { +// if (instance == null) { +// synchronized (HDLLinkConfig.class) { +// if (instance == null) { +// instance = new HDLLinkConfig(); +// instance.loadConfig(); +// } +// } +// } return instance; } @@ -53,7 +60,6 @@ this.gatewayId = ""; this.ipAddress = ""; this.localSecret = ""; - this.isLocalEncrypt = false; SPUtils.remove(AUTHENTICATE_LS_KEY); SPUtils.remove(AUTHENTICATE_GATEWAYID_KEY); SPUtils.remove(AUTHENTICATE_IPADDRESS_KEY); @@ -67,7 +73,6 @@ localSecret = SPUtils.getString(AUTHENTICATE_LS_KEY, ""); gatewayId = SPUtils.getString(AUTHENTICATE_GATEWAYID_KEY, ""); ipAddress = SPUtils.getString(AUTHENTICATE_IPADDRESS_KEY, ""); - isLocalEncrypt = SPUtils.getBoolean(AUTHENTICATE_IS_LS_KEY, false); } /** @@ -84,6 +89,13 @@ SPUtils.put(AUTHENTICATE_LS_KEY, localSecret); SPUtils.put(AUTHENTICATE_GATEWAYID_KEY, gatewayId); SPUtils.put(AUTHENTICATE_IPADDRESS_KEY, ipAddress); + } + + /** + * 閲嶆柊淇濆瓨 + */ + public void reSaveConfig() { + this.saveConfig(this.localSecret, this.gatewayId, this.ipAddress); } /** @@ -110,18 +122,15 @@ public String getGatewayId() { return gatewayId; } + public void setGatewayId(String gatewayId) { + this.gatewayId=gatewayId; + } public String getIpAddress() { return ipAddress; } - - public boolean isLocalEncrypt() { - return isLocalEncrypt; - } - - public void setLocalEncrypt(boolean localEncrypt) { - isLocalEncrypt = localEncrypt; - SPUtils.put(AUTHENTICATE_IS_LS_KEY, isLocalEncrypt); + public void setIpAddress(String ipAddress){ + this.ipAddress = ipAddress; } public GatewaySearchBean getCurrentGateway() { @@ -150,7 +159,8 @@ return (!topicStr.contains(TopicConstant.GATEWAY_AUTH_BROADCAST) //缃戝叧骞挎挱鍏ョ綉鎸囦护 && !topicStr.contains(TopicConstant.DEIVCE_AUTH_REQUEST) //鍏ョ綉璁よ瘉 && !topicStr.contains(TopicConstant.GATEWAY_SEARCH) //鎼滅储缃戝叧涓婚 - && isLocalEncrypt//鍚敤鍔犲瘑鏍囧織 + && !topicStr.contains(TopicConstant.BROADCAST) + && !TextUtils.isEmpty(localSecret) //鏈夊瘑閽ュ氨鏄姞瀵� ); } @@ -164,4 +174,11 @@ return String.format(topicStr, gatewayId); } + public AuthenticateRequest.AuthenticateDeviceInfoBean getDeviceInfoBean() { + return deviceInfoBean; + } + + public void setDeviceInfoBean(AuthenticateRequest.AuthenticateDeviceInfoBean deviceInfoBean) { + this.deviceInfoBean = deviceInfoBean; + } } -- Gitblit v1.8.0