Commit 5db5faa2718e795d5e2ee972db3c450679ff756e

Authored by wugian
1 parent 9d65ca5e

基本流程,获取相关信息

@@ -35,7 +35,7 @@ public class AppUpdateUtils { @@ -35,7 +35,7 @@ public class AppUpdateUtils {
35 private static final String UPDATE_ADS_VIDEO_INFO = API_ROOT + "/Api/Agent/CheckAdVedio?checkCode="; 35 private static final String UPDATE_ADS_VIDEO_INFO = API_ROOT + "/Api/Agent/CheckAdVedio?checkCode=";
36 private String updateApkUrl = API_ROOT + "/Api/Agent/CheckAppVersion?machineType=";// + XgimiDevice.getDeviceType() + "&imei=" + SystemUtils.getPID(); 36 private String updateApkUrl = API_ROOT + "/Api/Agent/CheckAppVersion?machineType=";// + XgimiDevice.getDeviceType() + "&imei=" + SystemUtils.getPID();
37 private String updatePosterUrl = API_ROOT + "/Agent/GetPoster?imei=";// + SystemUtils.getPID(); 37 private String updatePosterUrl = API_ROOT + "/Agent/GetPoster?imei=";// + SystemUtils.getPID();
38 - private String GET_AGENT_INFO = API_ROOT + "/Api/Agent/GetInfo?imei="; 38 + private String getAgentInfo = API_ROOT + "/Api/Agent/GetInfo?imei=";
39 39
40 private Context context; 40 private Context context;
41 private boolean showNoUpdate = true; 41 private boolean showNoUpdate = true;
@@ -291,7 +291,7 @@ public class AppUpdateUtils { @@ -291,7 +291,7 @@ public class AppUpdateUtils {
291 public void updateAgentInfo() { 291 public void updateAgentInfo() {
292 String verJson = null; 292 String verJson = null;
293 try { 293 try {
294 - verJson = OkHttpClientManager.getAsString(GET_AGENT_INFO + pid); 294 + verJson = OkHttpClientManager.getAsString(getAgentInfo + pid);
295 } catch (Exception e) { 295 } catch (Exception e) {
296 e.printStackTrace(); 296 e.printStackTrace();
297 } 297 }
@@ -323,7 +323,7 @@ public class AppUpdateUtils { @@ -323,7 +323,7 @@ public class AppUpdateUtils {
323 } 323 }
324 long l = System.currentTimeMillis() / 1000; 324 long l = System.currentTimeMillis() / 1000;
325 try { 325 try {
326 - l = OkHttpClientManager.getSysTime(GET_AGENT_INFO + pid); 326 + l = OkHttpClientManager.getSysTime(getAgentInfo + pid);
327 } catch (IOException | ParseException e) { 327 } catch (IOException | ParseException e) {
328 e.printStackTrace(); 328 e.printStackTrace();
329 } 329 }
@@ -8,6 +8,7 @@ import com.google.gson.Gson; @@ -8,6 +8,7 @@ import com.google.gson.Gson;
8 import com.google.gson.internal.$Gson$Types; 8 import com.google.gson.internal.$Gson$Types;
9 import com.squareup.okhttp.Call; 9 import com.squareup.okhttp.Call;
10 import com.squareup.okhttp.Callback; 10 import com.squareup.okhttp.Callback;
  11 +import com.squareup.okhttp.Dns;
11 import com.squareup.okhttp.FormEncodingBuilder; 12 import com.squareup.okhttp.FormEncodingBuilder;
12 import com.squareup.okhttp.Headers; 13 import com.squareup.okhttp.Headers;
13 import com.squareup.okhttp.HttpUrl; 14 import com.squareup.okhttp.HttpUrl;
@@ -33,13 +34,18 @@ import java.lang.reflect.Type; @@ -33,13 +34,18 @@ import java.lang.reflect.Type;
33 import java.net.CookieManager; 34 import java.net.CookieManager;
34 import java.net.CookiePolicy; 35 import java.net.CookiePolicy;
35 import java.net.FileNameMap; 36 import java.net.FileNameMap;
  37 +import java.net.InetAddress;
36 import java.net.URLConnection; 38 import java.net.URLConnection;
  39 +import java.net.UnknownHostException;
37 import java.security.KeyManagementException; 40 import java.security.KeyManagementException;
38 import java.security.NoSuchAlgorithmException; 41 import java.security.NoSuchAlgorithmException;
39 import java.security.cert.CertificateException; 42 import java.security.cert.CertificateException;
40 import java.text.ParseException; 43 import java.text.ParseException;
  44 +import java.util.ArrayList;
  45 +import java.util.Arrays;
41 import java.util.Date; 46 import java.util.Date;
42 import java.util.HashMap; 47 import java.util.HashMap;
  48 +import java.util.List;
43 import java.util.Map; 49 import java.util.Map;
44 import java.util.Set; 50 import java.util.Set;
45 51
@@ -56,7 +62,26 @@ public class OkHttpClientManager { @@ -56,7 +62,26 @@ public class OkHttpClientManager {
56 mOkHttpClient = new OkHttpClient(); 62 mOkHttpClient = new OkHttpClient();
57 //cookie enabled 63 //cookie enabled
58 mOkHttpClient.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER)); 64 mOkHttpClient.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER));
59 - 65 + mOkHttpClient.setDns(new Dns() {
  66 + @Override
  67 + public List<InetAddress> lookup(String hostname) throws UnknownHostException {
  68 + if (hostname == null)
  69 + throw new UnknownHostException("hostname == null");
  70 + if (hostname.equals("ft.qnbar.cn")) {
  71 +// String[] ips = new String[]{"10.10.4.1"};
  72 +// List<InetAddress> addresses = new ArrayList<InetAddress>();
  73 +// for (int i = 0; i < ips.length; i++) {
  74 +// addresses.add(InetAddress.getByName(ips[i]));
  75 +// }
  76 +// return addresses;
  77 + List<InetAddress> addresses = new ArrayList<InetAddress>();
  78 + addresses.add(InetAddress.getByName("10.10.4.6"));
  79 + return addresses;
  80 + } else {
  81 + return Arrays.asList(InetAddress.getAllByName(hostname));
  82 + }
  83 + }
  84 + });
60 // Create a trust manager that does not validate certificate chains 85 // Create a trust manager that does not validate certificate chains
61 TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { 86 TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
62 @Override 87 @Override
1 package com.qnbar.smc.service; 1 package com.qnbar.smc.service;
2 2
3 -import java.util.List;  
4 -  
5 /** 3 /**
6 * Created by wugian on 2017/3/11. 4 * Created by wugian on 2017/3/11.
7 */ 5 */
8 6
9 public class SocketResponse { 7 public class SocketResponse {
10 8
  9 +
11 /** 10 /**
12 - * code : 1001  
13 - * msg : roomsn is registered!please use reconnect 11 + * code : 0
  12 + * msg :
14 * data : [] 13 * data : []
15 - * cmd : 14 + * cmd : openDoor
16 */ 15 */
17 16
18 private int code; 17 private int code;
19 private String msg; 18 private String msg;
20 private String cmd; 19 private String cmd;
21 - private List<?> data; 20 +// private List<?> data;
22 21
23 public int getCode() { 22 public int getCode() {
24 return code; 23 return code;
@@ -44,11 +43,11 @@ public class SocketResponse { @@ -44,11 +43,11 @@ public class SocketResponse {
44 this.cmd = cmd; 43 this.cmd = cmd;
45 } 44 }
46 45
47 - public List<?> getData() {  
48 - return data;  
49 - }  
50 -  
51 - public void setData(List<?> data) {  
52 - this.data = data;  
53 - } 46 +// public List<?> getData() {
  47 +// return data;
  48 +// }
  49 +//
  50 +// public void setData(List<?> data) {
  51 +// this.data = data;
  52 +// }
54 } 53 }
@@ -30,11 +30,11 @@ public class SocketService extends Service { @@ -30,11 +30,11 @@ public class SocketService extends Service {
30 private static final int ROOM_NOT_EXIST_M = 1002; 30 private static final int ROOM_NOT_EXIST_M = 1002;
31 private static final int HEAT_BEAT_RTN = 1003; 31 private static final int HEAT_BEAT_RTN = 1003;
32 32
33 - public static final String HOST = "121.43.189.162";// "192.168.1.21";// 33 + public static final String HOST = "10.10.4.6";// "192.168.1.21";//
34 public static final int PORT = 9501; 34 public static final int PORT = 9501;
35 35
36 public static final String END_SYMBOL = "\\r\\n\\r\\n";//心跳包内容 36 public static final String END_SYMBOL = "\\r\\n\\r\\n";//心跳包内容
37 - public String testRoomSn = "000003"; 37 + public String testRoomSn = "R170413034374";
38 38
39 private ReadThread mReadThread; 39 private ReadThread mReadThread;
40 private HeatBeatThread mHeatBeatThread; 40 private HeatBeatThread mHeatBeatThread;
@@ -83,7 +83,7 @@ public class SocketService extends Service { @@ -83,7 +83,7 @@ public class SocketService extends Service {
83 context = this; 83 context = this;
84 //TODO change the room sn 84 //TODO change the room sn
85 if (!"LETEST".equals(SystemUtils.getPid(context, BuildConfig.MACHINE_TYPE))) { 85 if (!"LETEST".equals(SystemUtils.getPid(context, BuildConfig.MACHINE_TYPE))) {
86 - testRoomSn = "000002"; 86 + testRoomSn = "R170413034374";
87 } 87 }
88 new InitSocketThread().start(); 88 new InitSocketThread().start();
89 Log.d(TAG, "socket service onCreate"); 89 Log.d(TAG, "socket service onCreate");
@@ -197,7 +197,7 @@ public class SocketService extends Service { @@ -197,7 +197,7 @@ public class SocketService extends Service {
197 Log.d(TAG, "end:" + message.contains(END_SYMBOL) + ""); 197 Log.d(TAG, "end:" + message.contains(END_SYMBOL) + "");
198 Log.d(TAG, "recv msg:" + message); 198 Log.d(TAG, "recv msg:" + message);
199 try { 199 try {
200 - SocketResponse socketResponse = gson.fromJson(message.trim(), SocketResponse.class); 200 + SocketResponse socketResponse = gson.fromJson(message.substring(0, message.length() - 8), SocketResponse.class);
201 switch (socketResponse.getCode()) { 201 switch (socketResponse.getCode()) {
202 case SUCESS_MESSAGE: 202 case SUCESS_MESSAGE:
203 Log.d(TAG, "success:" + socketResponse.getCmd()); 203 Log.d(TAG, "success:" + socketResponse.getCmd());
@@ -17,7 +17,7 @@ import com.xgimi.gimicinema.application.FangTangApplication; @@ -17,7 +17,7 @@ import com.xgimi.gimicinema.application.FangTangApplication;
17 * Created by wugian on 2017/4/7 17 * Created by wugian on 2017/4/7
18 */ 18 */
19 public class RoomInfoModelImpl implements IRoomInfoModel { 19 public class RoomInfoModelImpl implements IRoomInfoModel {
20 - private static final String ROOT_URL = "https:/hulong.nat123.net/"; 20 + private static final String ROOT_URL = "https://ft.qnbar.cn/develop/";
21 private static final String ROOM_INFO_BY_IMEI_URL = ROOT_URL + "tcp/getRoomInfoByimei?imei="; 21 private static final String ROOM_INFO_BY_IMEI_URL = ROOT_URL + "tcp/getRoomInfoByimei?imei=";
22 private static final String ROOM_STATUS_BY_ROOM_SN_URL = ROOT_URL + "tcp/getRoomStatus?room_sn="; 22 private static final String ROOM_STATUS_BY_ROOM_SN_URL = ROOT_URL + "tcp/getRoomStatus?room_sn=";
23 private static final String ROOM_QRCODE_BY_ORDER_SN = ROOT_URL + "tcp/getEndQRCode?order_sn="; 23 private static final String ROOM_QRCODE_BY_ORDER_SN = ROOT_URL + "tcp/getEndQRCode?order_sn=";
@@ -54,7 +54,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel { @@ -54,7 +54,7 @@ public class RoomInfoModelImpl implements IRoomInfoModel {
54 e.printStackTrace(); 54 e.printStackTrace();
55 } 55 }
56 boolean equals = roomInfoStr.equals(response); 56 boolean equals = roomInfoStr.equals(response);
57 - if (roomInfo1 != null && !equals) { 57 + if (roomInfo1 != null && roomInfo1.getData() != null && !equals) {
58 Utils.saveString(applicationContext, "room-info", response); 58 Utils.saveString(applicationContext, "room-info", response);
59 listener.onGetRoomInfoUpdate(roomInfo1); 59 listener.onGetRoomInfoUpdate(roomInfo1);
60 } else { 60 } else {
Please register or login to post a comment