Commit deaab96f94435b9f5945fb0eb6cf9b5442fd3b16

Authored by 李攀
1 parent 5a9cdccd

prmote ,next film,format

@@ -41,6 +41,7 @@ public interface SmartControlContract { @@ -41,6 +41,7 @@ public interface SmartControlContract {
41 41
42 void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo); 42 void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo);
43 43
  44 + //重置下场及重置初始化获取订单信息
44 void updateInitGetOrderInfo(boolean b); 45 void updateInitGetOrderInfo(boolean b);
45 46
46 void setOpenDoorTime(int i); 47 void setOpenDoorTime(int i);
@@ -220,7 +220,7 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -220,7 +220,7 @@ public class SmartControlService extends BaseService implements EventListener<St
220 220
221 @Override 221 @Override
222 public void writeFailure(String error) { 222 public void writeFailure(String error) {
223 - LogUtils.i("room-info", "open failure," + error.toString()); 223 + LogUtils.i("room-info", "open failure," + error);
224 bleBroadcastReceiver.setResponseObj(null); 224 bleBroadcastReceiver.setResponseObj(null);
225 Toast.makeText(SmartControlService.this, "开门失败," + error, Toast.LENGTH_SHORT).show(); 225 Toast.makeText(SmartControlService.this, "开门失败," + error, Toast.LENGTH_SHORT).show();
226 } 226 }
@@ -335,18 +335,18 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -335,18 +335,18 @@ public class SmartControlService extends BaseService implements EventListener<St
335 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 335 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
336 startActivity(intent); 336 startActivity(intent);
337 roomStatusInfo = null; 337 roomStatusInfo = null;
338 - if (roomStatusInfo != null && roomStatusInfo.getData() != null & roomInfo != null && roomInfo.getData() != null) {  
339 - if (System.currentTimeMillis() - lastRequest > 3000) {  
340 - lastRequest = System.currentTimeMillis();  
341 - countMsg = messageEvent.getMessage();  
342 - presenter.getCleanQrCode(roomStatusInfo.getData().getOrder_sn(), roomInfo.getData().getRoom_sn());  
343 - }  
344 - } else {  
345 - String msg = "roomStatusInfo is Null:" + (roomStatusInfo == null) +  
346 - ",roomInfo is Null:" + (roomInfo == null);  
347 - Log.d("room-info", msg);  
348 - Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();  
349 - } 338 +// if (roomStatusInfo != null && roomStatusInfo.getData() != null & roomInfo != null && roomInfo.getData() != null) {
  339 +// if (System.currentTimeMillis() - lastRequest > 3000) {
  340 +// lastRequest = System.currentTimeMillis();
  341 +// countMsg = messageEvent.getMessage();
  342 +// presenter.getCleanQrCode(roomStatusInfo.getData().getOrder_sn(), roomInfo.getData().getRoom_sn());
  343 +// }
  344 +// } else {
  345 +// String msg = "roomStatusInfo is Null:" + (roomStatusInfo == null) +
  346 +// ",roomInfo is Null:" + (roomInfo == null);
  347 +// Log.d("room-info", msg);
  348 +// Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
  349 +// }
350 break; 350 break;
351 case ORDER_PLAY_COMPLETE: 351 case ORDER_PLAY_COMPLETE:
352 if (roomStatusInfo != null && roomStatusInfo.getData() != null & roomInfo != null && roomInfo.getData() != null) { 352 if (roomStatusInfo != null && roomStatusInfo.getData() != null & roomInfo != null && roomInfo.getData() != null) {
@@ -617,6 +617,9 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -617,6 +617,9 @@ public class SmartControlService extends BaseService implements EventListener<St
617 CToast.makeText(this, "没有找到电影信息,请联系客服", 90 * 1000).show(); 617 CToast.makeText(this, "没有找到电影信息,请联系客服", 90 * 1000).show();
618 } 618 }
619 } 619 }
  620 + if (nextNeedReport) {
  621 + mHandler.postDelayed(reportRunnable, 2 * 1000);
  622 + }
620 if (localMovieMessages != null) { 623 if (localMovieMessages != null) {
621 LogUtils.i("room-info", "play movie" + localMovieMessages.toString()); 624 LogUtils.i("room-info", "play movie" + localMovieMessages.toString());
622 String showMsg; 625 String showMsg;
@@ -626,12 +629,9 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -626,12 +629,9 @@ public class SmartControlService extends BaseService implements EventListener<St
626 R.string.delay_time_fill_time, 629 R.string.delay_time_fill_time,
627 R.string.play_movie_fill_name), 630 R.string.play_movie_fill_name),
628 offset, roomStatusInfo.getData().getFilm_name()); 631 offset, roomStatusInfo.getData().getFilm_name());
629 - Log.d("movie",roomStatusInfo.getData().getFilm_name());  
630 } else { 632 } else {
631 showMsg = String.format(ResUtils.getResResult(mContext, R.string.welcome, R.string.ads_promote, R.string.play_movie_fill_name), roomStatusInfo.getData().getFilm_name()); 633 showMsg = String.format(ResUtils.getResResult(mContext, R.string.welcome, R.string.ads_promote, R.string.play_movie_fill_name), roomStatusInfo.getData().getFilm_name());
632 - Log.d("movie",roomStatusInfo.getData().getFilm_name());  
633 } 634 }
634 - Log.d("movie","tostring:"+roomStatusInfo.getData().toString());  
635 CToast.makeText(this, showMsg, 100 * 1000).show(); 635 CToast.makeText(this, showMsg, 100 * 1000).show();
636 OpenMMUtils.openMMWithAds(this, localMovieMessages.getPlayPath(), null); 636 OpenMMUtils.openMMWithAds(this, localMovieMessages.getPlayPath(), null);
637 } else { 637 } else {
@@ -640,32 +640,31 @@ public class SmartControlService extends BaseService implements EventListener<St @@ -640,32 +640,31 @@ public class SmartControlService extends BaseService implements EventListener<St
640 } 640 }
641 } 641 }
642 642
  643 + private boolean nextNeedReport = false;//标记连场情况是否需要报告成功开门信息
  644 +
643 @Override 645 @Override
644 public void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo) { 646 public void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo) {
645 this.info = qrCodeInfo; 647 this.info = qrCodeInfo;
646 - if (info != null && info.getData() != null && TextUtils.isEmpty(info.getData().getRoom_sn())) { 648 + if (info != null && info.getData() != null) {
647 LogUtils.i(TAG, "order_sn is null,play end ads"); 649 LogUtils.i(TAG, "order_sn is null,play end ads");
648 - playEndAds();  
649 -// Intent intent = new Intent(this, QrCodeShowActivity.class)  
650 -// .putExtra("qr", info.getData().getCode())  
651 -// .putExtra("room_sn", roomInfo.getData().getRoom_sn())  
652 -// .putExtra("order_sn", roomStatusInfo.getData().getOrder_sn());  
653 -// if ("count_service".equals(countMsg)) {  
654 -// intent.putExtra("count_call", true);  
655 -// }  
656 -// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
657 -// startActivity(intent);  
658 - } else {  
659 - LogUtils.i(TAG, "order_sn not null:" + qrCodeInfo.toString());  
660 - String showMsg = ResUtils.getResResult(mContext, R.string.ads_promote, R.string.play_next_fill_name);  
661 - CToast.makeText(mContext, showMsg, 30 * 1000).show();  
662 - presenter.getNextOrderInfo(SmartControlService.this, info.getData().getOrder_sn()); 650 + if (TextUtils.isEmpty(info.getData().getOrder_sn())) {
  651 + playEndAds();
  652 + } else {
  653 + nextNeedReport = true;
  654 + LogUtils.i(TAG, "order_sn not null:" + qrCodeInfo.toString());
  655 + String showMsg = ResUtils.getResResult(mContext, R.string.ads_promote, R.string.play_next_fill_name);
  656 + CToast.makeText(mContext, showMsg, 30 * 1000).show();
  657 + presenter.getNextOrderInfo(SmartControlService.this, info.getData().getOrder_sn());
  658 + }
  659 + }else{
  660 + LogUtils.e("info != null && info.getData() != null");
663 } 661 }
664 } 662 }
665 663
666 @Override 664 @Override
667 public void updateInitGetOrderInfo(boolean b) { 665 public void updateInitGetOrderInfo(boolean b) {
668 initGetOderInfo = b; 666 initGetOderInfo = b;
  667 + nextNeedReport = b;
669 } 668 }
670 669
671 @Override 670 @Override
@@ -34,6 +34,7 @@ import com.qnbar.smc.socketProtocol.toServer.Heartbeat; @@ -34,6 +34,7 @@ import com.qnbar.smc.socketProtocol.toServer.Heartbeat;
34 import com.qnbar.smc.socketProtocol.toServer.SocketSendMsg; 34 import com.qnbar.smc.socketProtocol.toServer.SocketSendMsg;
35 import com.qnbar.smc.utils.LightOperationUtils; 35 import com.qnbar.smc.utils.LightOperationUtils;
36 import com.telink.bluetooth.light.ConnectionStatus; 36 import com.telink.bluetooth.light.ConnectionStatus;
  37 +import com.telink.bluetooth.light.DeviceInfo;
37 import com.xgimi.gimicinema.ICinemaControl; 38 import com.xgimi.gimicinema.ICinemaControl;
38 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity; 39 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
39 import com.xgimi.gimicinema.activity.MainActivity; 40 import com.xgimi.gimicinema.activity.MainActivity;
@@ -136,7 +137,7 @@ public class SocketService1 extends BaseService { @@ -136,7 +137,7 @@ public class SocketService1 extends BaseService {
136 AtomicBoolean sendRegister = new AtomicBoolean(false); 137 AtomicBoolean sendRegister = new AtomicBoolean(false);
137 AtomicInteger heartBeatErrorCount = new AtomicInteger(0); 138 AtomicInteger heartBeatErrorCount = new AtomicInteger(0);
138 139
139 - public ICinemaControl iPlayer=null; 140 + public ICinemaControl iPlayer = null;
140 private ServiceConnection conn = new ServiceConnection() { 141 private ServiceConnection conn = new ServiceConnection() {
141 public void onServiceConnected(ComponentName className, IBinder service) { 142 public void onServiceConnected(ComponentName className, IBinder service) {
142 Log.d("yao", "ServiceConnection -> onServiceConnected"); 143 Log.d("yao", "ServiceConnection -> onServiceConnected");
@@ -144,7 +145,9 @@ public class SocketService1 extends BaseService { @@ -144,7 +145,9 @@ public class SocketService1 extends BaseService {
144 } 145 }
145 146
146 public void onServiceDisconnected(ComponentName className) { 147 public void onServiceDisconnected(ComponentName className) {
147 - }; 148 + }
  149 +
  150 + ;
148 }; 151 };
149 152
150 public Runnable heartBeatRunnable = new Runnable() { 153 public Runnable heartBeatRunnable = new Runnable() {
@@ -154,14 +157,11 @@ public class SocketService1 extends BaseService { @@ -154,14 +157,11 @@ public class SocketService1 extends BaseService {
154 mHandler.postDelayed(this, HEART_BEAT_RATE); 157 mHandler.postDelayed(this, HEART_BEAT_RATE);
155 //就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket 158 //就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket
156 Heartbeat heartbeat = new Heartbeat(); 159 Heartbeat heartbeat = new Heartbeat();
157 - if (heartbearNum > 10)  
158 - {  
159 - heartbeat.setLightStatus( getLightStatus() );  
160 - heartbeat.setPlayStatus( getPlayStatus() );  
161 - heartbeat.setVolume( getAudioVolume()/6 + 1 );  
162 - }  
163 - else  
164 - { 160 + if (heartbearNum > 10) {
  161 + heartbeat.setLightStatus(getLightStatus());
  162 + heartbeat.setPlayStatus(getPlayStatus());
  163 + heartbeat.setVolume(getAudioVolume() / 6 + 1);
  164 + } else {
165 heartbearNum++; 165 heartbearNum++;
166 } 166 }
167 heartbeat.setRoom_sn(testRoomSn); 167 heartbeat.setRoom_sn(testRoomSn);
@@ -174,7 +174,7 @@ public class SocketService1 extends BaseService { @@ -174,7 +174,7 @@ public class SocketService1 extends BaseService {
174 boolean isSuccess = sendMsg(msg + END_SYMBOL); 174 boolean isSuccess = sendMsg(msg + END_SYMBOL);
175 if (!isSuccess) { 175 if (!isSuccess) {
176 LogUtils.i(TAG, "send heart beat error restart"); 176 LogUtils.i(TAG, "send heart beat error restart");
177 - Log.d("heartbeat content",msg); 177 + Log.d("heartbeat content", msg);
178 } 178 }
179 } 179 }
180 }; 180 };
@@ -213,7 +213,7 @@ public class SocketService1 extends BaseService { @@ -213,7 +213,7 @@ public class SocketService1 extends BaseService {
213 super.onStartCommand(intent, flags, startId); 213 super.onStartCommand(intent, flags, startId);
214 LogUtils.i(TAG, "onStartCommand"); 214 LogUtils.i(TAG, "onStartCommand");
215 int ftTest = Utils.getInt(this, "ft-test", 0); 215 int ftTest = Utils.getInt(this, "ft-test", 0);
216 - Log.d("Host", ""+ftTest); 216 + Log.d("Host", "" + ftTest);
217 switch (ftTest) { 217 switch (ftTest) {
218 case 0: 218 case 0:
219 serverHost = SERVER_HOST_ONLINE; 219 serverHost = SERVER_HOST_ONLINE;
@@ -333,8 +333,7 @@ public class SocketService1 extends BaseService { @@ -333,8 +333,7 @@ public class SocketService1 extends BaseService {
333 int length = 0; 333 int length = 0;
334 while (!socket.isClosed() 334 while (!socket.isClosed()
335 && !socket.isInputShutdown() 335 && !socket.isInputShutdown()
336 - && ((length = is.read(buffer)) > 0)  
337 - ) { 336 + && ((length = is.read(buffer)) > 0)) {
338 String tmp = new String(Arrays.copyOf(buffer, length)); 337 String tmp = new String(Arrays.copyOf(buffer, length));
339 readingMsg.append(tmp); 338 readingMsg.append(tmp);
340 int pos = readingMsg.indexOf(END_SYMBOL); 339 int pos = readingMsg.indexOf(END_SYMBOL);
@@ -375,7 +374,6 @@ public class SocketService1 extends BaseService { @@ -375,7 +374,6 @@ public class SocketService1 extends BaseService {
375 e.printStackTrace(); 374 e.printStackTrace();
376 LogUtils.e(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds"); 375 LogUtils.e(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds");
377 } 376 }
378 -  
379 try { 377 try {
380 Thread.sleep(1000); 378 Thread.sleep(1000);
381 } catch (InterruptedException e1) { 379 } catch (InterruptedException e1) {
@@ -463,7 +461,7 @@ public class SocketService1 extends BaseService { @@ -463,7 +461,7 @@ public class SocketService1 extends BaseService {
463 LogUtils.i(TAG, "RETURN_VERIFY_CODE"); 461 LogUtils.i(TAG, "RETURN_VERIFY_CODE");
464 if (!TextUtils.isEmpty(socketResponse.getData())) { 462 if (!TextUtils.isEmpty(socketResponse.getData())) {
465 VerifyCode verifyResponse = gson.fromJson(socketResponse.getData(), VerifyCode.class); 463 VerifyCode verifyResponse = gson.fromJson(socketResponse.getData(), VerifyCode.class);
466 - if(!TextUtils.isEmpty(verifyResponse.getVerify())){ 464 + if (!TextUtils.isEmpty(verifyResponse.getVerify())) {
467 String verifyMsg = AuthCode.getDecodeStr(verifyResponse.getVerify()); 465 String verifyMsg = AuthCode.getDecodeStr(verifyResponse.getVerify());
468 SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg); 466 SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg);
469 String msg = gson.toJson(ssm) + END_SYMBOL; 467 String msg = gson.toJson(ssm) + END_SYMBOL;
@@ -505,11 +503,11 @@ public class SocketService1 extends BaseService { @@ -505,11 +503,11 @@ public class SocketService1 extends BaseService {
505 503
506 /** 504 /**
507 * 处理服务器发送的命令 505 * 处理服务器发送的命令
  506 + *
508 * @param socketResponse 507 * @param socketResponse
509 */ 508 */
510 private void serverCommandDeal(MainResponse socketResponse) { 509 private void serverCommandDeal(MainResponse socketResponse) {
511 - switch (socketResponse.getCmd())  
512 - { 510 + switch (socketResponse.getCmd()) {
513 case OPEN_DOOR://开门 511 case OPEN_DOOR://开门
514 if (socketResponse.getData() != null) { 512 if (socketResponse.getData() != null) {
515 OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class); 513 OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class);
@@ -539,16 +537,15 @@ public class SocketService1 extends BaseService { @@ -539,16 +537,15 @@ public class SocketService1 extends BaseService {
539 break; 537 break;
540 538
541 case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态 539 case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态
542 - long time1 = System.currentTimeMillis();  
543 - Log.d("ReportInfo","收到上报命令"); 540 + Log.d("ReportInfo", "收到上报命令");
544 //获取serverId 541 //获取serverId
545 ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class); 542 ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class);
546 // String serverId = rps.getServerId(); 543 // String serverId = rps.getServerId();
547 - reportEquStatus(rps.getServerId(),0); 544 + reportEquStatus(rps.getServerId(), 0);
548 break; 545 break;
549 546
550 case SET_EQU_STATUS://设置声音,灯光,播放暂停 547 case SET_EQU_STATUS://设置声音,灯光,播放暂停
551 - Log.d("ReportInfo","收到控制命令:"+socketResponse.getData()); 548 + Log.d("ReportInfo", "收到控制命令:" + socketResponse.getData());
552 EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class); 549 EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class);
553 setEquipmentStatus(equc); 550 setEquipmentStatus(equc);
554 break; 551 break;
@@ -572,7 +569,7 @@ public class SocketService1 extends BaseService { @@ -572,7 +569,7 @@ public class SocketService1 extends BaseService {
572 } else { 569 } else {
573 sendMessage(USER_OPEN_DOOR, "user open the door"); 570 sendMessage(USER_OPEN_DOOR, "user open the door");
574 } 571 }
575 - Log.d("op","开门"); 572 + Log.d("op", "开门");
576 break; 573 break;
577 case 20: 574 case 20:
578 LogUtils.i(TAG, "admin open the door,del the log"); 575 LogUtils.i(TAG, "admin open the door,del the log");
@@ -593,43 +590,14 @@ public class SocketService1 extends BaseService { @@ -593,43 +590,14 @@ public class SocketService1 extends BaseService {
593 } 590 }
594 } 591 }
595 592
596 - private void reportEquStatus(String serverId,int lightSet) { 593 + private void reportEquStatus(String serverId, int lightSet) {
597 //填充返回数据 594 //填充返回数据
598 - int volume = getAudioVolume()/6 + 1; 595 + int volume = getAudioVolume() / 6 + 1;
599 int playStatus = getPlayStatus(); 596 int playStatus = getPlayStatus();
600 int lightStatus = 0; 597 int lightStatus = 0;
601 -  
602 -// try {  
603 -// playStatus = iPlayer.getCurrentStatus();  
604 -// Log.d("ReportInfo","playStatus:"+playStatus);  
605 -// } catch (RemoteException e) {  
606 -// e.printStackTrace();  
607 -// }  
608 -// if (playStatus == 0) {  
609 -// boolean bool = ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class);  
610 -// Log.d("ReportInfo","广告状态:"+bool);  
611 -// if(bool) {  
612 -// playStatus = 3;  
613 -// }  
614 -// }  
615 -  
616 if (lightSet == 1 || lightSet == 2) { 598 if (lightSet == 1 || lightSet == 2) {
617 lightStatus = lightSet; 599 lightStatus = lightSet;
618 } else { 600 } else {
619 -// try {  
620 -// ConnectionStatus stu = Lights.getInstance().  
621 -// getByMeshAddress(((FangTangApplication) getApplication()).  
622 -// getConnectDevice().meshAddress).status;  
623 -// if( stu == ConnectionStatus.ON ) {  
624 -// Log.d("ReportInfo","lightStatus==1");  
625 -// lightStatus = 1;  
626 -// } else {  
627 -// Log.d("ReportInfo", "lightStatus:"+stu);  
628 -// }  
629 -// } catch (Exception e) {  
630 -// e.printStackTrace();  
631 -// lightStatus = 0;//获取失败  
632 -// }  
633 lightStatus = getLightStatus(); 601 lightStatus = getLightStatus();
634 } 602 }
635 603
@@ -645,31 +613,36 @@ public class SocketService1 extends BaseService { @@ -645,31 +613,36 @@ public class SocketService1 extends BaseService {
645 rep.setData(equStatus); 613 rep.setData(equStatus);
646 String msg = gson.toJson(rep) + END_SYMBOL; 614 String msg = gson.toJson(rep) + END_SYMBOL;
647 sendMsg(msg); 615 sendMsg(msg);
648 - Log.d("ReportInfo",msg); 616 + Log.d("ReportInfo", msg);
649 } 617 }
650 618
  619 + private static final int SERVER_CMD_OPEN_LIGHT = 1;
  620 + private static final int SERVER_CMD_CLOSE_LIGHT = 2;
  621 +
651 private void setLight(int op) { 622 private void setLight(int op) {
652 - if (op == 1){//打开灯光  
653 - Log.d("setEqu","打开灯光"); 623 + if (op == SERVER_CMD_OPEN_LIGHT) {//打开灯光
  624 + Log.d("setEqu", "打开灯光");
654 LightOperationUtils.open(); 625 LightOperationUtils.open();
655 LightOperationUtils.setLightValue(5); 626 LightOperationUtils.setLightValue(5);
656 -  
657 //延时增亮 627 //延时增亮
658 - Timer timer=new Timer();//实例化Timer类  
659 - timer.schedule(new TimerTask(){  
660 - public void run(){ 628 + Timer timer = new Timer();//实例化Timer类
  629 + timer.schedule(new TimerTask() {
  630 + public void run() {
661 LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); 631 LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
662 - this.cancel();}},2000);//毫秒  
663 - } else if(op == 2) {//关闭灯光  
664 - Log.d("setEqu","关闭灯光"); 632 + this.cancel();
  633 + }
  634 + }, 2000);//毫秒
  635 + } else if (op == SERVER_CMD_CLOSE_LIGHT) {//关闭灯光
  636 + Log.d("setEqu", "关闭灯光");
665 LightOperationUtils.setLightValue(5); 637 LightOperationUtils.setLightValue(5);
666 -  
667 //延时关闭 638 //延时关闭
668 - Timer timer=new Timer();//实例化Timer类  
669 - timer.schedule(new TimerTask(){  
670 - public void run(){ 639 + Timer timer = new Timer();//实例化Timer类
  640 + timer.schedule(new TimerTask() {
  641 + public void run() {
671 LightOperationUtils.close(); 642 LightOperationUtils.close();
672 - this.cancel();}},2000);//毫秒 643 + this.cancel();
  644 + }
  645 + }, 2000);//毫秒
673 } 646 }
674 } 647 }
675 648
@@ -681,14 +654,11 @@ public class SocketService1 extends BaseService { @@ -681,14 +654,11 @@ public class SocketService1 extends BaseService {
681 e.printStackTrace(); 654 e.printStackTrace();
682 } 655 }
683 656
684 - if (op == 1 && status == 2)  
685 - {  
686 - Log.d("setEqu","开始播放"); 657 + if (op == 1 && status == 2) {
  658 + Log.d("setEqu", "开始播放");
687 ShellUtils.execCommand("input keyevent 23", false); 659 ShellUtils.execCommand("input keyevent 23", false);
688 - }  
689 - else if (op == 2 && status == 1)  
690 - {  
691 - Log.d("setEqu","暂停播放"); 660 + } else if (op == 2 && status == 1) {
  661 + Log.d("setEqu", "暂停播放");
692 ShellUtils.execCommand("input keyevent 23", false); 662 ShellUtils.execCommand("input keyevent 23", false);
693 } 663 }
694 } 664 }
@@ -700,15 +670,14 @@ public class SocketService1 extends BaseService { @@ -700,15 +670,14 @@ public class SocketService1 extends BaseService {
700 670
701 setAudioVolume(equc.getAudioCtl()); 671 setAudioVolume(equc.getAudioCtl());
702 672
703 - if (equc.getLightCtl() != 0){ 673 + if (equc.getLightCtl() != 0) {
704 try { 674 try {
705 Thread.sleep(500); 675 Thread.sleep(500);
706 } catch (InterruptedException e) { 676 } catch (InterruptedException e) {
707 e.printStackTrace(); 677 e.printStackTrace();
708 } 678 }
709 } 679 }
710 -  
711 - reportEquStatus(equc.getServerId(),equc.getLightCtl()); 680 + reportEquStatus(equc.getServerId(), equc.getLightCtl());
712 } 681 }
713 682
714 /*--命令处理-end-----------------------------------*/ 683 /*--命令处理-end-----------------------------------*/
@@ -716,54 +685,57 @@ public class SocketService1 extends BaseService { @@ -716,54 +685,57 @@ public class SocketService1 extends BaseService {
716 public int getAudioVolume() { 685 public int getAudioVolume() {
717 AudioManager mAudioManager; 686 AudioManager mAudioManager;
718 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 687 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
719 - return mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC ); 688 + return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
720 } 689 }
721 690
722 public int getPlayStatus() { 691 public int getPlayStatus() {
723 int playStatus = 0; 692 int playStatus = 0;
724 - 693 + if (iPlayer == null) {
  694 + return playStatus;
  695 + }
725 try { 696 try {
726 playStatus = iPlayer.getCurrentStatus(); 697 playStatus = iPlayer.getCurrentStatus();
727 - Log.d("ReportInfo","playStatus:"+playStatus); 698 + Log.d("ReportInfo", "playStatus:" + playStatus);
728 } catch (RemoteException e) { 699 } catch (RemoteException e) {
729 e.printStackTrace(); 700 e.printStackTrace();
730 } 701 }
731 if (playStatus == 0) { 702 if (playStatus == 0) {
732 boolean bool = ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class); 703 boolean bool = ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class);
733 - Log.d("ReportInfo","广告状态:"+bool);  
734 - if(bool) { 704 + Log.d("ReportInfo", "广告状态:" + bool);
  705 + if (bool) {
735 playStatus = 3; 706 playStatus = 3;
736 } 707 }
737 } 708 }
738 -  
739 return playStatus; 709 return playStatus;
740 } 710 }
741 711
742 public int getLightStatus() { 712 public int getLightStatus() {
743 int lightStatus = 2; 713 int lightStatus = 2;
744 -  
745 try { 714 try {
  715 + DeviceInfo connectDevice = ((FangTangApplication) getApplication()).
  716 + getConnectDevice();
  717 + if (connectDevice == null) {
  718 + return lightStatus;
  719 + }
746 ConnectionStatus stu = Lights.getInstance(). 720 ConnectionStatus stu = Lights.getInstance().
747 - getByMeshAddress(((FangTangApplication) getApplication()).  
748 - getConnectDevice().meshAddress).status;  
749 - if( stu == ConnectionStatus.ON ) {  
750 - Log.d("ReportInfo","lightStatus==1"); 721 + getByMeshAddress(connectDevice.meshAddress).status;
  722 + if (stu == ConnectionStatus.ON) {
  723 + Log.d("ReportInfo", "lightStatus==1");
751 lightStatus = 1; 724 lightStatus = 1;
752 } else { 725 } else {
753 - Log.d("ReportInfo", "lightStatus:"+stu); 726 + Log.d("ReportInfo", "lightStatus:" + stu);
754 } 727 }
755 } catch (Exception e) { 728 } catch (Exception e) {
756 e.printStackTrace(); 729 e.printStackTrace();
757 lightStatus = 0;//获取失败 730 lightStatus = 0;//获取失败
758 } 731 }
759 -  
760 return lightStatus; 732 return lightStatus;
761 } 733 }
762 734
763 private int setAudioVolume(int volume) { 735 private int setAudioVolume(int volume) {
764 AudioManager mAudioManager; 736 AudioManager mAudioManager;
765 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 737 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
766 - int now = getAudioVolume()/6; 738 + int now = getAudioVolume() / 6;
767 739
768 if (volume == 0) { 740 if (volume == 0) {
769 return now; 741 return now;
@@ -772,22 +744,22 @@ public class SocketService1 extends BaseService { @@ -772,22 +744,22 @@ public class SocketService1 extends BaseService {
772 } 744 }
773 745
774 if (volume > now) {//加音量 746 if (volume > now) {//加音量
775 - Log.d("setEqu","加音量"+now+":"+volume);  
776 - while(now < volume) { 747 + Log.d("setEqu", "加音量" + now + ":" + volume);
  748 + while (now < volume) {
777 mAudioManager.adjustStreamVolume( 749 mAudioManager.adjustStreamVolume(
778 AudioManager.STREAM_MUSIC, 750 AudioManager.STREAM_MUSIC,
779 AudioManager.ADJUST_RAISE, 751 AudioManager.ADJUST_RAISE,
780 AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); 752 AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
781 - now ++; 753 + now++;
782 } 754 }
783 - } else if(volume < now) {//减音量  
784 - Log.d("setEqu","减音量"+now+":"+volume);  
785 - while(now > volume) { 755 + } else if (volume < now) {//减音量
  756 + Log.d("setEqu", "减音量" + now + ":" + volume);
  757 + while (now > volume) {
786 mAudioManager.adjustStreamVolume( 758 mAudioManager.adjustStreamVolume(
787 AudioManager.STREAM_MUSIC, 759 AudioManager.STREAM_MUSIC,
788 AudioManager.ADJUST_LOWER, 760 AudioManager.ADJUST_LOWER,
789 AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); 761 AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
790 - now --; 762 + now--;
791 } 763 }
792 } 764 }
793 765
@@ -109,7 +109,7 @@ @@ -109,7 +109,7 @@
109 <string name="welcome">欢迎您的光临。</string> 109 <string name="welcome">欢迎您的光临。</string>
110 <string name="ads_promote">青柠影咖,年轻人的奇幻乐园。</string> 110 <string name="ads_promote">青柠影咖,年轻人的奇幻乐园。</string>
111 <string name="delay_time_fill_time">您已迟到%d分钟,</string> 111 <string name="delay_time_fill_time">您已迟到%d分钟,</string>
112 - <string name="play_movie_fill_name">即将为你播放%s</string> 112 + <string name="play_movie_fill_name">即将为你播放《%s》</string>
113 <string name="end_ads">本场电影已结束,请观看《青柠电影先锋》</string> 113 <string name="end_ads">本场电影已结束,请观看《青柠电影先锋》</string>
114 <string name="welcome_again">离场时请携带好随身物品,欢迎下次光临。</string> 114 <string name="welcome_again">离场时请携带好随身物品,欢迎下次光临。</string>
115 <string name="play_next_fill_name">本场电影已结束,即将为您播放下一部影片</string> 115 <string name="play_next_fill_name">本场电影已结束,即将为您播放下一部影片</string>
Please register or login to post a comment