Showing
2 changed files
with
36 additions
and
47 deletions
| @@ -11,6 +11,7 @@ import android.os.RemoteException; | @@ -11,6 +11,7 @@ import android.os.RemoteException; | ||
| 11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
| 12 | import android.util.Log; | 12 | import android.util.Log; |
| 13 | import android.widget.Toast; | 13 | import android.widget.Toast; |
| 14 | + | ||
| 14 | import com.gimi.common.cinema.model.MessageEvent; | 15 | import com.gimi.common.cinema.model.MessageEvent; |
| 15 | import com.gimi.common.cinema.model.RoomInfo; | 16 | import com.gimi.common.cinema.model.RoomInfo; |
| 16 | import com.gimi.common.cinema.utils.ActivityCollector; | 17 | import com.gimi.common.cinema.utils.ActivityCollector; |
| @@ -36,6 +37,7 @@ import com.xgimi.gimicinema.activity.QrCodeShowActivity; | @@ -36,6 +37,7 @@ import com.xgimi.gimicinema.activity.QrCodeShowActivity; | ||
| 36 | import com.xgimi.gimicinema.application.FangTangApplication; | 37 | import com.xgimi.gimicinema.application.FangTangApplication; |
| 37 | import com.xgimi.gimicinema.service.CinemaControlService; | 38 | import com.xgimi.gimicinema.service.CinemaControlService; |
| 38 | import com.xgimi.smartscreen.encrypt.AuthCode; | 39 | import com.xgimi.smartscreen.encrypt.AuthCode; |
| 40 | + | ||
| 39 | import org.greenrobot.eventbus.EventBus; | 41 | import org.greenrobot.eventbus.EventBus; |
| 40 | 42 | ||
| 41 | import java.io.IOException; | 43 | import java.io.IOException; |
| @@ -415,11 +417,11 @@ public class SocketService1 extends BaseService { | @@ -415,11 +417,11 @@ public class SocketService1 extends BaseService { | ||
| 415 | 417 | ||
| 416 | /** | 418 | /** |
| 417 | * 处理服务器发送的命令 | 419 | * 处理服务器发送的命令 |
| 420 | + * | ||
| 418 | * @param socketResponse | 421 | * @param socketResponse |
| 419 | */ | 422 | */ |
| 420 | private void serverCommandDeal(MainResponse socketResponse) { | 423 | private void serverCommandDeal(MainResponse socketResponse) { |
| 421 | - switch (socketResponse.getCmd()) | ||
| 422 | - { | 424 | + switch (socketResponse.getCmd()) { |
| 423 | case OPEN_DOOR://开门 | 425 | case OPEN_DOOR://开门 |
| 424 | if (socketResponse.getData() != null) { | 426 | if (socketResponse.getData() != null) { |
| 425 | OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class); | 427 | OpenDoor openDoorResponse = gson.fromJson(socketResponse.getData(), OpenDoor.class); |
| @@ -435,7 +437,7 @@ public class SocketService1 extends BaseService { | @@ -435,7 +437,7 @@ public class SocketService1 extends BaseService { | ||
| 435 | break; | 437 | break; |
| 436 | 438 | ||
| 437 | case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态 | 439 | case REPORT_EQU_STATUS://获取声音,灯光,播放暂停状态 |
| 438 | - Log.d("ReportInfo","收到上报命令"); | 440 | + Log.d("ReportInfo", "收到上报命令"); |
| 439 | //获取serverId | 441 | //获取serverId |
| 440 | ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class); | 442 | ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class); |
| 441 | // String serverId = rps.getServerId(); | 443 | // String serverId = rps.getServerId(); |
| @@ -443,7 +445,7 @@ public class SocketService1 extends BaseService { | @@ -443,7 +445,7 @@ public class SocketService1 extends BaseService { | ||
| 443 | break; | 445 | break; |
| 444 | 446 | ||
| 445 | case SET_EQU_STATUS://设置声音,灯光,播放暂停 | 447 | case SET_EQU_STATUS://设置声音,灯光,播放暂停 |
| 446 | - Log.d("ReportInfo","收到控制命令:"+socketResponse.getData()); | 448 | + Log.d("ReportInfo", "收到控制命令:" + socketResponse.getData()); |
| 447 | EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class); | 449 | EquipmentControl equc = gson.fromJson(socketResponse.getData(), EquipmentControl.class); |
| 448 | setEquipmentStatus(equc); | 450 | setEquipmentStatus(equc); |
| 449 | break; | 451 | break; |
| @@ -487,19 +489,19 @@ public class SocketService1 extends BaseService { | @@ -487,19 +489,19 @@ public class SocketService1 extends BaseService { | ||
| 487 | 489 | ||
| 488 | private void reportEquStatus(String serverId) { | 490 | private void reportEquStatus(String serverId) { |
| 489 | //填充返回数据 | 491 | //填充返回数据 |
| 490 | - int volume = getAudioVolume()/6 + 1; | 492 | + int volume = getAudioVolume() / 6 + 1; |
| 491 | int lightStatus = 2; | 493 | int lightStatus = 2; |
| 492 | int playStatus = 0; | 494 | int playStatus = 0; |
| 493 | 495 | ||
| 494 | try { | 496 | try { |
| 495 | playStatus = iPlayer.getCurrentStatus(); | 497 | playStatus = iPlayer.getCurrentStatus(); |
| 496 | - Log.d("ReportInfo","playStatus:"+playStatus); | 498 | + Log.d("ReportInfo", "playStatus:" + playStatus); |
| 497 | } catch (RemoteException e) { | 499 | } catch (RemoteException e) { |
| 498 | e.printStackTrace(); | 500 | e.printStackTrace(); |
| 499 | } | 501 | } |
| 500 | - if( Lights.getInstance().getByMeshAddress( | ||
| 501 | - ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status == ConnectionStatus.ON ) | ||
| 502 | - { | 502 | + if (Lights.getInstance().getByMeshAddress( |
| 503 | + ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status | ||
| 504 | + == ConnectionStatus.ON) { | ||
| 503 | lightStatus = 1; | 505 | lightStatus = 1; |
| 504 | } | 506 | } |
| 505 | 507 | ||
| @@ -515,19 +517,16 @@ public class SocketService1 extends BaseService { | @@ -515,19 +517,16 @@ public class SocketService1 extends BaseService { | ||
| 515 | rep.setData(equStatus); | 517 | rep.setData(equStatus); |
| 516 | String msg = gson.toJson(rep) + END_SYMBOL; | 518 | String msg = gson.toJson(rep) + END_SYMBOL; |
| 517 | sendMsg(msg); | 519 | sendMsg(msg); |
| 518 | - Log.d("ReportInfo",msg); | 520 | + Log.d("ReportInfo", msg); |
| 519 | } | 521 | } |
| 520 | 522 | ||
| 521 | private void setLight(int op) { | 523 | private void setLight(int op) { |
| 522 | - if (op == 1)//打开灯光 | ||
| 523 | - { | ||
| 524 | - Log.d("setEqu","打开灯光"); | 524 | + if (op == 1) {//打开灯光 |
| 525 | + Log.d("setEqu", "打开灯光"); | ||
| 525 | LightOperationUtils.open(); | 526 | LightOperationUtils.open(); |
| 526 | LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); | 527 | LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); |
| 527 | - } | ||
| 528 | - else if(op == 2)//关闭灯光 | ||
| 529 | - { | ||
| 530 | - Log.d("setEqu","关闭灯光"); | 528 | + } else if (op == 2) {//关闭灯光 |
| 529 | + Log.d("setEqu", "关闭灯光"); | ||
| 531 | LightOperationUtils.setLightValue(5); | 530 | LightOperationUtils.setLightValue(5); |
| 532 | LightOperationUtils.close(); | 531 | LightOperationUtils.close(); |
| 533 | } | 532 | } |
| @@ -541,14 +540,11 @@ public class SocketService1 extends BaseService { | @@ -541,14 +540,11 @@ public class SocketService1 extends BaseService { | ||
| 541 | e.printStackTrace(); | 540 | e.printStackTrace(); |
| 542 | } | 541 | } |
| 543 | 542 | ||
| 544 | - if (op == 1 && status == 2) | ||
| 545 | - { | ||
| 546 | - Log.d("setEqu","开始播放"); | 543 | + if (op == 1 && status == 2) { |
| 544 | + Log.d("setEqu", "开始播放"); | ||
| 547 | ShellUtils.execCommand("input keyevent 23", false); | 545 | ShellUtils.execCommand("input keyevent 23", false); |
| 548 | - } | ||
| 549 | - else if (op == 2 && status == 1) | ||
| 550 | - { | ||
| 551 | - Log.d("setEqu","暂停播放"); | 546 | + } else if (op == 2 && status == 1) { |
| 547 | + Log.d("setEqu", "暂停播放"); | ||
| 552 | ShellUtils.execCommand("input keyevent 23", false); | 548 | ShellUtils.execCommand("input keyevent 23", false); |
| 553 | } | 549 | } |
| 554 | } | 550 | } |
| @@ -569,46 +565,38 @@ public class SocketService1 extends BaseService { | @@ -569,46 +565,38 @@ public class SocketService1 extends BaseService { | ||
| 569 | private int getAudioVolume() { | 565 | private int getAudioVolume() { |
| 570 | AudioManager mAudioManager; | 566 | AudioManager mAudioManager; |
| 571 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); | 567 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
| 572 | - int current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC ); | 568 | + int current = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); |
| 573 | return current; | 569 | return current; |
| 574 | } | 570 | } |
| 575 | 571 | ||
| 576 | private int setAudioVolume(int volume) { | 572 | private int setAudioVolume(int volume) { |
| 577 | AudioManager mAudioManager; | 573 | AudioManager mAudioManager; |
| 578 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); | 574 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
| 579 | - int now = getAudioVolume()/6; | 575 | + int now = getAudioVolume() / 6; |
| 580 | 576 | ||
| 581 | - if (volume == 0) | ||
| 582 | - { | 577 | + if (volume == 0) { |
| 583 | return now; | 578 | return now; |
| 584 | - } | ||
| 585 | - else | ||
| 586 | - { | 579 | + } else { |
| 587 | volume--; | 580 | volume--; |
| 588 | } | 581 | } |
| 589 | 582 | ||
| 590 | - if (volume > now)//加音量 | ||
| 591 | - { | ||
| 592 | - Log.d("setEqu","加音量"+now+":"+volume); | ||
| 593 | - while(now < volume) | ||
| 594 | - { | 583 | + if (volume > now) {//加音量 |
| 584 | + Log.d("setEqu", "加音量" + now + ":" + volume); | ||
| 585 | + while (now < volume) { | ||
| 595 | mAudioManager.adjustStreamVolume( | 586 | mAudioManager.adjustStreamVolume( |
| 596 | AudioManager.STREAM_MUSIC, | 587 | AudioManager.STREAM_MUSIC, |
| 597 | AudioManager.ADJUST_RAISE, | 588 | AudioManager.ADJUST_RAISE, |
| 598 | AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); | 589 | AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); |
| 599 | - now ++; | 590 | + now++; |
| 600 | } | 591 | } |
| 601 | - } | ||
| 602 | - else if(volume < now)//减音量 | ||
| 603 | - { | ||
| 604 | - Log.d("setEqu","减音量"+now+":"+volume); | ||
| 605 | - while(now > volume) | ||
| 606 | - { | 592 | + } else if (volume < now) {//减音量 |
| 593 | + Log.d("setEqu", "减音量" + now + ":" + volume); | ||
| 594 | + while (now > volume) { | ||
| 607 | mAudioManager.adjustStreamVolume( | 595 | mAudioManager.adjustStreamVolume( |
| 608 | AudioManager.STREAM_MUSIC, | 596 | AudioManager.STREAM_MUSIC, |
| 609 | AudioManager.ADJUST_LOWER, | 597 | AudioManager.ADJUST_LOWER, |
| 610 | AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); | 598 | AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); |
| 611 | - now --; | 599 | + now--; |
| 612 | } | 600 | } |
| 613 | } | 601 | } |
| 614 | 602 | ||
| @@ -622,6 +610,8 @@ public class SocketService1 extends BaseService { | @@ -622,6 +610,8 @@ public class SocketService1 extends BaseService { | ||
| 622 | } | 610 | } |
| 623 | 611 | ||
| 624 | public void onServiceDisconnected(ComponentName className) { | 612 | public void onServiceDisconnected(ComponentName className) { |
| 625 | - }; | 613 | + } |
| 614 | + | ||
| 615 | + ; | ||
| 626 | }; | 616 | }; |
| 627 | } | 617 | } |
Please
register
or
login
to post a comment