| | |
| | | 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;
|
| | |
| | | import com.hdl.sdk.socket.codec.ByteToMessageDecoder;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Base64;
|
| | | import java.util.List;
|
| | |
|
| | | import android.util.Base64;
|
| | |
|
| | | import kotlin.ParameterName;
|
| | |
|
| | |
| | | //之前的版本这块是明文的
|
| | | if (!topic.contains("heartbeat_reply")) {
|
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
| | | LogUtils.e("解密失败,数据内容是:\r\n" + Base64.getEncoder().encodeToString(body));
|
| | | LogUtils.e("解密失败,数据内容是:\r\n" + Base64.encodeToString(body, Base64.NO_WRAP));
|
| | | else {
|
| | | LogUtils.e("解密失败,数据内容是:\r\n" + new String(body, "utf-8"));
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | |
| | | @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) {
|