Commit deaab96f94435b9f5945fb0eb6cf9b5442fd3b16

Authored by 李攀
1 parent 5a9cdccd

prmote ,next film,format

... ... @@ -41,6 +41,7 @@ public interface SmartControlContract {
41 41
42 42 void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo);
43 43
  44 + //重置下场及重置初始化获取订单信息
44 45 void updateInitGetOrderInfo(boolean b);
45 46
46 47 void setOpenDoorTime(int i);
... ...
... ... @@ -220,7 +220,7 @@ public class SmartControlService extends BaseService implements EventListener<St
220 220
221 221 @Override
222 222 public void writeFailure(String error) {
223   - LogUtils.i("room-info", "open failure," + error.toString());
  223 + LogUtils.i("room-info", "open failure," + error);
224 224 bleBroadcastReceiver.setResponseObj(null);
225 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 335 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
336 336 startActivity(intent);
337 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 350 break;
351 351 case ORDER_PLAY_COMPLETE:
352 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 617 CToast.makeText(this, "没有找到电影信息,请联系客服", 90 * 1000).show();
618 618 }
619 619 }
  620 + if (nextNeedReport) {
  621 + mHandler.postDelayed(reportRunnable, 2 * 1000);
  622 + }
620 623 if (localMovieMessages != null) {
621 624 LogUtils.i("room-info", "play movie" + localMovieMessages.toString());
622 625 String showMsg;
... ... @@ -626,12 +629,9 @@ public class SmartControlService extends BaseService implements EventListener<St
626 629 R.string.delay_time_fill_time,
627 630 R.string.play_movie_fill_name),
628 631 offset, roomStatusInfo.getData().getFilm_name());
629   - Log.d("movie",roomStatusInfo.getData().getFilm_name());
630 632 } else {
631 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 635 CToast.makeText(this, showMsg, 100 * 1000).show();
636 636 OpenMMUtils.openMMWithAds(this, localMovieMessages.getPlayPath(), null);
637 637 } else {
... ... @@ -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 645 @Override
644 646 public void prepareRoomQrCodeInfo(RoomQrCodeInfo qrCodeInfo) {
645 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 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 664 @Override
667 665 public void updateInitGetOrderInfo(boolean b) {
668 666 initGetOderInfo = b;
  667 + nextNeedReport = b;
669 668 }
670 669
671 670 @Override
... ...
... ... @@ -34,6 +34,7 @@ import com.qnbar.smc.socketProtocol.toServer.Heartbeat;
34 34 import com.qnbar.smc.socketProtocol.toServer.SocketSendMsg;
35 35 import com.qnbar.smc.utils.LightOperationUtils;
36 36 import com.telink.bluetooth.light.ConnectionStatus;
  37 +import com.telink.bluetooth.light.DeviceInfo;
37 38 import com.xgimi.gimicinema.ICinemaControl;
38 39 import com.xgimi.gimicinema.activity.AdsPreVideoPlayerActivity;
39 40 import com.xgimi.gimicinema.activity.MainActivity;
... ... @@ -136,7 +137,7 @@ public class SocketService1 extends BaseService {
136 137 AtomicBoolean sendRegister = new AtomicBoolean(false);
137 138 AtomicInteger heartBeatErrorCount = new AtomicInteger(0);
138 139
139   - public ICinemaControl iPlayer=null;
  140 + public ICinemaControl iPlayer = null;
140 141 private ServiceConnection conn = new ServiceConnection() {
141 142 public void onServiceConnected(ComponentName className, IBinder service) {
142 143 Log.d("yao", "ServiceConnection -> onServiceConnected");
... ... @@ -144,7 +145,9 @@ public class SocketService1 extends BaseService {
144 145 }
145 146
146 147 public void onServiceDisconnected(ComponentName className) {
147   - };
  148 + }
  149 +
  150 + ;
148 151 };
149 152
150 153 public Runnable heartBeatRunnable = new Runnable() {
... ... @@ -154,14 +157,11 @@ public class SocketService1 extends BaseService {
154 157 mHandler.postDelayed(this, HEART_BEAT_RATE);
155 158 //就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket
156 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 165 heartbearNum++;
166 166 }
167 167 heartbeat.setRoom_sn(testRoomSn);
... ... @@ -174,7 +174,7 @@ public class SocketService1 extends BaseService {
174 174 boolean isSuccess = sendMsg(msg + END_SYMBOL);
175 175 if (!isSuccess) {
176 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 213 super.onStartCommand(intent, flags, startId);
214 214 LogUtils.i(TAG, "onStartCommand");
215 215 int ftTest = Utils.getInt(this, "ft-test", 0);
216   - Log.d("Host", ""+ftTest);
  216 + Log.d("Host", "" + ftTest);
217 217 switch (ftTest) {
218 218 case 0:
219 219 serverHost = SERVER_HOST_ONLINE;
... ... @@ -333,8 +333,7 @@ public class SocketService1 extends BaseService {
333 333 int length = 0;
334 334 while (!socket.isClosed()
335 335 && !socket.isInputShutdown()
336   - && ((length = is.read(buffer)) > 0)
337   - ) {
  336 + && ((length = is.read(buffer)) > 0)) {
338 337 String tmp = new String(Arrays.copyOf(buffer, length));
339 338 readingMsg.append(tmp);
340 339 int pos = readingMsg.indexOf(END_SYMBOL);
... ... @@ -375,7 +374,6 @@ public class SocketService1 extends BaseService {
375 374 e.printStackTrace();
376 375 LogUtils.e(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds");
377 376 }
378   -
379 377 try {
380 378 Thread.sleep(1000);
381 379 } catch (InterruptedException e1) {
... ... @@ -463,7 +461,7 @@ public class SocketService1 extends BaseService {
463 461 LogUtils.i(TAG, "RETURN_VERIFY_CODE");
464 462 if (!TextUtils.isEmpty(socketResponse.getData())) {
465 463 VerifyCode verifyResponse = gson.fromJson(socketResponse.getData(), VerifyCode.class);
466   - if(!TextUtils.isEmpty(verifyResponse.getVerify())){
  464 + if (!TextUtils.isEmpty(verifyResponse.getVerify())) {
467 465 String verifyMsg = AuthCode.getDecodeStr(verifyResponse.getVerify());
468 466 SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg);
469 467 String msg = gson.toJson(ssm) + END_SYMBOL;
... ... @@ -505,11 +503,11 @@ public class SocketService1 extends BaseService {
505 503
506 504 /**
507 505 * 处理服务器发送的命令
  506 + *
508 507 * @param socketResponse
509 508 */
510 509 private void serverCommandDeal(MainResponse socketResponse) {
511   - switch (socketResponse.getCmd())
512   - {
  510 + switch (socketResponse.getCmd()) {
513 511 case OPEN_DOOR://开门
514 512 if (socketResponse.getData() != null) {
515 513 OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class);
... ... @@ -539,16 +537,15 @@ public class SocketService1 extends BaseService {
539 537 break;
540 538
541 539 case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态
542   - long time1 = System.currentTimeMillis();
543   - Log.d("ReportInfo","收到上报命令");
  540 + Log.d("ReportInfo", "收到上报命令");
544 541 //获取serverId
545 542 ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class);
546 543 // String serverId = rps.getServerId();
547   - reportEquStatus(rps.getServerId(),0);
  544 + reportEquStatus(rps.getServerId(), 0);
548 545 break;
549 546
550 547 case SET_EQU_STATUS://设置声音,灯光,播放暂停
551   - Log.d("ReportInfo","收到控制命令:"+socketResponse.getData());
  548 + Log.d("ReportInfo", "收到控制命令:" + socketResponse.getData());
552 549 EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class);
553 550 setEquipmentStatus(equc);
554 551 break;
... ... @@ -572,7 +569,7 @@ public class SocketService1 extends BaseService {
572 569 } else {
573 570 sendMessage(USER_OPEN_DOOR, "user open the door");
574 571 }
575   - Log.d("op","开门");
  572 + Log.d("op", "开门");
576 573 break;
577 574 case 20:
578 575 LogUtils.i(TAG, "admin open the door,del the log");
... ... @@ -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 596 int playStatus = getPlayStatus();
600 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 598 if (lightSet == 1 || lightSet == 2) {
617 599 lightStatus = lightSet;
618 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 601 lightStatus = getLightStatus();
634 602 }
635 603
... ... @@ -645,31 +613,36 @@ public class SocketService1 extends BaseService {
645 613 rep.setData(equStatus);
646 614 String msg = gson.toJson(rep) + END_SYMBOL;
647 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 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 625 LightOperationUtils.open();
655 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 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 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 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 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 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 662 ShellUtils.execCommand("input keyevent 23", false);
693 663 }
694 664 }
... ... @@ -700,15 +670,14 @@ public class SocketService1 extends BaseService {
700 670
701 671 setAudioVolume(equc.getAudioCtl());
702 672
703   - if (equc.getLightCtl() != 0){
  673 + if (equc.getLightCtl() != 0) {
704 674 try {
705 675 Thread.sleep(500);
706 676 } catch (InterruptedException e) {
707 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 683 /*--命令处理-end-----------------------------------*/
... ... @@ -716,54 +685,57 @@ public class SocketService1 extends BaseService {
716 685 public int getAudioVolume() {
717 686 AudioManager mAudioManager;
718 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 691 public int getPlayStatus() {
723 692 int playStatus = 0;
724   -
  693 + if (iPlayer == null) {
  694 + return playStatus;
  695 + }
725 696 try {
726 697 playStatus = iPlayer.getCurrentStatus();
727   - Log.d("ReportInfo","playStatus:"+playStatus);
  698 + Log.d("ReportInfo", "playStatus:" + playStatus);
728 699 } catch (RemoteException e) {
729 700 e.printStackTrace();
730 701 }
731 702 if (playStatus == 0) {
732 703 boolean bool = ActivityCollector.isActivityExist(AdsPreVideoPlayerActivity.class);
733   - Log.d("ReportInfo","广告状态:"+bool);
734   - if(bool) {
  704 + Log.d("ReportInfo", "广告状态:" + bool);
  705 + if (bool) {
735 706 playStatus = 3;
736 707 }
737 708 }
738   -
739 709 return playStatus;
740 710 }
741 711
742 712 public int getLightStatus() {
743 713 int lightStatus = 2;
744   -
745 714 try {
  715 + DeviceInfo connectDevice = ((FangTangApplication) getApplication()).
  716 + getConnectDevice();
  717 + if (connectDevice == null) {
  718 + return lightStatus;
  719 + }
746 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 724 lightStatus = 1;
752 725 } else {
753   - Log.d("ReportInfo", "lightStatus:"+stu);
  726 + Log.d("ReportInfo", "lightStatus:" + stu);
754 727 }
755 728 } catch (Exception e) {
756 729 e.printStackTrace();
757 730 lightStatus = 0;//获取失败
758 731 }
759   -
760 732 return lightStatus;
761 733 }
762 734
763 735 private int setAudioVolume(int volume) {
764 736 AudioManager mAudioManager;
765 737 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
766   - int now = getAudioVolume()/6;
  738 + int now = getAudioVolume() / 6;
767 739
768 740 if (volume == 0) {
769 741 return now;
... ... @@ -772,22 +744,22 @@ public class SocketService1 extends BaseService {
772 744 }
773 745
774 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 749 mAudioManager.adjustStreamVolume(
778 750 AudioManager.STREAM_MUSIC,
779 751 AudioManager.ADJUST_RAISE,
780 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 758 mAudioManager.adjustStreamVolume(
787 759 AudioManager.STREAM_MUSIC,
788 760 AudioManager.ADJUST_LOWER,
789 761 AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
790   - now --;
  762 + now--;
791 763 }
792 764 }
793 765
... ...
... ... @@ -109,7 +109,7 @@
109 109 <string name="welcome">欢迎您的光临。</string>
110 110 <string name="ads_promote">青柠影咖,年轻人的奇幻乐园。</string>
111 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 113 <string name="end_ads">本场电影已结束,请观看《青柠电影先锋》</string>
114 114 <string name="welcome_again">离场时请携带好随身物品,欢迎下次光临。</string>
115 115 <string name="play_next_fill_name">本场电影已结束,即将为您播放下一部影片</string>
... ...
Please register or login to post a comment