|
@@ -3,7 +3,9 @@ package com.emato.ich;
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
import com.cherry.sdk.controller.utils.ScanGunKeyEventHelper;
|
|
|
+import com.emato.ich.api.ICSPApi;
|
|
|
import com.emato.ich.api.ICSPClient;
|
|
|
+import com.emato.ich.api.ICSPConstant;
|
|
|
import com.emato.ich.api.ICSPResponseCodeEnum;
|
|
|
import com.emato.ich.api.SystemConfigConstant;
|
|
|
import com.emato.ich.crash.CrashApplication;
|
|
@@ -262,50 +264,50 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
// 注册柜子信息
|
|
|
|
|
|
-// String appVersion = BaseUtils.getAppVersion(getApplicationContext());
|
|
|
-// String androidVersion = BaseUtils.getVersionName();
|
|
|
-// CountDownLatch countDownLatch = new CountDownLatch(10);
|
|
|
-// Cabinet cabinet = DeviceControl.queryCabinetInfo(countDownLatch);
|
|
|
-// try {
|
|
|
-// countDownLatch.await();
|
|
|
-// } catch (InterruptedException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-//
|
|
|
-// cabinet.setClientId(clientId);
|
|
|
-// cabinet.setSoftwareVersion(appVersion);
|
|
|
-// cabinet.setAndroidVersion(androidVersion);
|
|
|
-// cabinet.setSoftwareType("android");
|
|
|
-// cabinet.setImei(BaseUtils.getIMEI(getApplicationContext()));
|
|
|
-// cabinet.setMacIpv4("111");
|
|
|
-// cabinet.setMacIpv6("unknown");
|
|
|
-// cabinet.setNetType("111");
|
|
|
-// cabinet.setPlatType("S905");
|
|
|
-// cabinet.setSim("111");
|
|
|
-// cabinet.setWifiSSid("111");
|
|
|
-//
|
|
|
-// ObjectMapper objectMapper = JacksonUtils.objectmapper;
|
|
|
-//
|
|
|
-// try {
|
|
|
-// String jsonData = objectMapper.writeValueAsString(cabinet);
|
|
|
-// Log.i(TAG, "onCreate: jsonData===============>" + jsonData);
|
|
|
-//
|
|
|
-// MqttMessage message = new MqttMessage();
|
|
|
-// message.setQos(1);
|
|
|
-// message.setPayload(jsonData.getBytes());
|
|
|
-// ichPublishClient.publish(String.format(ICHTopic.CABINET_INFO_REPORT, clientId), message);
|
|
|
-// } catch (JsonProcessingException e) {
|
|
|
-// Log.e(TAG, "onCreate: 解析成JSON失败!", e);
|
|
|
-// }
|
|
|
+ String appVersion = BaseUtils.getAppVersion(getApplicationContext());
|
|
|
+ String androidVersion = BaseUtils.getVersionName();
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(10);
|
|
|
+ Cabinet cabinet = DeviceControl.queryCabinetInfo(countDownLatch);
|
|
|
+ try {
|
|
|
+ countDownLatch.await();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ cabinet.setClientId(clientId);
|
|
|
+ cabinet.setSoftwareVersion(appVersion);
|
|
|
+ cabinet.setAndroidVersion(androidVersion);
|
|
|
+ cabinet.setSoftwareType("android");
|
|
|
+ cabinet.setImei(BaseUtils.getIMEI(getApplicationContext()));
|
|
|
+ cabinet.setMacIpv4("111");
|
|
|
+ cabinet.setMacIpv6("unknown");
|
|
|
+ cabinet.setNetType("111");
|
|
|
+ cabinet.setPlatType("S905");
|
|
|
+ cabinet.setSim("111");
|
|
|
+ cabinet.setWifiSSid("111");
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = JacksonUtils.objectmapper;
|
|
|
+
|
|
|
+ try {
|
|
|
+ String jsonData = objectMapper.writeValueAsString(cabinet);
|
|
|
+ Log.i(TAG, "onCreate: jsonData===============>" + jsonData);
|
|
|
+
|
|
|
+ MqttMessage message = new MqttMessage();
|
|
|
+ message.setQos(1);
|
|
|
+ message.setPayload(jsonData.getBytes());
|
|
|
+ ichPublishClient.publish(String.format(ICHTopic.CABINET_INFO_REPORT, clientId), message);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ Log.e(TAG, "onCreate: 解析成JSON失败!", e);
|
|
|
+ }
|
|
|
|
|
|
// TODO 更新版本监听
|
|
|
ichPublishClient.subscribe(String.format(ICHTopic.APK_UPDATE_PATH, BaseUtils.getClientId()), (msgId, msg) -> {
|
|
|
try {
|
|
|
- String path = new String(msg.getPayload());
|
|
|
+ // String path = new String(msg.getPayload());
|
|
|
// 发起请求下载APK
|
|
|
XUpdate.newBuild(this)
|
|
|
- .updateUrl(path)
|
|
|
- .isAutoMode(true) //如果需要完全无人干预,自动更新,需要root权限【静默安装需要】
|
|
|
+ .updateUrl(ICSPApi.GET_UPDATE_PATH.getUrl())
|
|
|
+ .isAutoMode(true) // 如果需要完全无人干预,自动更新,需要root权限【静默安装需要】
|
|
|
.update();
|
|
|
// APKUpdateDownload.getInstance().downloadAPK(MainActivity.this, getApplication(), path);
|
|
|
} catch (Exception e) {
|