HomeAutomation_Call.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. package kr.co.icontrols.homeautomation;
  2. import android.app.ActivityManager;
  3. import android.content.ComponentName;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.util.Log;
  7. import com.artncore.WallPadDataMgr.WallpadStatusData;
  8. import com.artncore.commons.define;
  9. import java.util.List;
  10. public class HomeAutomation_Call {
  11. private static final String TAG = "HomeAutomation_Call";
  12. Context context;
  13. /** BR Action Name <br>
  14. * 본 Action Name을 BroadcastReceiver에 getAction 후 문자열 비교 등록 후 일치 시 사용해야 한다.
  15. * **/
  16. public static final String BR_ACTION_NAME = "HOME_AUTOMATION_CALL";
  17. public static final String BR_ACTION_NAME_OPTION = "HOME_AUTOMATION_CALL_OPTION";
  18. /** BR Data Type **/
  19. public static final String BR_DEVICE = "DEVICE";
  20. public static final String BR_TYPE_CALL = "TYPE_CALL";
  21. public static final String BR_ID_DONG = "ID_DONG";
  22. public static final String BR_ID_HO = "ID_HO";
  23. public static final String BR_BLOCK_NEWCALL = "BLOCK_NEWCALL";
  24. public static final String BR_BLOCK_NEWCALL_RELEASESEC = "BLOCK_NEWCALL_RELEASESEC";
  25. /** BR APP Name **/
  26. public static final String APP_NAME_WALLPADDEVSERVICE = "WallPadDevService";
  27. public static final String APP_NAME_WALLPADCALL = "WallPadCall";
  28. /** Device Define **/
  29. public static final int DEVICE_NONE = 0;
  30. public static final int DEVICE_GUARD = 1;
  31. public static final int DEVICE_LOBBY = 2;
  32. public static final int DEVICE_NEIBOR = 3;
  33. /** Call Type Define **/
  34. public static final int CALLTYPE_NONE = 0;
  35. public static final int CALLTYPE_RECEIVE_CALL_REQUEST = 1; //통화 요청 받음(수신)
  36. public static final int CALLTYPE_SEND_CALL_ACK = 2; //통화 요청 응답
  37. public static final int CALLTYPE_SEND_CALL_ACK_FAIL = 3; //통화 중 또는 통화 거절 응답
  38. public static final int CALLTYPE_SEND_CALL_START = 4; //통화 시작 보냄
  39. public static final int CALLTYPE_RECEIVE_CALL_END = 5; //통화 종료 받음
  40. public static final int CALLTYPE_SEND_CALL_END = 6; //통화 종료 보냄
  41. public static final int CALLTYPE_SEND_CALL_REQUEST = 7; //통화 요청 보냄(발신)
  42. public static final int CALLTYPE_RECEIVE_CALL_ACK = 8; //통화 응답 받음
  43. public static final int CALLTYPE_RECEIVE_CALL_ACK_FAIL = 9; //통화 중 또는 통화 거절 받음
  44. public static final int CALLTYPE_RECEIVE_CALL_START = 10; //통화 시작 받음
  45. public static final int CALLTYPE_SEND_DOOR_OPEN = 11; //문열림 요청
  46. public static final int CALLTYPE_RECEIVE_DOOR_OPEN_ACK = 12; //문열림 응답 (응답 수신 후, 통화 종료 BR Send 해야 함, 그리고 통화 APP 종료)
  47. public class Call_Info {
  48. /** 기기 종류 **/
  49. public int Type_Device;
  50. /** 통화 구분자 **/
  51. public int Type_Call;
  52. /** 동 정보
  53. * 경비인 경우 0사용 **/
  54. public int ID_Dong;
  55. /** 호 정보
  56. * 로비, 경비인 경우는 ID로 사용됨**/
  57. public int ID_Ho;
  58. public Call_Info() {
  59. Type_Device = DEVICE_NONE;
  60. Type_Call = CALLTYPE_NONE;
  61. ID_Dong = 0;
  62. ID_Ho = 0;
  63. }
  64. }
  65. /**
  66. * 생성자
  67. * **/
  68. public HomeAutomation_Call(Context ctx) {
  69. context = ctx;
  70. Log.d(TAG, "HomeAutomation_Call API Start");
  71. }
  72. /**
  73. * @description
  74. * 홈오토 통화 관련 BR 파싱 함수
  75. *
  76. * @return Call_Info Class (null인지 비교하고 사용)
  77. *
  78. * @param intent -> 수신 받은 intent 원형
  79. * @param AppName -> 본 함수 사용하는 APP의 Name ("WallPadDevService or WallPadCall")
  80. * **/
  81. int m_nCallType = 0;
  82. public Call_Info BR_Parsing(Intent intent, String AppName) {
  83. Log.e(TAG, "[BR_Parsing] AppName : " + AppName);
  84. Call_Info call_info = null;
  85. // 1. 디바이스 정보 범위 체크
  86. int Device = intent.getIntExtra(BR_DEVICE, DEVICE_NONE);
  87. if ((Device < DEVICE_NONE) || (Device > DEVICE_NEIBOR)) {
  88. Log.e(TAG, "BR_Parsing - Device is error : " + Device);
  89. return null;
  90. }
  91. // 2. 통화 정보 범위 체크
  92. int CallType = intent.getIntExtra(BR_TYPE_CALL, CALLTYPE_NONE);
  93. if ((CallType < CALLTYPE_NONE) || (CALLTYPE_RECEIVE_DOOR_OPEN_ACK < CallType)) {
  94. Log.e(TAG, "BR_Parsing - CallType is error : " + CallType);
  95. return null;
  96. }
  97. // 2.1 WallPadDevService 일 경우 받은 BR 종류 범위 체크
  98. if (AppName.equalsIgnoreCase(APP_NAME_WALLPADDEVSERVICE) == true) {
  99. switch (CallType) {
  100. case CALLTYPE_SEND_CALL_ACK:
  101. case CALLTYPE_SEND_CALL_ACK_FAIL:
  102. case CALLTYPE_SEND_CALL_START:
  103. case CALLTYPE_SEND_CALL_END:
  104. case CALLTYPE_SEND_CALL_REQUEST:
  105. case CALLTYPE_SEND_DOOR_OPEN:
  106. break;
  107. default:
  108. Log.e(TAG, "BR_Parsing - " + APP_NAME_WALLPADDEVSERVICE + " - CallType is error : " + CallType);
  109. return null;
  110. }
  111. }
  112. // 2.2 WallPadCall 일 경우 받은 BR 종류 범위 체크
  113. if (AppName.equalsIgnoreCase(APP_NAME_WALLPADCALL) == true) {
  114. switch (CallType) {
  115. case CALLTYPE_RECEIVE_CALL_REQUEST:
  116. case CALLTYPE_RECEIVE_CALL_END:
  117. case CALLTYPE_RECEIVE_CALL_ACK:
  118. case CALLTYPE_RECEIVE_CALL_ACK_FAIL:
  119. case CALLTYPE_RECEIVE_CALL_START:
  120. case CALLTYPE_RECEIVE_DOOR_OPEN_ACK:
  121. break;
  122. default:
  123. Log.e(TAG, "BR_Parsing - " + APP_NAME_WALLPADCALL + " - CallType is error : " + CallType);
  124. return null;
  125. }
  126. }
  127. // 3. 동 정보 범위 체크
  128. int Dong = intent.getIntExtra(BR_ID_DONG, -1);
  129. if ((Dong < 0) || (Dong > 9999)) {
  130. Log.e(TAG, "BR_Parsing - Dong is error : " + Dong);
  131. return null;
  132. }
  133. if (Device == DEVICE_GUARD) {
  134. if (Dong != 0) {
  135. Log.e(TAG, "BR_Parsing - Dong is error : " + Dong + "(DEVICE_GUARD)");
  136. return null;
  137. }
  138. }
  139. // 4. 호 정보 범위 체크
  140. int Ho = intent.getIntExtra(BR_ID_HO, -1);
  141. if ((Ho < 0) || (Ho > 9999)) {
  142. Log.e(TAG, "BR_Parsing - Ho is error : " + Ho);
  143. return null;
  144. }
  145. // 5. 데이터 응답
  146. call_info = new Call_Info();
  147. call_info.Type_Device = Device;
  148. call_info.Type_Call = CallType;
  149. call_info.ID_Dong = Dong;
  150. call_info.ID_Ho = Ho;
  151. Log.d(TAG, "BR_Parsing - call_info.Type_Device : " + call_info.Type_Device);
  152. Log.d(TAG, "BR_Parsing - call_info.Type_Call : " + call_info.Type_Call);
  153. Log.d(TAG, "BR_Parsing - call_info.ID_Dong : " + call_info.ID_Dong);
  154. Log.d(TAG, "BR_Parsing - call_info.ID_Ho : " + call_info.ID_Ho);
  155. return call_info;
  156. }
  157. /**
  158. * @description
  159. * 홈오토 통화 관련 BR 송신
  160. *
  161. * @return boolean -> true(정상), false(송신 실패)
  162. *
  163. * @param DeviceType -> 디바이스 종류
  164. * @param CallType -> 통화 종류
  165. * @param ID_Dong -> 동 ID (경비실인 경우는 무시)
  166. * @param ID_Ho -> 호 ID (로비, 경비인 경우는 ID로 사용됨)
  167. * **/
  168. public boolean BR_Send(int DeviceType, int CallType, int ID_Dong, int ID_Ho) {
  169. /** param check **/
  170. /*
  171. if(CallType == CALLTYPE_SEND_CALL_END || CallType == CALLTYPE_SEND_CALL_ACK_FAIL ||
  172. CallType == CALLTYPE_RECEIVE_CALL_END || CallType == CALLTYPE_RECEIVE_CALL_ACK_FAIL ||
  173. CallType == CALLTYPE_SEND_DOOR_OPEN || CallType == CALLTYPE_RECEIVE_DOOR_OPEN_ACK)
  174. {
  175. m_nCallType = 0;
  176. }
  177. else
  178. {
  179. m_nCallType = CallType;
  180. }
  181. */
  182. // 1. 디바이스 정보 범위 체크
  183. if ((DeviceType < DEVICE_NONE) || (DeviceType > DEVICE_NEIBOR)) {
  184. Log.e(TAG, "BR_Send - DeviceType is error : " + DeviceType);
  185. //m_nCallType = 0;
  186. return false;
  187. }
  188. // 2. 통화 정보 범위 체크
  189. if ((CallType < CALLTYPE_NONE) || (CallType > CALLTYPE_RECEIVE_DOOR_OPEN_ACK)) {
  190. Log.e(TAG, "BR_Send - CallType is error : " + CallType);
  191. //m_nCallType = 0;
  192. return false;
  193. }
  194. // 3. 동 정보 범위 체크
  195. if ((ID_Dong < 0) || (ID_Dong > 9999)) {
  196. Log.e(TAG, "BR_Send - ID_Dong is error : " + ID_Dong);
  197. //m_nCallType = 0;
  198. return false;
  199. }
  200. if (DeviceType == DEVICE_GUARD) {
  201. if (ID_Dong != 0) {
  202. Log.e(TAG, "BR_Send - ID_Dong is error : " + ID_Dong + "(DEVICE_GUARD)");
  203. //m_nCallType = 0;
  204. return false;
  205. }
  206. }
  207. // 4. 호 정보 범위 체크
  208. if ((ID_Ho < 0) || (ID_Ho > 9999)) {
  209. Log.e(TAG, "BR_Send - ID_Dong is error : " + ID_Ho);
  210. //m_nCallType = 0;
  211. return false;
  212. }
  213. Log.d(TAG, "BR_Send - DeviceType : " + DeviceType);
  214. Log.d(TAG, "BR_Send - CallType : " + CallType);
  215. Log.d(TAG, "BR_Send - ID_Dong : " + ID_Dong);
  216. Log.d(TAG, "BR_Send - ID_Ho : " + ID_Ho);
  217. //5. Broadcast 전송
  218. sendCallBR(DeviceType, CallType, ID_Dong, ID_Ho);
  219. /*
  220. if(CallType == CALLTYPE_SEND_CALL_END || CallType == CALLTYPE_SEND_CALL_ACK_FAIL ||
  221. CallType == CALLTYPE_RECEIVE_CALL_END || CallType == CALLTYPE_RECEIVE_CALL_ACK_FAIL ||
  222. CallType == CALLTYPE_SEND_DOOR_OPEN || CallType == CALLTYPE_RECEIVE_DOOR_OPEN_ACK)
  223. {
  224. m_nCallType = 0;
  225. }
  226. else
  227. {
  228. m_nCallType = CallType;
  229. }
  230. */
  231. //Log.d(TAG, "BR_Send - CallType1 : " + m_nCallType);
  232. // Intent mIntent = new Intent();
  233. // mIntent.setAction(BR_ACTION_NAME);
  234. // mIntent.putExtra(BR_DEVICE, DeviceType);
  235. // mIntent.putExtra(BR_TYPE_CALL, ID_Dong);
  236. // mIntent.putExtra(BR_ID_DONG, nDong);
  237. // mIntent.putExtra(BR_ID_HO, ID_Ho);
  238. // context.sendBroadcast(mIntent);
  239. return true;
  240. }
  241. public void setCallStaus(int nStatus) {
  242. m_nCallType = nStatus;
  243. Log.d(TAG, "BR_Send - CallType1 : " + m_nCallType);
  244. }
  245. public void sendCallBR(int nCallType, int nEventType, int nDong, int nHo) {
  246. try {
  247. Log.i(TAG, "[sendCallBR] nCallType [" + nCallType + "], nEventType [" + nEventType + "], nDong [" + nDong + "], nHo [" + nHo + "]");
  248. // 통화관련 BR을 전송하기 전에 신규호출과 관련된 내용이면, 통화어플이 동작중인지 확인하여
  249. // 통화어플이 동작중이면 BR을 전송하고,
  250. // 동작중이 아니면, 통화어플을 구동한다.
  251. if (nEventType == CALLTYPE_RECEIVE_CALL_REQUEST) {
  252. receiveNewCall(nCallType, nEventType, nDong, nHo);
  253. }
  254. else {
  255. Intent mIntent = new Intent();
  256. mIntent.setAction(BR_ACTION_NAME);
  257. mIntent.putExtra(BR_DEVICE, nCallType);
  258. mIntent.putExtra(BR_TYPE_CALL, nEventType);
  259. mIntent.putExtra(BR_ID_DONG, nDong);
  260. mIntent.putExtra(BR_ID_HO, nHo);
  261. context.sendBroadcast(mIntent);
  262. }
  263. } catch (Exception e) {
  264. Log.e(TAG, "[Exception] sendCallBR(int nCallType, int nEventType, int nDong, int nHo)");
  265. e.printStackTrace();
  266. }
  267. }
  268. public void sendBlockCallFalg(boolean bBlock, int nAutoReleaseSec) {
  269. try {
  270. Log.i(TAG, "[sendBlockCallFalg] bBlock [" + bBlock + "], nAutoReleaseSec [" + nAutoReleaseSec + "]");
  271. Intent mIntent = new Intent();
  272. mIntent.setAction(BR_ACTION_NAME_OPTION);
  273. mIntent.putExtra(BR_BLOCK_NEWCALL, bBlock);
  274. mIntent.putExtra(BR_BLOCK_NEWCALL_RELEASESEC, nAutoReleaseSec);
  275. context.sendBroadcast(mIntent);
  276. } catch (Exception e) {
  277. Log.e(TAG, "[Exception] sendBlockCallFalg(boolean bBlock, int nAutoReleaseSec)");
  278. e.printStackTrace();
  279. }
  280. }
  281. //String strWallPadAnalogCallPakageName = "kr.co.icontrols.wallpadanalogcall";
  282. String strWallPadAnalogCallPakageName = "kr.co.icontrols.wallpadcall";
  283. public void receiveNewCall(int nCallType, int nEventType, int nDong, int nHo) {
  284. try {
  285. Log.i(TAG, "[receiveNewCall] nCallType [" + nCallType + "], nEventType [" + nEventType + "], nDong [" + nDong + "], nHo [" + nHo + "]" + "], m_nCallType [" + m_nCallType + "]");
  286. CALLEVENTTYPE eEventType = CALLEVENTTYPE.RECEIVE_CALL;
  287. CALLTYPE eCallType = CALLTYPE.NONE;
  288. if (nCallType == DEVICE_LOBBY) eCallType = CALLTYPE.LOBBY;
  289. else if (nCallType == DEVICE_GUARD) eCallType = CALLTYPE.GUARD;
  290. else if (nCallType == DEVICE_NEIBOR) eCallType = CALLTYPE.RESIDENCE;
  291. else {
  292. Log.e(TAG, "[receiveNewCall] SIPID is not correct!!!");
  293. return;
  294. }
  295. //if (isCallAppRunning()) {
  296. if (m_nCallType == 0) {
  297. // 통화어플을 실행시킨다.
  298. //m_nCallType = 1;
  299. Log.w(TAG, "[runCallMainActivity] ########## START ##########");
  300. WallpadStatusData mWallpadStatusData = new WallpadStatusData(context);
  301. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  302. mWallpadStatusData.closeDB();
  303. if (nAlramStatus != WallpadStatusData.GUARD_OUT) sendBR_AppFinish(context);
  304. // 통화어플 실행 후, ACK 전송시 타임아웃 되는 경우가 있어서 통화어플이 실행중이지 않는 경우에는 API에서 바로 ACK를 전송한다.
  305. sendDirectACKBR(nCallType, CALLTYPE_SEND_CALL_ACK, nDong, nHo);
  306. //ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadanalogcall", "kr.co.icontrols.wallpadanalogcall.MainActivity");
  307. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  308. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  309. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  310. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  311. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  312. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  313. mIntent.putExtra(CALLTRIGGER.REMOTEINFO_DONG, nDong);
  314. mIntent.putExtra(CALLTRIGGER.REMOTEINFO_HO, nHo);
  315. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  316. mIntent.setComponent(mComponentName);
  317. context.startActivity(mIntent);
  318. // Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  319. }
  320. else {
  321. Log.w(TAG, "[runCallMainActivity] wallpadcall is already running!!");
  322. Log.e(TAG, "[runCallMainActivity] ############################## RUNNING ##############################");
  323. Intent mIntent = new Intent();
  324. mIntent.setAction(BR_ACTION_NAME);
  325. mIntent.putExtra(BR_DEVICE, nCallType);
  326. mIntent.putExtra(BR_TYPE_CALL, nEventType);
  327. mIntent.putExtra(BR_ID_DONG, nDong);
  328. mIntent.putExtra(BR_ID_HO, nHo);
  329. context.sendBroadcast(mIntent);
  330. }
  331. } catch (Exception e) {
  332. Log.e(TAG, "[Exception] runCallMainActivity()");
  333. e.printStackTrace();
  334. }
  335. }
  336. private boolean isCallAppRunning() {
  337. try {
  338. for (int i = 0; i < 5; i++) {
  339. Log.w(TAG, "[isCallAppRunning] Check Count [" + i + "]");
  340. if (!getTopActivity().equals(strWallPadAnalogCallPakageName)) {
  341. return true;
  342. }
  343. Thread.sleep(100);
  344. }
  345. return false;
  346. } catch (Exception e) {
  347. Log.e(TAG, "[Exception] isCallAppRunning()");
  348. e.printStackTrace();
  349. return false;
  350. }
  351. }
  352. private void sendDirectACKBR(int nCallType, int nEventType, int nDong, int nHo) {
  353. try {
  354. Log.i(TAG, "[sendDirectACKBR] nCallType [" + nCallType + "], nEventType [" + nEventType + "], nDong [" + nDong + "], nHo [" + nHo + "]");
  355. // Thread.sleep(500);
  356. Intent mIntent = new Intent();
  357. mIntent.setAction(BR_ACTION_NAME);
  358. mIntent.putExtra(BR_DEVICE, nCallType);
  359. mIntent.putExtra(BR_TYPE_CALL, nEventType);
  360. mIntent.putExtra(BR_ID_DONG, nDong);
  361. mIntent.putExtra(BR_ID_HO, nHo);
  362. context.sendBroadcast(mIntent);
  363. } catch (Exception e) {
  364. Log.e(TAG, "[Exception] sendDirectACKBR(int nCallType, int nEventType, int nDong, int nHo)");
  365. e.printStackTrace();
  366. }
  367. }
  368. private String getTopActivity() {
  369. try {
  370. // ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  371. ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  372. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  373. Log.i(TAG, "[getTopActivity] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  374. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  375. Log.i(TAG, "[getTopActivity] getPackageName = " + mComponentName.getPackageName());
  376. return mComponentName.getPackageName();
  377. } catch (Exception e) {
  378. Log.e(TAG, "[Exception] getTopActivity()");
  379. e.printStackTrace();
  380. return null;
  381. }
  382. }
  383. private void sendBR_AppFinish(Context context) {
  384. try {
  385. Log.w(TAG, "[sendBR_AppFinish] Send App Finish!!");
  386. Intent mIntent = new Intent();
  387. mIntent.setAction(define.BR_APP_FINISH);
  388. context.sendBroadcast(mIntent);
  389. } catch (Exception e) {
  390. Log.e(TAG, "[Exception] sendBR_AppFinish(Context context)");
  391. e.printStackTrace();
  392. }
  393. }
  394. public static class CALLTRIGGER {
  395. public static String CALLOWNER = "CALLOWNER";
  396. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  397. public static String CALLTYPE = "CALLTYPE";
  398. public static String REMOTEINFO = "REMOTEINFO";
  399. public static String REMOTEINFO_DONG = "REMOTEINFO_DONG";
  400. public static String REMOTEINFO_HO = "REMOTEINFO_HO";
  401. public enum SOURCE {
  402. USER,
  403. CALL_RECEIVE,
  404. SUBPHONE
  405. }
  406. public enum TYPE {
  407. MENU,
  408. FRONT,
  409. LOBBY,
  410. GUARD,
  411. RESIDENCE,
  412. PSTN
  413. }
  414. }
  415. // 통화상태정보를 다루는 enum
  416. public enum CALLTYPE {
  417. NONE,
  418. FRONT,
  419. RESIDENCE,
  420. LOBBY,
  421. GUARD,
  422. PSTN,
  423. IHUB,
  424. HISTORY_CALL,
  425. HISTORY_VISITORPIC,
  426. ERROR;
  427. public static CALLTYPE getCALLTYPE(String value) {
  428. try {
  429. if (value.equals(NONE.toString())) {
  430. return NONE;
  431. }
  432. else if (value.equals(FRONT.toString())) {
  433. return FRONT;
  434. }
  435. else if (value.equals(RESIDENCE.toString())) {
  436. return RESIDENCE;
  437. }
  438. else if (value.equals(LOBBY.toString())) {
  439. return LOBBY;
  440. }
  441. else if (value.equals(GUARD.toString())) {
  442. return GUARD;
  443. }
  444. else if (value.equals(PSTN.toString())) {
  445. return PSTN;
  446. }
  447. else if (value.equals(IHUB.toString())) {
  448. return IHUB;
  449. }
  450. else if (value.equals(HISTORY_CALL.toString())) {
  451. return HISTORY_CALL;
  452. }
  453. else if (value.equals(HISTORY_VISITORPIC.toString())) {
  454. return HISTORY_VISITORPIC;
  455. }
  456. else if (value.equals(ERROR.toString())) {
  457. return ERROR;
  458. }
  459. else {
  460. return null;
  461. }
  462. } catch (Exception e) {
  463. Log.e(TAG, "[Exception] getCALLTYPE()");
  464. e.printStackTrace();
  465. return null;
  466. }
  467. }
  468. }
  469. public enum CALLEVENTTYPE {
  470. RECEIVE_CALL, // 호출 수신 (호출 수신)
  471. TRYING_CALL, // 호출 시도중 (호출 발신)
  472. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  473. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  474. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  475. CONNECT_CALL, // 통화 시작
  476. TERMINATE_CALL, // 통화 종료
  477. CANCEL_CALL, // 호출 취소
  478. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  479. REJECT_CALL, // 호출수신 거절
  480. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  481. FORWARD_CALL, // 착신전환 설정
  482. CALLERID, // Caller ID
  483. TIMEOUT_1STCALL, // 1st Call Timeout
  484. TIMEOUT_2NDCALL, // 2nd Call Timeout
  485. TIMEOUT_3RDCALL, // 3rd Call Timeout
  486. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  487. DOOR_OPEN, // 문열림 설정
  488. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  489. PSTN_DTMF, // PSTN DTMF 수신
  490. NONE;
  491. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  492. try {
  493. if (value.equals(RECEIVE_CALL.toString())) {
  494. return RECEIVE_CALL;
  495. }
  496. else if (value.equals(TRYING_CALL.toString())) {
  497. return TRYING_CALL;
  498. }
  499. else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  500. return RECEIVE_CALL_2ND;
  501. }
  502. else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  503. return RECEIVE_CALL_ACK;
  504. }
  505. else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  506. return REQUEST_FRONT_MONITORING;
  507. }
  508. else if (value.equals(CONNECT_CALL.toString())) {
  509. return CONNECT_CALL;
  510. }
  511. else if (value.equals(TERMINATE_CALL.toString())) {
  512. return TERMINATE_CALL;
  513. }
  514. else if (value.equals(CANCEL_CALL.toString())) {
  515. return CANCEL_CALL;
  516. }
  517. else if (value.equals(REJECT_CALL.toString())) {
  518. return REJECT_CALL;
  519. }
  520. else if (value.equals(REJECT_BUSY_CALL.toString())) {
  521. return REJECT_BUSY_CALL;
  522. }
  523. else if (value.equals(FORWARD_CALL.toString())) {
  524. return FORWARD_CALL;
  525. }
  526. else if (value.equals(CALLERID.toString())) {
  527. return CALLERID;
  528. }
  529. else if (value.equals(TIMEOUT_1STCALL.toString())) {
  530. return TIMEOUT_1STCALL;
  531. }
  532. else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  533. return TIMEOUT_2NDCALL;
  534. }
  535. else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  536. return TIMEOUT_3RDCALL;
  537. }
  538. else if (value.equals(MOIP_VIDEO_SET.toString())) {
  539. return MOIP_VIDEO_SET;
  540. }
  541. else if (value.equals(DOOR_OPEN.toString())) {
  542. return DOOR_OPEN;
  543. }
  544. else if (value.equals(PSTN_RING.toString())) {
  545. return PSTN_RING;
  546. }
  547. else if (value.equals(PSTN_DTMF.toString())) {
  548. return PSTN_DTMF;
  549. }
  550. else if (value.equals(NONE.toString())) {
  551. return NONE;
  552. }
  553. else {
  554. return null;
  555. }
  556. } catch (Exception e) {
  557. Log.e(TAG, "[Exception] getCALLEVENTTYPE()");
  558. e.printStackTrace();
  559. return null;
  560. }
  561. }
  562. }
  563. public enum CALLOWNER {
  564. NONE,
  565. WALLPAD,
  566. SUB_WALLPAD,
  567. KITCHEN_TV,
  568. BATH_PHONE,
  569. BATH_TV,
  570. UNIVERSAL_DEVICE,
  571. ERROR;
  572. public static CALLOWNER getCALLOWNER(String value) {
  573. try {
  574. if (value.equals(NONE.toString())) {
  575. return NONE;
  576. }
  577. else if (value.equals(WALLPAD.toString())) {
  578. return WALLPAD;
  579. }
  580. else if (value.equals(SUB_WALLPAD.toString())) {
  581. return SUB_WALLPAD;
  582. }
  583. else if (value.equals(KITCHEN_TV.toString())) {
  584. return KITCHEN_TV;
  585. }
  586. else if (value.equals(BATH_PHONE.toString())) {
  587. return BATH_PHONE;
  588. }
  589. else if (value.equals(BATH_TV.toString())) {
  590. return BATH_TV;
  591. }
  592. else if (value.equals(UNIVERSAL_DEVICE.toString())) {
  593. return UNIVERSAL_DEVICE;
  594. }
  595. else if (value.equals(ERROR.toString())) {
  596. return ERROR;
  597. }
  598. else {
  599. return null;
  600. }
  601. } catch (Exception e) {
  602. Log.e(TAG, "[Exception] getCALLOWNER()");
  603. e.printStackTrace();
  604. return null;
  605. }
  606. }
  607. }
  608. }