Commit 613f630df7454b527e0dc02410b89e5b23dd8007

Authored by 李攀
1 parent 9a0d88c0

some log ,send success charge

... ... @@ -11,8 +11,8 @@ def isWindows = {
11 11 }
12 12
13 13 ext {
14   - APP_VERSION_CODE = 3;
15   - APP_VERSION_NAME = "v2.1-0601";
  14 + APP_VERSION_CODE = 4;
  15 + APP_VERSION_NAME = "v2.1-0603";
16 16 }
17 17
18 18 android {
... ...
... ... @@ -35,6 +35,7 @@ import java.io.OutputStream;
35 35 import java.net.Socket;
36 36 import java.util.Arrays;
37 37 import java.util.concurrent.atomic.AtomicBoolean;
  38 +import java.util.concurrent.atomic.AtomicInteger;
38 39
39 40 import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR;
40 41 import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR;
... ... @@ -109,6 +110,7 @@ public class SocketService1 extends BaseService {
109 110 private Handler mHandler = new Handler();
110 111
111 112 AtomicBoolean sendRegister = new AtomicBoolean(false);
  113 + AtomicInteger heartBeatErrorCount = new AtomicInteger(0);
112 114
113 115 private Runnable heartBeatRunnable = new Runnable() {
114 116 @Override
... ... @@ -123,7 +125,6 @@ public class SocketService1 extends BaseService {
123 125 }
124 126 }
125 127 };
126   -
127 128 int mainChargeCount = 0;
128 129 private Runnable startMainRunnable = new Runnable() {
129 130 @Override
... ... @@ -226,6 +227,9 @@ public class SocketService1 extends BaseService {
226 227 if (!msg.contains("20025")) {
227 228 LogUtils.d(TAG, "send msg:" + msg);
228 229 } else {
  230 + if (heartBeatErrorCount.getAndDecrement() > 3) {
  231 + clearConnect();
  232 + }
229 233 LogUtils.d(TAG, "send heart beat msg:" + msg);
230 234 }
231 235 Socket soc = socket;
... ... @@ -297,6 +301,7 @@ public class SocketService1 extends BaseService {
297 301 LogUtils.d(TAG, "clearConnect");
298 302 mHandler.removeCallbacks(heartBeatRunnable);
299 303 sendRegister.set(false);
  304 + heartBeatErrorCount.set(0);
300 305 releaseLastSocket();
301 306 }
302 307 ///end socket operation
... ... @@ -366,6 +371,7 @@ public class SocketService1 extends BaseService {
366 371
367 372 switch (socketResponse.getCode()) {
368 373 case SUCCESS_MESSAGE:
  374 + heartBeatErrorCount.set(0);
369 375 Log.d(TAG, "SUCCESS_MESSAGE");
370 376 break;
371 377 case VERIFY_SUCCESS:
... ... @@ -374,6 +380,7 @@ public class SocketService1 extends BaseService {
374 380 LogUtils.d(TAG, "verify success start heart beat");
375 381 break;
376 382 case HEART_BEAT_SUCCESS:
  383 + heartBeatErrorCount.set(0);
377 384 //每成功5次心跳判定是否启动main activity
378 385 if (++mainChargeCount == 5) {
379 386 mainChargeCount = 0;
... ... @@ -385,7 +392,6 @@ public class SocketService1 extends BaseService {
385 392 boolean serviceLaunched = ActivityCollector.getActivity(MainActivity.class) != null;
386 393 Log.d(TAG, "HEART_BEAT_SUCCESS,MainActivity Launched:" + serviceLaunched);
387 394 break;
388   -
389 395 case HEART_BEAT_ERROR_SYMBOL:
390 396 case ROOM_SN_CONNECTED:
391 397 String msg1 = socketResponse.getCode() == HEART_BEAT_ERROR_SYMBOL ? "HEART_BEAT_ERROR_SYMBOL" : "ROOM_SN_CONNECTED";
... ... @@ -402,6 +408,7 @@ public class SocketService1 extends BaseService {
402 408 }
403 409 break;
404 410 case CONTAIN_MESSAGE:
  411 + heartBeatErrorCount.set(0);
405 412 LogUtils.d(TAG, "CONTAIN_MESSAGE");
406 413 if (socketResponse.getData() != null) {
407 414 if (socketResponse.getCmd() == OPEN_DOOR) {
... ...
... ... @@ -32,19 +32,30 @@ public class QrCodeShowActivity extends Activity implements IUpdateQrCodeView {
32 32 Runnable r = new Runnable() {
33 33 @Override
34 34 public void run() {
35   - LightOperationUtils.close();
36   - LightOperationUtils.setLightValue(5);
37   - new SystemUtils().closeFtLed(QrCodeShowActivity.this.getApplicationContext());
38   - present.reportSleepStatus(orderSn, roomSn);
39   - QrCodeShowActivity.this.finish();
  35 + closeSystem();
40 36 }
41 37 };
  38 +
  39 + private void closeSystem() {
  40 + LightOperationUtils.close();
  41 + LightOperationUtils.setLightValue(5);
  42 + new SystemUtils().closeFtLed(QrCodeShowActivity.this.getApplicationContext());
  43 + present.reportSleepStatus(orderSn, roomSn);
  44 + QrCodeShowActivity.this.finish();
  45 + }
  46 +
42 47 private String orderSn;
43 48 private String roomSn;
44 49 private ImageView iv;
  50 + int updateCount = 0;
45 51 private Runnable updateQrCodeRunnable = new Runnable() {
46 52 @Override
47 53 public void run() {
  54 + //日志显示,没有结束,以此确保20min后关闭相关
  55 + if (updateCount++ == 2) {
  56 + closeSystem();
  57 + return;
  58 + }
48 59 LogUtils.d("room-info", "QrCodeShowActivity update qr code runnable run");
49 60 handler.postDelayed(this, 10 * 60 * 1000);
50 61 present.getQrCode(roomSn, orderSn);
... ...
1 1 package com.xgimi.gimicinema.presenter;
2 2
3   -import android.util.Log;
4 3 import com.gimi.common.cinema.model.RoomQrCodeInfo;
5 4 import com.gimi.common.cinema.model.WrongMsg;
  5 +import com.gimi.common.cinema.utils.LogUtils;
6 6 import com.xgimi.gimicinema.model.IRoomInfoModel;
7 7 import com.xgimi.gimicinema.model.RoomInfoModelImpl;
8 8 import com.xgimi.gimicinema.mview.IUpdateQrCodeView;
... ... @@ -23,12 +23,12 @@ public class QrCodeShowPresent {
23 23 roomInfoModel.reportSleepSysStatus(orderSn, roomSn, new RoomInfoModelImpl.SleepSysStatusListener() {
24 24 @Override
25 25 public void onSleepSuccess() {
26   - Log.d("room-info", "onSleepSuccess");
  26 + LogUtils.d("room-info", "onSleepSuccess");
27 27 }
28 28
29 29 @Override
30 30 public void onSleepFailure() {
31   - Log.d("room-info", "onSleepFailure");
  31 + LogUtils.d("room-info", "onSleepFailure");
32 32 }
33 33 });
34 34 }
... ...
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:orientation="vertical">
  6 +
  7 +
  8 + <TextView
  9 + android:id="@+id/LauncherMetro_Category"
  10 + android:layout_width="wrap_content"
  11 + android:layout_height="wrap_content"
  12 + android:text="@string/actor"
  13 + android:layout_marginLeft="5dp"
  14 + android:layout_centerHorizontal="true"
  15 + android:layout_alignBottom="@+id/LauncherMetro_Substance"/>
  16 +
  17 + <TextView
  18 + android:id="@+id/LauncherMetro_Substance"
  19 + android:layout_width="wrap_content"
  20 + android:layout_height="wrap_content"
  21 + android:text="@string/actor"
  22 + android:maxWidth="150dp"
  23 + />
  24 +
  25 +</RelativeLayout>
\ No newline at end of file
... ...
Please register or login to post a comment