package kr.co.icontrols.wallpadmain.util; import java.util.List; import kr.co.icontrols.gledeviceinterface.jni; import kr.co.icontrols.wallpadmain.declare.Common; import kr.co.icontrols.wallpadmain.declare.ID; import kr.co.icontrols.wallpadsupport.Version; import com.artncore.WallPadDataMgr.WallpadDeviceSet; import com.artncore.WallPadDataMgr.WallpadStatusData; import com.artncore.deviceinterface.WallPadInterface; import com.artncore.wallpadapi.DLockAPI; import com.artncore.wallpadapi.DLockAPI.DOORSTATUS; import com.artncore.wallpadapi.FP_DlockAPI; import com.artncore.wallpadapi.IGW200dAPI; import com.artncore.wallpadapi.IGW300API; import com.artncore.wallpadapi.WallPadAPI; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.KeyEvent; import com.util.LogUtil; public class IGW300 { private Context mContext = null; private String TAG = "IGW300"; private IGW300API mIGW300API = null; private WallPadAPI mWallPadAPI = null; private IGW300API.Data mIGW300API_Data = null; protected DLockAPI mDLockAPI = null; private DLockAPI doorLockAPI = null; private FP_DlockAPI FPdoorLockAPI = null; public IGW300(Context context , WallPadAPI wapi) { mContext = context; mWallPadAPI = wapi; initIGW300(); registerIGW300InterfaceBR(); getResidentSafetyCheckSetting(); } public void registerIGW300InterfaceBR() { Log.i(TAG, "[registerIGW300InterfaceBR] ========== START =========="); IntentFilter filter = new IntentFilter(); filter.addAction(Common.BR_IGW200FILTER ); filter.addAction(Common.BR_EMER_LED_CONTROL ); filter.addAction(IGW300API.SENSOR_BR_NAME); filter.addAction(Common.BR_CALLED_CID_ACK); mContext.registerReceiver(IGW300InterfaceBR, filter); Log.i(TAG, "[registerIGW300InterfaceBR] ========== END =========="); } private void checkSensor() { if (mIGW300API == null) return; if (mIGW300API_Data == null) return; if (Common.GetSensorSampleMode(mContext)) { // 영업샘플 모드 이면 처리하지 않도록 한다 return; } WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext); int nAlarmMode = mWallpadStatusData.GetAlarmStatus(); mWallpadStatusData.closeDB(); WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext); int StatusValLadder = mWallpadDeviceSet.GetDeviceSetted("피난사다리"); mWallpadDeviceSet.closeDB(); Log.d(TAG , "[checkSensor] nAlarmMode = " + nAlarmMode); // 외출이나 재택모드 인 경우 동체와 마그네틱 센서를 감지하도록 한다 // 재택모드인 경우 알람을 바로 발생시키도록 하고... if (nAlarmMode == WallpadStatusData.GUARD_OUT || nAlarmMode == WallpadStatusData.GUARD_IN) { Log.d(TAG , "[checkSensor] GUARD_OUT or GUARD_IN"); // 동체 if (mIGW300API_Data.senIn.In_Motion) { setSendEventBR(WallPadInterface.EVT_SENSOR_MOTIONIN); } if (mIGW300API_Data.senIn.Out_Motion) { setSendEventBR(WallPadInterface.EVT_SENSOR_MOTIONOUT); } // 마그네틱 if (mIGW300API_Data.senIn.Magnetic) { setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0); } } else { Log.d(TAG , "[checkSensor] nAlarmMode is not set!!!"); // 정전화면 시험을 위한 임시 코드 } // APU 감지가 되면 월패드 비상등을 켜도록 한다. if (mIGW300API_Data.senIn.APU) { // 월패드 비상등을 켠다. ( 상태를 저장하여 월패드의 화면에 비상등이 표시되면 동기화 시키도록 한다. 무드등으로 쓰는 경우) // 월패드에 비상등이 달려있지 않고 일체형 조명 제어기를 제어를 하기도 한다. 일체형 조명제어기의 비상전원이 공급되는 경우 ( 설정된 조명제어기를 켜고 끄도록 한다. ) if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) { WallPadInterface mWallPadInterface = new WallPadInterface(); mWallPadInterface.DoControl(WallPadInterface.IOCTL_MOOD_BACKLIGHT_SET, 255); } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) { setSendEventBR(WallPadInterface.EVT_BLACKOUT_OCCURRED); } } else { // 월패드 비상등을 끈다. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) { WallPadInterface mWallPadInterface = new WallPadInterface(); mWallPadInterface.DoControl(WallPadInterface.IOCTL_MOOD_BACKLIGHT_SET, 0); } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) { setSendEventBR(WallPadInterface.EVT_BLACKOUT_RELEASED); } } // 피난사다리 우리집 if (StatusValLadder == WallpadDeviceSet.DEV_DATA_ENABLE) { if (mIGW300API_Data.senIn.EVAC_Home) { if (nAlarmMode != WallpadStatusData.ALARM_ARISE && nAlarmMode != WallpadStatusData.ALARM_STOP ) sendLadderEmergencyBR("ladder_Open"); } // 피난사다리 윗집 - 우리집과 윗집 피난사다리 구분하여 처리하도록한다. if (mIGW300API_Data.senIn.EVAC_UP) { if (nAlarmMode != WallpadStatusData.ALARM_ARISE && nAlarmMode != WallpadStatusData.ALARM_STOP ) sendLadderEmergencyBR("upladder_Open"); } } } private int setSendEventBR(int code) { try { KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code); Intent intent = new Intent("EVENT_DEVICE_CONTROL", null); intent.putExtra(Intent.EXTRA_KEY_EVENT, event); intent.putExtra("keycode", code); mContext.sendBroadcast(intent); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return -100; } catch (Exception e) { Log.e(TAG, "[Exception] setSendEventBR(int code) code = " + code); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return -100; } return 0; } private void sendLadderEmergencyBR(String detailOption) { int base = 7000; int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41}; int Menu_Start_Option = 1; WallpadStatusData wdb = new WallpadStatusData(mContext); int AlarmStatus = wdb.GetAlarmStatus(); wdb.closeDB(); boolean MgrAppRun = false; final String packageNameMgr = "com.artncore.managersetting"; MgrAppRun = getForegroundAPP().equals(packageNameMgr); if (MgrAppRun) return; if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) return; WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext); int StatusVal = mWallpadDeviceSet.GetDeviceSetted("피난사다리"); String pentHo = mWallpadDeviceSet.getPentHouseHoEscapeLadder(); mWallpadDeviceSet.closeDB(); Log.d(TAG, "[sendLadderEmergencyBR] pentHo [" + pentHo + "]"); if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) { Common.SendAppFinishReqBR(mContext); Intent newintent = new Intent(Intent.ACTION_MAIN); newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION newintent.putExtra("MENU_DETAIL_INFO", detailOption); newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity")); newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(newintent); } } protected String getForegroundAPP() { try { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List taskInfo = am.getRunningTasks(1); ComponentName topActivity=taskInfo.get(0).topActivity; String str=topActivity.getPackageName(); return str; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return " "; } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return " "; } } private WallPadEmerButton mWallPadEmerButton = null; private boolean bMuticall_Front_Accept = false; private boolean bMulticall_PSTN_Accept = false; private boolean bPSTN_Connected = false; private boolean bMulticall_PSTN_Hold = false; private boolean bSubphone_Connected = false; BroadcastReceiver IGW300InterfaceBR = new BroadcastReceiver() { private boolean bFirst = true; @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "[IGW300InterfaceBR] intent [" + intent + "]"); String strActionName = intent.getAction(); if (strActionName.equals(IGW300API.SENSOR_BR_NAME)) { updateDeviceStatus(false); checkSensor(); } else if (strActionName.equals(Common.BR_CALLED_CID_ACK)) { Log.d( TAG , "[IGW300InterfaceBR] BR_CALLED_CID_ACK"); } else if (strActionName.equals(Common.BR_IGW200FILTER)) { int kind = intent.getIntExtra("KIND",0); Log.i(TAG, "[IGW300InterfaceBR] strActionName : " + Common.BR_IGW200FILTER + ", kind : " + kind); switch (kind) { case Common.IGW200_DOOR_MONITERING : ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false); ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true); break; case Common.IGW200_DOOR_CONNECT: bMuticall_Front_Accept = false; bSubphone_Connected = false; ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false); changeCallPath(IGW200dAPI.TEL_PATH.WPAD_DOOR); break; case Common.IGW200_DOOR_SUBPHONE_CONNECT: bMuticall_Front_Accept = false; bSubphone_Connected = true; ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false); changeCallPath(IGW200dAPI.TEL_PATH.SUB_DOOR); break; case Common.IGW200_DOOR_CLOSE: if (!bMuticall_Front_Accept) { if (!bPSTN_Connected) { changeCallPath(IGW200dAPI.TEL_PATH.OFF); } ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, false); ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false); } bSubphone_Connected = false; break; case Common.IGW200_PSTN_CONNECT: bPSTN_Connected = true; bMulticall_PSTN_Hold = false; bSubphone_Connected = false; changeCallPath(IGW200dAPI.TEL_PATH.WPAD_TEL); break; case Common.IGW200_PSTN_CLOSE: Log.d( TAG , "[IGW300InterfaceBR] IGW300_PSTN_CLOSE, bMulticall_PSTN_Hold : " + bMulticall_PSTN_Hold); if (!bMulticall_PSTN_Hold) { bPSTN_Connected = false; changeCallPath(IGW200dAPI.TEL_PATH.OFF); } else { bMulticall_PSTN_Hold = false; } bSubphone_Connected = false; break; case Common.IGW200_MOIP_SUBPHONE_CONNECT: bSubphone_Connected = true; changeCallPath(IGW200dAPI.TEL_PATH.MOIP_SUB); break; case Common.IGW200_MOIP_CLOSE: bSubphone_Connected = false; changeCallPath(IGW200dAPI.TEL_PATH.OFF); ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false); break; case Common.IGW200_VIDEO_FRONT: if (!bSubphone_Connected) ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false); break; case Common.IGW200_VIDEO_LOBBY: if (!bSubphone_Connected) ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, true); break; case Common.MULTICALL_DOOR_ACCEPT : bMuticall_Front_Accept = true; if (bPSTN_Connected) { changeCallPath(IGW200dAPI.TEL_PATH.OFF); bPSTN_Connected = false; } break; case Common.MULTICALL_PSTN_ACCEPT : bMulticall_PSTN_Accept = true; break; case Common.MULTICALL_HOLD_DOOR_ACCEPT: bMuticall_Front_Accept = true; bMulticall_PSTN_Hold = true; break; // case Common.IGW200_EMER_ACK: // mIGW300API.BathEmerAckRelase(); // mSensorCheckHandler.sendEmptyMessageDelayed(0, 5000); // break; case Common.IGW200_SENSOR_CHECK: Log.d(TAG, "[IGW300InterfaceBR] Common.IGW200_SENSOR_CHECK " ); mSensorCheckHandler.sendEmptyMessageDelayed(0, 500); mSensorCheckHandler.sendEmptyMessageDelayed(1, 600); break; } } else if (strActionName.equals(Common.BR_EMER_LED_CONTROL)) { int kind = intent.getIntExtra("KIND",0); Log.d( TAG , "[IGW300InterfaceBR] Common.BR_EMER_LED_CONTROL, kind : " + kind); if (kind == 1) { if (mWallPadEmerButton == null) { mWallPadEmerButton = new WallPadEmerButton(); mWallPadEmerButton.start(); } } else { if (mWallPadEmerButton != null) { mWallPadEmerButton.Exit(); try{Thread.sleep(100);} catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e){ LogUtil.errorLogInfo("", TAG, e); } mWallPadEmerButton = null; } } } } }; private void initIGW300() { mIGW300API = mWallPadAPI.Get_IGW300Controller(); mDLockAPI = mWallPadAPI.Get_DLockController(); doorLockAPI = mWallPadAPI.Get_DLockController(); FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController(); if (mIGW300API == null) { Common.DebugLog("mIGW300API == null"); } } public int ctrlDeviceIO(byte kind, boolean OnOff) { try { //DebugLogOutput("[ctrlDeviceIO] - Start (" + kind + ", " + OnOff + ")"); Log.d(TAG, "[ctrlDeviceIO] kind :" + kind + " , OnOff :" + OnOff ); if (mIGW300API == null) { Log.e(TAG, "[ctrlDeviceIO] - mIGW300API unload !!!"); return -1; } int ret = mIGW300API.ControlOutput(kind, OnOff); if (ret < 0) { Log.e(TAG, "[ctrlDeviceIO] - mIGW300API.ControlOutput() ret = " + ret + " / ErrorCode = " + mIGW300API.ErrorCode.ErrStr()); return -2; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return -102; }catch(Exception e) { Log.e(TAG, "[ctrlDeviceIO] - [Exception Error] mIGW300API.ControlOutput()"); Log.e(TAG, "[ctrlDeviceIO] - " + e.toString()); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return -102; } //DebugLogOutput("[ctrlDeviceIO] - OK"); return 0; } /** * 통화체널 설정을 변경한다. * * @param ChangePath - (int) 변경할 체널패스 ( {@link IGW200dAPI.TEL_PATH} ) * @return (int) - >=0 : 성공, <0 : 실패 */ public int changeCallPath(byte ChangePath) { try { if (mIGW300API == null) { Log.e(TAG, "[changeCallPath] - mIGW200dAPI unload !!!"); return -1; } try { Log.e(TAG, "[changeCallPath] - -----------------1------ !!!"); int ret = mIGW300API.ControlTelPath(ChangePath); if (ret < 0) { Log.e(TAG, "[changeCallPath] - mIGW300API.ControlTelPath(" + ChangePath + ") ret = " + ret + " / ErrorCode = " + mIGW300API.ErrorCode.ErrStr()); return -2; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return -102; }catch(Exception e) { Log.e(TAG, "[changeCallPath] - [Exception Error] mIGW300API.ControlTelPath()"); Log.e(TAG, "[changeCallPath] - " + e.toString()); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return -102; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[changeCallPath] - " + e.toString()); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return 0; } /** * 제어기 상태를 가져온다. * * @param real - (boolean) true : 실시간 , false : 가장최근 * @return (int) - >=0 : 성공, <0 : 실패 */ private int updateDeviceStatus(boolean real) { // 1. Api Load Check if (mIGW300API == null) { Log.e(TAG, "[updateDeviceStatus] - mIGW200dAPI unload !!!"); return -1; } // 2. Reflash try { int ret = mIGW300API.Refresh(real); if (ret < 0) { Log.e(TAG, "[updateDeviceStatus] getState - ret (" + ret + ") ErrorCode = " + mIGW300API.ErrorCode.ErrStr()); return -2; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return -102; }catch(Exception e) { Log.e(TAG, "[updateDeviceStatus] - [Exception Error] mIGW300API.Refresh(" + real + ")"); Log.e(TAG, "[updateDeviceStatus] - " + e.toString()); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return -102; } // 3. EMData Copy mIGW300API_Data = mIGW300API.data; // 4. Debug msg Common.DebugLog("---------------------------------------"); Common.DebugLog("[updateDeviceStatus]"); Common.DebugLog("---------------------------------------"); Common.DebugLog("[senIn]"); Common.DebugLog("In_Motion : " + mIGW300API_Data.senIn.In_Motion); Common.DebugLog("Out_Motion : " + mIGW300API_Data.senIn.Out_Motion); Common.DebugLog("Magnetic : " + mIGW300API_Data.senIn.Magnetic); Common.DebugLog("APU : " + mIGW300API_Data.senIn.APU); Common.DebugLog("EVAC_Home : " + mIGW300API_Data.senIn.EVAC_Home); Common.DebugLog("EVAC_UP : " + mIGW300API_Data.senIn.EVAC_UP); Common.DebugLog("---------------------------------------"); Common.DebugLog("[updateDeviceStatus] - OK"); // // 테스트 코드 // if( mIGW200dAPI_Data.senIn.Magnetic == true ) // { // callEmerAPK( mContext , ID_OLD.SubEmergency.BREAKIN_ALARM , 1 , "IO_Margnetic"); // } if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) { if (mIGW300API_Data.senIn.Magnetic) sendDoorOpenBR(); } return 0; } /** * Device_BathEmerAckRelase * * @return (int) - >=0 : 성공, <0 : 실패 */ // private int Device_BathEmerAckRelase() { // if (mIGW300API == null) { // Log.e(TAG, "[Device_BathEmerAckRelase] - mIGW200dAPI unload !!!"); // return -1; // } // // try { // int ret = mIGW300API.BathEmerAckRelase(); // if (ret < 0) { // Log.e(TAG, "[Device_BathEmerAckRelase] - mIGW200dAPI.BathEmerAckRelase() ret = " + ret + " / ErrorCode = " + mIGW300API.ErrorCode.ErrStr()); // return -2; // } // } catch (RuntimeException re) { // LogUtil.errorLogInfo("", TAG, re); // } // catch (Exception e) { // Log.e(TAG, "[Device_BathEmerAckRelase] - [Exception Error] mIGW200dAPI.BathEmerAckRelase()"); // Log.e(TAG, "[Device_BathEmerAckRelase] - " + e.toString()); // e.printStackTrace(); // return -102; // } // return 0; // } // input param // int nScreen 알람 종류 // int startOption // 발생이냐 1 , 정지냐 2 // int detailOption // 상세 알람 내역 private void callEmerAPK(Context context, int nScreenID , int startOption, String detailInfo ) { try { // DB 체크 해서 띄우 도록 한다. int [] m_EmerMenuList = new int[4]; m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM; m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM; m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM; m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM; Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList); // KEY : MENU_ID_LIST intent.putExtra(Common.MENU_START_ID, nScreenID); // KEY : MENU_START_ID intent.putExtra(Common.MENU_START_OPTION, startOption); // KEY : MENU_START_OPTION intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo); intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY )); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, e.toString()); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } // 비상 발생시 월패드 비상버튼 점멸 처리 쓰레드 // class WallPadEmerButton extends Thread { private jni mGleInterface = null; private boolean m_LedOn = false; private boolean m_ThreadExit = false; public WallPadEmerButton() { try { mGleInterface = new jni(); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e("Exception", "[ExceptionError] - onCreate->mGleInterface Create : " + e); } } public void run() { try { Common.DebugLog("WallPadEmerButton------ Thread Run"); do { if (mGleInterface != null) { if (m_LedOn == false) { mGleInterface.setEmerLedOnOff(true); m_LedOn = true; } else { mGleInterface.setEmerLedOnOff(false); m_LedOn = false; } } for (int i = 0 ; i < 10 ; i++) { try{Thread.sleep(50);} catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e){ LogUtil.errorLogInfo("", TAG, e); } if (m_ThreadExit && mGleInterface!=null) { mGleInterface.setEmerLedOnOff(false); return; } } } while (true); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return; } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); e.getStackTrace(); return; } } private void Exit() { m_ThreadExit = true; } } public boolean checkSensorforOutmode() { updateDeviceStatus(true); IGW300API.Data mData = mIGW300API.data; boolean bInMotionSensor = mData.senIn.In_Motion; boolean bOutMotionSensor = mData.senIn.Out_Motion; boolean bMagneticSensor = mData.senIn.Magnetic; Log.d(TAG, "[checkSensorforOutmode] bInMotionSensor [" + bInMotionSensor + "], bOutMotionSensor [" + bOutMotionSensor + "], bMagneticSensor [" + bMagneticSensor + "]"); // 도어락 상태 추가 체크 byte DoorLockState = DOORSTATUS.Close ; try { WallpadDeviceSet devSet = new WallpadDeviceSet(mContext); String[] GetValue = devSet.GetSettingData("디지털도어락"); devSet.closeDB(); if (GetValue == null) { Log.e("Common", "GetSettingData(디지털도어락) is null"); return false; } Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]); if( GetValue[1].indexOf("유선") > 0 ) { Log.d("Common", "Normal Line Doorlock"); if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { doorLockAPI = mWallPadAPI.Get_DLockController(); doorLockAPI.Refresh(true); DoorLockState = doorLockAPI.data.DoorStatus; Log.d(TAG, "Normal Line DoorLock State : ==> " + DoorLockState ); } } else if(GetValue[1].indexOf("지문인식") > 0) { //FPdoorLockAPI if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController(); FPdoorLockAPI.Refresh(true); DoorLockState = FPdoorLockAPI.data.DoorStatus; Log.d(TAG, "FingerPrint DoorLock State : ==> " + DoorLockState ); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } // 현산향이 무선 도어락이 들어가면서 추가되어야 함 if (Common.isWirelessDoorlock(mContext)) { DoorLockState = DOORSTATUS.Close; } int[] SensorInfoDB; SensorInfoDB = Common.GetInSensorUseOfNotFromDB(mContext); // 동체감지기 사용여부 확인 Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length); if (SensorInfoDB[0] == 0) { // 내부동체가 사용함이면 상태 검사 bInMotionSensor = false; } if (SensorInfoDB[1] == 0) { // 외부동체가 사용함이면 상태 검사 bOutMotionSensor = false; } if (bInMotionSensor == false && bOutMotionSensor == false && bMagneticSensor == false && DoorLockState == DOORSTATUS.Close) { return true; } return false; } public boolean checkSensorforInmode() { updateDeviceStatus(true); IGW300API.Data mData = mIGW300API.data; boolean bMagneticSensor = mData.senIn.Magnetic; Log.d(TAG, "[checkSensorforInmode] bMagneticSensor [" + bMagneticSensor + "]"); // 도어락 상태 추가 체크 byte DoorLockState = DOORSTATUS.Close ; /*try { if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { mDLockAPI = mWallPadAPI.Get_DLockController(); mDLockAPI.Refresh(true); DoorLockState = mDLockAPI.data.DoorStatus; Log.d(TAG, "[checkSensorforInmode] DoorLockState [" + DoorLockState + "]"); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { e.printStackTrace(); }*/ try { WallpadDeviceSet devSet = new WallpadDeviceSet(mContext); String[] GetValue = devSet.GetSettingData("디지털도어락"); devSet.closeDB(); if (GetValue == null) { Log.e("Common", "GetSettingData(디지털도어락) is null"); return false; } Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]); if( GetValue[1].indexOf("유선") > 0 ) { Log.d("Common", "Normal Line Doorlock"); if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { doorLockAPI = mWallPadAPI.Get_DLockController(); doorLockAPI.Refresh(true); DoorLockState = doorLockAPI.data.DoorStatus; Log.d(TAG, "Normal Line DoorLock State : ==> " + DoorLockState ); } } else if(GetValue[1].indexOf("지문인식") > 0) { //FPdoorLockAPI if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController(); FPdoorLockAPI.Refresh(true); DoorLockState = FPdoorLockAPI.data.DoorStatus; Log.d(TAG, "FingerPrint DoorLock State : ==> " + DoorLockState ); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } // 현산향이 무선 도어락이 들어가면서 추가되어야 함 if (Common.isWirelessDoorlock(mContext)) { DoorLockState = DOORSTATUS.Close; } if (bMagneticSensor == false && DoorLockState == DOORSTATUS.Close) { return true; } return false; } private Handler mSensorCheckHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0) { Log.d(TAG, "[mSensorCheckHandler] "); //얻어오기 checkSensor(); } else if (msg.what == 1) { checkGLEDoorlock(); } } }; private boolean checkGLEDoorlock() { byte DoorLockState = DOORSTATUS.Close ; Log.d(TAG, "[checkGLEDoorlock] ========== START ==========" ); // 현산향이 무선 도어락이 들어가면서 추가되어야 함 if (Common.isWirelessDoorlock(mContext)) { return true; } /*try { if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { mDLockAPI = mWallPadAPI.Get_DLockController(); mDLockAPI.Refresh(true); DoorLockState = mDLockAPI.data.DoorStatus; Log.d(TAG, "[checkGLEDoorlock] DoorLockState [" + DoorLockState + "]"); if (DoorLockState != DOORSTATUS.Close) { setSendEventBR(WallPadInterface.EVT_MAG0); return true; } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { e.printStackTrace(); }*/ try { WallpadDeviceSet devSet = new WallpadDeviceSet(mContext); String[] GetValue = devSet.GetSettingData("디지털도어락"); devSet.closeDB(); if (GetValue == null) { Log.e("Common", "GetSettingData(디지털도어락) is null"); return false; } Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]); if( GetValue[1].indexOf("유선") > 0 ) { Log.d("Common", "Normal Line Doorlock"); if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { doorLockAPI = mWallPadAPI.Get_DLockController(); doorLockAPI.Refresh(true); DoorLockState = doorLockAPI.data.DoorStatus; Log.d(TAG, "[checkGLEDoorlock] DoorLockState [" + DoorLockState + "]"); if (DoorLockState != DOORSTATUS.Close) { setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0); return true; } } } else if(GetValue[1].indexOf("지문인식") > 0) { //FPdoorLockAPI if (mWallPadAPI != null && mWallPadAPI.Check_Connect()) { FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController(); FPdoorLockAPI.Refresh(true); DoorLockState = FPdoorLockAPI.data.DoorStatus; Log.d(TAG, "[checkGLEDoorlock] DoorLockState [" + DoorLockState + "]"); if (DoorLockState != DOORSTATUS.Close) { setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0); return true; } } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return false; } public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE; private void getResidentSafetyCheckSetting() { try { WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext); nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck(); mWallpadDeviceSet.closeDB(); Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void sendDoorOpenBR() { try { Intent mIntent = new Intent(); mIntent.setAction(Version.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); mIntent.putExtra(Version.NOTIBR_KIND, Version.NOTIFY_DOOR_OPENED); mContext.sendBroadcast(mIntent); } catch (RuntimeException re) { kr.co.icontrols.wallpadsupport.LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] sendDoorOpenBR()"); //e.printStackTrace(); kr.co.icontrols.wallpadsupport.LogUtil.errorLogInfo("", TAG, e); } } }