ソースを参照

[WallPadMain]
1.거동 수상자 관련 메인 시나리오 정리 적용

jglee 2 年 前
コミット
8a53d76737

+ 121 - 2
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/MainActivity.java

@@ -2722,7 +2722,7 @@ public class MainActivity extends WpadActivity {
                         case Common.BR_MAIN_NOTI.ACCEPT_RECORDING:
                             int nEmerState = intent.getIntExtra("EMERGENCY_STATE", -1);
                             //여기서 거동 수상자 녹화 시작 여부 확인
-                            Common.bWallPadRecoder = true;
+                            Common.bRecordStatus = true;
 
                             boolean bFromCall = intent.getBooleanExtra("FROMCALL", false);
 
@@ -2735,7 +2735,9 @@ public class MainActivity extends WpadActivity {
                         case Common.BR_MAIN_NOTI.STOP_RECORDING:
                             // yjyoon. 거동수상자 녹화중지 시 상태값 변경.
                             Log.v("yjyoon", "Common.BR_MAIN_NOTI.STOP_RECORDING     Common.bWallPadRecoder = false");
-                            Common.bWallPadRecoder = false;
+                            //Common.bWallPadRecoder = false;
+                            Common.bRecordStatus = false;
+                            mediaStopRecord();
                             break;
 
                         default:
@@ -3605,6 +3607,8 @@ public class MainActivity extends WpadActivity {
 
             registerMainActivityBR();
 
+            registerStrangeRecordBR();
+
 		} catch (RuntimeException re) {
             LogUtil.errorLogInfo("", TAG, re);
         }
@@ -3619,6 +3623,8 @@ public class MainActivity extends WpadActivity {
             unregisterReceiver(mWallPadAlertBR);
             unregisterReceiver(mWallPadNotifyBR);
             unregisterReceiver(MainActivityBroadcastReceiver);
+            //거동수상자 관련 리시버 해제
+            unregisterReceiver(StrangeRecordBroadcastReceiver);
         } catch (RuntimeException re) {
             LogUtil.errorLogInfo("", TAG, re);
         }
@@ -10055,5 +10061,118 @@ public class MainActivity extends WpadActivity {
     }
 
 
+    /**
+     * 거동 수상자 녹화 중지(MainActivity -> WallPadCall)
+     */
+    private void stopStrangerRecord() {
+        try {
+            Log.d(TAG, "[stopStrangerRecord] bRecordStatus [" + Common.bRecordStatus + "]");
+            if (Common.bRecordStatus) {
+                Common.bRecordStatus = false;
+
+                // yjyoon. 녹화 중지 브로드캐스트
+                Intent iIntent = new Intent();
+                iIntent.setAction(Common.BR_REQUEST_RECORD_STOP);
+                iIntent.putExtra(define.NOTIBR_KIND, 1);
+                getApplicationContext().sendBroadcast(iIntent);
+
+                mediaStopRecord();
+            }
+        } catch (RuntimeException re) {
+            LogUtil.errorLogInfo("", TAG, re);
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] stopStrangerRecord(boolean bSave)");
+            //e.printStackTrace();
+            LogUtil.errorLogInfo("", TAG, e);
+        }
+    }
+
+    /**
+     * 거동 수상자 연속 녹화 방지(10초간 막음)
+     */
+    private void RecordDelayOn()
+    {
+        try {
+            Log.d(TAG, "[RecordDelay]");
+            Common.bRecordDelay = true;
+            Message msg = recordDelayHandler.obtainMessage();
+            recordDelayHandler.sendMessageDelayed(msg, 10 * 1000); // 녹화 종료 후 10초 동안 녹화를 막는다.
+        }
+        catch (Exception e)
+        {
+
+        }
+    }
+
+
+    /**
+     * 거동 수상자 녹화 중지 관련 내부 변수 처리
+     */
+    private void mediaStopRecord() {
+        try {
+            Log.d(TAG, "[mediaStopRecord]");
+            RecordDelayOn();
+            Common.bRecordStatus = false; // 녹화 종료
+        } catch (RuntimeException re) {
+            LogUtil.errorLogInfo("", TAG, re);
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] mediaStopRecord()");
+            //e.printStackTrace();
+            LogUtil.errorLogInfo("", TAG, e);
+        }
+    }
+
+
+    /**
+     * 거동 수상자 역속 녹화를 막기 위한 Handler
+     */
+    Handler recordDelayHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            Common.bRecordDelay = false;
+        }
+    };
+
+
+    /**
+     * 거동 수상자 관련 BR 등록
+     */
+    private void registerStrangeRecordBR() {
+        try {
+            IntentFilter filter = new IntentFilter();
+            filter.addAction(Common.BR_RECORD_EXCEPTION);
+            filter.addAction(Common.BR_RECORD_STOP);
+            filter.addAction(Common.BR_RECORD_DELAY);
+            mContext.registerReceiver(StrangeRecordBroadcastReceiver, filter);
+        } catch (RuntimeException re) {
+            LogUtil.errorLogInfo("", TAG, re);
+        }
+        catch (Exception e) {
+            Log.e(TAG, "[Exception] registerMainActivityBR()");
+            LogUtil.errorLogInfo("", TAG, e);
+        }
+    }
+
+
+    /**
+     * 거동 수상자 관련 BR
+     */
+    BroadcastReceiver StrangeRecordBroadcastReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if(intent.getAction().equals(Common.BR_RECORD_EXCEPTION))
+            {
+                Common.bRecordStatus = false;
+            }
+            else if(intent.getAction().equals(Common.BR_RECORD_STOP))
+            {
+                stopStrangerRecord();
+            }
+            else if(intent.getAction().equals(Common.BR_RECORD_DELAY))
+            {
+                RecordDelayOn();
+            }
+        }
+    };
 }
 

+ 12 - 1
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/declare/Common.java

@@ -26,7 +26,15 @@ public final class Common {
 
     public static boolean bWallPadCallLive = false;
 
-    public static boolean bWallPadRecoder = false;
+    /***
+     * 거동 수상자 녹화 상태 확인 변수
+     */
+    public static boolean bRecordStatus = false;
+
+    /**
+     * 거동 수상자 연속 녹화 방지 변수
+     */
+    public static boolean bRecordDelay = false;
 
     public static int CurrentBoardType = BOARD_TYPE.V40_IGW300_NOUGAT;
 
@@ -259,6 +267,9 @@ public final class Common {
     public static final String BR_ACK_WALLPADCALL_LIVE      = "kr.co.icontrols.wallpad.BR_ACK_WALLPADCALL_LIVE";
     public static final String PID_WALLPADCALL              = "PID_WALLPADCALL";
 	public static final String BR_REQUEST_RECORD_STOP       = "kr.co.icontrols.wallpad.BR_RECORDSTOP"; // yjyoon. 20220705 거동수상자 녹화 중지
+    public static final String BR_RECORD_DELAY              = "StrangeDelayOn"; // jglee. 20220706 거동수상자 Delay(내부사용)
+    public static final String BR_RECORD_STOP               = "StrangeRecordStop"; // jglee. 20220706 거동수상자 Stop(내부사용)
+    public static final String BR_RECORD_EXCEPTION          = "StrangeRecordStopException"; // jglee. 20220706 거동수상자 Exception
 
     // 거실에너지미터 연동
     public static byte LIVINGEM_CTRL_NORMAL = (byte) 0x00;

+ 25 - 8
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/util/iMapServer.java

@@ -984,33 +984,51 @@ public class iMapServer extends Service {
                         case define.NOTIFY_SMART_DCAM_DETECT:
                             // 스마트현관카메라 거동수상자 발생
 //                            Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
-                            Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
+                            Log.i(TAG, "jglee - [mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
                             if (!bWallPadCallLive && !bBlockFrontCall) {
                                 if (getStrangerRecordingManagerSetting()) {
                                     if (getStrangerRecordingUserSetting()) {
                                         Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
+                                        //거동 수상자 감지 또는 딜레인 경우 처리
+                                        if(Common.bRecordDelay || Common.bRecordStatus)
+                                        {
+                                            ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
+                                            ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
+                                            Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording is DelayTime ");
+                                            return;
+                                        }
+
                                         Intent Newintent = new Intent();
                                         Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
                                         Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
                                         Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
                                         getApplicationContext().sendBroadcast(Newintent);
+                                        Log.d(TAG, "Strange Recording Start");
                                     }
                                     else {
                                         ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
                                         ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
-                                        Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
+                                        Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
                                     }
                                 }
                                 else {
                                     ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
                                     ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
-                                    Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
+                                    Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
                                 }
                             }
                             else {
                                 ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
                                 ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
-                                Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
+                                //MOIP 통화 중, 거동 수상자 신호가 들어오는 경우 중복 신호 방지
+                                if(Common.bWallPadCallLive)
+                                {
+                                    Intent Newintent = new Intent();
+                                    Newintent.setAction("StrangeDelayOn");
+                                    getApplicationContext().sendBroadcast(Newintent);
+                                    Log.w(TAG, "jglee - StrangeRecord Delay by Call");
+                                }
+                                Log.w(TAG, "jglee - [mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
                             }
                             break;
 
@@ -2377,12 +2395,12 @@ public class iMapServer extends Service {
                                 LogUtil.errorLogInfo("", TAG, e);
                             }
                         }
-                        else if(Common.bWallPadRecoder && bWallPadCallLive)
+                        else if(Common.bRecordStatus)
                         {
                             //여기서 거동 수상자 확인이 필요함
                             //녹화 여부 확인 후, 거동 수상자 녹화 중지 BR을 전송
                             // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
-                            Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + Common.bWallPadRecoder + "]");
+                            Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + Common.bRecordStatus + "]");
 
                             bBlockFrontCall = true;
                             handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
@@ -2391,8 +2409,7 @@ public class iMapServer extends Service {
 
                             // yjyoon. 녹화 중지 브로드캐스트
                             Intent iIntent = new Intent();
-                            iIntent.setAction(Common.BR_REQUEST_RECORD_STOP);
-                            iIntent.putExtra(define.NOTIBR_KIND, 1);
+                            iIntent.setAction(Common.BR_RECORD_STOP);
                             getApplicationContext().sendBroadcast(iIntent);
 
                             try {