فهرست منبع

[WallPadMain]
1. App Ver. 갱신
- 2022.05.17.01
2. 최신 WallPadAPI 적용
- 통화이벤트 알림용 BR 추가
3. 방문자 사진 정리함수 추가
- 방문자 사진 삭제시 또는 임시사진이 남아있는 경우를 대비하여, 방문자 사진 DB와 비교하여 DB에 없는 사진은 삭제한다.
- 해당 기능은 월패드 부팅시에만 동작한다.
4. 현관통화 시작 BR 연동기능 추가
- 현관통화 BR을 수신하면, 일정시간(3초, 통화앱이 완전히 구동되기 까지)동안 다른 호호출을 무시한다.
5. 무인경비 호출수신 알림BR추가
- WallPadMain에서 현관통화 호출을 일정시간(약 3초) 무시한다.
6. 통화앱 비정상 종료 대비 보완코드 추가
- 통화앱이 종료되면, 하단 LED버튼을 LED를 off한다.

[WallPadAPI]
1. API Ver. 갱신
- 2022.05.17.01
2. 통화이벤트 알림용 BR 추가
- public static final String BR_NOTIFY_FRONTCALL_EVENT = "kr.co.icontrols.wallpad.BR_NOTIFY_FRONTCALL_EVENT"; // 현관 호출 수신 알림용 BR
- public static final String BR_NOTIFY_HOMEAUTOCALL_EVENT = "kr.co.icontrols.wallpad.BR_NOTIFY_HOMEAUTOCALL_EVENT"; // 무인경비 호출 수신 알림용 BR

Changwoo Nam 3 سال پیش
والد
کامیت
17e23c30c9

BIN
WallPadMain/libs/WallPadAPI.jar


+ 1 - 1
WallPadMain/src/main/AndroidManifest.xml

@@ -1,7 +1,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="kr.co.icontrols.wallpadmain"
     android:versionCode="17"
-    android:versionName="2022.05.12.01">
+    android:versionName="2022.05.17.01">
 
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
 	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

+ 206 - 0
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/MainActivity.java

@@ -12,6 +12,8 @@ import android.content.IntentFilter;
 import android.content.SharedPreferences;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Color;
 import android.hardware.Camera;
 import android.media.AudioManager;
@@ -1009,6 +1011,18 @@ public class MainActivity extends WpadActivity {
         }
 //        forceCtrlStrangerRecordingUserSettingDisable(false);
         getLCDKeeperUsage();
+
+        try {
+            ThreadCleanVisitorPic mThreadCleanVisitorPic = new ThreadCleanVisitorPic();
+            mThreadCleanVisitorPic.start();
+        } catch (RuntimeException re) {
+            Log.e(TAG, "[RuntimeException] Call ThreadCleanVisitorPic!!");
+            re.printStackTrace();
+        } catch (Exception e) {
+            Log.e(TAG, "[RuntimeException] Call ThreadCleanVisitorPic!!");
+            e.printStackTrace();
+        }
+
         Log.i(TAG, "[onCreate] ==================== onCreate end ====================");
     }
 
@@ -8709,6 +8723,198 @@ public class MainActivity extends WpadActivity {
         }
     }
 
+    /**
+     * 방문객 사진 정리 기능 (added by jeffrey, 2022.03.17)
+     * 방문객 사진 정리 함수
+     * - 동작조건: 방문객 사진폴더에 파일이 100개 이상 존재하는 경우에만 동작함.
+     * - 부팅시 방문객 사진 폴더에 방문객사진 목록 DB에 없는 사진파일이 존재하는 경우, 이 사진파일을 삭제한다.
+     * - DB파일이 없거나 DB내에 목록이 없는 경우 방문객 사진 폴더를 삭제한다.
+     */
+
+    class ThreadCleanVisitorPic extends Thread {
+        public ThreadCleanVisitorPic() {
+            super();
+            Log.i(TAG, "[cleanOverVisitorPic] Thread init!!!");
+        }
+
+        public void run() {
+            try {
+                Log.i(TAG, "[cleanOverVisitorPic] ThreadCleanVisitorPic.run() 1");
+                Thread.sleep(5000);
+                Log.i(TAG, "[cleanOverVisitorPic] ThreadCleanVisitorPic.run() 2");
+                cleanOverVisitorPic();
+                Log.i(TAG, "[cleanOverVisitorPic] ThreadCleanVisitorPic.run() 3");
+            } catch (RuntimeException re) {
+                Log.e(TAG, "[RuntimeException] ThreadCleanVisitorPic().run()");
+                re.printStackTrace();
+            } catch (Exception e) {
+                Log.e(TAG, "[Exception] ThreadCleanVisitorPic().run()");
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public void cleanOverVisitorPic() {
+        try {
+            Log.i(TAG, "[cleanOverVisitorPic] start");
+            int MAXHISTORYCNT = 100;
+            File mFile = new File(define.VISITOR_PICTURE_LOCATION);
+            if (mFile.exists()) {
+                File[] mFiles = mFile.listFiles();
+                int nFileCnt = mFiles.length;
+                Log.i(TAG, "[cleanOverVisitorPic] nFileCnt [" + nFileCnt + "]");
+//                if (MAXHISTORYCNT >= nFileCnt) {
+//                    Log.i(TAG, "[cleanOverVisitorPic] VisitorPic nFileCnt OK!!");
+//                    return;
+//                }
+
+                Log.i(TAG, "[cleanOverVisitorPic] VisitorPic nFileCnt over the Max(" + nFileCnt + "/" + MAXHISTORYCNT + ")!!");
+
+                ArrayList<String> BDList = new ArrayList<String>();   // DB내 파일 목록
+                BDList.clear();
+                BDList = getVisitorPictureList();   // DB에서 방문객 사진 파일 목록 가져오기
+
+                if (BDList == null) {
+                    // DB가 없거나 DB내에 목록이 없는 경우, 파일을 모두 지운다.
+                    Log.w(TAG, "[cleanOverVisitorPic] doesn't exist the list in the DB or the DB file!!");
+                    deleteDirectory(define.VISITOR_PICTURE_LOCATION);
+                    return;
+                }
+
+                ArrayList<String> TargetURIs = new ArrayList<String>();   // DB내 파일 목록
+                for (int i = 0; i < nFileCnt; i++) {
+                    int nIndex = BDList.indexOf(mFiles[i].getName());
+                    if (nIndex < 0) {
+                        // DB에 없는 파일처리
+                        TargetURIs.add(mFiles[i].getPath());
+                    }
+                }
+
+                // Arrays가 비어있지 않으면 목록의 파일을 삭제한다.
+                if (TargetURIs.size() > 0) {
+                    deleteVisitorPicture(TargetURIs);
+                }
+            }
+            else {
+                Log.w(TAG, "[cleanOverVisitorPic] Visitor picture directory is not exist!!!");
+            }
+            Log.i(TAG, "[cleanOverVisitorPic] end");
+        } catch (RuntimeException re) {
+            Log.e(TAG, "[RuntimeException] cleanOverVisitorPic()");
+            re.printStackTrace();
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] cleanOverVisitorPic()");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 방문객 사진 정리 기능 (added by jeffrey, 2022.03.17)
+     * 방문객 사진 DB 목록 읽기 함수
+     * - 방문객 사진 DB에 저장된 방문객 사진 파일의 URI(path)를 반환한다.
+     * - DB파일이 없거나
+     */
+    String FILENAME_DB_HISTORY_VISITORPICTURE = "HISTORY_VISITORPICTURE.DB";
+    String TABLE_NAME_HISTORY_VISITORPICTURE = "HISTORY_VISITORPICTURE";
+    public ArrayList<String> getVisitorPictureList() {
+        try {
+            Log.i(TAG, "[getVisitorPictureList] start");
+            String DBPath = define.DATABASE_LOCATION + FILENAME_DB_HISTORY_VISITORPICTURE;
+            File DBFile = new File(DBPath);
+            if (DBFile.exists()) {
+                // DB 파일이 있는 경우
+                Log.i(TAG, "[getVisitorPictureList] DB file is exist!! -> " + DBPath);
+                String strDBQuery = "select URI from " + TABLE_NAME_HISTORY_VISITORPICTURE;
+                SQLiteDatabase mSQLiteDatabase = openOrCreateDatabase(DBPath, SQLiteDatabase.OPEN_READONLY, null);
+                ArrayList<String> VisitorPicList = new ArrayList<String>();
+                VisitorPicList.clear();
+
+                if (mSQLiteDatabase == null) {
+                    Log.w(TAG, "[getVisitorPictureList] mSQLiteDatabase is null!!!");
+                    return VisitorPicList;
+                }
+
+                // DB 검색 시작
+                Cursor mCursor = mSQLiteDatabase.rawQuery(strDBQuery, null);
+                while (mCursor.moveToNext()) {
+                    for (int i = 0; i < mCursor.getColumnCount(); i++) {
+                        String[] strParsed = mCursor.getString(i).split("/");
+                        VisitorPicList.add(strParsed[strParsed.length - 1]);
+                    }
+                }
+                mSQLiteDatabase.close();
+
+//                int nCnt = VisitorPicList.size();
+//                Log.i(TAG, "[getVisitorPictureList] VisitorPicList nCnt [" + nCnt + "]");
+//                for (int i = 0; i < nCnt; i++) {
+//                    Log.e(TAG, "[getVisitorPictureList] List[" + i + "] = " + VisitorPicList.get(i));
+//                }
+
+                return VisitorPicList;
+            }
+            else {
+                Log.w(TAG, "[getVisitorPictureList] DB file is not exist!! -> " + DBPath);
+                return null;
+            }
+        } catch (RuntimeException re) {
+            Log.e(TAG, "[RuntimeException] deleteHistoryList(ArrayList<String> strURI)");
+            re.printStackTrace();
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] deleteHistoryList(ArrayList<String> strURI)");
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private void deleteDirectory(String strPath) {
+        try {
+            File mFile = new File(strPath);
+            File[] childFileList = mFile.listFiles();
+            if (childFileList!=null) {
+                for (File childFile : childFileList) {
+                    if (childFile.isDirectory())
+                        deleteDirectory(childFile.getAbsolutePath()); // 혹시 있을지 모르는 하위폴더 삭제
+                    else childFile.delete(); // 파일 삭제
+                }
+                mFile.delete(); // 상위 폴더 삭제
+            }
+        } catch (RuntimeException re) {
+            re.printStackTrace();
+        }
+        catch (Exception e) {
+            Log.e(TAG, "[Exception] deleteDirectory(String strPath)");
+            e.printStackTrace();
+        }
+    }
+
+    public void deleteVisitorPicture(ArrayList<String> strURI) {
+        try {
+            int nCnt = strURI.size();
+            for (int i = 0; i < nCnt; i++) {
+                File mFile = new File(strURI.get(i));
+                if (mFile.exists()) {
+                    Log.i(TAG, "[deleteVisitorPicture] strPath exists!! [" + strURI.get(i) + "]");
+                    FileDelete(mFile);
+                }
+                else {
+                    Log.i(TAG, "[deleteVisitorPicture] There is no strPath!! [" + strURI.get(i) + "]");
+                }
+            }
+        } catch (RuntimeException re) {
+            re.printStackTrace();
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] deleteVisitorPicture(ArrayList<String> strURI)");
+            e.printStackTrace();
+        }
+    }
+
+    private synchronized void FileDelete(File file) {
+        if (file!=null && file.exists()) {
+            file.delete();
+        }
+    }
+
+
 
 }
 

+ 24 - 0
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/util/iMapServer.java

@@ -103,6 +103,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
 
 import kr.co.icontrols.gledeviceinterface.jni;
 import kr.co.icontrols.hdcftp.HDCFTPManager;
+import kr.co.icontrols.homeautomation.HomeAutomation_Call;
 import kr.co.icontrols.sslapi.SSLClient;
 import kr.co.icontrols.sslapi.SSLServer;
 import kr.co.icontrols.wallpadmain.IOInterface;
@@ -570,6 +571,11 @@ public class iMapServer extends Service {
                         Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
                     }
                 }
+                else if (strActionName.equals(HomeAutomation_Call.BR_NOTIFY_HOMEAUTOCALL_EVENT)) {
+                    bBlockFrontCall = true;
+                    handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
+                    handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
+                }
                 else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
                     runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
                 }
@@ -2100,6 +2106,7 @@ public class iMapServer extends Service {
 						// Jeff added below codes for call app (2018.01.25)
                         Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
                         if (!bWallPadCallLive && !bBlockFrontCall) {
+                            sendFrontCallBlockBR();
                             bBlockFrontCall = true;
                             handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
                             handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
@@ -2560,6 +2567,7 @@ public class iMapServer extends Service {
         mIntentFilter.addAction(define.NOTIFY_DAIL);
         mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
         mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
+        mIntentFilter.addAction(HomeAutomation_Call.BR_NOTIFY_HOMEAUTOCALL_EVENT);
 		registerReceiver(mWallPadNotifyBR, mIntentFilter);
         Log.d(TAG, "[onStartCommand] BR register end!!!");
 		// BR 등록 완료
@@ -13371,6 +13379,10 @@ public class iMapServer extends Service {
 
             if (bWallPadCallLive != getCallAppRunning()) {
                 setCallAppRunning(bWallPadCallLive);
+                if (!bWallPadCallLive) {
+                    // 통화앱 비정상 종료시를 대비하여, 통화 LED버튼 초기화 코드를 넣는다.
+                    mIOInterface.ctrlWallPadLED_Call(true);
+                }
             }
             Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
         } catch (Exception e) {
@@ -13964,6 +13976,18 @@ public class iMapServer extends Service {
         return -1;
     }
 
+    private void sendFrontCallBlockBR() {
+        try {
+//            Log.i(TAG, "[sendFrontCallBlockBR] ===== START =====");
+            Intent mIntent = new Intent();
+            mIntent.setAction(HomeAutomation_Call.BR_NOTIFY_FRONTCALL_EVENT);
+            getApplicationContext().sendBroadcast(mIntent);
+        } catch (Exception e) {
+            Log.e(TAG, "[Exception] sendFrontCallBlockBR()");
+            e.printStackTrace();
+        }
+    }
+