From adba037d593cae303557bb686025b8ccc3bdf418 Mon Sep 17 00:00:00 2001 From: 562935844@qq.com Date: 星期二, 12 九月 2023 13:58:19 +0800 Subject: [PATCH] 澳斯迪去除申请密钥等功能 --- HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java index a227a2a..debec18 100644 --- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java +++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java @@ -5,7 +5,6 @@ import android.text.TextUtils; import android.util.Log; -import androidx.annotation.RequiresApi; import com.google.gson.reflect.TypeToken; import com.hdl.sdk.common.config.TopicConstant; @@ -15,6 +14,7 @@ import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.SPUtils; import com.hdl.sdk.common.utils.gson.GsonConvert; +import com.hdl.sdk.connect.HDLLink; import com.hdl.sdk.connect.bean.LinkResponse; import com.hdl.sdk.connect.bean.request.AuthenticateRequest; import com.hdl.sdk.connect.bean.response.DeviceDeleteResponse; @@ -27,10 +27,10 @@ import com.hdl.sdk.socket.codec.ByteToMessageDecoder; import java.util.ArrayList; -import java.util.Base64; import java.util.List; -import kotlin.ParameterName; +import android.util.Base64; + /** * Created by Tong on 2021/9/22. @@ -129,7 +129,7 @@ } - @RequiresApi(api = Build.VERSION_CODES.O) +// @RequiresApi(api = Build.VERSION_CODES.O) @Override protected synchronized LinkResponse decoder(Object msg, String ipaddress) throws Exception { if (msg instanceof byte[]) { @@ -181,7 +181,7 @@ //涔嬪墠鐨勭増鏈繖鍧楁槸鏄庢枃鐨� if (!topic.contains("heartbeat_reply")) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) - LogUtils.e("瑙e瘑澶辫触锛屾暟鎹唴瀹规槸锛歕r\n" + Base64.getEncoder().encodeToString(body)); + LogUtils.e("瑙e瘑澶辫触锛屾暟鎹唴瀹规槸锛歕r\n" + Base64.encodeToString(body, Base64.NO_WRAP)); else { LogUtils.e("瑙e瘑澶辫触锛屾暟鎹唴瀹规槸锛歕r\n" + new String(body, "utf-8")); } @@ -213,18 +213,19 @@ LogUtils.i("UploadGatewayInfo onError"); } }); - } else if (response.getTopic().equals(updateLocalSecret)) { + } else if (response.getTopic().equals(updateLocalSecret) || response.getTopic().equals(TopicConstant.LINK_BROADCAST)) { try { DeviceInfoResponse deviceInfoResponse = GsonConvert.getGson().fromJson(response.getData(), new TypeToken<DeviceInfoResponse>() { }.getType()); if (!TextUtils.isEmpty(deviceInfoResponse.getObjects().getLocalSecret())) { - byte[] baseBytes = Base64.getDecoder().decode(deviceInfoResponse.getObjects().getLocalSecret()); + byte[] baseBytes = Base64.decode(deviceInfoResponse.getObjects().getLocalSecret(), Base64.NO_WRAP); String mackey = ""; if (!TextUtils.isEmpty(SPUtils.getString("auth_mackey_key", ""))) { mackey = SPUtils.getString("auth_mackey_key", ""); byte[] bodyBytes = AesUtil.aesDecrypt(baseBytes, mackey.substring(mackey.length() - 16)); String localSecret = new String(bodyBytes, "utf-8"); + Log.d("panlili", "鏇存柊瀵嗛挜----->localSecret= " + localSecret); HDLLinkConfig.getInstance().setLocalSecret(localSecret); } } @@ -239,11 +240,17 @@ @Override public void onSuccess(String msg) { LogUtils.i("deleteNetwork onSucceed"); + if (HDLLink.getInstance().listener != null) { + HDLLink.getInstance().listener.onSuccess(msg); + } } @Override public void onError(HDLLinkException e) { LogUtils.i("deleteNetwork onError"); + if (HDLLink.getInstance().listener != null) { + HDLLink.getInstance().listener.onFailure(); + } } }); } catch (Exception e) { -- Gitblit v1.8.0