diff --git a/app/build.gradle b/app/build.gradle index a3107d8..6e61b68 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,8 +22,8 @@ android { minSdkVersion 26 //noinspection ExpiredTargetSdkVersion targetSdkVersion 30 - versionCode 200000012 - versionName "2.0.12" + versionCode 200000022 + versionName "2.0.22" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk.abiFilters 'armeabi-v7a' } diff --git a/app/src/main/java/kr/co/enicom/acs/BaseService.java b/app/src/main/java/kr/co/enicom/acs/BaseService.java index 060662a..a203b6d 100644 --- a/app/src/main/java/kr/co/enicom/acs/BaseService.java +++ b/app/src/main/java/kr/co/enicom/acs/BaseService.java @@ -294,8 +294,8 @@ public class BaseService extends Service { } if(getUTC() - touchTimeLong > GlobalInfo.mInputTimeout) { if (mLastActivity != null) { - //Log.w(TAG, "Input Timeout! Back to Main Activity"); - //mLastActivity.forceTimeoutReturn(); + Log.w(TAG, "Input Timeout! Back to Main Activity"); + mLastActivity.forceTimeoutReturn(); } } @@ -367,18 +367,54 @@ public class BaseService extends Service { } else if(testDebug.equals("3")) { SystemUtil.property_set("sys.rito.test", ""); GlobalInfo.updateHolidayList(); + } else if(testDebug.equals("4")) { + GlobalInfo.mUseDoorControlTimeOuting = 1; + GlobalInfo.mDoorControlTimeStatus = -1; + SystemUtil.property_set("sys.rito.test", ""); + } else if(testDebug.equals("5")) { + GlobalInfo.mUseDoorControlTimeOuting = 0; + GlobalInfo.mDoorControlTimeStatus = 0; + SystemUtil.property_set("sys.rito.test", ""); } //if(MainActivity.INSTANCE != null) { - { + { // 개방 모드 제어 관련 부분 if (GlobalInfo.mUseDoorControlTime == 1) { - if (GlobalInfo.checkIsDoorControlOpenTime()) { + if(GlobalInfo.mIsOnOutingConfirm == 1 && GlobalInfo.mOutingConfirmStartTime > 0) { + if (MainActivity.INSTANCE != null) { + long curTime = SystemClock.uptimeMillis(); + if(curTime - GlobalInfo.mOutingConfirmStartTime >= 10 * 1000) { // 10초 이내 입력 없을 시 컨펌 모드 해제 + GlobalInfo.mIsOnOutingConfirm = 0; + GlobalInfo.mOutingConfirmStartTime = 0; + MainActivity.INSTANCE.clearOnRfidVerifyingProcess(); + MainActivity.INSTANCE.turnToBaseUI(); + } + } + } + + if(GlobalInfo.mIsOnOuting == 1) { + String curTimeStr = GlobalInfo.getCurrentDateString(); + if(GlobalInfo.mOutingDate.length() > 0 && !GlobalInfo.mOutingDate.equals(curTimeStr)) { + GlobalInfo.mIsOnOuting = 0; + GlobalInfo.updateOutingInfo(false); + + if (MainActivity.INSTANCE != null) { + Log.w(TAG, "Call turnToBaseUI here 0"); + MainActivity.INSTANCE.turnToBaseUI(); + } + } + } + + if (GlobalInfo.checkIsDoorControlOpenTime() && !GlobalInfo.checkIsOutingMode()) { long curTime = SystemClock.uptimeMillis(); - if (GlobalInfo.mDoorControlTimeStatus != 1) { + boolean isTimeChanged = GlobalInfo.checkIsDoorControlOpenTimeChanged(); + if (GlobalInfo.mDoorControlTimeStatus != 1 || isTimeChanged) { + Log.w(TAG, "강제 개방 트리거"); //mDoorManager.controlDoor(true, -1); mDoorManager.forceStatusOrder(DOOR_CONTROL_STATUS_OPEN_LOCK); GlobalInfo.mDoorControlSentLastTime = curTime; if (MainActivity.INSTANCE != null) { + //Log.w(TAG, "Call turnToBaseUI here 1"); MainActivity.INSTANCE.turnToBaseUI(); } } @@ -392,6 +428,7 @@ public class BaseService extends Service { //mDoorManager.controlDoor(false, 0); mDoorManager.queueControlOrder(DOOR_CONTROL_STATUS_CLOSE); if (MainActivity.INSTANCE != null) { + //Log.w(TAG, "Call turnToBaseUI here 2"); MainActivity.INSTANCE.turnToBaseUI(); } } @@ -403,6 +440,7 @@ public class BaseService extends Service { mDoorManager.queueControlOrder(DOOR_CONTROL_STATUS_CLOSE); if (MainActivity.INSTANCE != null) { + //Log.w(TAG, "Call turnToBaseUI here 3"); MainActivity.INSTANCE.turnToBaseUI(); } } diff --git a/app/src/main/java/kr/co/enicom/acs/GlobalInfo.java b/app/src/main/java/kr/co/enicom/acs/GlobalInfo.java index 8767ef7..249d4c4 100644 --- a/app/src/main/java/kr/co/enicom/acs/GlobalInfo.java +++ b/app/src/main/java/kr/co/enicom/acs/GlobalInfo.java @@ -12,10 +12,12 @@ import android.os.Environment; import android.util.Log; import java.io.BufferedInputStream; +import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; @@ -29,6 +31,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.Locale; import kr.co.enicom.acs.manage.LogInfo; import kr.co.enicom.acs.system.SystemUtil; @@ -96,6 +99,7 @@ public class GlobalInfo { public static final int DEFAULT_ATTENDANCE_END_TIME = 18 * 60; public static final int DEFAULT_USE_DOOR_CONTROL_TIME = 0; public static final int DEFAULT_USE_DOOR_CONTROL_TIME_HOLIDAY = 0; + public static final int DEFAULT_USE_DOOR_CONTROL_TIME_OUTING = 0; public static final int DEFAULT_DOOR_CONTROL_TIME_START = 9 * 60; public static final int DEFAULT_DOOR_CONTROL_TIME_END = 18 * 60; public static final String DEFAULT_DOOR_CONTROL_TIME_DATA = convertTimeToLonger(convertMinutesToSimpleTime(DEFAULT_DOOR_CONTROL_TIME_START)) + "~" + convertTimeToLonger(convertMinutesToSimpleTime(DEFAULT_DOOR_CONTROL_TIME_END)); @@ -282,12 +286,18 @@ public class GlobalInfo { public static int mDoorControlTimeStart = 9 * 60; // 개방시간 시작 시간(Minute) Default = 09:00 public static int mDoorControlTimeEnd = 18 * 60; //18 * 60; // 개방시간 종료 시간(Minute) Default = 18:00 public static int mUseDoorControlTimeHoliday = 0; // 개방시간 주말 및 휴무일 사용 여부 + public static int mUseDoorControlTimeOuting = 0; // 개방시간 외출/복귀 모드 사용 여부 + public static int mIsOnOuting = 0; // 개방시간 외출중 여부. 0 : 복귀상태, 1 : 외출중상태. mUseDoorControlTimeOuting = 1인 경우만 유효 + public static int mIsOnOutingConfirm = 0; // 외출하기, 복귀하기 버튼 처리 중인지 + public static long mOutingConfirmStartTime = 0; // 외출하기, 복귀하기 버튼 처리 시작 uptimeMillis + public static String mOutingDate = ""; // 외출 시작 일자 public static String mDoorControlTimeData = DEFAULT_DOOR_CONTROL_TIME_DATA; public static ArrayList mHolidayList = null; public static ArrayList mUserList; private static Object mLock = new Object(); public static DoorControlTime[] mDoorControlTimeList = null; + public static DoorControlTime mCurrentDoorControlTime = null; public static void updateHolidayList() { LocalDate today = LocalDate.now(); @@ -365,6 +375,15 @@ public class GlobalInfo { } } + public static String getCurrentDateString() { + SimpleDateFormat dayFormat = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); + Date currentTime = Calendar.getInstance().getTime(); + + String curdate = dayFormat.format(currentTime); + return curdate; + } + + public static int getCurrentMinutesInDay() { Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); @@ -617,7 +636,7 @@ public class GlobalInfo { "auto_forgery integer, auto_mask_wear integer, manager_login_capture_send integer, use_attendance integer, " + "use_door_control_time integer, door_control_time_start integer, door_control_time_end integer, " + "attendance_start_time integer, attendance_end_time integer, use_attendance_auto_mode integer, attendance_auto_time integer, " + - "use_door_control_time_holiday integer, door_control_time_data text" + + "use_door_control_time_holiday integer, door_control_time_data text, use_door_control_time_outing integer" + ")"; try { database.execSQL(sql); @@ -629,7 +648,7 @@ public class GlobalInfo { "auto_forgery, auto_mask_wear, manager_login_capture_send, use_attendance, " + "use_door_control_time, door_control_time_start, door_control_time_end, " + "attendance_start_time, attendance_end_time, use_attendance_auto_mode, attendance_auto_time, " + - "use_door_control_time_holiday, door_control_time_data " + + "use_door_control_time_holiday, door_control_time_data, use_door_control_time_outing " + ") " + "values (0, '', '', 0, 0, %d, " + "%d, %d, %d, %d, %d, %d, " + @@ -639,7 +658,7 @@ public class GlobalInfo { "%d, %d, %d, %d, " + "%d, %d, %d, " + "%d, %d, %d, %d, " + - "%d, '%s'" + + "%d, '%s', %d" + ")", VERIFY_COMBINATION_OR, DEFAULT_VERIFY_PRINTUSERNAME, DEFAULT_VERIFY_POPUPTIME, DEFAULT_LOG_DELETESTATUS , 1, 1, 1, @@ -649,7 +668,7 @@ public class GlobalInfo { DEFAULT_AUTO_FORGERY, DEFAULT_AUTO_MASK_WEAR, DEFAULT_MANAGER_LOGIN_CAPTURE_SEND, DEFAULT_USE_ATTENDANCE, DEFAULT_USE_DOOR_CONTROL_TIME, DEFAULT_DOOR_CONTROL_TIME_START, DEFAULT_DOOR_CONTROL_TIME_END, DEFAULT_ATTENDANCE_START_TIME, DEFAULT_ATTENDANCE_END_TIME, DEFAULT_USE_ATTENDANCE_AUTO_MODE, DEFAULT_ATTENDANCE_AUTO_TIME, - DEFAULT_USE_DOOR_CONTROL_TIME_HOLIDAY, DEFAULT_DOOR_CONTROL_TIME_DATA + DEFAULT_USE_DOOR_CONTROL_TIME_HOLIDAY, DEFAULT_DOOR_CONTROL_TIME_DATA, DEFAULT_USE_DOOR_CONTROL_TIME_OUTING ); database.execSQL(sql); @@ -761,6 +780,14 @@ public class GlobalInfo { } catch (Exception e) { } } + if(!columnExists(database, "settings", "use_door_control_time_outing")) { + columnAppend(database, "settings", "use_door_control_time_outing", "integer"); + sql = String.format("update settings set use_door_control_time_outing = %d where idx = 0", DEFAULT_USE_DOOR_CONTROL_TIME_OUTING); + try { + database.execSQL(sql); + } catch (Exception e) { + } + } if(!columnExists(database, "settings", "attendance_start_time")) { columnAppend(database, "settings", "attendance_start_time", "integer"); @@ -1360,7 +1387,7 @@ public class GlobalInfo { "dcu_watchdog_timeout, verify_log_auto_resend, verify_activate_method, auto_forgery, auto_mask_wear, manager_login_capture_send, use_attendance, " + "use_door_control_time, door_control_time_start, door_control_time_end, " + "attendance_start_time, attendance_end_time, use_attendance_auto_mode, attendance_auto_time, " + - "use_door_control_time_holiday, door_control_time_data " + + "use_door_control_time_holiday, door_control_time_data, use_door_control_time_outing " + " from settings where idx = 0"; try { Cursor cursor = database.rawQuery(sql, null); @@ -1414,6 +1441,8 @@ public class GlobalInfo { GlobalInfo.mUseDoorControlTimeHoliday = cursor.getInt(38); GlobalInfo.mDoorControlTimeData = cursor.getString(39); + GlobalInfo.mUseDoorControlTimeOuting = cursor.getInt(40); + Log.w("RITO", "mAutoForgery : " + GlobalInfo.mAutoForgery); Log.w("RITO", "mAutoMaskWear : " + GlobalInfo.mAutoMaskWear); } @@ -2314,7 +2343,7 @@ public class GlobalInfo { "auto_forgery = %d, auto_mask_wear = %d, manager_login_capture_send = %d, use_attendance = %d, " + "use_door_control_time = %d, door_control_time_start = %d, door_control_time_end = %d, " + "attendance_start_time = %d, attendance_end_time = %d, use_attendance_auto_mode = %d, attendance_auto_time = %d, " + - "use_door_control_time_holiday = %d, door_control_time_data = '%s' " + + "use_door_control_time_holiday = %d, door_control_time_data = '%s', use_door_control_time_outing = %d " + " where idx = 0", GlobalInfo.mDeviceId, GlobalInfo.mDeviceName, GlobalInfo.mVerifyMode, GlobalInfo.mVerifyMethod, GlobalInfo.mVerifyCombination, GlobalInfo.mVerifyPrintUserName, GlobalInfo.mVerifyPopupTime, GlobalInfo.mLogDeleteStatus, GlobalInfo.mLogDeleteTerm, GlobalInfo.mLogDeleteCheckPeriod, GlobalInfo.mLogDeleteCheckPeriodCnt, @@ -2325,7 +2354,7 @@ public class GlobalInfo { GlobalInfo.mAutoForgery, GlobalInfo.mAutoMaskWear, GlobalInfo.mManagerLoginCaptureSend, GlobalInfo.mUseAttendance, GlobalInfo.mUseDoorControlTime, GlobalInfo.mDoorControlTimeStart, GlobalInfo.mDoorControlTimeEnd, GlobalInfo.mAttendanceStartTime, GlobalInfo.mAttendanceEndTime, GlobalInfo.mUseAttendanceAutoMode, GlobalInfo.mAttendanceAutoTimeMinute, - GlobalInfo.mUseDoorControlTimeHoliday, GlobalInfo.mDoorControlTimeData + GlobalInfo.mUseDoorControlTimeHoliday, GlobalInfo.mDoorControlTimeData, GlobalInfo.mUseDoorControlTimeOuting ); try { @@ -2567,6 +2596,44 @@ public class GlobalInfo { return tableCount; } + public static void updateOutingInfo(boolean isOut) { + String saveStr = null; + if(isOut) { + saveStr = "1"; + } else { + saveStr = "0"; + } + String dateStr = getCurrentDateString(); + saveStr += ":"; + saveStr += dateStr; + saveStringInfo("outing.info", saveStr); + GlobalInfo.mOutingDate = dateStr; + } + + public static String readValueFromFile(String filename) { + String _storagePath = Environment.getExternalStorageDirectory().toString(); + String _acsPath = _storagePath + "/ACS"; + String _acsFilePath = _acsPath + "/" + filename; + + File file = new File(_acsFilePath); + BufferedReader reader = null; + try { + reader = new BufferedReader(new FileReader(file)); + // 한 줄만 읽기 + return reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } public static void saveStringInfo(String filename, String data) { String _storagePath = Environment.getExternalStorageDirectory().toString(); String _acsPath = _storagePath + "/ACS"; @@ -2686,6 +2753,55 @@ public class GlobalInfo { return null; } + public static boolean checkIsDoorControlOpenTimeChanged() { + boolean isChanged = false; + if(!checkIsDoorControlOpenTime()) + return false; + + DoorControlTime[] timeList; + synchronized (mLock) { + timeList = mDoorControlTimeList; + } + if(timeList == null || timeList.length == 0) + return false; + + int currentMinutes = getCurrentMinutesInDay(); + for(DoorControlTime info : timeList) { + if(currentMinutes >= info.startTime && currentMinutes < info.endTime) { + if(mCurrentDoorControlTime == null || mCurrentDoorControlTime.startTime != info.startTime || mCurrentDoorControlTime.endTime != info.endTime) { + isChanged = true; + mCurrentDoorControlTime = info; + String changedTime = convertTimeToLonger(convertMinutesToSimpleTime(info.startTime)) + "~" + convertTimeToLonger(convertMinutesToSimpleTime(info.endTime)); + Log.d(TAG, "DoorOpen Time is Changed to [" + changedTime + "]"); + } + + break; + } + } + + return isChanged; + } + + public static boolean checkIsOutingConfirmMode() { + if(mUseDoorControlTimeOuting == 0) + return false; + + if(mIsOnOutingConfirm == 1) + return true; + + return false; + } + + public static boolean checkIsOutingMode() { + if(mUseDoorControlTimeOuting == 0) + return false; + + if(mIsOnOuting == 1) + return true; + + return false; + } + public static boolean checkIsDoorControlOpenTime() { if(mUseDoorControlTime == 0) return false; diff --git a/app/src/main/java/kr/co/enicom/acs/MWMessage.java b/app/src/main/java/kr/co/enicom/acs/MWMessage.java index 60afb8b..a6f58e0 100644 --- a/app/src/main/java/kr/co/enicom/acs/MWMessage.java +++ b/app/src/main/java/kr/co/enicom/acs/MWMessage.java @@ -88,4 +88,6 @@ public class MWMessage { public String yearOfHoliday; public String monthOfHoliday; public String daysOfHoliday; + + public String useDoorControlTimeOuting; } diff --git a/app/src/main/java/kr/co/enicom/acs/MainActivity.java b/app/src/main/java/kr/co/enicom/acs/MainActivity.java index 11895a0..05cd0f9 100644 --- a/app/src/main/java/kr/co/enicom/acs/MainActivity.java +++ b/app/src/main/java/kr/co/enicom/acs/MainActivity.java @@ -18,6 +18,7 @@ import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.SystemClock; +import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Spannable; @@ -62,6 +63,7 @@ import static kr.co.enicom.acs.GlobalInfo.VERIFY_METHOD_VEIN; import static kr.co.enicom.acs.GlobalInfo.VERIFY_METHOD_VEIN_COMB_RFID; import static kr.co.enicom.acs.GlobalInfo.VERIFY_METHOD_VEIN_FACE; import static kr.co.enicom.acs.GlobalInfo.getCurrentMinutesInDay; +import static kr.co.enicom.acs.GlobalInfo.mSerialNumber; import static kr.co.enicom.acs.GlobalInfo.mVerifyCombination; import static kr.co.enicom.acs.GlobalInfo.mVerifyMethod; @@ -81,6 +83,8 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul VerifyPopupManager mPopupManager = null; MediaPlayer mPlayer = null; + public boolean mIsOnUiTransition = false; // turnToBaseUI 블럭 + ServerManager.ServerNotify NOTIFY_HANDLER; public static int POPUP_TYPE_GRANT = 1; @@ -114,6 +118,8 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul private Handler mDelayHandler = new Handler(); private Button mSettingButton = null, mTitleBackButton = null; private Button mWorkinButton = null, mWorkoutButton = null, mAttendanceButton = null; + private Button mOutButton = null, mReturnButton = null; + private CameraSurfaceView mCameraView = null; @@ -680,6 +686,9 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul }.start();*/ } + public void clearOnRfidVerifyingProcess() { + mIsOnRfidVerifyingProcess = false; + } @Override public void onRfidResult(String status, String value) { @@ -687,6 +696,15 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul //if(mMainUiStatus == MAIN_SELECT_VEIN) //return; + // OpenLock 상태인지 체크 후 강제 개방 처리 + if (GlobalInfo.checkIsDoorControlOpenTime() && !GlobalInfo.checkIsOutingMode()) + { + int doorStatus = BaseService.mDCUManager.getReportValues(DCUManager.DCU_REPORT_TYPE_DMON)[0]; + if(doorStatus == GlobalInfo.DOOR_CONTROL_STATUS_CLOSE) { + GlobalInfo.mDoorControlTimeStatus = 0; + } + } + if(mMainUiStatus == RESULT_SUCCESS || mMainUiStatus == RESULT_FAIL) return; @@ -1107,11 +1125,14 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul GlobalInfo.mDeviceStatusNormal = true; - GlobalInfo.initInfo(); GlobalInfo.reloadUserListWithProgress(this); GlobalInfo.updateDoorControlTimeList(); + if(GlobalInfo.mDeviceId.length() > 0) { + version.setText(String.format("[ V%s](ID:%s)", getVersionInfo(this), GlobalInfo.mDeviceId)); + } + //test //GlobalInfo.mVerifyMethod = GlobalInfo.VERIFY_METHOD_FINGER_FACE; //GlobalInfo.mVerifyCombination = VERIFY_COMBINATION_AND; @@ -1280,6 +1301,11 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul @Override public void onClick(View view) { // TODO : click event + + if(GlobalInfo.checkIsOutingConfirmMode()) { + return; + } + mMainUiStatus = -1; if(GlobalInfo.isActivatedMethod(VERIFY_METHOD_VEIN) || GlobalInfo.isActivatedMethod(VERIFY_METHOD_VEIN_FACE)) { GlobalInfo.mVeinWorkMode = GlobalInfo.VEIN_WORK_MODE_NONE; @@ -1386,6 +1412,36 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } }); + + + if(mOutButton == null) + mOutButton = (Button) findViewById(R.id.outbutton) ; + + mOutButton.setOnClickListener(new Button.OnClickListener() { + @Override + public void onClick(View view) + { + GlobalInfo.mOutingConfirmStartTime = SystemClock.uptimeMillis(); + GlobalInfo.mIsOnOutingConfirm = 1; + turnToBaseUI(); + } + }); + + + + if(mReturnButton == null) + mReturnButton = (Button) findViewById(R.id.returnbutton) ; + + mReturnButton.setOnClickListener(new Button.OnClickListener() { + @Override + public void onClick(View view) + { + GlobalInfo.mOutingConfirmStartTime = SystemClock.uptimeMillis(); + GlobalInfo.mIsOnOutingConfirm = 1; + turnToBaseUI(); + } + }); + startService(new Intent(this, BaseService.class)); GlobalInfo.mDoorControlTimeStatus = -1; @@ -1472,6 +1528,8 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } @Override public void run() { + boolean prev_link_status = false; + boolean prev_conn_status = false; mIsAlive = true; while(mIsAlive) { TextView _view = findViewById(R.id.editDateTime); @@ -1491,43 +1549,47 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul if (BaseService.mServerManager != null) { _view = findViewById(R.id.textNetwork); - if (BaseService.mServerManager.checkServerConnection()/* || force*/) { - runOnUiThread(new Runnable() { - @Override - public void run() { + boolean conn_status = BaseService.mServerManager.checkServerConnection(); + if(prev_conn_status != conn_status) { + prev_conn_status = conn_status; + if (conn_status/* || force*/) { + runOnUiThread(new Runnable() { + @Override + public void run() { // TextView _textNetwork = findViewById(R.id.textNetwork); // _textNetwork.setTextColor(Color.parseColor("#3AD531")); // _textNetwork.setText(R.string.main_network_success); - ImageView _imgView = findViewById(R.id.imageViewServerLink); - if (_imgView != null) { - //_imgView.setImageResource(R.drawable.network_icon); - _imgView.setImageResource(R.drawable.main_server_icon_nor); - _imgView.setVisibility(View.VISIBLE); + ImageView _imgView = findViewById(R.id.imageViewServerLink); + if (_imgView != null) { + //_imgView.setImageResource(R.drawable.network_icon); + _imgView.setImageResource(R.drawable.main_server_icon_nor); + _imgView.setVisibility(View.VISIBLE); - //_imgView.setVisibility(View.INVISIBLE); + //_imgView.setVisibility(View.INVISIBLE); + } } - } - }); - } else { + }); + } else { /*_view.setTextColor(Color.RED); _view.setText("네트워크 오류");*/ - runOnUiThread(new Runnable() { - @Override - public void run() { + runOnUiThread(new Runnable() { + @Override + public void run() { // TextView _textNetwork = findViewById(R.id.textNetwork); // _textNetwork.setTextColor(Color.parseColor("#FF0000")); // _textNetwork.setText(R.string.main_network_fail); - ImageView _imgView = findViewById(R.id.imageViewServerLink); - if (_imgView != null) { - //_imgView.setImageResource(R.drawable.network_icon_error); - _imgView.setImageResource(R.drawable.main_server_icon_error); - _imgView.setVisibility(View.VISIBLE); + ImageView _imgView = findViewById(R.id.imageViewServerLink); + if (_imgView != null) { + //_imgView.setImageResource(R.drawable.network_icon_error); + _imgView.setImageResource(R.drawable.main_server_icon_error); + _imgView.setVisibility(View.VISIBLE); + } } - } - }); + }); + } } // Check physical link @@ -1535,13 +1597,21 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul if(file != null && file.exists()) { String linkCheck = null; - try { - String line = null; - BufferedReader buf = new BufferedReader(new FileReader(file.getAbsoluteFile().toString())); - while((line=buf.readLine())!=null){ - linkCheck = line.trim(); - } - buf.close(); +// try { +// String line = null; +// BufferedReader buf = new BufferedReader(new FileReader(file.getAbsoluteFile().toString())); +// while((line=buf.readLine())!=null){ +// linkCheck = line.trim(); +// } +// buf.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + // 작업 수행 (끝나면 자동으로 close 호출됨) + String line = br.readLine(); + linkCheck = line.trim(); } catch (Exception e) { e.printStackTrace(); } @@ -1553,21 +1623,28 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } } - final boolean link_status = link_is_okay; - runOnUiThread(new Runnable() { - @Override - public void run() { - ImageView _imgView = findViewById(R.id.imageViewNetwork); - if (_imgView != null) { - if(link_status) { - _imgView.setImageResource(R.drawable.main_network_icon_nor); - } else { - _imgView.setImageResource(R.drawable.main_network_icon_error); - } - _imgView.setVisibility(View.VISIBLE); - } + if(prev_link_status != link_is_okay) { + if(prev_link_status && !link_is_okay) { + SystemUtil.shellCommand("niasysc SHELL-ORDER=ifconfig eth0 down && ifconfig eth0 up && touch /mnt/obb/ethrenew"); } - }); + + prev_link_status = link_is_okay; + final boolean link_status = link_is_okay; + runOnUiThread(new Runnable() { + @Override + public void run() { + ImageView _imgView = findViewById(R.id.imageViewNetwork); + if (_imgView != null) { + if (link_status) { + _imgView.setImageResource(R.drawable.main_network_icon_nor); + } else { + _imgView.setImageResource(R.drawable.main_network_icon_error); + } + _imgView.setVisibility(View.VISIBLE); + } + } + }); + } } } @@ -1823,6 +1900,23 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } //Log.e("ryu", "on start face init!"); + if(GlobalInfo.mUseDoorControlTimeOuting == 1) { + String outingValue = GlobalInfo.readValueFromFile("outing.info"); + if (outingValue != null) { + outingValue = outingValue.trim(); + Log.w(TAG, "outingValue : " + outingValue); + try { + String[] values = outingValue.split(":"); + Log.w(TAG, "values[0] : " + values[0]); + GlobalInfo.mIsOnOuting = Integer.parseInt(values[0]); + GlobalInfo.mOutingDate = values[1]; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + Log.w(TAG, "mIsOnOuting : " + GlobalInfo.mIsOnOuting); turnToBaseUI(); } }.start(); @@ -2076,6 +2170,59 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } } + if(GlobalInfo.checkIsOutingMode() && !GlobalInfo.checkIsOutingConfirmMode()) { + mIsOnRfidVerifyingProcess = false; + return; + } + + if(logResult.mId.length() > 0 && GlobalInfo.checkIsOutingConfirmMode()) { // 외출 인증 모드인 경우 + if(mOutButton.getVisibility() == View.VISIBLE) { + GlobalInfo.mIsOnOuting = 1; + + mIsOnUiTransition = true; + + Message message = new Message(); + message.what= RESULT_OUTING_CHANGE; + message.obj = logResult.mName; + mMainUiHandler.handleMessage(message); + + new Thread() { + @Override + public void run() { + GlobalInfo.updateOutingInfo(true); + } + }.start(); + return; + } else if(mReturnButton.getVisibility() == View.VISIBLE) { + GlobalInfo.mIsOnOuting = 0; + + mIsOnUiTransition = true; + + Message message = new Message(); + message.what= RESULT_OUTING_CHANGE; + message.obj = logResult.mName; + mMainUiHandler.handleMessage(message); + + new Thread() { + @Override + public void run() { + GlobalInfo.updateOutingInfo(false); + } + }.start(); + return; + } + } + + if(logResult.mId.length() == 0 && GlobalInfo.checkIsOutingConfirmMode()) { + mIsOnUiTransition = true; + + Message message = new Message(); + message.what= RESULT_OUTING_CHANGE_FAIL; + message.obj = logResult.mName; + mMainUiHandler.handleMessage(message); + return; + } + GlobalInfo.updateLogging(logResult); if(BaseService.mServerManager != null) { if(GlobalInfo.mUseAttendance == 1 && GlobalInfo.mAttendanceMode != GlobalInfo.ATTENDANCE_MODE_NONE) { @@ -2179,6 +2326,9 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } public void turnToBaseUI() { + if(mIsOnUiTransition) + return; + if(mVerifyMethod == GlobalInfo.VERIFY_METHOD_VEIN) mMainUiHandler.sendEmptyMessage(MAIN_SELECT_VEIN); else if(mVerifyMethod == VERIFY_METHOD_RFID) @@ -2273,7 +2423,7 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul mCameraView.setDropFrame(true); BaseService.mFaceManager.mRBitmapFrameQueue.clear(); - if(GlobalInfo.checkIsDoorControlOpenTime()) { // 개방시간 사용 시간여부 + if((GlobalInfo.checkIsOutingMode() || GlobalInfo.checkIsDoorControlOpenTime()) && !GlobalInfo.checkIsOutingConfirmMode()) { // 개방시간 사용 시간여부(외출 모드 인증 모드는 아니어야 함) LayoutSetting(mVerifyCheck, CHECK, 563, 126, 155, 155, R.drawable.popup_fail, View.INVISIBLE); LayoutSetting(mLoginImage[CARD], CARD, 348, 40, 0, 0, R.drawable.main_img1, View.INVISIBLE); LayoutSetting(mLoginImage[VEIN], VEIN, 348, 40, 0, 0, R.drawable.main_img2, View.INVISIBLE); @@ -2288,18 +2438,52 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul mAttendanceButton.setVisibility(View.INVISIBLE); } - TextView tv = findViewById(R.id.doorcontroltimetext); + if(GlobalInfo.mUseDoorControlTimeOuting == 1) { + if(GlobalInfo.mIsOnOuting == 0) { + TextView tv = findViewById(R.id.doorcontroltimeoutingtext); + GlobalInfo.DoorControlTime timeInfo = GlobalInfo.getMatchDoorControlOpenTime(getCurrentMinutesInDay()); + if (timeInfo != null) { + tv.setText(String.format("%02d:%02d~%02d:%02d", timeInfo.startTime / 60, timeInfo.startTime % 60 + , timeInfo.endTime / 60, timeInfo.endTime % 60)); + } + mOutButton.setVisibility(View.VISIBLE); + findViewById(R.id.doorcontroltimeoutingtext).setVisibility(View.VISIBLE); + findViewById(R.id.doorcontrolmsgoutingtext).setVisibility(View.VISIBLE); + findViewById(R.id.doorcontrolframeouting).setVisibility(View.VISIBLE); + + mReturnButton.setVisibility(View.INVISIBLE); + findViewById(R.id.doorcontroltimeoutingtext2).setVisibility(View.INVISIBLE); + findViewById(R.id.doorcontrolmsgoutingtext2).setVisibility(View.INVISIBLE); + } else { + mOutButton.setVisibility(View.INVISIBLE); + findViewById(R.id.doorcontroltimeoutingtext).setVisibility(View.INVISIBLE); + findViewById(R.id.doorcontrolmsgoutingtext).setVisibility(View.INVISIBLE); + + mReturnButton.setVisibility(View.VISIBLE); + findViewById(R.id.doorcontroltimeoutingtext2).setVisibility(View.VISIBLE); + findViewById(R.id.doorcontrolmsgoutingtext2).setVisibility(View.VISIBLE); + + findViewById(R.id.doorcontrolframeouting).setVisibility(View.VISIBLE); + } + + findViewById(R.id.doorcontrolframeouting).setVisibility(View.VISIBLE); + findViewById(R.id.doorcontrolframe).setVisibility(View.INVISIBLE); + } else { + TextView tv = findViewById(R.id.doorcontroltimetext); // tv.setText(String.format("%d:%02d~%d:%02d", GlobalInfo.mDoorControlTimeStart / 60, GlobalInfo.mDoorControlTimeStart % 60 // , GlobalInfo.mDoorControlTimeEnd / 60, GlobalInfo.mDoorControlTimeEnd % 60)); - GlobalInfo.DoorControlTime timeInfo = GlobalInfo.getMatchDoorControlOpenTime(getCurrentMinutesInDay()); - if(timeInfo != null) { - tv.setText(String.format("%02d:%02d~%02d:%02d", timeInfo.startTime / 60, timeInfo.startTime % 60 - , timeInfo.endTime / 60, timeInfo.endTime % 60)); + GlobalInfo.DoorControlTime timeInfo = GlobalInfo.getMatchDoorControlOpenTime(getCurrentMinutesInDay()); + if (timeInfo != null) { + tv.setText(String.format("%02d:%02d~%02d:%02d", timeInfo.startTime / 60, timeInfo.startTime % 60 + , timeInfo.endTime / 60, timeInfo.endTime % 60)); + } + findViewById(R.id.doorcontrolframe).setVisibility(View.VISIBLE); + findViewById(R.id.doorcontrolframeouting).setVisibility(View.INVISIBLE); } - findViewById(R.id.doorcontrolframe).setVisibility(View.VISIBLE); return; } else { + findViewById(R.id.doorcontrolframeouting).setVisibility(View.INVISIBLE); findViewById(R.id.doorcontrolframe).setVisibility(View.INVISIBLE); } @@ -2509,6 +2693,8 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } break; + + case RESULT_OUTING_CHANGE: case RESULT_SUCCESS: if(mCameraView != null) { mCameraView.setDropFrame(true); @@ -2520,6 +2706,36 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul LayoutSetting(mLoginImage[VEIN], VEIN, 348, 40, 0, 0, R.drawable.main_img2, View.INVISIBLE); LayoutSetting(mLoginImage[FINGER], FINGER, 348, 40, 0, 0, R.drawable.main_fingerprint, View.INVISIBLE); LayoutSetting(mLoginImage[FACE], FACE, 348, 40, 0, 0, R.drawable.main_fingerprint, View.INVISIBLE); + + if(msg.what == RESULT_OUTING_CHANGE) { + String user = "[외출모드]"; + if(GlobalInfo.mIsOnOuting == 0) { + user = "[개방모드]"; + } + int width = (int)mLoginText[COLOR_YELLOW].getPaint().measureText(user); + int startx = (1280 - 465 - width)/2; + LayoutSetting(mLoginText[COLOR_WHITE], COLOR_WHITE, startx + width, 375, 465, 65, R.string.main_outing_change, View.VISIBLE); + LayoutSetting(mLoginText[COLOR_YELLOW], COLOR_YELLOW, startx, 375, width, 65, 0, View.VISIBLE, user); + + GlobalInfo.mIsOnOutingConfirm = 0; + GlobalInfo.mOutingConfirmStartTime = 0; + mIsOnRfidVerifyingProcess = false; + //waitTimeHandler(MAIN_UI_INIT, GlobalInfo.mVerifyPopupTime * 1000); + + new Thread() { + @Override + public void run() { + try { + sleep(GlobalInfo.mVerifyPopupTime * 1000); + mIsOnUiTransition = false; + turnToBaseUI(); + } catch(Exception e) { + } + } + }.start(); + break; + } + String user = getString(R.string.main_verify_1) + ((String)msg.obj) + getString(R.string.main_verify_2) + getString(R.string.main_verify_3); if(GlobalInfo.mVerifyPrintUserName == GlobalInfo.DEFAULT_VERIFY_PRINTUSERNAME) { int width = (int)mLoginText[COLOR_YELLOW].getPaint().measureText(user); @@ -2541,7 +2757,9 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul waitTimeHandler(RESULT_SUCCESS,GlobalInfo.mVerifyPopupTime * 1000); break; + case RESULT_OUTING_CHANGE_FAIL: case RESULT_FAIL: + if(mCameraView != null) { mCameraView.setDropFrame(true); } @@ -2563,6 +2781,26 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul } mIsOnRfidVerifyingProcess = false; + if(msg.what == RESULT_OUTING_CHANGE_FAIL) { + GlobalInfo.mIsOnOutingConfirm = 0; + GlobalInfo.mOutingConfirmStartTime = 0; + mIsOnRfidVerifyingProcess = false; + + new Thread() { + @Override + public void run() { + try { + sleep(GlobalInfo.mVerifyPopupTime * 1000); + mIsOnUiTransition = false; + turnToBaseUI(); + } catch(Exception e) { + } + } + }.start(); + break; + } + + waitTimeHandler(RESULT_FAIL,GlobalInfo.mVerifyPopupTime * 1000); break; } @@ -2689,6 +2927,7 @@ public class MainActivity extends AppCompatActivity implements RfidManager.resul mDelayHandler.removeMessages(MAIN_SELECT_FACE); mDelayHandler.removeMessages(MAIN_SELECT_VEIN_FACE); mDelayHandler.removeMessages(MAIN_SELECT_FINGER_FACE); + mDelayHandler.removeMessages(RESULT_OUTING_CHANGE); } } diff --git a/app/src/main/java/kr/co/enicom/acs/MainUiDefine.java b/app/src/main/java/kr/co/enicom/acs/MainUiDefine.java index 18efd5f..740d9d8 100644 --- a/app/src/main/java/kr/co/enicom/acs/MainUiDefine.java +++ b/app/src/main/java/kr/co/enicom/acs/MainUiDefine.java @@ -28,5 +28,6 @@ public interface MainUiDefine { public static final int MAIN_SELECT_FACE = 6; public static final int MAIN_SELECT_VEIN_FACE = 7; public static final int MAIN_SELECT_FINGER_FACE = 8; - + public static final int RESULT_OUTING_CHANGE = 9; + public static final int RESULT_OUTING_CHANGE_FAIL = 10; } diff --git a/app/src/main/java/kr/co/enicom/acs/RfidManager.java b/app/src/main/java/kr/co/enicom/acs/RfidManager.java index cab4f68..56bb106 100644 --- a/app/src/main/java/kr/co/enicom/acs/RfidManager.java +++ b/app/src/main/java/kr/co/enicom/acs/RfidManager.java @@ -12,6 +12,7 @@ import android.util.Log; import com.hitachi.fv.android.h1client.SecurityLevel; +import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -173,6 +174,10 @@ public class RfidManager implements SerialInputOutputManager.Listener { Log.d(RfidManager.class.getName(), String.format("Received from BLE Reader Module : %d bytes. [%s]", recvSize, byteArrayToHexString(rfidId))); System.arraycopy(readData, 0, accData, accFilled, recvSize); accFilled += recvSize; + } else if(recvSize == 0) { + accFilled = 0; + mSerialManager.CloseSerial(acmHandle); + acmHandle = -1; } if(accFilled > 0) { @@ -212,19 +217,40 @@ public class RfidManager implements SerialInputOutputManager.Listener { } if(acmHandle < 0) { - acmHandle = mSerialManager.OpenSerial("/dev/ttyACM0", 115200); - if(acmHandle < 0) { - if(failedCount < 10000) { + String acmDevice = ""; + for(int i = 0;i < 20;i++) { + acmDevice = "/dev/ttyACM" + i; + File acmCheck = new File(acmDevice); + if(acmCheck.exists()) + break; + + acmDevice = ""; + } + + if(acmDevice.length() > 0) { + acmHandle = mSerialManager.OpenSerial(acmDevice, 115200); + if (acmHandle < 0) { + if (failedCount < 10000) { + failedCount++; + } + Log.e(RfidManager.class.getName(), "Error to open BLE Reader Module[" + acmDevice + "]!"); + try { + sleep(500 * failedCount); + } catch (InterruptedException e) { + } + } else { + failedCount = 0; + Log.d(RfidManager.class.getName(), "Success to open BLE Reader Module[" + acmDevice + "] :-)"); + } + } else { + Log.d(RfidManager.class.getName(), "Cannot find BLE Reader Module :-("); + if (failedCount < 10000) { failedCount++; } - Log.e(RfidManager.class.getName(), "Error to open BLE Reader Module[ttyACM0]!"); try { sleep(500 * failedCount); } catch (InterruptedException e) { } - } else { - failedCount = 0; - Log.d(RfidManager.class.getName(), "Success to open BLE Reader Module[ttyACM0] :-)"); } } } diff --git a/app/src/main/java/kr/co/enicom/acs/ServerManager.java b/app/src/main/java/kr/co/enicom/acs/ServerManager.java index bc0ed6b..31ebf34 100644 --- a/app/src/main/java/kr/co/enicom/acs/ServerManager.java +++ b/app/src/main/java/kr/co/enicom/acs/ServerManager.java @@ -489,6 +489,7 @@ public class ServerManager extends Thread { public final static int FINGER_CODE_LENGTH = 960; public final static int FACE_EMBED_LENGTH = 2048; public final static int DOOR_CONTROL_COMMAND_LENGTH = 1; + public final static int FIRE_STATUS_LENGTH = 20; public final static int NETWORK_TYPE_LENGTH = 1; public final static int NETWORK_IPV4_LENGTH = 15; public final static int DEVICE_NAME_LENGTH = 20; @@ -566,11 +567,16 @@ public class ServerManager extends Thread { public final static byte COMMAND_TYPE_ATTENDANCE_LOG_GET = 0x44; // 41. 근태 이력 로그 요청 public final static byte COMMAND_TYPE_DELETE_ATTENDANCE_LOG_ALL = 0x45; + // v3.8 public final static byte COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V2 = 0x46; // 43. 개방시간 저장(2) - 다중저장 public final static byte COMMAND_TYPE_DOOR_CONTROL_TIME_GET_V2 = 0x47; public final static byte COMMAND_TYPE_HOLYDAY_SET = 0x48; // 45. 공휴일 저장 public final static byte COMMAND_TYPE_HOLYDAY_GET = 0x49; + // v3.9 + public final static byte COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V3 = 0x50; + public final static byte COMMAND_TYPE_DOOR_CONTROL_TIME_GET_V3 = 0x51; + boolean callback_progress = true; LogInfo result_handler = new LogInfo(); ServerNotify NOTIFY_HANDLER = new ServerNotify() { @@ -1641,8 +1647,11 @@ public class ServerManager extends Thread { if(!GlobalInfo.mDeviceStatusNormal) replyStatus = PKT_STATUS_FAIL; - String[] dataArray = new String[1]; + String[] dataArray = new String[2]; dataArray[0] = getPaddingString("" + openStatus, DOOR_CONTROL_COMMAND_LENGTH); + int[] values = BaseService.mDCUManager.getReportValues(DCUManager.DCU_REPORT_TYPE_FIRESW); + String fireStatus = String.format("%d,%d", values[0], values[1]); + dataArray[1] = getPaddingString(fireStatus, FIRE_STATUS_LENGTH); message = createClientMessage(COMMAND_TYPE_DEVICE_DOOR_STATUS_GET, getMsgDeviceId(), replyStatus, dataArray); sendPushMessage(message); } @@ -2457,6 +2466,57 @@ public class ServerManager extends Thread { message = createClientMessage(COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V2, getMsgDeviceId(), replyStatus, null); sendPushMessage(message); } + } else if(commandMsg[1] == COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V3) { // 47. 개방시간 설정 3 + if(statusMsgStr.equals(PKT_STATUS_OKAY)) { + int parseLen = 1; + byte[] parseMsg = new byte[parseLen]; + System.arraycopy(message, idx, parseMsg, 0, parseLen); + idx += parseLen; + msg.useDoorControlTime = new String(parseMsg).trim(); + Log.i(TAG, "parseMessage. useDoorControlTime : " + msg.useDoorControlTime); + + parseMsg = new byte[parseLen]; + System.arraycopy(message, idx, parseMsg, 0, parseLen); + idx += parseLen; + msg.useDoorControlTimeHoliday = new String(parseMsg).trim(); + Log.i(TAG, "parseMessage. useDoorControlTimeHoliday : " + msg.useDoorControlTimeHoliday); + + parseMsg = new byte[parseLen]; + System.arraycopy(message, idx, parseMsg, 0, parseLen); + idx += parseLen; + msg.useDoorControlTimeOuting = new String(parseMsg).trim(); + Log.i(TAG, "parseMessage. useDoorControlTimeOuting : " + msg.useDoorControlTimeOuting); + + parseLen = TOTAL_COUNT_LENGTH; + parseMsg = new byte[parseLen]; + System.arraycopy(message, idx, parseMsg, 0, parseLen); + idx += parseLen; + int totalCount = SystemUtil.fromByteArrayToInt(parseMsg); + msg.doorControlTimeListCount = "" + totalCount; + + if(totalCount > 0) { + msg.doorControlTimeList = new String[totalCount]; + for (int i = 0; i < totalCount; i++) { + parseLen = TIME_LENGTH_RANGE; + parseMsg = new byte[parseLen]; + System.arraycopy(message, idx, parseMsg, 0, parseLen); + idx += parseLen; + try { + msg.doorControlTimeList[i] = new String(parseMsg).trim(); + Log.i(TAG, "parseMessage. doorControlTime : " + msg.doorControlTimeList[i]); + } catch (Exception e) { + } + } + } + + String replyStatus = PKT_STATUS_FAIL; + boolean result = handleMessage(msg); + if(result) + replyStatus = PKT_STATUS_OKAY; + + message = createClientMessage(COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V3, getMsgDeviceId(), replyStatus, null); + sendPushMessage(message); + } } else if(commandMsg[1] == COMMAND_TYPE_DOOR_CONTROL_TIME_GET_V2) { // 개방시간 정보 조회 2 String replyStatus = PKT_STATUS_OKAY; if(statusMsgStr.equals(PKT_STATUS_OKAY)) { @@ -2479,6 +2539,30 @@ public class ServerManager extends Thread { message = createClientMessage(commandMsg[1], getMsgDeviceId(), replyStatus, null); } + sendPushMessage(message); + } else if(commandMsg[1] == COMMAND_TYPE_DOOR_CONTROL_TIME_GET_V3) { // 개방시간 정보 조회 3 + String replyStatus = PKT_STATUS_OKAY; + if(statusMsgStr.equals(PKT_STATUS_OKAY)) { + GlobalInfo.DoorControlTime[] timeList = GlobalInfo.getDoorControlTimeList(); + int totalCount = timeList.length; + byte[][] dataArray = new byte[4 + totalCount][]; + dataArray[0] = getPaddingString(GlobalInfo.mUseDoorControlTime == 1 ? "Y" : "N", 1).getBytes(); + dataArray[1] = getPaddingString(GlobalInfo.mUseDoorControlTimeHoliday == 1 ? "Y" : "N", 1).getBytes(); + dataArray[2] = getPaddingString(GlobalInfo.mUseDoorControlTimeOuting == 1 ? "Y" : "N", 1).getBytes(); + dataArray[3] = intTobyte(totalCount, ByteOrder.LITTLE_ENDIAN); + for(int i = 0;i < totalCount;i++) { + String timeRange = getPaddingString(GlobalInfo.convertMinutesToSimpleTime(timeList[i].startTime), TIME_LENGTH); + timeRange += getPaddingString(GlobalInfo.convertMinutesToSimpleTime(timeList[i].endTime), TIME_LENGTH); + dataArray[4 + i] = timeRange.getBytes(); + } + + message = createClientMessageByte(commandMsg[1], getMsgDeviceId(), replyStatus, dataArray); + sendPushMessage(message); + } else { + replyStatus = PKT_STATUS_FAIL; + message = createClientMessage(commandMsg[1], getMsgDeviceId(), replyStatus, null); + } + sendPushMessage(message); } else if(commandMsg[1] == COMMAND_TYPE_HOLYDAY_SET) { // 45. 공휴일 설정 if(statusMsgStr.equals(PKT_STATUS_OKAY)) { @@ -3129,23 +3213,23 @@ public class ServerManager extends Thread { } else if(msg.command == COMMAND_TYPE_DOOR_CONTROL_TIME_SET) { // 37. 개방시간 설정 try { int nextUse = msg.useDoorControlTime.equals("Y") ? 1 : 0; - boolean isNeedInvalidate = false; - if(nextUse != GlobalInfo.mUseDoorControlTime) { - isNeedInvalidate = true; - } +// boolean isNeedInvalidate = false; +// if(nextUse != GlobalInfo.mUseDoorControlTime) { +// isNeedInvalidate = true; +// } +// isNeedInvalidate = true; // GlobalInfo.mUseDoorControlTime = msg.useDoorControlTime.equals("Y") ? 1 : 0; GlobalInfo.mDoorControlTimeStart = GlobalInfo.convertSimpleTimeToMinutes(msg.doorControlStartTime); GlobalInfo.mDoorControlTimeEnd = GlobalInfo.convertSimpleTimeToMinutes(msg.doorControlEndTime); GlobalInfo.mDoorControlTimeData = GlobalInfo.convertTimeToLonger(msg.doorControlStartTime) + "~" + GlobalInfo.convertTimeToLonger(msg.doorControlEndTime); GlobalInfo.updateDoorControlTimeList(); GlobalInfo.mUseDoorControlTime = nextUse; - if(isNeedInvalidate) { - if (nextUse == 1) { - GlobalInfo.mDoorControlTimeStatus = -1; - } else { - GlobalInfo.mDoorControlTimeStatus = 0; - } + if (nextUse == 1) { + GlobalInfo.mDoorControlTimeStatus = -1; + } else { + GlobalInfo.mDoorControlTimeStatus = 0; } + GlobalInfo.updateDatabase(GlobalInfo.TARGET_FLAG_DEVICE_INFO); } catch(Exception e) { ret = false; @@ -3154,13 +3238,13 @@ public class ServerManager extends Thread { try { int nextUse = msg.useDoorControlTime.equals("Y") ? 1 : 0; int nextUseHoliday = msg.useDoorControlTimeHoliday.equals("Y") ? 1 : 0; - boolean isNeedInvalidate = false; - if(nextUse != GlobalInfo.mUseDoorControlTime) { - isNeedInvalidate = true; - } - if(nextUseHoliday != GlobalInfo.mUseDoorControlTimeHoliday) { - isNeedInvalidate = true; - } +// boolean isNeedInvalidate = false; +// if(nextUse != GlobalInfo.mUseDoorControlTime) { +// isNeedInvalidate = true; +// } +// if(nextUseHoliday != GlobalInfo.mUseDoorControlTimeHoliday) { +// isNeedInvalidate = true; +// } int totalCount = Integer.parseInt(msg.doorControlTimeListCount); String newTime = ""; @@ -3176,13 +3260,13 @@ public class ServerManager extends Thread { GlobalInfo.updateDoorControlTimeList(); GlobalInfo.mUseDoorControlTimeHoliday = nextUseHoliday; GlobalInfo.mUseDoorControlTime = nextUse; - if(isNeedInvalidate) { - if (nextUse == 1) { - GlobalInfo.mDoorControlTimeStatus = -1; - } else { - GlobalInfo.mDoorControlTimeStatus = 0; - } + + if (nextUse == 1) { + GlobalInfo.mDoorControlTimeStatus = -1; + } else { + GlobalInfo.mDoorControlTimeStatus = 0; } + GlobalInfo.updateDatabase(GlobalInfo.TARGET_FLAG_DEVICE_INFO); } catch(Exception e) { ret = false; @@ -3204,6 +3288,37 @@ public class ServerManager extends Thread { } catch(Exception e) { ret = false; } + } else if(msg.command == COMMAND_TYPE_DOOR_CONTROL_TIME_SET_V3) { // 47. 개방시간 설정 3 + try { + int nextUse = msg.useDoorControlTime.equals("Y") ? 1 : 0; + int nextUseHoliday = msg.useDoorControlTimeHoliday.equals("Y") ? 1 : 0; + + int totalCount = Integer.parseInt(msg.doorControlTimeListCount); + String newTime = ""; + for(int i = 0;i < totalCount;i++) { + String startTime = msg.doorControlTimeList[i].substring(0, 4); + String endTime = msg.doorControlTimeList[i].substring(4); + if(i > 0) { + newTime += ","; + } + newTime += (GlobalInfo.convertTimeToLonger(startTime) + "~" + GlobalInfo.convertTimeToLonger(endTime)); + } + GlobalInfo.mDoorControlTimeData = newTime; + GlobalInfo.updateDoorControlTimeList(); + GlobalInfo.mUseDoorControlTimeHoliday = nextUseHoliday; + GlobalInfo.mUseDoorControlTime = nextUse; + GlobalInfo.mUseDoorControlTimeOuting = msg.useDoorControlTimeOuting.equals("Y") ? 1 : 0; + + if (nextUse == 1) { + GlobalInfo.mDoorControlTimeStatus = -1; + } else { + GlobalInfo.mDoorControlTimeStatus = 0; + } + + GlobalInfo.updateDatabase(GlobalInfo.TARGET_FLAG_DEVICE_INFO); + } catch(Exception e) { + ret = false; + } } @@ -3291,6 +3406,7 @@ public class ServerManager extends Thread { public void run() { byte[] buffer = new byte[32768]; int cnt = 0; + int prevFireStatus = -1; int ret; long checkTime = SystemClock.uptimeMillis() - GlobalInfo.mStatePeriod * 1000; long reportTime = SystemClock.uptimeMillis() - GlobalInfo.mStatePeriod * 1000 + 1000; @@ -3400,6 +3516,19 @@ public class ServerManager extends Thread { } } + // 소방 상태 주기적 체크 + int[] fireStatusValue = BaseService.mDCUManager.getReportValues(DCUManager.DCU_REPORT_TYPE_FIRESW); + boolean needToNotifyDoorStatus = false; + if(fireStatusValue != null) { + if(prevFireStatus < 0) + prevFireStatus = fireStatusValue[0]; + + if(prevFireStatus != fireStatusValue[0]) { + needToNotifyDoorStatus = true; + } + prevFireStatus = fireStatusValue[0]; + } + long curTime = SystemClock.uptimeMillis(); if(curTime - checkTime > GlobalInfo.mStatePeriod * 1000) { checkTime = curTime; @@ -3419,7 +3548,7 @@ public class ServerManager extends Thread { } } - if(curTime - reportTime > GlobalInfo.mStatePeriod * 1000) { + if(curTime - reportTime > GlobalInfo.mStatePeriod * 1000 || needToNotifyDoorStatus) { reportTime = curTime; if(mWrite != null) { byte[] message; @@ -3429,8 +3558,15 @@ public class ServerManager extends Thread { if(!GlobalInfo.mDeviceStatusNormal) replyStatus = PKT_STATUS_FAIL; - String[] dataArray = new String[1]; + // SDK V3.7까지 +// String[] dataArray = new String[1]; +// dataArray[0] = getPaddingString("" + openStatus, DOOR_CONTROL_COMMAND_LENGTH); + // SDK V3.8 + String[] dataArray = new String[2]; dataArray[0] = getPaddingString("" + openStatus, DOOR_CONTROL_COMMAND_LENGTH); + //int[] values = BaseService.mDCUManager.getReportValues(DCUManager.DCU_REPORT_TYPE_FIRESW); + String fireStatus = String.format("%d,%d", fireStatusValue[0], fireStatusValue[1]); + dataArray[1] = getPaddingString(fireStatus, FIRE_STATUS_LENGTH); message = createClientMessage(COMMAND_TYPE_DEVICE_DOOR_REPORT, getMsgDeviceId(), replyStatus, dataArray); sendPushMessage(message); } diff --git a/app/src/main/java/kr/co/enicom/acs/system/DoorControlTimeActivity.java b/app/src/main/java/kr/co/enicom/acs/system/DoorControlTimeActivity.java index 49bba46..f8f7151 100644 --- a/app/src/main/java/kr/co/enicom/acs/system/DoorControlTimeActivity.java +++ b/app/src/main/java/kr/co/enicom/acs/system/DoorControlTimeActivity.java @@ -46,12 +46,13 @@ public class DoorControlTimeActivity extends BaseActivity { private final int DEVICE_NAME_POPUP = 1; private int modifyIdx = 0; + private static int INSERT_DATA_ROW = 3; protected void refreshDoorControlTimeList() { String[] timeList = GlobalInfo.mDoorControlTimeData.split(","); LinearLayout parentLayout = findViewById(R.id.frameLayout2); int viewCount = parentLayout.getChildCount(); - if(viewCount > 3) { - parentLayout.removeViews(2, viewCount - 3); + if(viewCount > INSERT_DATA_ROW + 1) { + parentLayout.removeViews(INSERT_DATA_ROW, viewCount - INSERT_DATA_ROW - 1); } int offset = -60; @@ -155,7 +156,7 @@ public class DoorControlTimeActivity extends BaseActivity { newLayout.addView(imgButton); } - int insertIndex = 2; // 원하는 위치 + int insertIndex = INSERT_DATA_ROW; // 원하는 위치 parentLayout.addView(newLayout, insertIndex); } @@ -217,6 +218,26 @@ public class DoorControlTimeActivity extends BaseActivity { } + ImageView doorcontroltimeuseoutingimage = (ImageView) findViewById(R.id.doorcontroltimeuseoutingimage); + doorcontroltimeuseoutingimage.setOnClickListener(new Button.OnClickListener() { + @Override + public void onClick(View view) { + if(GlobalInfo.mUseDoorControlTimeOuting == 0) { + doorcontroltimeuseoutingimage.setImageResource(R.drawable.toggle_pressed); + GlobalInfo.mUseDoorControlTimeOuting = 1; + } + else { + GlobalInfo.mUseDoorControlTimeOuting = 0; + doorcontroltimeuseoutingimage.setImageResource(R.drawable.toggle_nor); + } + } + }); + + if(GlobalInfo.mUseDoorControlTimeOuting == 0) { + doorcontroltimeuseoutingimage.setImageResource(R.drawable.toggle_nor); + } else { + doorcontroltimeuseoutingimage.setImageResource(R.drawable.toggle_pressed); + } // Button button = (Button) findViewById(R.id.doorcontroltimesetimagebutton) ; // button.setOnClickListener(new Button.OnClickListener() { diff --git a/app/src/main/res/drawable/out_btn.xml b/app/src/main/res/drawable/out_btn.xml new file mode 100644 index 0000000..ff144fd --- /dev/null +++ b/app/src/main/res/drawable/out_btn.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/out_btn_nor.png b/app/src/main/res/drawable/out_btn_nor.png new file mode 100644 index 0000000..0d2dcbc Binary files /dev/null and b/app/src/main/res/drawable/out_btn_nor.png differ diff --git a/app/src/main/res/drawable/out_btn_pressed.png b/app/src/main/res/drawable/out_btn_pressed.png new file mode 100644 index 0000000..864d926 Binary files /dev/null and b/app/src/main/res/drawable/out_btn_pressed.png differ diff --git a/app/src/main/res/drawable/return_btn.xml b/app/src/main/res/drawable/return_btn.xml new file mode 100644 index 0000000..a85238c --- /dev/null +++ b/app/src/main/res/drawable/return_btn.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/return_btn_nor.png b/app/src/main/res/drawable/return_btn_nor.png new file mode 100644 index 0000000..c13df27 Binary files /dev/null and b/app/src/main/res/drawable/return_btn_nor.png differ diff --git a/app/src/main/res/drawable/return_btn_pressed.png b/app/src/main/res/drawable/return_btn_pressed.png new file mode 100644 index 0000000..681fee3 Binary files /dev/null and b/app/src/main/res/drawable/return_btn_pressed.png differ diff --git a/app/src/main/res/layout/activity_door_control_time.xml b/app/src/main/res/layout/activity_door_control_time.xml index b640601..0c56afe 100644 --- a/app/src/main/res/layout/activity_door_control_time.xml +++ b/app/src/main/res/layout/activity_door_control_time.xml @@ -144,6 +144,50 @@ app:srcCompat="@drawable/toggle_pressed" /> + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index bd62687..984761e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -23,7 +23,7 @@ android:layout_marginStart="1104px" android:layout_marginTop="20px" android:visibility="visible" - app:srcCompat="@drawable/main_network_icon_nor" /> + app:srcCompat="@drawable/main_network_icon_error" /> + app:srcCompat="@drawable/main_server_icon_error" /> @@ -92,6 +94,7 @@ android:layout_height="95px" android:layout_marginStart="1145px" android:layout_marginTop="481px" + android:alpha="0" android:background="@drawable/admin_icon_btn" />