|
|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|