From af2cbc2a24b3724e7fc3e6b42e134b21a3144c75 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期四, 17 二月 2022 15:33:19 +0800
Subject: [PATCH] 过滤掉非json数据不传给三方使用
---
HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java | 55 +++++++++++++++++++++++++++----------------------------
1 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java b/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
index 2533b47..571b025 100644
--- a/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
+++ b/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -4,12 +4,14 @@
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.Manifest;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@@ -27,6 +29,7 @@
import com.hdl.sdk.common.exception.HDLLinkException;
import com.hdl.sdk.common.utils.IdUtils;
import com.hdl.sdk.common.utils.IpUtils;
+import com.hdl.sdk.common.utils.LogUtils;
import com.hdl.sdk.common.utils.gson.GsonConvert;
import com.hdl.sdk.connect.HDLLink;
import com.hdl.sdk.connect.bean.LinkRequest;
@@ -45,15 +48,18 @@
import com.hdl.sdk.connect.protocol.LinkMessageEncoder;
import com.hdl.sdk.socket.SocketOptions;
import com.hdl.sdk.socket.codec.MessagePipeLine;
+import java.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.List;
import java.util.Map;
import static com.hdl.sdk.common.config.TopicConstant.GATEWAY_SEARCH_REPLY;
+import static java.util.Base64.*;
public class MainActivity extends AppCompatActivity {
@@ -71,7 +77,12 @@
super.onDestroy();
removeAllTopicsListener();
}
-
+void init() {
+// HDLLinkConfig.getInstance().setLocalSecret("7d04c4e3c2b7d600");
+// HDLLinkConfig.getInstance().setGatewayId("1473119283609321473");
+// HDLLinkConfig.getInstance().setLocalEncrypt(true);
+}
+ @RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -81,6 +92,7 @@
rv = findViewById(R.id.rv);
rv.setLayoutManager(new LinearLayoutManager(this));
+ init();
checkIfCertified();
initDeviceInfo();
registerAllTopicsListener();
@@ -254,17 +266,18 @@
void initDeviceInfo()
{
AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean();
- infoBean.setDeviceMAC("123456789");
- infoBean.setIPMAC("12345678900");
+ infoBean.setDeviceMAC("AA000000000000AF");
+ infoBean.setIPMAC("AA000000000000AF");
infoBean.setDeviceName("闊充箰鎾斁鍣�");//璁惧鍚嶅瓧
infoBean.setDeviceModel("MCLog.431");//璁惧鍨嬪彿
infoBean.setAccessMode("WIFI");
- infoBean.setIPGateway("192.168.88.1");
- infoBean.setIPAddress(IpUtils.getIP(this));
+ infoBean.setIPGateway("192.168.1.1");
+ infoBean.setIPAddress("192.168.1.101");
+ infoBean.setGateway_type("music.standard");
infoBean.setHw_version("HW2.0");
infoBean.setFw_version("Fw1.0");
- infoBean.setOID("010105000000FE08");
- infoBean.setSid("010105000000FE08110100000000");
+ infoBean.setOID("010105000000FE10");//姣忎釜璁惧oid閮借涓嶄竴鏍�
+ infoBean.setSid("110105000000FE08110100000000");//姣忎釜璁惧鐨剆id閮借涓嶄竴鏍�
HDLLinkConfig.getInstance().setDeviceInfoBean(infoBean);
}
@@ -277,10 +290,10 @@
//娴嬭瘯鏈嶅姟
String spkStr = "ir.module";//浜у搧spk
- String macStr = "AA000000000000BB";//璁惧鍞竴MAC鍦板潃
- String secret = "87ae414b7a853f65";//閫氳繃spk鍜宮ac鎻愪氦浜戠璁よ瘉鍚庡垎閰嶇殑secret
+ String macStr = "AA000000000000AF";//璁惧鍞竴MAC鍦板潃
+ String secret = "44b360eb74b7ba64";//閫氳繃spk鍜宮ac鎻愪氦浜戠璁よ瘉鍚庡垎閰嶇殑secret
- //姝e紡鏈嶅姟鍣�
+// //姝e紡鏈嶅姟鍣�
// String spkStr = "screen.mirror";//浜у搧spk
// String macStr = "AA000000000000AC";//璁惧鍞竴MAC鍦板潃
// String secret = "ee62124c151b737c";//閫氳繃spk鍜宮ac鎻愪氦浜戠璁よ瘉鍚庡垎閰嶇殑secret
@@ -288,34 +301,20 @@
String mac_key = stringToMD5(stringToMD5(macStr + secret));
String versionString = "HDL_V1.0.1";//
String time = String.valueOf(System.currentTimeMillis());
+ HDLLinkConfig.getInstance().getDeviceInfoBean().setDeviceMAC(macStr);
//1.璁剧疆璁よ瘉淇℃伅
AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean();
requestBean.setMAC(macStr);
- requestBean.setSupplier("raysgem");
+ requestBean.setSupplier("WISE");
requestBean.setFirmwareVersion(versionString);
requestBean.setHardwareModel("1956F");
AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean();
authbean.setSpk(spkStr);
authbean.setMACKey(mac_key);
authbean.setRequest(requestBean);
-
- //2.璁剧疆璁惧淇℃伅
- AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean();
- infoBean.setDeviceMAC(macStr);
- infoBean.setIPMAC(macStr);
- infoBean.setDeviceName("绾㈠瀹�");//璁惧鍚嶅瓧
- infoBean.setDeviceModel("HDL");//
- infoBean.setAccessMode("WIFI");
- infoBean.setIPGateway("192.168.88.1");
- infoBean.setIPAddress(IpUtils.getIP(this));
-
- infoBean.setOID("010105000000FE08");
- infoBean.setSid("010105000000FE08110100000000");
-// infoBean.set
- AuthenticateRequest.VersionBean[] versionBeans = new AuthenticateRequest.VersionBean[]{new AuthenticateRequest.VersionBean("FW", versionString), new AuthenticateRequest.VersionBean("HW", "1956F")};
- infoBean.setVersions(versionBeans);
- AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, infoBean, authbean);
+ //HDLLinkConfig.getInstance().getDeviceInfoBean()杩欎釜鍒濆鍖栫殑鏃跺�欒鍏堣缃ソ
+ AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), authbean);
HDLLink.getInstance().startAuthenticateRequest(request, new HDLLinkCallBack() {
@Override
public void onError(HDLLinkException e) {
--
Gitblit v1.8.0