Commit d6e7bd3948adc9af2be6ebf42fb7825bad38cc3d

Authored by jinyan.yi
2 parents 0bc9e82d 2124bb0f

观影控制代码合并

... ... @@ -233,7 +233,7 @@ public class SmartControlService extends BaseService implements EventListener<St
233 233 @Subscribe(threadMode = ThreadMode.MAIN)
234 234 public void onMoonEvent(MessageEvent messageEvent) {
235 235 switch (messageEvent.getEventId()) {
236   - case SocketService.JUST_OPEN_DOOR:
  236 + case SocketService1.JUST_OPEN_DOOR:
237 237 //check qr code is showing
238 238 openDoor();
239 239 if (ActivityCollector.isActivityExist(QrCodeShowActivity.class)
... ... @@ -269,13 +269,13 @@ public class SmartControlService extends BaseService implements EventListener<St
269 269 }
270 270 }
271 271 break;
272   - case SocketService.USER_OPEN_DOOR_AND_GET_MOVIE:
  272 + case SocketService1.USER_OPEN_DOOR_AND_GET_MOVIE:
273 273 needReport = true;
274 274 openDoor();
275 275 presenter.getOrderInfo(this);
276 276 Log.i("event bus", "user open door" + messageEvent.getMessage());
277 277 break;
278   - case SocketService.USER_OPEN_DOOR:
  278 + case SocketService1.USER_OPEN_DOOR:
279 279 needReport = true;
280 280 openDoor();
281 281 Log.i("event bus", "user open door" + messageEvent.getMessage());
... ...
1   -package com.qnbar.smc.service;
2   -
3   -import android.app.Service;
4   -import android.content.Context;
5   -import android.content.Intent;
6   -import android.os.IBinder;
7   -import android.text.TextUtils;
8   -import android.util.Log;
9   -import android.widget.Toast;
10   -import com.gimi.common.cinema.model.MessageEvent;
11   -import com.gimi.common.cinema.model.RoomInfo;
12   -import com.gimi.common.cinema.utils.SystemUtils;
13   -import com.gimi.common.cinema.utils.Utils;
14   -import com.google.gson.Gson;
15   -import com.google.gson.JsonSyntaxException;
16   -import com.qnbar.smc.utils.LightOperationUtils;
17   -import com.xgimi.gimicinema.activity.QrCodeShowActivity;
18   -import com.xgimi.gimicinema.application.FangTangApplication;
19   -import com.xgimi.smartscreen.encrypt.AuthCode;
20   -import org.greenrobot.eventbus.EventBus;
21   -
22   -import java.io.IOException;
23   -import java.io.InputStream;
24   -import java.io.OutputStream;
25   -import java.lang.ref.WeakReference;
26   -import java.net.Socket;
27   -import java.util.Arrays;
28   -
29   -public class SocketService extends Service {
30   - private static final String TAG = "BackService";
31   - private static final long HEART_BEAT_RATE = 5 * 1000;
32   -
33   - public static final int JUST_OPEN_DOOR = 1701;
34   - public static final int USER_OPEN_DOOR_AND_GET_MOVIE = 1703;
35   - public static final int USER_OPEN_DOOR = 1704;//get the movie again charge show new movie
36   - // public static final int USER_OPEN_DOOR_AND_GET_MOVIE = 1703;
37   - /*
38   - * 10001 //服务器发送了命令(带命令的返回消息),这个一般是服务器主动发消息的时候code为这个值
39   - 10002 //连接(认证)失败
40   - 10003 //还未注册连接就进行认证
41   - 10004 //终端编号未传
42   - 10005 //心跳异常,没有找到房间连接信息
43   - 10006 //心跳异常,连接标识符不一致
44   - 10007 //收到未知命令
45   - 10008 //收到无法解析的消息
46   - 10009 //已经认证过了,不允许再认证
47   - 10010 //room_sn 已连接,不能再连接
48   - */
49   - private static final int VERIFY_SUCCESS = 9999;
50   - private static final int SUCCESS_MESSAGE = 10000;
51   - private static final int CONTAIN_MESSAGE = 10001;
52   - private static final int AUTHENTICATION_FAILED = 10002; //连接(认证)失败
53   - private static final int CONNECTION_BEFORE_AUTHENTICATION = 10003;//还未注册连接就进行认证
54   - private static final int NOT_SEND_ROOM_SN = 10004;//终端编号未传
55   - private static final int HEART_BEAR_ERROR = 10005; //心跳异常,没有找到房间连接信息
56   - private static final int HEART_BEAR_ERROR_SYMBOL = 10006;//心跳异常,连接标识符不一致
57   - private static final int OPEN_DOOR = 50001;//开门命令
58   - private static final int CLEAN_OVER = 50002;//
59   -
60   - private static final int ROOM_HAS_REGISTERED = 1001;
61   - private static final int ROOM_NOT_EXIST_M = 1002;
62   - private static final int HEAT_BEAT_RTN = 1003;
63   -
64   - // online
65   - public static final String SERVER_HOST_ONLINE = "conn.ft.qnbar.com";// "192.168.1.21";//
66   - public static final int SERVER_PORT_ONLINE = 8899;
67   -
68   - // develop
69   - public static final String SERVER_HOST_DEVELOP = "10.10.4.6";// "192.168.1.21";//
70   - public static final int SERVER_PORT_DEVELOP = 9501;
71   - // test
72   - public static final String SERVER_HOST = "10.10.4.6";// "192.168.1.21";//
73   - public static final int SERVER_PORT = 8899;
74   -
75   - private String serverHost = SERVER_HOST;
76   - private int serverPort = SERVER_PORT;
77   -
78   -
79   - public static final String END_SYMBOL = "\\r\\n\\r\\n";//心跳包内容
80   - // public String testRoomSn = "R170413034374";
81   - public String testRoomSn = "c";
82   -
83   - private ReadThread mReadThread;
84   - private HeatBeatThread mHeatBeatThread;
85   - private Gson gson;
86   -
87   -// private LocalBroadcastManager mLocalBroadcastManager;
88   -
89   - private WeakReference<Socket> mSocket;
90   -
91   - // For heart Beat
92   -// private Handler mHandler = new Handler();
93   -// private Runnable heartBeatRunnable = new Runnable() {
94   -//
95   -// @Override
96   -// public void run() {
97   -// if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
98   -// Log.d(TAG, "heart beat");
99   -// boolean isSuccess = sendMsg(new Gson().toJson(new SocketSendMsg().contractHeartBeatMsg(testRoomSn)) + END_SYMBOL);//就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket
100   -// if (!isSuccess) {
101   -// Log.d(TAG, "heart beat error restart");
102   -// mHandler.removeCallbacks(heartBeatRunnable);
103   -// mReadThread.release();
104   -// mHeatBeatThread.release();
105   -// releaseLastSocket(mSocket);
106   -// new InitSocketThread().start();
107   -// }
108   -// } else {
109   -// Log.d(TAG, "heart beat less than beat rate");
110   -// }
111   -// mHandler.postDelayed(this, HEART_BEAT_RATE);
112   -// }
113   -// };
114   -
115   - private long sendTime = 0L;
116   - private Context context;
117   -
118   - @Override
119   - public IBinder onBind(Intent arg0) {
120   - return null;
121   - }
122   -
123   - @Override
124   - public void onCreate() {
125   - super.onCreate();
126   - gson = new Gson();
127   - context = this;
128   - }
129   -
130   - @Override
131   - public int onStartCommand(Intent intent, int flags, int startId) {
132   - int ftTest = Utils.getInt(this, "ft-test", 0);
133   - switch (ftTest) {
134   - case 0:
135   - serverHost = SERVER_HOST_ONLINE;
136   - serverPort = SERVER_PORT_ONLINE;
137   - break;
138   - case 1:
139   - serverHost = SERVER_HOST_DEVELOP;
140   - serverPort = SERVER_PORT_DEVELOP;
141   - break;
142   - case 2:
143   - serverHost = SERVER_HOST;
144   - serverPort = SERVER_PORT;
145   - break;
146   - }
147   -
148   - String roomInfoStr = Utils.getString(this, "room-info");
149   - if (!TextUtils.isEmpty(roomInfoStr)) {
150   - Log.d("room-info", "room info not null");
151   - RoomInfo roomInfo = null;
152   - try {
153   - roomInfo = gson.fromJson(roomInfoStr, RoomInfo.class);
154   - Log.d("room-info", "room info room_sn update");
155   - testRoomSn = roomInfo.getData().getRoom_sn();
156   - } catch (JsonSyntaxException e) {
157   - Log.d("room-info", "room gson parse exception return");
158   - Toast.makeText(this, "房间信息配置出错,请重新进入应用获取", Toast.LENGTH_SHORT).show();
159   - e.printStackTrace();
160   - return super.onStartCommand(intent, flags, startId);
161   - }
162   - } else {
163   - Log.d("room-info", "room info not exist");
164   - Toast.makeText(this, "没有获取到房间信息,请查看后台配置", Toast.LENGTH_SHORT).show();
165   - return super.onStartCommand(intent, flags, startId);
166   - }
167   -// }
168   - new InitSocketThread().start();
169   - Log.d(TAG, "socket service onCreate");
170   - return super.onStartCommand(intent, flags, startId);
171   - }
172   -
173   - public boolean sendMsg(String msg) {
174   - if (null == mSocket || null == mSocket.get()) {
175   - return false;
176   - }
177   - Log.d(TAG, "send msg:" + msg);
178   - Socket soc = mSocket.get();
179   - try {
180   - if (!soc.isClosed() && !soc.isOutputShutdown()) {
181   - OutputStream os = soc.getOutputStream();
182   - String message = msg;
183   - os.write(message.getBytes());
184   - os.flush();
185   - sendTime = System.currentTimeMillis();//每次发送成数据,就改一下最后成功发送的时间,节省心跳间隔时间
186   - } else {
187   - return false;
188   - }
189   - } catch (IOException e) {
190   - e.printStackTrace();
191   - return false;
192   - }
193   - return true;
194   - }
195   -
196   - private void initSocket() throws IOException {//初始化Socket
197   - Log.d(TAG, "serverHost:serverPort:" + serverHost + ":" + serverPort);
198   - Socket so = new Socket(serverHost, serverPort);
199   - mSocket = new WeakReference<Socket>(so);
200   - mReadThread = new ReadThread(so);
201   - mReadThread.start();
202   -// new Thread(heartBeatRunnable).start();
203   -// mHandler.post(heartBeatRunnable);//初始化成功后,就准备发送心跳包
204   - mHeatBeatThread = new HeatBeatThread(so);
205   -// mHeatBeatThread.start();//上面的 one plus 3t NetworkOnMainThreadException!!!
206   - }
207   -
208   -
209   - private void releaseLastSocket(WeakReference<Socket> mSocket) {
210   - try {
211   - if (null != mSocket) {
212   - Socket sk = mSocket.get();
213   - if (!sk.isClosed()) {
214   - sk.close();
215   - }
216   - sk = null;
217   - mSocket = null;
218   - }
219   - } catch (IOException e) {
220   - e.printStackTrace();
221   - }
222   - }
223   -
224   - class InitSocketThread extends Thread {
225   - @Override
226   - public void run() {
227   - super.run();
228   - try {
229   - initSocket();
230   - } catch (IOException e) {
231   - e.printStackTrace();
232   - Log.d(TAG, "init socket thread error,restart again after 10's");
233   - try {
234   - Thread.sleep(HEART_BEAT_RATE);
235   - } catch (InterruptedException e1) {
236   - e1.printStackTrace();
237   - }
238   - this.run();
239   - }
240   - }
241   - }
242   -
243   - private String varifyMsg = "";
244   -
245   - // Thread to read content from Socket
246   - class ReadThread extends Thread {
247   - private WeakReference<Socket> mWeakSocket;
248   - private boolean isStart = true;
249   -
250   - public ReadThread(Socket socket) {
251   - mWeakSocket = new WeakReference<Socket>(socket);
252   - }
253   -
254   - public void release() {
255   - isStart = false;
256   - releaseLastSocket(mWeakSocket);
257   - }
258   -
259   - @Override
260   - public void run() {
261   - super.run();
262   - Socket socket = mWeakSocket.get();
263   - if (null != socket) {
264   - try {
265   - if (!sendRegister) {
266   - Log.d(TAG, "send register mes");
267   - SocketSendMsg ssm = new SocketSendMsg().contractRegisterMsg(testRoomSn);
268   - String msg = gson.toJson(ssm) + END_SYMBOL;
269   - sendMsg(msg);
270   - Log.d(TAG, "" + msg);
271   - sendRegister = true;
272   - }
273   - Log.d(TAG, "send register mes end");
274   - InputStream is = socket.getInputStream();
275   - byte[] buffer = new byte[1024 * 4];
276   - int length = 0;
277   - while (!socket.isClosed() && !socket.isInputShutdown()
278   - && isStart && ((length = is.read(buffer)) != -1)) {
279   - if (length > 0) {
280   - String message = new String(Arrays.copyOf(buffer,
281   - length)).trim();
282   - Log.d(TAG, "end:" + message.contains(END_SYMBOL) + "");
283   - Log.d(TAG, "recv msg:" + message);
284   - try {
285   - if (message.endsWith(END_SYMBOL)) {
286   - message = message.replace(END_SYMBOL, "");
287   - }
288   - SocketResponse socketResponse = gson.fromJson(message/*.substring(0, message.length() - 8)*/, SocketResponse.class);
289   - switch (socketResponse.getCode()) {
290   - case SUCCESS_MESSAGE:
291   - Log.d(TAG, "success:" + socketResponse.getCmd());
292   - if (!TextUtils.isEmpty(socketResponse.getData().getVerify())) {
293   - varifyMsg = AuthCode.getDecodeStr(socketResponse.getData().getVerify());
294   - SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, varifyMsg);
295   - String msg = gson.toJson(ssm) + END_SYMBOL;
296   - sendMsg(msg);
297   - }
298   - break;
299   - case VERIFY_SUCCESS:
300   - Log.d(TAG, "VERIFY_SUCCESS:" + socketResponse.getCmd());
301   - mHeatBeatThread.start();//上面的 one plus 3t NetworkOnMainThreadException!!!
302   - Log.d(TAG, "verify success start heart beat");
303   - break;
304   - case CONTAIN_MESSAGE:
305   - if (socketResponse.getData() != null) {
306   - if (socketResponse.getCmd() == OPEN_DOOR) {
307   -// new SystemUtils().openFtLed(context.getApplicationContext());
308   - switch (socketResponse.getData().getUser()) {
309   - //10用户,20管理员,默认值为0
310   - case 10:
311   - new SystemUtils().openFtLed(context.getApplicationContext());
312   - if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
313   - LightOperationUtils.open();
314   - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
315   - }
316   - sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when new user come in");
317   - if (socketResponse.getData().getFirst() == 1) {
318   -// LightOperationUtils.open();
319   -// LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
320   - sendMessage(USER_OPEN_DOOR_AND_GET_MOVIE, "user first open the door");
321   - } else {
322   - sendMessage(USER_OPEN_DOOR, "user open the door");
323   - }
324   - break;
325   - case 20:
326   - if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
327   - Log.d("LightOperationUtils", "admin open light");
328   - LightOperationUtils.open();
329   - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
330   - }
331   - sendMessage(JUST_OPEN_DOOR, "administrator open the door");
332   - break;
333   - case 0:
334   - sendMessage(JUST_OPEN_DOOR, "get zero none user or administrator open the door");
335   - break;
336   - default:
337   - sendMessage(JUST_OPEN_DOOR, "none user or administrator open the door");
338   - break;
339   - }
340   - } else if (socketResponse.getCmd() == CLEAN_OVER) {
341   - Log.d("LightOperationUtils", "admin clean over close light");
342   - LightOperationUtils.setLightValue(5);
343   - LightOperationUtils.close();
344   - new SystemUtils().closeFtLed(context.getApplicationContext());
345   - sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when clean over");
346   - }
347   - }
348   - break;
349   - default:
350   - Log.d(TAG, "print msg:" + socketResponse.toString());
351   - }
352   -// if (("sendMessage").equals(socketResponse.getCmd())) {
353   -// MessageEvent messageEvent = new MessageEvent();
354   -// messageEvent.setEventId(JUST_OPEN_DOOR);
355   -// messageEvent.setMessage("click item");
356   -// EventBus.getDefault().post(messageEvent);
357   -// }
358   - } catch (JsonSyntaxException e) {
359   - Log.d(TAG, message);
360   - e.printStackTrace();
361   - }
362   - //收到服务器过来的消息,就通过Broadcast发送出去
363   -// if (message.equals(END_SYMBOL)) {//处理心跳回复
364   -// Intent intent = new Intent(HEART_BEAT_ACTION);
365   -// mLocalBroadcastManager.sendBroadcast(intent);
366   -// } else {
367   -// //其他消息回复
368   -// Intent intent = new Intent(MESSAGE_ACTION);
369   -// intent.putExtra("message", message);
370   -// mLocalBroadcastManager.sendBroadcast(intent);
371   -// }
372   - }
373   - }
374   - } catch (IOException e) {
375   - e.printStackTrace();
376   - }
377   - }
378   - }
379   - }
380   -
381   - private void sendMessage(int type, String msg) {
382   - MessageEvent messageEvent = new MessageEvent();
383   - messageEvent.setEventId(type);
384   - messageEvent.setMessage(msg);
385   - EventBus.getDefault().post(messageEvent);
386   - }
387   -
388   - boolean sendRegister = false;
389   -
390   -
391   - // Thread to read content from Socket
392   - class HeatBeatThread extends Thread {
393   - private WeakReference<Socket> mWeakSocket;
394   - private boolean isStart = true;
395   -
396   - public HeatBeatThread(Socket socket) {
397   - mWeakSocket = new WeakReference<Socket>(socket);
398   - }
399   -
400   - public void release() {
401   - isStart = false;
402   - releaseLastSocket(mWeakSocket);
403   - }
404   -
405   - @Override
406   - public void run() {
407   - super.run();
408   - Socket socket = mWeakSocket.get();
409   - if (null != socket) {
410   - while (isStart) {
411   - if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
412   - Log.d(TAG, "heart beat:" + Thread.currentThread().getId());
413   - boolean isSuccess = sendMsg(new Gson().toJson(new SocketSendMsg().contractHeartBeatMsg(testRoomSn)) + END_SYMBOL);//就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket
414   - if (!isSuccess) {
415   - Log.d(TAG, "heart beat error restart:" + Thread.currentThread().getId());
416   -// mHandler.removeCallbacks(heartBeatRunnable);
417   - mReadThread.release();
418   - mHeatBeatThread.release();
419   - sendRegister = false;
420   - releaseLastSocket(mSocket);
421   - new InitSocketThread().start();
422   - }
423   - } else {
424   - Log.d(TAG, "heart beat less than beat rate:" + Thread.currentThread().getId());
425   - }
426   - try {
427   - Thread.sleep(HEART_BEAT_RATE);
428   - } catch (InterruptedException e) {
429   - e.printStackTrace();
430   - }
431   - }
432   - }
433   - }
434   - }
435   -
436   - @Override
437   - public void onDestroy() {
438   - Log.d(TAG, "socket service destroy");
439   - super.onDestroy();
440   - }
441   -}
\ No newline at end of file
1 1 package com.qnbar.smc.service;
2 2
  3 +import android.content.ComponentName;
3 4 import android.content.Context;
4 5 import android.content.Intent;
  6 +import android.content.ServiceConnection;
  7 +import android.media.AudioManager;
5 8 import android.os.Handler;
6 9 import android.os.IBinder;
  10 +import android.os.RemoteException;
7 11 import android.text.TextUtils;
8 12 import android.util.Log;
9 13 import android.widget.Toast;
... ... @@ -13,17 +17,30 @@ import com.gimi.common.cinema.utils.ActivityCollector;
13 17 import com.gimi.common.cinema.utils.CToast;
14 18 import com.gimi.common.cinema.utils.LogUtils;
15 19 import com.gimi.common.cinema.utils.NetStatusUtils;
  20 +import com.gimi.common.cinema.utils.ShellUtils;
16 21 import com.gimi.common.cinema.utils.SystemUtils;
17 22 import com.gimi.common.cinema.utils.Utils;
18 23 import com.google.gson.Gson;
19 24 import com.google.gson.JsonSyntaxException;
  25 +import com.qnbar.smc.model.Lights;
  26 +import com.qnbar.smc.socketProtocol.MainRequest;
  27 +import com.qnbar.smc.socketProtocol.MainResponse;
  28 +import com.qnbar.smc.socketProtocol.fromServer.EquipmentControl;
  29 +import com.qnbar.smc.socketProtocol.fromServer.OpenDoor;
  30 +import com.qnbar.smc.socketProtocol.fromServer.ReportEquStatus;
  31 +import com.qnbar.smc.socketProtocol.fromServer.VerifyCode;
  32 +import com.qnbar.smc.socketProtocol.toServer.EquipmentStatus;
  33 +import com.qnbar.smc.socketProtocol.toServer.SocketSendMsg;
20 34 import com.qnbar.smc.utils.LightOperationUtils;
  35 +import com.telink.bluetooth.light.ConnectionStatus;
  36 +import com.xgimi.gimicinema.ICinemaControl;
21 37 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
22 38 import com.xgimi.gimicinema.activity.MainActivity;
23 39 import com.xgimi.gimicinema.activity.QrCodeShowActivity;
24 40 import com.xgimi.gimicinema.activity.SimpleAdsPlayer2;
25 41 import com.xgimi.gimicinema.application.FangTangApplication;
26 42 import com.xgimi.gimicinema.poll.PollingUtils;
  43 +import com.xgimi.gimicinema.service.CinemaControlService;
27 44 import com.xgimi.gimicinema.service.CountService;
28 45 import com.xgimi.smartscreen.encrypt.AuthCode;
29 46 import org.greenrobot.eventbus.EventBus;
... ... @@ -34,17 +51,18 @@ import java.io.InterruptedIOException;
34 51 import java.io.OutputStream;
35 52 import java.net.Socket;
36 53 import java.util.Arrays;
  54 +import java.util.Timer;
  55 +import java.util.TimerTask;
37 56 import java.util.concurrent.atomic.AtomicBoolean;
38 57 import java.util.concurrent.atomic.AtomicInteger;
39 58
40   -import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR;
41   -import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR;
42   -import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR_AND_GET_MOVIE;
43   -
44 59 public class SocketService1 extends BaseService {
45 60 private static final String TAG = "BackService1";
46 61 private static final long HEART_BEAT_RATE = 2 * 1000;
47 62 private final long READ_THREAD_DEFAULT_SLEEP_MTIME = 100;
  63 + public static final int JUST_OPEN_DOOR = 1701;
  64 + public static final int USER_OPEN_DOOR_AND_GET_MOVIE = 1703;
  65 + public static final int USER_OPEN_DOOR = 1704;
48 66
49 67 // public static final int USER_OPEN_DOOR_AND_GET_MOVIE = 1703;
50 68 /*
... ... @@ -75,7 +93,10 @@ public class SocketService1 extends BaseService {
75 93 private static final int ROOM_SN_CONNECTED = 10010;//room_sn 已连接,不能再连接
76 94 private static final int OPEN_DOOR = 50001;//开门命令
77 95 private static final int CLEAN_OVER = 50002;//
  96 + private static final int REPORT_EQU_STATUS = 50003;//返回设备状态信息
  97 + private static final int SET_EQU_STATUS = 50004;//返回设备状态信息
78 98
  99 + private static final int CMD_REPORT_EQU_STATUS = 20030;//上报设备状态信息
79 100 private static final int ROOM_HAS_REGISTERED = 1001;
80 101 private static final int ROOM_NOT_EXIST_M = 1002;
81 102 private static final int HEAT_BEAT_RTN = 1003;
... ... @@ -112,6 +133,8 @@ public class SocketService1 extends BaseService {
112 133 AtomicBoolean sendRegister = new AtomicBoolean(false);
113 134 AtomicInteger heartBeatErrorCount = new AtomicInteger(0);
114 135
  136 + ICinemaControl iPlayer;
  137 +
115 138 private Runnable heartBeatRunnable = new Runnable() {
116 139 @Override
117 140 public void run() {
... ... @@ -151,6 +174,8 @@ public class SocketService1 extends BaseService {
151 174 public void onCreate() {
152 175 super.onCreate();
153 176 LogUtils.i(TAG, "onCreate");
  177 + bindService(new Intent(SocketService1.this, CinemaControlService.class), conn, Context.BIND_AUTO_CREATE);
  178 + startService(new Intent(SocketService1.this, CinemaControlService.class));
154 179 }
155 180
156 181 @Override
... ... @@ -158,6 +183,7 @@ public class SocketService1 extends BaseService {
158 183 super.onStartCommand(intent, flags, startId);
159 184 LogUtils.i(TAG, "onStartCommand");
160 185 int ftTest = Utils.getInt(this, "ft-test", 0);
  186 + Log.d("Host", ""+ftTest);
161 187 switch (ftTest) {
162 188 case 0:
163 189 serverHost = SERVER_HOST_ONLINE;
... ... @@ -359,10 +385,9 @@ public class SocketService1 extends BaseService {
359 385 sleepTime = READ_THREAD_DEFAULT_SLEEP_MTIME;
360 386
361 387 LogUtils.d(TAG, "recv msg:" + message);
362   - SocketResponse socketResponse;
  388 + MainResponse socketResponse;
363 389 try {
364   - socketResponse = gson.fromJson(message.toString(),
365   - SocketResponse.class);
  390 + socketResponse = gson.fromJson(message.toString(), MainResponse.class);
366 391 if (socketResponse.getCode() != HEART_BEAT_SUCCESS) {
367 392 LogUtils.i(TAG, "recv msg:" + message);
368 393 }
... ... @@ -372,6 +397,7 @@ public class SocketService1 extends BaseService {
372 397 clearConnect();
373 398 break;
374 399 }
  400 +
375 401 switch (socketResponse.getCode()) {
376 402 case SUCCESS_MESSAGE:
377 403 heartBeatErrorCount.set(0);
... ... @@ -404,72 +430,20 @@ public class SocketService1 extends BaseService {
404 430 break;
405 431 case RETURN_VERIFY_CODE:
406 432 LogUtils.i(TAG, "RETURN_VERIFY_CODE");
407   - if (!TextUtils.isEmpty(socketResponse.getData().getVerify())) {
408   - String verifyMsg = AuthCode.getDecodeStr(socketResponse.getData().getVerify());
409   - SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg);
410   - String msg = gson.toJson(ssm) + END_SYMBOL;
411   - sendMsg(msg);
  433 + if (!TextUtils.isEmpty(socketResponse.getData())) {
  434 + VerifyCode verifyResponse = gson.fromJson(socketResponse.getData(), VerifyCode.class);
  435 + if(!TextUtils.isEmpty(verifyResponse.getVerify())){
  436 + String verifyMsg = AuthCode.getDecodeStr(verifyResponse.getVerify());
  437 + SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg);
  438 + String msg = gson.toJson(ssm) + END_SYMBOL;
  439 + sendMsg(msg);
  440 + }
412 441 }
413 442 break;
414 443 case CONTAIN_MESSAGE:
415 444 heartBeatErrorCount.set(0);
416 445 LogUtils.i(TAG, "CONTAIN_MESSAGE");
417   - if (socketResponse.getData() != null) {
418   - if (socketResponse.getCmd() == OPEN_DOOR) {
419   - switch (socketResponse.getData().getUser()) {
420   - //10用户,20管理员,默认值为0
421   - case 10:
422   - new SystemUtils().openFtLed(context.getApplicationContext());
423   - if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
424   - LightOperationUtils.open();
425   - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
426   - }
427   - sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when new user come in");
428   - if (socketResponse.getData().getFirst() == 1) {
429   - sendMessage(USER_OPEN_DOOR_AND_GET_MOVIE, "user first open the door");
430   - } else {
431   - sendMessage(USER_OPEN_DOOR, "user open the door");
432   - }
433   - break;
434   - case 20:
435   - LogUtils.i(TAG, "admin open the door,del the log");
436   - LogUtils.delLog();
437   - if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
438   - LogUtils.i("LightOperationUtils", "admin open light");
439   - LightOperationUtils.open();
440   - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
441   - }
442   - sendMessage(JUST_OPEN_DOOR, "administrator open the door");
443   - break;
444   - case 0:
445   - sendMessage(JUST_OPEN_DOOR, "get zero none user or administrator open the door");
446   - break;
447   - default:
448   - sendMessage(JUST_OPEN_DOOR, "none user or administrator open the door");
449   - break;
450   - }
451   - } else if (socketResponse.getCmd() == CLEAN_OVER) {
452   - LogUtils.i("LightOperationUtils", "admin clean over close light");
453   - LightOperationUtils.setLightValue(5);
454   - LightOperationUtils.close();
455   - new SystemUtils().closeFtLed(context.getApplicationContext());
456   - sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when clean over");
457   - if (ActivityCollector.isActivityExist(SimpleAdsPlayer2.class)) {
458   - ActivityCollector.getActivity(SimpleAdsPlayer2.class).finish();
459   - }
460   - if (ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class)) {
461   - ActivityCollector.getActivity(AdsPreVideoPlayerActivity.class).finish();
462   - }
463   - if (ActivityCollector.isActivityExist(QrCodeShowActivity.class)) {
464   - ActivityCollector.getActivity(QrCodeShowActivity.class).finish();
465   - }
466   - try {
467   - PollingUtils.stopPollingService(context, CountService.class, CountService.STATUS_ACTION);
468   - } catch (Exception e) {
469   - e.printStackTrace();
470   - }
471   - }
472   - }
  446 + serverCommandDeal(socketResponse);
473 447 break;
474 448 default:
475 449 clearConnect();
... ... @@ -497,4 +471,250 @@ public class SocketService1 extends BaseService {
497 471 LogUtils.i(TAG, "socket service destroy");
498 472 super.onDestroy();
499 473 }
  474 +
  475 + /**
  476 + * 处理服务器发送的命令
  477 + * @param socketResponse
  478 + */
  479 + private void serverCommandDeal(MainResponse socketResponse) {
  480 + switch (socketResponse.getCmd())
  481 + {
  482 + case OPEN_DOOR://开门
  483 + if (socketResponse.getData() != null) {
  484 + OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class);
  485 + openDoor(openDoorResponse);
  486 + }
  487 + break;
  488 + case CLEAN_OVER://清洁完成处理
  489 + LogUtils.i("LightOperationUtils", "admin clean over close light");
  490 + LightOperationUtils.setLightValue(5);
  491 + LightOperationUtils.close();
  492 + new SystemUtils().closeFtLed(context.getApplicationContext());
  493 + sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when clean over");
  494 + if (ActivityCollector.isActivityExist(SimpleAdsPlayer2.class)) {
  495 + ActivityCollector.getActivity(SimpleAdsPlayer2.class).finish();
  496 + }
  497 + if (ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class)) {
  498 + ActivityCollector.getActivity(AdsPreVideoPlayerActivity.class).finish();
  499 + }
  500 + if (ActivityCollector.isActivityExist(QrCodeShowActivity.class)) {
  501 + ActivityCollector.getActivity(QrCodeShowActivity.class).finish();
  502 + }
  503 + try {
  504 + PollingUtils.stopPollingService(context, CountService.class, CountService.STATUS_ACTION);
  505 + } catch (Exception e) {
  506 + e.printStackTrace();
  507 + }
  508 + break;
  509 +
  510 + case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态
  511 + long time1 = System.currentTimeMillis();
  512 + Log.d("ReportInfo","收到上报命令");
  513 + //获取serverId
  514 + ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class);
  515 +// String serverId = rps.getServerId();
  516 + reportEquStatus(rps.getServerId(),0);
  517 + break;
  518 +
  519 + case SET_EQU_STATUS://设置声音,灯光,播放暂停
  520 + Log.d("ReportInfo","收到控制命令:"+socketResponse.getData());
  521 + EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class);
  522 + setEquipmentStatus(equc);
  523 + break;
  524 + }
  525 + }
  526 +
  527 + /*--命令处理-start-----------------------------------*/
  528 +
  529 + private void openDoor(OpenDoor openDoorResponse) {
  530 + switch (openDoorResponse.getUser()) {
  531 + //10用户,20管理员,默认值为0
  532 + case 10:
  533 + new SystemUtils().openFtLed(context.getApplicationContext());
  534 + if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
  535 + LightOperationUtils.open();
  536 + LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
  537 + }
  538 + sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when new user come in");
  539 + if (openDoorResponse.getFirst() == 1) {
  540 + sendMessage(USER_OPEN_DOOR_AND_GET_MOVIE, "user first open the door");
  541 + } else {
  542 + sendMessage(USER_OPEN_DOOR, "user open the door");
  543 + }
  544 + break;
  545 + case 20:
  546 + LogUtils.i(TAG, "admin open the door,del the log");
  547 + LogUtils.delLog();
  548 + if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
  549 + LogUtils.i("LightOperationUtils", "admin open light");
  550 + LightOperationUtils.open();
  551 + LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
  552 + }
  553 + sendMessage(JUST_OPEN_DOOR, "administrator open the door");
  554 + break;
  555 + case 0:
  556 + sendMessage(JUST_OPEN_DOOR, "get zero none user or administrator open the door");
  557 + break;
  558 + default:
  559 + sendMessage(JUST_OPEN_DOOR, "none user or administrator open the door");
  560 + break;
  561 + }
  562 + }
  563 +
  564 + private void reportEquStatus(String serverId,int lightSet) {
  565 + //填充返回数据
  566 + int volume = getAudioVolume()/6 + 1;
  567 + int lightStatus = 2;
  568 + int playStatus = 0;
  569 +
  570 + try {
  571 + playStatus = iPlayer.getCurrentStatus();
  572 + Log.d("ReportInfo","playStatus:"+playStatus);
  573 + } catch (RemoteException e) {
  574 + e.printStackTrace();
  575 + }
  576 +
  577 + if (lightSet == 1 || lightSet == 2) {
  578 + lightStatus = lightSet;
  579 + } else {
  580 + ConnectionStatus stu = Lights.getInstance().getByMeshAddress(((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status;
  581 + if( Lights.getInstance().getByMeshAddress(
  582 + ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status == ConnectionStatus.ON ) {
  583 + Log.d("ReportInfo","lightStatus==1");
  584 + lightStatus = 1;
  585 + } else {
  586 + Log.d("ReportInfo", "lightStatus:"+stu);
  587 + }
  588 + }
  589 +
  590 + EquipmentStatus equStatus = new EquipmentStatus();
  591 + equStatus.setLightStatus(lightStatus);
  592 + equStatus.setPlayStatus(playStatus);
  593 + equStatus.setVolume(volume);
  594 + equStatus.setServerId(serverId);
  595 + equStatus.setRoom_sn(testRoomSn);
  596 +
  597 + MainRequest rep = new MainRequest();
  598 + rep.setCmd(CMD_REPORT_EQU_STATUS);
  599 + rep.setData(equStatus);
  600 + String msg = gson.toJson(rep) + END_SYMBOL;
  601 + sendMsg(msg);
  602 + Log.d("ReportInfo",msg);
  603 + }
  604 +
  605 + private void setLight(int op) {
  606 + if (op == 1){//打开灯光
  607 + Log.d("setEqu","打开灯光");
  608 + LightOperationUtils.open();
  609 + LightOperationUtils.setLightValue(5);
  610 +
  611 + //延时增亮
  612 + Timer timer=new Timer();//实例化Timer类
  613 + timer.schedule(new TimerTask(){
  614 + public void run(){
  615 + LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
  616 + this.cancel();}},2000);//毫秒
  617 + } else if(op == 2) {//关闭灯光
  618 + Log.d("setEqu","关闭灯光");
  619 + LightOperationUtils.setLightValue(5);
  620 +
  621 + //延时关闭
  622 + Timer timer=new Timer();//实例化Timer类
  623 + timer.schedule(new TimerTask(){
  624 + public void run(){
  625 + LightOperationUtils.close();
  626 + this.cancel();}},2000);//毫秒
  627 + }
  628 + }
  629 +
  630 + private void playCtl(int op) {
  631 + int status = -1;
  632 + try {
  633 + status = iPlayer.getCurrentStatus();
  634 + } catch (RemoteException e) {
  635 + e.printStackTrace();
  636 + }
  637 +
  638 + if (op == 1 && status == 2)
  639 + {
  640 + Log.d("setEqu","开始播放");
  641 + ShellUtils.execCommand("input keyevent 23", false);
  642 + }
  643 + else if (op == 2 && status == 1)
  644 + {
  645 + Log.d("setEqu","暂停播放");
  646 + ShellUtils.execCommand("input keyevent 23", false);
  647 + }
  648 + }
  649 +
  650 + private void setEquipmentStatus(EquipmentControl equc) {
  651 + setLight(equc.getLightCtl());
  652 +
  653 + playCtl(equc.getPlayCtl());
  654 +
  655 + setAudioVolume(equc.getAudioCtl());
  656 +
  657 + if (equc.getLightCtl() != 0){
  658 + try {
  659 + Thread.sleep(500);
  660 + } catch (InterruptedException e) {
  661 + e.printStackTrace();
  662 + }
  663 + }
  664 +
  665 + reportEquStatus(equc.getServerId(),equc.getLightCtl());
  666 + }
  667 +
  668 +/*--命令处理-end-----------------------------------*/
  669 +
  670 + private int getAudioVolume() {
  671 + AudioManager mAudioManager;
  672 + mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  673 + return mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );
  674 + }
  675 +
  676 + private int setAudioVolume(int volume) {
  677 + AudioManager mAudioManager;
  678 + mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  679 + int now = getAudioVolume()/6;
  680 +
  681 + if (volume == 0) {
  682 + return now;
  683 + } else {
  684 + volume--;
  685 + }
  686 +
  687 + if (volume > now) {//加音量
  688 + Log.d("setEqu","加音量"+now+":"+volume);
  689 + while(now < volume) {
  690 + mAudioManager.adjustStreamVolume(
  691 + AudioManager.STREAM_MUSIC,
  692 + AudioManager.ADJUST_RAISE,
  693 + AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
  694 + now ++;
  695 + }
  696 + } else if(volume < now) {//减音量
  697 + Log.d("setEqu","减音量"+now+":"+volume);
  698 + while(now > volume) {
  699 + mAudioManager.adjustStreamVolume(
  700 + AudioManager.STREAM_MUSIC,
  701 + AudioManager.ADJUST_LOWER,
  702 + AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
  703 + now --;
  704 + }
  705 + }
  706 +
  707 + return now;
  708 + }
  709 +
  710 + private ServiceConnection conn = new ServiceConnection() {
  711 + public void onServiceConnected(ComponentName className, IBinder service) {
  712 + Log.d("yao", "ServiceConnection -> onServiceConnected");
  713 + iPlayer = ICinemaControl.Stub.asInterface(service);
  714 + }
  715 +
  716 + public void onServiceDisconnected(ComponentName className) {
  717 + };
  718 + };
  719 +
500 720 }
\ No newline at end of file
... ...
  1 +package com.qnbar.smc.socketProtocol;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public abstract class DataInfo {}
... ...
  1 +package com.qnbar.smc.socketProtocol;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public class MainRequest {
  8 + private int cmd;
  9 + private DataInfo data;
  10 +
  11 + public int getCmd() {
  12 + return cmd;
  13 + }
  14 +
  15 + public void setCmd(int cmd) {
  16 + this.cmd = cmd;
  17 + }
  18 +
  19 + public DataInfo getData() {
  20 + return data;
  21 + }
  22 +
  23 + public void setData(DataInfo data) {
  24 + this.data = data;
  25 + }
  26 +
  27 + @Override
  28 + public String toString() {
  29 + return "MainRequest{" +
  30 + "cmd=" + cmd +
  31 + ", data=" + data +
  32 + '}';
  33 + }
  34 +}
... ...
1   -package com.qnbar.smc.service;
  1 +package com.qnbar.smc.socketProtocol;
2 2
3 3 /**
4   - * Created by wugian on 2017/3/11.
  4 + * Created by jinyan.yi on 2017/5/23.
5 5 */
6 6
7   -public class SocketResponse {
8   - /**
9   - * code : 10007
10   - * msg : unknown command!
11   - * data : {"verify":"","user":0,"first":0}
12   - * cmd : 10000
13   - */
14   -
  7 +public class MainResponse {
15 8 private int code;
16 9 private String msg;
17   - private DataEntity data;
  10 + private String data;
18 11 private int cmd;
19 12
20 13 public int getCode() {
... ... @@ -33,11 +26,11 @@ public class SocketResponse {
33 26 this.msg = msg;
34 27 }
35 28
36   - public DataEntity getData() {
  29 + public String getData() {
37 30 return data;
38 31 }
39 32
40   - public void setData(DataEntity data) {
  33 + public void setData(String data) {
41 34 this.data = data;
42 35 }
43 36
... ... @@ -49,57 +42,12 @@ public class SocketResponse {
49 42 this.cmd = cmd;
50 43 }
51 44
52   - public static class DataEntity {
53   - /**
54   - * verify :
55   - * user : 0
56   - * first : 0
57   - */
58   -
59   - private String verify;
60   - private int user;
61   - private int first;
62   -
63   - public String getVerify() {
64   - return verify;
65   - }
66   -
67   - public void setVerify(String verify) {
68   - this.verify = verify;
69   - }
70   -
71   - public int getUser() {
72   - return user;
73   - }
74   -
75   - public void setUser(int user) {
76   - this.user = user;
77   - }
78   -
79   - public int getFirst() {
80   - return first;
81   - }
82   -
83   - public void setFirst(int first) {
84   - this.first = first;
85   - }
86   -
87   - @Override
88   - public String toString() {
89   - return "DataEntity{" +
90   - "verify='" + verify + '\'' +
91   - ", user=" + user +
92   - ", first=" + first +
93   - '}';
94   - }
95   - }
96   -
97 45 @Override
98 46 public String toString() {
99   - return "SocketResponse{" +
  47 + return "MainResponse{" +
100 48 "code=" + code +
101 49 ", msg='" + msg + '\'' +
102   - ", data=" + data +
  50 + ", data='" + data + '\'' +
103 51 ", cmd=" + cmd +
104 52 '}';
105 53 }
... ...
  1 +package com.qnbar.smc.socketProtocol.fromServer;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public class EquipmentControl {
  8 + private int audioCtl;
  9 + private int playCtl;
  10 + private int lightCtl;
  11 + private String serverId;
  12 +
  13 + public int getAudioCtl() {
  14 + return audioCtl;
  15 + }
  16 +
  17 + public void setAudioCtl(int audioCtl) {
  18 + this.audioCtl = audioCtl;
  19 + }
  20 +
  21 + public int getPlayCtl() {
  22 + return playCtl;
  23 + }
  24 +
  25 + public void setPlayCtl(int playCtl) {
  26 + this.playCtl = playCtl;
  27 + }
  28 +
  29 + public int getLightCtl() {
  30 + return lightCtl;
  31 + }
  32 +
  33 + public void setLightCtl(int lightCtl) {
  34 + this.lightCtl = lightCtl;
  35 + }
  36 +
  37 + public String getServerId() {
  38 + return serverId;
  39 + }
  40 +
  41 + public void setServerId(String serverId) {
  42 + this.serverId = serverId;
  43 + }
  44 +
  45 + @Override
  46 + public String toString() {
  47 + return "EquipmentControl{" +
  48 + "audioCtl=" + audioCtl +
  49 + ", playCtl=" + playCtl +
  50 + ", lightCtl=" + lightCtl +
  51 + ", serverId='" + serverId + '\'' +
  52 + '}';
  53 + }
  54 +}
... ...
  1 +package com.qnbar.smc.socketProtocol.fromServer;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public class OpenDoor {
  8 + private String verify;
  9 + private int user;
  10 + private int first;
  11 +
  12 + public String getVerify() {
  13 + return verify;
  14 + }
  15 +
  16 + public void setVerify(String verify) {
  17 + this.verify = verify;
  18 + }
  19 +
  20 + public int getUser() {
  21 + return user;
  22 + }
  23 +
  24 + public void setUser(int user) {
  25 + this.user = user;
  26 + }
  27 +
  28 + public int getFirst() {
  29 + return first;
  30 + }
  31 +
  32 + public void setFirst(int first) {
  33 + this.first = first;
  34 + }
  35 +
  36 + @Override
  37 + public String toString() {
  38 + return "OpenDoor{" +
  39 + "verify='" + verify + '\'' +
  40 + ", user=" + user +
  41 + ", first=" + first +
  42 + '}';
  43 + }
  44 +}
... ...
  1 +package com.qnbar.smc.socketProtocol.fromServer;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public class ReportEquStatus {
  8 + private String serverId;
  9 +
  10 + public String getServerId() {
  11 + return serverId;
  12 + }
  13 +
  14 + public void setServerId(String serverId) {
  15 + this.serverId = serverId;
  16 + }
  17 +}
... ...
  1 +package com.qnbar.smc.socketProtocol.fromServer;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/6/2.
  5 + */
  6 +
  7 +public class VerifyCode {
  8 + private String verify;
  9 +
  10 + public String getVerify() {
  11 + return verify;
  12 + }
  13 +
  14 + public void setVerify(String verify) {
  15 + this.verify = verify;
  16 + }
  17 +
  18 + @Override
  19 + public String toString() {
  20 + return "VerifyCode{" +
  21 + "verify='" + verify + '\'' +
  22 + '}';
  23 + }
  24 +}
... ...
  1 +package com.qnbar.smc.socketProtocol.toServer;
  2 +
  3 +import com.qnbar.smc.socketProtocol.DataInfo;
  4 +
  5 +/**
  6 + * Created by jinyan.yi on 2017/5/23.
  7 + */
  8 +
  9 +public class EquipmentStatus extends DataInfo {
  10 + private int volume;
  11 + private int lightStatus;
  12 + private int playStatus;
  13 + private String serverId;
  14 + private String room_sn;
  15 +
  16 + public int getVolume() {
  17 + return volume;
  18 + }
  19 +
  20 + public void setVolume(int volume) {
  21 + this.volume = volume;
  22 + }
  23 +
  24 + public int getLightStatus() {
  25 + return lightStatus;
  26 + }
  27 +
  28 + public void setLightStatus(int lightStatus) {
  29 + this.lightStatus = lightStatus;
  30 + }
  31 +
  32 + public int getPlayStatus() {
  33 + return playStatus;
  34 + }
  35 +
  36 + public void setPlayStatus(int playStatus) {
  37 + this.playStatus = playStatus;
  38 + }
  39 +
  40 + public String getServerId() {
  41 + return serverId;
  42 + }
  43 +
  44 + public void setServerId(String serverId) {
  45 + this.serverId = serverId;
  46 + }
  47 +
  48 + public String getRoom_sn() {
  49 + return room_sn;
  50 + }
  51 +
  52 + public void setRoom_sn(String room_sn) {
  53 + this.room_sn = room_sn;
  54 + }
  55 +
  56 + @Override
  57 + public String toString() {
  58 + return "EquipmentStatus{" +
  59 + "volume=" + volume +
  60 + ", lightStatus=" + lightStatus +
  61 + ", playStatus=" + playStatus +
  62 + ", serverId='" + serverId + '\'' +
  63 + ", room_sn='" + room_sn + '\'' +
  64 + '}';
  65 + }
  66 +}
... ...
1   -package com.qnbar.smc.service;
  1 +package com.qnbar.smc.socketProtocol.toServer;
2 2
3 3 /**
4 4 * Created by wugian on 2017/3/29
... ...
  1 +package com.qnbar.smc.soketProtocol;
  2 +
  3 +/**
  4 + * Created by jinyan.yi on 2017/5/23.
  5 + */
  6 +
  7 +public abstract class DataInfo {}
... ...
... ... @@ -24,7 +24,7 @@ import com.gimi.common.cinema.model.MessageEvent;
24 24 import com.gimi.common.cinema.model.SambaMsg;
25 25 import com.gimi.common.cinema.utils.T;
26 26 import com.gimi.common.cinema.utils.WifiApManger;
27   -import com.qnbar.smc.service.SocketService;
  27 +import com.qnbar.smc.service.SocketService1;
28 28 import com.xgimi.gimicinema.BuildConfig;
29 29 import com.xgimi.gimicinema.R;
30 30 import com.xgimi.gimicinema.mview.ISettingView;
... ... @@ -336,7 +336,7 @@ public class SettingActivity extends BaseActivity implements ISettingView {
336 336 }
337 337
338 338 public void testOpenDoor(View view) {
339   - openDoor(SocketService.JUST_OPEN_DOOR, "setting test open door");
  339 + openDoor(SocketService1.JUST_OPEN_DOOR, "setting test open door");
340 340 // PollingUtils.stopPollingService(this.getApplicationContext(), PollingServiceDemo.class, PollingService.ACTION);
341 341 // new SystemUtils().closeFtLed(this);;//test close led,could open by power
342 342 }
... ...
... ... @@ -48,7 +48,7 @@ public class CinemaControlService extends Service {
48 48 private int currentState = 0;
49 49 private String currentPath = null;
50 50 // private static final int SAVE_BEAT = 500;
51   - private static final int SAVE_BEAT = 100;//default 500
  51 + private static final int SAVE_BEAT = 5;//default 50
52 52 private int saveBeat = SAVE_BEAT;
53 53
54 54 private final ICinemaControl.Stub cinemaControl = new ICinemaControl.Stub() {
... ... @@ -73,10 +73,10 @@ public class CinemaControlService extends Service {
73 73 public void setCurrentMoviePosition(long duration) throws RemoteException {
74 74 // Log.d("aidl", "setCurrentMoviePosition: " + duration);
75 75 currentPosition = duration;
76   - if (saveBeat-- <= 0) {
  76 + if (saveBeat-- == 0) {
77 77 //TODO 保存当前进度,需要时从保存位置开始播放,取消播放器播放记录功能
78 78 // 播放一段时间确保状态为关闭
79   - saveBeat = SAVE_BEAT;
  79 +// saveBeat = SAVE_BEAT;
80 80 try {
81 81 if (!fadeOuting && Lights.getInstance().getByMeshAddress(
82 82 ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status
... ... @@ -129,7 +129,7 @@ public class CinemaControlService extends Service {
129 129 // EventBus.getDefault().post(msgEvent);
130 130 break;
131 131 case 2://暂停
132   - fadeIn();
  132 +// fadeIn();
133 133 // msgEvent.setEventId(0x19910);
134 134 // msgEvent.setMessage("open_switch");
135 135 // EventBus.getDefault().post(msgEvent);
... ...
Please register or login to post a comment