MainActivity.java 273 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772
  1. package kr.co.icontrols.wallpadcall;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.content.pm.PackageManager;
  9. import android.graphics.Bitmap;
  10. import android.graphics.BitmapFactory;
  11. import android.graphics.Color;
  12. import android.graphics.Matrix;
  13. import android.hardware.Camera;
  14. import android.hardware.Camera.ErrorCallback;
  15. import android.media.AudioManager;
  16. import android.media.CamcorderProfile;
  17. import android.media.MediaPlayer;
  18. import android.media.MediaRecorder;
  19. import android.os.Build;
  20. import android.os.Bundle;
  21. import android.os.CountDownTimer;
  22. import android.os.Handler;
  23. import android.os.Looper;
  24. import android.os.Message;
  25. import android.os.PowerManager;
  26. import android.util.Log;
  27. import android.view.Gravity;
  28. import android.view.KeyEvent;
  29. import android.view.MotionEvent;
  30. import android.view.SurfaceHolder;
  31. import android.view.SurfaceHolder.Callback;
  32. import android.view.SurfaceView;
  33. import android.view.View;
  34. import android.view.animation.AccelerateInterpolator;
  35. import android.view.animation.Animation;
  36. import android.view.animation.AnimationUtils;
  37. import android.view.animation.TranslateAnimation;
  38. import android.widget.Button;
  39. import android.widget.ExpandableListView;
  40. import android.widget.RelativeLayout;
  41. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  42. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  43. import com.artncore.WallPadDataMgr.WallpadStatusData;
  44. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  45. import com.artncore.commons.API_Menu;
  46. import com.artncore.commons.API_Menu.MenuListDataClass;
  47. import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping;
  48. import com.artncore.commons.define;
  49. import com.artncore.wallpadapi.FP_DlockAPI;
  50. import com.artncore.wallpadapi.IGW300API;
  51. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  52. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  53. import com.artncore.wallpadapi.WallPadAPI;
  54. import com.artncore.wallpadimap.RetProci;
  55. import com.util.LogUtil;
  56. import java.io.BufferedInputStream;
  57. import java.io.BufferedOutputStream;
  58. import java.io.File;
  59. import java.io.FileDescriptor;
  60. import java.io.FileInputStream;
  61. import java.io.FileNotFoundException;
  62. import java.io.FileOutputStream;
  63. import java.io.IOException;
  64. import java.io.InputStream;
  65. import java.io.OutputStream;
  66. import java.util.ArrayList;
  67. import java.util.Calendar;
  68. import java.util.Date;
  69. import java.util.List;
  70. import javax.crypto.Cipher;
  71. import javax.crypto.spec.SecretKeySpec;
  72. import kr.co.icontrols.ReliefCall.ReliefCallInterface;
  73. import kr.co.icontrols.callengine.engine.AudioRecordController;
  74. import kr.co.icontrols.callengine.engine.CallController;
  75. import kr.co.icontrols.callengine.engine.CallManager.CALLEVENTTYPE;
  76. import kr.co.icontrols.callengine.engine.CallManager.CALLOWNER;
  77. import kr.co.icontrols.callengine.engine.CallManager.CALLPATH;
  78. import kr.co.icontrols.callengine.engine.CallManager.CALLSTATUS;
  79. import kr.co.icontrols.callengine.engine.CallManager.CALLTYPE;
  80. import kr.co.icontrols.callengine.engine.RemoteCallController;
  81. import kr.co.icontrols.callengine.engine.VideoController;
  82. import kr.co.icontrols.callengine.history.CallHistoryManager;
  83. import kr.co.icontrols.callengine.history.VisitorPictureHistoryManager;
  84. import kr.co.icontrols.callengine.pstn.ATCmds.PSTNHANDLERMSG;
  85. import kr.co.icontrols.callengine.pstn.PSTNController;
  86. import kr.co.icontrols.callengine.remotecall.DataSender;
  87. import kr.co.icontrols.callengine.subphone.SubPhoneController;
  88. import kr.co.icontrols.callengine.subwallpad.SubWallPadController;
  89. import kr.co.icontrols.wallpadcall.declare.Common;
  90. import kr.co.icontrols.wallpadcall.declare.DataClasses.RemoteIDInfo;
  91. import kr.co.icontrols.wallpadcall.declare.DataClasses.SmartRFCamLEDMode;
  92. import kr.co.icontrols.wallpadcall.declare.DataClasses.SmartRFCamStatusMode;
  93. import kr.co.icontrols.wallpadcall.declare.Declare;
  94. import kr.co.icontrols.wallpadcall.declare.Declare.CALLTRIGGER;
  95. import kr.co.icontrols.wallpadcall.declare.Declare.IGW300CMD;
  96. import kr.co.icontrols.wallpadcall.declare.Global;
  97. import kr.co.icontrols.wallpadcall.declare.Global.BOARD_TYPE;
  98. import kr.co.icontrols.wallpadcall.declare.Global.ConfigValues;
  99. import kr.co.icontrols.wallpadcall.declare.Global.DOORLOCKTYPE;
  100. import kr.co.icontrols.wallpadcall.declare.Global.FRONTCAMERATYPE;
  101. import kr.co.icontrols.wallpadcall.declare.Global.SUBWALLPAD_PSTNTYPE;
  102. import kr.co.icontrols.wallpadcall.declare.Global.WALLPADTYPE;
  103. import kr.co.icontrols.wallpadcall.declare.ID;
  104. import kr.co.icontrols.wallpadcall.imap.Request_check_sip_activation;
  105. import kr.co.icontrols.wallpadcall.screen.InquiryCallHistory;
  106. import kr.co.icontrols.wallpadcall.screen.InquiryVisitorPictureHistory;
  107. import kr.co.icontrols.wallpadcall.screen.TalkFront;
  108. import kr.co.icontrols.wallpadcall.screen.TalkGuard;
  109. import kr.co.icontrols.wallpadcall.screen.TalkLobby;
  110. import kr.co.icontrols.wallpadcall.screen.TalkPSTN;
  111. import kr.co.icontrols.wallpadcall.screen.TalkResidence;
  112. import kr.co.icontrols.wallpadcall.screen.VisitorPictureViewer;
  113. import kr.co.icontrols.wallpadcall.subwallpadscreen.TalkFront_SubWallPad;
  114. import kr.co.icontrols.wallpadcall.subwallpadscreen.TalkGuard_SubWallPad;
  115. import kr.co.icontrols.wallpadcall.subwallpadscreen.TalkLobby_SubWallPad;
  116. import kr.co.icontrols.wallpadcall.subwallpadscreen.TalkPSTN_SubWallPad;
  117. import kr.co.icontrols.wallpadcall.subwallpadscreen.TalkResidence_SubWallPad;
  118. import kr.co.icontrols.wallpadsupport.Version;
  119. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  120. import kr.co.icontrols.wallpadsupport.WpadActivity;
  121. import kr.co.icontrols.wallpadsupport.WpadImageView;
  122. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  123. import kr.co.icontrols.wallpadsupport.WpadRelativeLayoutParams;
  124. import kr.co.icontrols.wallpadsupport.WpadScale;
  125. import kr.co.icontrols.wallpadsupport.WpadSound;
  126. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  127. import kr.co.icontrols.wallpadsupport.WpadTextView;
  128. import kr.co.icontrols.wallpadsupport.WpadUtil;
  129. import static kr.co.icontrols.wallpadcall.declare.Declare.BR.ACNAME_MAIN_NOTI;
  130. /**
  131. * @description 월패드 [통화] 메인화면 이다.
  132. * 상단의 Top 메뉴, [홈] [돌아가기]
  133. * 좌측의 슬라이드 메뉴, [현관] [경비] [이웃] ... 등 선택 메뉴
  134. * 를 여기서 처리한다.
  135. */
  136. public class MainActivity extends WpadActivity {
  137. private final static String TAG = "MainActivity";
  138. //test
  139. /**
  140. * MoIP 영상통화시, FFMPEG 사용 여부 설정
  141. * true: FFMPEG 사용, MoIP 영상을 안드로이드 화면의 surface에 출력
  142. * false: FFMPEG 미사용, MoIP 영상을 OS에서 프레임버퍼에 직접 출력 (surface에 출력 안함)
  143. * FFMPEG 적용 모델
  144. * - IHN-1020B-I
  145. */
  146. public static boolean bFFMPEGEnable = false;
  147. boolean bLOG = true;
  148. private void LOG(String log) {
  149. if (bLOG) Log.v(TAG, log);
  150. }
  151. boolean bLOG_DEBUG = false;
  152. private void LOG_DEBUG(String log) {
  153. if (bLOG_DEBUG) Log.d(TAG, log);
  154. }
  155. boolean bLOG_INFO = true;
  156. private void LOG_INFO(String log) {
  157. if (bLOG_INFO) Log.i(TAG, log);
  158. }
  159. boolean bLOG_WARN = true;
  160. private void LOG_WARN(String log) {
  161. if (bLOG_WARN) Log.w(TAG, log);
  162. }
  163. // =================================================================================================
  164. // [[ Declaration ]] region
  165. // =================================================================================================
  166. protected Context mContext = null;
  167. public Context getContext() {
  168. return mContext;
  169. }
  170. public WallPadAPI mWallPadAPI = null;
  171. public SmartKeyRfDoorAPI smartKeyRfDoorAPI;
  172. Sdb_LivingRoomLightAPI sdbLivingRoomLightAPI;
  173. public FP_DlockAPI fpDlockAPI;
  174. private int OPERATION_MODE = Common.MODE;
  175. // Layout
  176. private RelativeLayout AllLayout; // 화면 전체
  177. private RelativeLayout TopLayout; // 상단 메뉴
  178. private RelativeLayout MenuLayout; // 메뉴 화면
  179. private RelativeLayout ScreenLayout; // 제어기기 화면
  180. RelativeLayout SurfaceLayout; // 영상표시 화면
  181. // SurfaceLayout 구성
  182. RelativeLayout MyVideoLayout; // MoIP 카메라 영상 (월패드 전면 카메라)
  183. // SurfaceHolder MyVideoHolder;
  184. SurfaceView MyVideoSurface;
  185. RelativeLayout RemoteVideoLayout; // MoIP 수신 영상 (로비/경비/이웃 영상)
  186. // SurfaceHolder RemoteVideoHolder;
  187. SurfaceView RemoteVideoSurface;
  188. WpadImageView IMG_REMOTE_VIDEO_PATCH;
  189. RelativeLayout FrontVideoLayout; // 현관 카메라 영상
  190. SurfaceHolder FrontVideoHolder;
  191. SurfaceView FrontVideoSurface;
  192. WpadTextView TXT_REMOTE_ID;
  193. WpadImageView ScreenBackground;
  194. private static final int REQUEST_EXTERNAL_STORAGE = 100;
  195. // Top
  196. private WpadImageView TopBackground;
  197. private WpadTextView TopTitle;
  198. private WpadTextView SampleModeTitle;
  199. private WpadTextView TopStrangerRecodingNotice;
  200. private WpadTextView TopRemoteCallNotice;
  201. public WpadImageView TopHomeBtn;
  202. public WpadImageView TopBackBtn;
  203. private WpadImageView TopMenuBtn;
  204. private WpadImageView TopManualBtn;
  205. private WpadImageView TopSetBtn;
  206. private WpadImageView TopHideBtn;
  207. // Menu
  208. private WpadImageView MenuBackground;
  209. private WpadImageView MenuClose;
  210. private WpadTextView MenuTitle;
  211. private static ExpandableListView mListView;
  212. private Menu_AdptMain adptMain;
  213. private MenuListDataClass menuListDataClass;
  214. private Menu mMenu = null; // WPadAPI의 Menu class
  215. private boolean MenuOpen = false;
  216. public boolean mNewDanjiServer = false;
  217. // PopupActivityRun
  218. private static boolean PopupActivityRun = false;
  219. public static boolean getPopupActivityRun() {
  220. Log.d(TAG, "[getPopupActivityRun] PopupActivityRun [" + PopupActivityRun + "]");
  221. return PopupActivityRun;
  222. }
  223. public static void setPopupActivityRun(boolean run) {
  224. PopupActivityRun = run;
  225. Log.d(TAG, "[setPopupActivityRun] PopupActivityRun [" + PopupActivityRun + "]");
  226. if (!PopupActivityRun) resetCurrentPopUpScreenID();
  227. }
  228. // ManualActivityRun
  229. private static boolean ManualActivityRun = false;
  230. public static boolean getManualActivityRun() {
  231. Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun);
  232. return ManualActivityRun;
  233. }
  234. public static void setManualActivityRun(boolean run) {
  235. ManualActivityRun = run;
  236. if (!ManualActivityRun) resetCurrentManualScreenID();
  237. }
  238. // CurrentScreenId
  239. private int mCurrentScreenId = -1;
  240. private int mTempCurrentScreenId = -1;
  241. private static int mCurrentPopUpScreenId = -1;
  242. private static int mCurrentManualScreenId = -1;
  243. int allWidth, allHeight, screenWidth, screenHeight, topHeight, fontSize;
  244. // System Volume
  245. int nSysVolume = 0;
  246. int nTempSysVolume = 7;
  247. int nTempDTMFVolume = 11;
  248. int nTempReliefVolume = 11;
  249. int nTempDingDongVolume = 12;
  250. int nTempDingDongVolume_IDCHS100 = 10;
  251. // Screen
  252. private TalkFront ScreenTalkFront = null; // 현관통화
  253. private TalkLobby ScreenTalkLobby = null; // 로비통화
  254. private TalkGuard ScreenTalkGuard = null; // 경비실통화
  255. private TalkResidence ScreenTalkResidence = null; // 세대통화
  256. private TalkPSTN ScreenTalkPSTN = null; // 국선통화
  257. private InquiryCallHistory ScreenInquiryCallHistory = null; // 통화내역
  258. private InquiryVisitorPictureHistory ScreenInquiryVisitorPictureHistory = null; // 방문자 사진
  259. private VisitorPictureViewer ScreenVisitorPictureViewer = null; // 방문자 사진 뷰어
  260. // SubWallPad Screen
  261. private TalkFront_SubWallPad ScreenTalkFrontSub = null;
  262. private TalkLobby_SubWallPad ScreenTalkLobbySub = null;
  263. private TalkGuard_SubWallPad ScreenTalkGuardSub = null;
  264. private TalkResidence_SubWallPad ScreenResidenceSub = null;
  265. private TalkPSTN_SubWallPad ScreenPSTNSub = null;
  266. public static IOInterface mIOInterface;
  267. public static AudioManager mAudioManager;
  268. public static PowerManager mPowerManager;
  269. public static CallHistoryManager mCallHistoryManager;
  270. public static VisitorPictureHistoryManager mVisitorPictureHistoryManager;
  271. public static CallController mCallController;
  272. public static VideoController mVideoController;
  273. public static AudioRecordController mAudioRecordController;
  274. public static WpadSound mSound;
  275. public static PSTNController mPSTNController;
  276. public static SubPhoneController mSubPhoneController;
  277. public static SubWallPadController mSubWallPadController;
  278. public static RemoteCallController mRemoteCallController;
  279. // ***** 방문객 원격통화 솔루션 관련 *****
  280. public static DataSender mDataSender; // 영상 데이터를 SendMedia API를 통해 모바일쪽에 전달
  281. // ***** 안심통화 솔루션 관련 *****
  282. public static ReliefCallInterface mReliefCallIF;
  283. public boolean bBlockHomeBTN = false;
  284. public boolean bLCDReverse = false;
  285. public static boolean bFrontCallUse, bLobbyCallUse, bGuardCallUse, bResiCallUse, bPSTNCallUse, bCallHistoryUse, bVisitorPicUse;
  286. /* =================================================================================================
  287. * [ Activity Life Cycle ] region
  288. ================================================================================================ */
  289. @Override
  290. protected void onCreate(Bundle savedInstanceState) {
  291. super.onCreate(savedInstanceState);
  292. try {
  293. Log.i(TAG, "=============== [START - MainActivity] ===============");
  294. registerWallPadCallLiveBRReceiver();
  295. Global.setGlobalContext(this);
  296. Global.getConfigValues(); // 디바이스 설정
  297. nSysVolume = Global.getConfigSystemVolume();
  298. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1020B_I) bFFMPEGEnable = true;
  299. else bFFMPEGEnable = false;
  300. Log.i(TAG, "[onCreate] bFFMPEGEnable [" + bFFMPEGEnable + "]");
  301. registerBRReceiver();
  302. if (ConfigValues.bReliefCall) {
  303. Log.i(TAG, "[onCreate] --------------- ReliefCallInterface ---------------");
  304. mReliefCallIF = new ReliefCallInterface();
  305. }
  306. // API 호출
  307. if (OPERATION_MODE == Common.MODE_NORMAL) {
  308. LOG_DEBUG("OperationMode = MODE_NORMAL");
  309. try {
  310. mWallPadAPI = new WallPadAPI(this);
  311. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  312. // IHN-D101 일 경우, 스마트폰 조명제어 사용여부 설정 제어하기 위함 (거실에너지미터 BT-Wifi 모듈이 마이크에 무선 노이즈를 발생시키므로)
  313. mWallPadApiCheckHandler.sendEmptyMessage(2);
  314. }
  315. if (ConfigValues.eDoorLockType == DOORLOCKTYPE.FINGERPRINT) {
  316. // 지문인식 도어락일경우, API 로딩
  317. mWallPadApiCheckHandler.sendEmptyMessage(4);
  318. }
  319. } catch (RuntimeException re) {
  320. LogUtil.errorLogInfo("", TAG, re);
  321. } catch (Exception e) {
  322. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  323. //e.printStackTrace();
  324. LogUtil.errorLogInfo("", TAG, e);
  325. }
  326. }
  327. else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  328. LOG_DEBUG("OperationMode = MODE_BUSINESS_SAMPLE");
  329. }
  330. checkDevService(); // 디바이스 서비스 실행여부를 확인하고, 실행중이 아니면 실행시킨다.
  331. initIOInterface(); // I/O 제어 JNI
  332. mSound = new WpadSound(this);
  333. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101) LOG_INFO("[onCreate] Model Type [IHN_D101]");
  334. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I) LOG_INFO("[onCreate] Model Type [IHN_D101-I]");
  335. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I_OCF) LOG_INFO("[onCreate] Model Type [IHN_D101-I-OCF]");
  336. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL) LOG_INFO("[onCreate] Model Type [IHN_1010GL]");
  337. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I) LOG_INFO("[onCreate] Model Type [IHN_1010GL-I]");
  338. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I_2443) LOG_INFO("[onCreate] Model Type [IHN_1010GL-I-2443]");
  339. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I_6410) LOG_INFO("[onCreate] Model Type [IHN_1010GL-I-6410]");
  340. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K) LOG_INFO("[onCreate] Model Type [IHN_D101K]");
  341. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K_I) LOG_INFO("[onCreate] Model Type [IHN_D101K-I]");
  342. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010) {
  343. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) LOG_INFO("[onCreate] Model Type [IHN_1010]");
  344. else LOG_INFO("[onCreate] Model Type [IHN_1010S]"); // 서브월패드
  345. }
  346. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010_I) {
  347. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) LOG_INFO("[onCreate] Model Type [IHN_1010-I]");
  348. else LOG_INFO("[onCreate] Model Type [IHN_1010-IS]"); // 서브월패드
  349. }
  350. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1030_I) LOG_INFO("[onCreate] Model Type [IHN_1030-I]");
  351. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1040) LOG_INFO("[onCreate] Model Type [IHN_1040]");
  352. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1040_I) LOG_INFO("[onCreate] Model Type [IHN_1040-I]");
  353. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1050) LOG_INFO("[onCreate] Model Type [IHN_1050]");
  354. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1050_I) LOG_INFO("[onCreate] Model Type [IHN_1050-I]");
  355. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_T1010) LOG_INFO("[onCreate] Model Type [IHN_T1010]");
  356. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_T1010_I) LOG_INFO("[onCreate] Model Type [IHN_T1010-I]");
  357. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101) LOG_INFO("[onCreate] Model Type [IHN_HS101]");
  358. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101_I) LOG_INFO("[onCreate] Model Type [IHN_HS101-I]");
  359. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_430) LOG_INFO("[onCreate] Model Type [IHN_430]");
  360. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_430_I) LOG_INFO("[onCreate] Model Type [IHN_430-I]");
  361. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_DW101_I) LOG_INFO("[onCreate] Model Type [IHN_DW101_I]");
  362. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1020B_I) LOG_INFO("[onCreate] Model Type [IHN_1020B_I]");
  363. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1303_I) LOG_INFO("[onCreate] Model Type [IHN_1303_I]");
  364. else LOG_INFO("[onCreate] ConfigValues.DEVICE_MODELTYPE [" + ConfigValues.DEVICE_MODELTYPE + "]");
  365. // @ AutoScale 설정
  366. WpadScale.setAutoScale(true);
  367. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  368. LOG_INFO("[Create] WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "]");
  369. mContext = this;
  370. ManualActivityRun = false;
  371. // setCallAppRunning(true);
  372. setPopupActivityRun(false);
  373. // checkMemoryUsage(); // 통화 앱 시작시 메모리 체크
  374. getCallFunctionUse();
  375. mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  376. mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  377. Global.ctrlLCDOnOff(true);
  378. // ****************** VOLUME 값 확인 ******************
  379. Log.d(TAG, "[VOLUME TEST] nSysVolume [" + nSysVolume + "]");
  380. // Log.d(TAG, "[VOLUME TEST] STREAM_SYSTEM ---> Volume : " + mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM));
  381. // Log.d(TAG, "[VOLUME TEST] STREAM_VOICE_CALL ---> Volume : " + mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL));
  382. // Log.d(TAG, "[VOLUME TEST] STREAM_RING ---> Volume : " + mAudioManager.getStreamVolume(AudioManager.STREAM_RING));
  383. // Log.d(TAG, "[VOLUME TEST] STREAM_DTMF ---> Volume : " + mAudioManager.getStreamVolume(AudioManager.STREAM_DTMF));
  384. // 2. 자동 종료 셋팅
  385. LOG_INFO("[Create] - Step2 : Auto Finish Setting");
  386. // 2-1. 자동종료 타이머 셋팅
  387. super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  388. // 3. API 호출 -> 코드 이동
  389. // 4. Layout registration
  390. LOG_INFO("[Create] - Step4 : Layout registration");
  391. allWidth = WpadScale.getWidthPixels();
  392. allHeight = WpadScale.getHeightPixels();
  393. screenWidth = 1280;
  394. screenHeight = 800;
  395. topHeight = 110;
  396. fontSize = Common.fontsize._44;
  397. LOG("[Create] allWidth [" + allWidth + "], allHeight [" + allHeight + "]");
  398. // 4-1. mainLayout
  399. AllLayout = new RelativeLayout(this);
  400. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(allWidth, allHeight);
  401. AllLayout.setLayoutParams(params);
  402. AllLayout.setId(ID.MAINACTIVITY.LAYOUT.ALL);
  403. super.setAllLayoutRegistration(AllLayout);
  404. // 4-2. TopLayout
  405. TopLayout = new RelativeLayout(this);
  406. WpadUtil.LayoutRegistration(AllLayout, TopLayout, screenWidth, topHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.TOP);
  407. // 4-4. ScreenLayout
  408. ScreenLayout = new RelativeLayout(this);
  409. WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, screenWidth, screenHeight - topHeight, 0, topHeight, ID.MAINACTIVITY.LAYOUT.SCREEN);
  410. ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, screenWidth, screenHeight - topHeight, R.drawable.bg_body, R.drawable.bg_body, ID.MAINACTIVITY.IMAGE.SCREEN_BACKGROUND);
  411. ViewRegistration(ScreenLayout, ScreenBackground, 0, 0);
  412. SurfaceLayout = new RelativeLayout(this);
  413. WpadUtil.LayoutRegistration(AllLayout, SurfaceLayout, allWidth, allHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  414. TXT_REMOTE_ID = new WpadTextView(this, false, 356, 50, Gravity.CENTER, Color.WHITE, 30, false, ID.MAINACTIVITY.TEXT.REMOTE_ID);
  415. ViewRegistration(AllLayout, TXT_REMOTE_ID, 273, 577);
  416. // Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/NanumGothicCoding.ttf");
  417. // TXT_REMOTE_ID.setTypeface(typeface);
  418. TXT_REMOTE_ID.setVisibility(View.INVISIBLE);
  419. initCallEngine();
  420. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  421. initCallHistoryDB();
  422. initVisitorPictureHistoryDB();
  423. }
  424. // 5. Top Menu - ImageView registration
  425. LOG_INFO("[Create] - Step5 : Top Menu - ImageView registration");
  426. TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, screenWidth, topHeight, R.drawable.bg_topbar, 0, ID.TOP.IMAGE.TOP_BACKGROUND);
  427. ViewRegistration(TopLayout, TopBackground, 0, 0);
  428. TopTitle = new WpadTextView(this, false, 247 + 50, 80, Gravity.LEFT, Color.WHITE, fontSize, true, ID.TOP.TEXT.TITLE);
  429. ViewRegistration(TopLayout, TopTitle, 133, 15);
  430. TopHideBtn = new WpadImageView(this, TOUCH_KIND.BUTTON_LC, 110, 110, 0, 0, ID.TOP.BUTTON.HIDE);
  431. ViewRegistration(TopLayout, TopHideBtn, 250, 0);
  432. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  433. SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0);
  434. ViewRegistration(TopLayout, SampleModeTitle, 316, 17);
  435. SampleModeTitle.setText("[영업샘플모드]");
  436. }
  437. else if (Common.MODE == Common.MODE_PRODUCTION) {
  438. SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0);
  439. ViewRegistration(TopLayout, SampleModeTitle, 316, 17);
  440. SampleModeTitle.setText("[생산 검수 모드]");
  441. }
  442. if (getStrangerRecording()) {
  443. TopStrangerRecodingNotice = new WpadTextView(this, false, 640, 72, Gravity.CENTER, Color.parseColor("#FF8C00"), Common.fontsize._50, true, 0);
  444. ViewRegistration(TopLayout, TopStrangerRecodingNotice, 320, 17);
  445. TopStrangerRecodingNotice.setVisibility(View.INVISIBLE);
  446. }
  447. if (ConfigValues.bRemoteCall) {
  448. TopRemoteCallNotice = new WpadTextView(this, false, 640, 72, Gravity.CENTER, Color.parseColor("#FF8C00"), Common.fontsize._50, true, 0);
  449. ViewRegistration(TopLayout, TopRemoteCallNotice, 320, 17);
  450. TopRemoteCallNotice.setVisibility(View.INVISIBLE);
  451. }
  452. TopHomeBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_home_normal, R.drawable.topbar_icon_home_pressed, ID.TOP.BUTTON.HOME);
  453. ViewRegistration(TopLayout, TopHomeBtn, 1145, 0);
  454. TopBackBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.TOP.BUTTON.BACK);
  455. ViewRegistration(TopLayout, TopBackBtn, 1019, 0);
  456. setTopBackBtnVisible(false);
  457. bBlockTopMenuBTN = true;
  458. sendHandlerMsgDelayed(HANDLERMSG.RELEASE_TOPMENUBTN_BLOCK, 0, 0, 2000);
  459. TopMenuBtn = new WpadImageView(this, TOUCH_KIND.BUTTON_LC, 110, 110, R.drawable.topbar_icon_menu_normal, R.drawable.topbar_icon_menu_pressed, ID.TOP.BUTTON.MENU);
  460. ViewRegistration(TopLayout, TopMenuBtn, 0, 0);
  461. setTopMenuBtnVisible(true);
  462. TopManualBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_manual_normal, R.drawable.topbar_icon_manual_pressed, ID.TOP.BUTTON.MANUAL);
  463. setManualBtnVisible(getManualUse(), 1019);
  464. setTopHideBtnVisible(false);
  465. // 6. Menu Loading
  466. LOG_INFO("[Create] - Step6 : Menu Loading");
  467. // 6-1. 메뉴 정보를 가져온다 (DB에서 가져온다)
  468. wallpaddbmgr mwallpaddbmgr = new wallpaddbmgr(getApplicationContext());
  469. mwallpaddbmgr.DeleteMenuList();
  470. ArrayList<ArrayList<Integer>> mGroupList = null;
  471. ArrayList<Integer> mChildList = null;
  472. mGroupList = new ArrayList<ArrayList<Integer>>();
  473. mChildList = new ArrayList<Integer>();
  474. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  475. if (bFrontCallUse) mChildList.add(API_Menu.SubMenuCall.Door);
  476. if (bLobbyCallUse) mChildList.add(API_Menu.SubMenuCall.Lobby);
  477. if (bGuardCallUse) mChildList.add(API_Menu.SubMenuCall.Guard);
  478. if (bResiCallUse) mChildList.add(API_Menu.SubMenuCall.Neighbor);
  479. if (bPSTNCallUse) mChildList.add(API_Menu.SubMenuCall.PSTN);
  480. if (bCallHistoryUse) mChildList.add(API_Menu.SubMenuCall.CallList);
  481. if (bVisitorPicUse) mChildList.add(API_Menu.SubMenuCall.Visitor);
  482. }
  483. else {
  484. if (bFrontCallUse) mChildList.add(ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD);
  485. if (bLobbyCallUse) mChildList.add(ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD);
  486. if (bGuardCallUse) mChildList.add(ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD);
  487. if (bResiCallUse) mChildList.add(ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD);
  488. }
  489. mGroupList.add(mChildList);
  490. mwallpaddbmgr.SetMenuList(mGroupList);
  491. menuListDataClass = mwallpaddbmgr.GetMenuList();
  492. mwallpaddbmgr.closeDB();
  493. if (menuListDataClass == null) {
  494. Log.e(TAG, "menueListDataClass == null, Load Default List");
  495. menuListDataClass = LoadDefaultMenuList();
  496. }
  497. boolean isUseKakao = getKakaoHomeCheck();
  498. if(isUseKakao)
  499. {
  500. mContext.sendBroadcast(new Intent("com.kakao.i.hdc.notuse"));
  501. }
  502. // 6-2. 시작 화면을 main APP으로 부터 받아서 처리한다.
  503. mMenu = StartMenuSetting();
  504. if (mMenu == null) {
  505. Log.w(TAG, "[onCreate] menu is null!!");
  506. mTempCurrentScreenId = API_Menu.SubMenuCall.Guard;
  507. if (!bGuardCallUse) {
  508. if (bFrontCallUse) mTempCurrentScreenId = API_Menu.SubMenuCall.Door;
  509. else if (bResiCallUse) mTempCurrentScreenId = API_Menu.SubMenuCall.Neighbor;
  510. else if (bPSTNCallUse) mTempCurrentScreenId = API_Menu.SubMenuCall.PSTN;
  511. else if (bCallHistoryUse) mTempCurrentScreenId = API_Menu.SubMenuCall.CallList;
  512. else if (bVisitorPicUse) mTempCurrentScreenId = API_Menu.SubMenuCall.Visitor;
  513. }
  514. setChangeScreen(mTempCurrentScreenId, false); // 시작화면: 경비실
  515. }
  516. else {
  517. mTempCurrentScreenId = mMenu.getStartId();
  518. mWallPadApiCheckHandler.sendEmptyMessage(0);
  519. /** (JEFF, 2020.04.02)
  520. * RS-485 통신을 이용하는 현관카메라의 경우에만 WallPadAPI 로딩 여부를 확인하게 되면, 일반 현관카메라의 경우에는
  521. * WallPadAPI 연결이 늦은 경우 에러가 발생하므로 모든 경우에 WallPadAPI 연결확인을 진행한다.
  522. * 여기에 구현되어 있던 현관카메라(통신) API 로딩 기능은 WallPadAPI 확인 핸들러에서 현관카메라 종류에 따라 API를 로딩하도록 수정함
  523. */
  524. // if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_HS || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_DW) {
  525. // mWallPadApiCheckHandler.sendEmptyMessage(0);
  526. // }
  527. // else {
  528. // boolean result = setChangeScreen(mTempCurrentScreenId, false);
  529. // if (!result) {
  530. // setChangeScreen(API_Menu.SubMenuCall.Guard, false);
  531. // }
  532. // }
  533. }
  534. // 7. Draw
  535. LOG_INFO("[Create] - Step7 : setContentView");
  536. setContentView(AllLayout);
  537. getCallTimeoutEnable();
  538. sendHandlerMsgDelayed(HANDLERMSG.CHECK_RECEIVINGCALL, 0, 0, 500);
  539. // 거주자 안전확인 서비스 사용여부 확인하고, 화면 WallPadSupport Lib.에 관련 설정을 한다.
  540. getResidentSafetyCheckSetting();
  541. // 8. Window Resize
  542. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  543. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  544. wallpadDeviceSet.closeDB();
  545. LOG_INFO("[Create] - Step8 : Window Resize");
  546. } catch (RuntimeException re) {
  547. LogUtil.errorLogInfo("", TAG, re);
  548. } catch (Exception e) {
  549. Log.e(TAG, "[Exception] onCreate(Bundle savedInstanceState)");
  550. //e.printStackTrace();
  551. LogUtil.errorLogInfo("", TAG, e);
  552. }
  553. }
  554. public boolean getKakaoHomeCheck()
  555. {
  556. boolean result = false;
  557. WallpadDeviceSet mWallpadDeviceSet = null;
  558. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  559. try {
  560. result = mWallpadDeviceSet.Get_KakaoUse();
  561. }
  562. catch (Exception e)
  563. {
  564. LogUtil.errorLogInfo("", TAG, e);
  565. }
  566. return result;
  567. }
  568. @Override
  569. protected void onDestroy() {
  570. LOG("=============== [onDestroy] ===============");
  571. sendBlockSIPCallBR();
  572. mSound.StopAll();
  573. mSound.Release();
  574. finishPopUp(ID.POPUP.POPUP_ALL);
  575. finishManual(ID.MANUAL.MANUAL_ALL);
  576. sendHandlerMsg(HANDLERMSG.RECOVER_SYSTEM_VOLUME, 0, 0);
  577. if (sdbLivingRoomLightAPI != null) {
  578. Log.d(TAG, "[onDestroy] sdbLivingRoomLightAPI.SetWifiModuleOnOff [TRUE]");
  579. sdbLivingRoomLightAPI.SetWifiModuleOnOff(true);
  580. }
  581. Global.ctrlLCDOnOff(false); // 절전모드 해제
  582. Global.stopMelodyRepeat();
  583. ctrlSmartIOTCamStatusMode(SmartRFCamStatusMode.STATUS_OFF);
  584. ctrlSmartIOTCamLEDMode(SmartRFCamLEDMode.LED_OFF);
  585. setChangeScreen(mCurrentScreenId, true);
  586. releaseCallEngine();
  587. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  588. releaseCallHistoryDB();
  589. releaseVisitorPictureHistoryDB();
  590. }
  591. if (mIOInterface != null) {
  592. mIOInterface.releaseIOInterface();
  593. mIOInterface = null;
  594. }
  595. unregisterWallPadCallLiveBRReceiver();
  596. // Handler 해제
  597. if (mWallPadApiCheckHandler != null) {
  598. mWallPadApiCheckHandler.removeMessages(0);
  599. mWallPadApiCheckHandler.removeMessages(1);
  600. mWallPadApiCheckHandler.removeMessages(2);
  601. mWallPadApiCheckHandler.removeMessages(3);
  602. mWallPadApiCheckHandler.removeMessages(4);
  603. mWallPadApiCheckHandler.removeMessages(5);
  604. }
  605. if (mFrontCamOpenCheckHandler != null) {
  606. mFrontCamOpenCheckHandler.removeMessages(0);
  607. mFrontCamOpenCheckHandler.removeMessages(1);
  608. mFrontCamOpenCheckHandler.removeMessages(2);
  609. mFrontCamOpenCheckHandler.removeMessages(3);
  610. mFrontCamOpenCheckHandler.removeMessages(4);
  611. mFrontCamOpenCheckHandler.removeMessages(5);
  612. mFrontCamOpenCheckHandler.removeMessages(6);
  613. mFrontCamOpenCheckHandler.removeMessages(7);
  614. }
  615. if (mCallPathCheckHandler != null) {
  616. mCallPathCheckHandler.removeMessages(0);
  617. mCallPathCheckHandler.removeMessages(1);
  618. mCallPathCheckHandler.removeMessages(2);
  619. mCallPathCheckHandler.removeMessages(3);
  620. }
  621. super.setFinishTimerDestroy();
  622. notifyAppFinish();
  623. // setCallAppRunning(false);
  624. boolean isUseKakao = getKakaoHomeCheck();
  625. if(isUseKakao)
  626. {
  627. WallpadDeviceSet devSet = new WallpadDeviceSet(this.getContext());
  628. boolean bKakaoShow = devSet.Get_KakaoShow();
  629. if(bKakaoShow)
  630. mContext.sendBroadcast(new Intent("com.kakao.i.hdc.use"));
  631. devSet.closeDB();
  632. }
  633. Log.i(TAG, "*************************************************************");
  634. Log.i(TAG, "******************* [END - MainActivity] ******************");
  635. Log.i(TAG, "*************************************************************");
  636. super.onDestroy();
  637. }
  638. @Override
  639. protected void onResume() {
  640. super.onResume();
  641. try {
  642. LOG_INFO("[onResume] ========== START ==========");
  643. if (mWallPadAPI != null) mWallPadAPI.Resume();
  644. registerBRReceiver();
  645. } catch (RuntimeException re) {
  646. LogUtil.errorLogInfo("", TAG, re);
  647. } catch (Exception e) {
  648. Log.e(TAG, "[Exception] onResume()");
  649. //e.printStackTrace();
  650. LogUtil.errorLogInfo("", TAG, e);
  651. }
  652. }
  653. @Override
  654. protected void onPause() {
  655. try {
  656. LOG_INFO("[onPause] ========== START ==========");
  657. unregisterBRReceiver();
  658. if (mWallPadAPI != null) mWallPadAPI.Pause();
  659. } catch (RuntimeException re) {
  660. LogUtil.errorLogInfo("", TAG, re);
  661. } catch (Exception e) {
  662. Log.e(TAG, "[Exception] onResume()");
  663. //e.printStackTrace();
  664. LogUtil.errorLogInfo("", TAG, e);
  665. }
  666. super.onPause();
  667. }
  668. @Override
  669. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  670. super.onActivityResult(requestCode, resultCode, data);
  671. Log.d(TAG, "[onActivityResult] requestCode [" + requestCode +"], resultCode [" + resultCode +"]");
  672. if (mCallController.mCallInfo.getIDLECnt() != mCallController.mCallInfo.IDLECNT_MAX) {
  673. super.setFinishTimerDestroy();
  674. }
  675. if (resultCode == RESULT_OK) {
  676. try {
  677. // PopupActivity 에서 FinishTimer 로 인하여 종료가 되었을 경우
  678. // MainActivity 도 즉시 종료시킨다.
  679. String code = (String) data.getExtras().get("Finish_Kind");
  680. Log.d(TAG, "Finish_Kind : " + code);
  681. if (code.equals("FinishTimer")) {
  682. Log.d(TAG, "FinishTimer finish");
  683. finish();
  684. }
  685. } catch (RuntimeException re) {
  686. LogUtil.errorLogInfo("", TAG, re);
  687. } catch (Exception e) {
  688. Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get");
  689. //e.printStackTrace();
  690. LogUtil.errorLogInfo("", TAG, e);
  691. }
  692. }
  693. }
  694. @Override
  695. public boolean dispatchKeyEvent(KeyEvent event) {
  696. if (Common.MODE == Common.MODE_PRODUCTION) {
  697. int KeyCode = event.getKeyCode();
  698. if (KeyCode == 221) {
  699. int Action = event.getAction();
  700. if (Action == KeyEvent.ACTION_DOWN) {
  701. Log.i(TAG, "**************************");
  702. Log.i(TAG, " H/W Emergency BUTTON ");
  703. Log.i(TAG, "**************************");
  704. mSound.PlayMent(SND.emergency.DEFAULT); // "[비상 상황]이 발생되었습니다" 비상 경고음
  705. mTopBackgroundBlinkHandler.sendEmptyMessage(0);
  706. return true;
  707. }
  708. }
  709. }
  710. return super.dispatchKeyEvent(event);
  711. }
  712. @Override
  713. public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
  714. Log.d(TAG, "[onRequestPermissionsResult] requestCode: " + requestCode);
  715. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  716. switch (requestCode) {
  717. case REQUEST_EXTERNAL_STORAGE: {
  718. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  719. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED");
  720. } else {
  721. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED");
  722. }
  723. return;
  724. }
  725. }
  726. }
  727. protected Handler mTopBackgroundBlinkHandler = new Handler() {
  728. int Count = 0;
  729. @SuppressLint("HandlerLeak")
  730. @Override
  731. public void handleMessage(Message msg) {
  732. if (msg.what == 0) {
  733. TopBackground.setImageResource(0);
  734. TopBackground.setBackgroundColor(Color.RED);
  735. mTopBackgroundBlinkHandler.sendEmptyMessageDelayed(1, 500);
  736. Count = 0;
  737. } else if (msg.what == 1) {
  738. TopBackground.setImageResource(R.drawable.bg_topbar);
  739. TopBackground.setBackgroundColor(0);
  740. if (++Count <= 4) mTopBackgroundBlinkHandler.sendEmptyMessageDelayed(2, 500);
  741. } else if (msg.what == 2) {
  742. TopBackground.setImageResource(0);
  743. TopBackground.setBackgroundColor(Color.RED);
  744. mTopBackgroundBlinkHandler.sendEmptyMessageDelayed(1, 500);
  745. }
  746. }
  747. };
  748. /* ================================================================================================
  749. * [BroadcastReceiver] Section
  750. ================================================================================================ */
  751. /**
  752. * BroadcastReceiver.onReceive for [WpadActivity]
  753. */
  754. @Override
  755. protected void onBrReceive(Intent intent) {
  756. super.onBrReceive(intent);
  757. LOG_INFO("[onBrReceive] Action : " + intent.getAction());
  758. }
  759. /* ================================================================================================
  760. * [Touch & Key Event] Section
  761. ================================================================================================ */
  762. private int LONGKEY_THRESHOLD = 30;
  763. private int nLongKeyCnt = 0;
  764. private int nPreviousTargetID = 0;
  765. private boolean bBlockTopMenuBTN = true;
  766. @Override
  767. protected void onTouchEvent(View v, MotionEvent event) {
  768. super.onTouchEvent(v, event);
  769. int TargetId = v.getId();
  770. int MoveEvent = event.getAction();
  771. // Log.d(TAG, "[onTouchEvent] TargetId [" + TargetId + "], MoveEvent [" + MoveEvent + "]");
  772. if (MoveEvent == MotionEvent.ACTION_UP) {
  773. Log.d(TAG, "[onTouchEvent] ACTION UP");
  774. if (TargetId == ID.TOP.BUTTON.HOME) {
  775. LOG_INFO("[onTouchEvent] [HOME] BUTTON");
  776. if (bBlockHomeBTN) return;
  777. bBlockHomeBTN = true;
  778. if (mMainEventListener != null) mMainEventListener.onMainTouchEvent(MAINEVENT.BTN_HOME);
  779. sendHandlerMsgDelayed(HANDLERMSG.REFRESH_HOMEICON, 0, 0, 3000);
  780. } else if (TargetId == ID.TOP.BUTTON.BACK) {
  781. LOG_INFO("[onTouchEvent] [BACK] BUTTON");
  782. mSound.Play(SND.effect.TOUCH_LATCHED);
  783. if (mCurrentScreenId == ID.SCREEN.SCREEN_VISITORPICTUREVIEWER) {
  784. setChangeScreen(API_Menu.SubMenuCall.Visitor, false);
  785. }
  786. } else if (TargetId == ID.TOP.BUTTON.MENU) {
  787. LOG_INFO("[onTouchEvent] [MENU] BUTTON -> bBlockTopMenuBTN [" + bBlockTopMenuBTN + "], MenuOpen [" + MenuOpen + "]");
  788. if (bBlockTopMenuBTN) return;
  789. if (MenuOpen) {
  790. return;
  791. }
  792. mSound.Play(SND.effect.TOUCH_LATCHED);
  793. OpenMenuLayout();
  794. } else if (TargetId == ID.MENU.BUTTON.CLOSE) {
  795. LOG_INFO("[onTouchEvent] [CLOSE] BUTTON");
  796. if (MenuOpen) {
  797. mSound.Play(SND.effect.TOUCH_LATCHED);
  798. CloseMenuLayout();
  799. }
  800. }
  801. else if (TargetId == ID.TOP.BUTTON.MANUAL) {
  802. LOG_INFO("[onTouchEvent] [MANUAL] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]");
  803. if (mCallController.mCallInfo.getTalkingCnt() <= 0)
  804. mSound.Play(SND.effect.TOUCH_LATCHED); // 통화중인 경우 버튼 터치음 안나도록 설정
  805. if (mCurrentScreenId == API_Menu.SubMenuCall.Door) {
  806. StartManual(ID.MANUAL.MANUAL_TALKFRONT);
  807. } else if (mCurrentScreenId == API_Menu.SubMenuCall.Lobby) {
  808. StartManual(ID.MANUAL.MANUAL_TALKLOBBY);
  809. } else if (mCurrentScreenId == API_Menu.SubMenuCall.Guard) {
  810. StartManual(ID.MANUAL.MANUAL_TALKGUARD);
  811. } else if (mCurrentScreenId == API_Menu.SubMenuCall.Neighbor) {
  812. StartManual(ID.MANUAL.MANUAL_TALKRESIDENCE);
  813. } else if (mCurrentScreenId == API_Menu.SubMenuCall.PSTN) {
  814. StartManual(ID.MANUAL.MANUAL_TALKPSTN);
  815. } else if (mCurrentScreenId == API_Menu.SubMenuCall.CallList) {
  816. StartManual(ID.MANUAL.MANUAL_INQUIRYCALLHISTORY);
  817. } else if (mCurrentScreenId == API_Menu.SubMenuCall.Visitor) {
  818. StartManual(ID.MANUAL.MANUAL_INQUIRYVISITORPICTUREHISTORY);
  819. } else if (mCurrentScreenId == ID.SCREEN.SCREEN_VISITORPICTUREVIEWER) {
  820. StartManual(ID.MANUAL.MANUAL_VISITORPICTUREVIEWER);
  821. }
  822. }
  823. } else if (MoveEvent == MotionEvent.ACTION_POINTER_DOWN) {
  824. if (TargetId == ID.TOP.BUTTON.HIDE) {
  825. if (nPreviousTargetID == TargetId) {
  826. if (getPopupActivityRun()) return;
  827. else nLongKeyCnt++;
  828. Log.v(TAG, "[onTouchEvent] TargetId [" + TargetId + "], nLongKeyCnt [" + nLongKeyCnt + "]");
  829. if (nLongKeyCnt > LONGKEY_THRESHOLD) {
  830. nLongKeyCnt = 0;
  831. nPreviousTargetID = 0;
  832. startHideMenu();
  833. }
  834. } else {
  835. nPreviousTargetID = TargetId;
  836. nLongKeyCnt = 0;
  837. Log.v(TAG, "[onTouchEvent] nPreviousTargetID [" + nPreviousTargetID + "], TargetId [" + TargetId + "]");
  838. }
  839. }
  840. }
  841. }
  842. @Override
  843. public boolean onKeyDown(int keyCode, KeyEvent event) {
  844. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  845. return super.onKeyDown(keyCode, event);
  846. }
  847. /* ================================================================================================
  848. * [TOP] Section
  849. ================================================================================================ */
  850. /**
  851. * TOP 돌아가기 버튼 활성화 & 비활성화
  852. *
  853. * @param Enabled - true : 활성화, false : 비활성화
  854. * @return (boolean) true : 성공, false : 실패
  855. */
  856. public boolean setTopBackBtnVisible(boolean Enabled) {
  857. if (Enabled) {
  858. if (TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE);
  859. TopBackBtn.bringToFront();
  860. } else {
  861. if (TopBackBtn.getVisibility() != View.INVISIBLE)
  862. TopBackBtn.setVisibility(View.INVISIBLE);
  863. }
  864. return true;
  865. }
  866. /**
  867. * TOP 메뉴 버튼 활성화 & 비활성화
  868. *
  869. * @param Enabled - true : 활성화, false : 비활성화
  870. * @return (boolean) true : 성공, false : 실패
  871. * 2017.11.20 SEULKI
  872. */
  873. public boolean setTopMenuBtnVisible(boolean Enabled) {
  874. if (Enabled) {
  875. if (TopMenuBtn.getVisibility() != View.VISIBLE) TopMenuBtn.setVisibility(View.VISIBLE);
  876. TopMenuBtn.bringToFront();
  877. } else {
  878. if (TopMenuBtn.getVisibility() != View.INVISIBLE)
  879. TopMenuBtn.setVisibility(View.INVISIBLE);
  880. }
  881. return true;
  882. }
  883. public boolean setTopHideBtnVisible(boolean Enabled) {
  884. if (Enabled) {
  885. if (TopHideBtn.getVisibility() != View.VISIBLE) TopHideBtn.setVisibility(View.VISIBLE);
  886. TopHideBtn.bringToFront();
  887. } else {
  888. if (TopHideBtn.getVisibility() != View.INVISIBLE)
  889. TopHideBtn.setVisibility(View.INVISIBLE);
  890. }
  891. return true;
  892. }
  893. /* ================================================================================================
  894. * [Popup Activity] Section
  895. ================================================================================================ */
  896. public static PopupActivity mPopupActivity;
  897. /**
  898. * Popup Activity 를 시작시킨다.
  899. *
  900. * @param ScreenId - 팝업시작시 Screen ID
  901. * @return (boolean) true : 성공, false : 실패
  902. */
  903. public boolean StartPopup(int ScreenId) {
  904. Log.e(TAG, "[StartPopup] ScreenId [" + ScreenId + "], mCurrentPopUpScreenId [" + mCurrentPopUpScreenId + "]");
  905. if (getPopupActivityRun()) {
  906. mCurrentPopUpScreenId = ScreenId;
  907. return ((WpadActivity) (PopupActivity.getContext())).ChangeScreen(ScreenId);
  908. } else {
  909. if (mCurrentPopUpScreenId == ScreenId) return false;
  910. mCurrentPopUpScreenId = ScreenId;
  911. setPopupActivityRun(true);
  912. Intent intent = new Intent(mContext, PopupActivity.class);
  913. intent.putExtra("ScreenId", ScreenId);
  914. overridePendingTransition(0, 0);
  915. startActivityForResult(intent, 0);
  916. return true;
  917. }
  918. }
  919. /**
  920. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  921. *
  922. * @param ScreenId - 팝업시작시 Screen ID
  923. * @param data - 전달할 데이터
  924. * @return (boolean) true : 성공, false : 실패
  925. */
  926. public boolean startPopup(int ScreenId, Intent data) {
  927. if (getPopupActivityRun()) {
  928. return false;
  929. } else {
  930. if (mCurrentPopUpScreenId == ScreenId) return false;
  931. mCurrentPopUpScreenId = ScreenId;
  932. setPopupActivityRun(true);
  933. Intent intent = new Intent(mContext, PopupActivity.class);
  934. intent.putExtra("ScreenId", ScreenId);
  935. intent.putExtra("PopupScreenDataIntent", data);
  936. overridePendingTransition(0, 0);
  937. startActivityForResult(intent, 0);
  938. return true;
  939. }
  940. }
  941. public boolean startMultiCallPopup(int ScreenId) {
  942. LOG("[startMultiCallPopup] ScreenId [" + ScreenId + "]");
  943. if (getPopupActivityRun()) {
  944. return false;
  945. } else {
  946. if (mCurrentPopUpScreenId == ScreenId) return false;
  947. mCurrentPopUpScreenId = ScreenId;
  948. setPopupActivityRun(true);
  949. Intent intent = new Intent(mContext, PopupActivity.class);
  950. intent.putExtra("ScreenId", ScreenId);
  951. Intent data = new Intent();
  952. data.putExtra("BaseMultiCallType", mCallController.mCallInfo.getBaseMultiCallType().toString());
  953. data.putExtra("MultiCallType", mCallController.mCallInfo.getMultiCallType().toString());
  954. data.putExtra("MultiCallStatus", mCallController.mCallInfo.getMultiCallStatus().toString());
  955. data.putExtra("RemoteName", mCallController.mCallInfo.getMultiCall_Name());
  956. intent.putExtra("PopupScreenDataIntent", data);
  957. overridePendingTransition(0, 0);
  958. startActivityForResult(intent, 0);
  959. return true;
  960. }
  961. }
  962. public boolean startMultiCallPopup(int ScreenId, CALLSTATUS eCurrentCallStatus) {
  963. LOG("[startMultiCallPopup] ScreenId [" + ScreenId + "], eCurrentCallStatus [" + eCurrentCallStatus + "]");
  964. if (getPopupActivityRun()) {
  965. return false;
  966. } else {
  967. if (mCurrentPopUpScreenId == ScreenId) return false;
  968. mCurrentPopUpScreenId = ScreenId;
  969. setPopupActivityRun(true);
  970. Intent intent = new Intent(mContext, PopupActivity.class);
  971. intent.putExtra("ScreenId", ScreenId);
  972. Intent data = new Intent();
  973. data.putExtra("CurrentCallStatus", eCurrentCallStatus.toString());
  974. data.putExtra("MultiCallType", mCallController.mCallInfo.getMultiCallType().toString());
  975. data.putExtra("MultiCallStatus", mCallController.mCallInfo.getMultiCallStatus().toString());
  976. data.putExtra("RemoteName", mCallController.mCallInfo.getMultiCall_Name());
  977. intent.putExtra("PopupScreenDataIntent", data);
  978. overridePendingTransition(0, 0);
  979. startActivityForResult(intent, 0);
  980. return true;
  981. }
  982. }
  983. public static void resetCurrentPopUpScreenID() {
  984. try {
  985. mCurrentPopUpScreenId = -1;
  986. } catch (RuntimeException re) {
  987. LogUtil.errorLogInfo("", TAG, re);
  988. } catch (Exception e) {
  989. Log.e(TAG, "[Exception] resetCurrentPopUpScreenID()");
  990. //e.printStackTrace();
  991. LogUtil.errorLogInfo("", TAG, e);
  992. }
  993. }
  994. public void finishPopUp(int ScreenId) {
  995. try {
  996. Log.e(TAG, "[finishPopUp] mCurrentPopUpScreenId [" + mCurrentPopUpScreenId + "], ScreenId [" + ScreenId + "]");
  997. if (ScreenId == ID.POPUP.POPUP_ALL) FinishPopupActivity();
  998. else {
  999. if (mCurrentPopUpScreenId != ScreenId) return;
  1000. if (ScreenId == ID.POPUP.POPUP_NOTICE_SUBPHONETALK) {
  1001. Log.d(TAG, "[finishPopup] mCallController.mCallInfo.getCallOwner() [" + mCallController.mCallInfo.getCallOwner() + "]");
  1002. if (mCallController.mCallInfo.getCallOwner() != CALLOWNER.WALLPAD)
  1003. FinishPopupActivity();
  1004. } else FinishPopupActivity();
  1005. }
  1006. } catch (RuntimeException re) {
  1007. LogUtil.errorLogInfo("", TAG, re);
  1008. } catch (Exception e) {
  1009. Log.e(TAG, "[Exception] finishPopUp(int ScreenId)");
  1010. //e.printStackTrace();
  1011. LogUtil.errorLogInfo("", TAG, e);
  1012. }
  1013. }
  1014. /**
  1015. * Popup Activity 를 종료시킨다
  1016. */
  1017. public void FinishPopupActivity() {
  1018. try {
  1019. if (mPopupActivity != null) {
  1020. Log.i(TAG, "[FinishPopupActivity]");
  1021. mCurrentPopUpScreenId = -1;
  1022. mPopupActivity.finish();
  1023. }
  1024. } catch (RuntimeException re) {
  1025. LogUtil.errorLogInfo("", TAG, re);
  1026. } catch (Exception e) {
  1027. Log.e(TAG, "[Exception] FinishPopupActivity()");
  1028. //e.printStackTrace();
  1029. LogUtil.errorLogInfo("", TAG, e);
  1030. }
  1031. }
  1032. /* ================================================================================================
  1033. * [Manual Activity] Section
  1034. ================================================================================================ */
  1035. public static ManualActivity mManualActivity;
  1036. public boolean StartManual(int screenId) {
  1037. Log.d(TAG, "[StartManual] screenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]");
  1038. if (getManualActivityRun()) {
  1039. mCurrentManualScreenId = screenId;
  1040. return ((WpadActivity) (ManualActivity.getContext())).ChangeScreen(screenId);
  1041. }
  1042. else {
  1043. if (mCurrentManualScreenId == screenId) return false;
  1044. mCurrentManualScreenId = screenId;
  1045. setManualActivityRun(true);
  1046. Intent intent = new Intent(mContext, ManualActivity.class);
  1047. intent.putExtra("ScreenId", screenId);
  1048. overridePendingTransition(0, 0);
  1049. startActivityForResult(intent, 0);
  1050. return true;
  1051. }
  1052. }
  1053. public static void resetCurrentManualScreenID() {
  1054. try {
  1055. mCurrentManualScreenId = -1;
  1056. } catch (RuntimeException re) {
  1057. LogUtil.errorLogInfo("", TAG, re);
  1058. } catch (Exception e) {
  1059. Log.e(TAG, "[Exception] resetCurrentManualScreenID()");
  1060. //e.printStackTrace();
  1061. LogUtil.errorLogInfo("", TAG, e);
  1062. }
  1063. }
  1064. public void finishManual(int screenId) {
  1065. try {
  1066. Log.d(TAG, "[finishManual] mCurrentManualScreenId [" + mCurrentManualScreenId +"], screenId [" + screenId +"]");
  1067. if (screenId == ID.MANUAL.MANUAL_ALL) FinishManualActivity();
  1068. else {
  1069. if (mCurrentManualScreenId != screenId) return;
  1070. FinishManualActivity();
  1071. }
  1072. } catch (RuntimeException re) {
  1073. LogUtil.errorLogInfo("", TAG, re);
  1074. } catch (Exception e) {
  1075. Log.e(TAG, "[Exception] finishManual(int screenId)");
  1076. //e.printStackTrace();
  1077. LogUtil.errorLogInfo("", TAG, e);
  1078. }
  1079. }
  1080. public static void FinishManualActivity() {
  1081. Log.i(TAG, "[FinishManualActivity]");
  1082. try {
  1083. if (mManualActivity != null) {
  1084. mCurrentManualScreenId = -1;
  1085. mManualActivity.finish();
  1086. }
  1087. } catch (RuntimeException re) {
  1088. LogUtil.errorLogInfo("", TAG, re);
  1089. } catch (Exception e) {
  1090. Log.e(TAG, "[Exception] FinishManualActivity()");
  1091. //e.printStackTrace();
  1092. LogUtil.errorLogInfo("", TAG, e);
  1093. }
  1094. }
  1095. /**
  1096. * 매뉴얼 버튼 사용 유무
  1097. * @return boolean 타입 - true: 사용, false: 미사용
  1098. */
  1099. public boolean getManualUse() {
  1100. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  1101. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  1102. devSet.closeDB();
  1103. if (DBinfo != null) {
  1104. if (DBinfo[1].indexOf("사용함") > 0) {
  1105. Log.d(TAG, "[getManualUse] Use Manual");
  1106. return true;
  1107. } else {
  1108. // 미사용
  1109. Log.d(TAG, "[getManualUse] Not Use Manual [1]");
  1110. return false;
  1111. }
  1112. } else {
  1113. // 미사용
  1114. Log.d(TAG, "[getManualUse] Not Use Manual [2]");
  1115. return false;
  1116. }
  1117. }
  1118. public void setManualBtnVisible(boolean bUse, int marginLeft) {
  1119. try {
  1120. Log.d(TAG, "[setManualBtnVisible] bUse [" + bUse + "], marginLeft [" + marginLeft + "]");
  1121. if (bUse) TopManualBtn.setVisibility(View.VISIBLE);
  1122. else TopManualBtn.setVisibility(View.INVISIBLE);
  1123. TopLayout.removeView(TopManualBtn);
  1124. ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0);
  1125. } catch (RuntimeException re) {
  1126. LogUtil.errorLogInfo("", TAG, re);
  1127. } catch (Exception e) {
  1128. Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable)");
  1129. //e.printStackTrace();
  1130. LogUtil.errorLogInfo("", TAG, e);
  1131. }
  1132. }
  1133. public void setTopSetBtnVisible(boolean Enabled) {
  1134. if (TopSetBtn != null) {
  1135. if (Enabled) {
  1136. if (TopSetBtn.getVisibility() != View.VISIBLE) TopSetBtn.setVisibility(View.VISIBLE);
  1137. TopSetBtn.bringToFront();
  1138. if (TopSetBtn.getVisibility() == View.VISIBLE) {
  1139. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  1140. }
  1141. } else {
  1142. if (TopSetBtn.getVisibility() != View.INVISIBLE)
  1143. TopSetBtn.setVisibility(View.INVISIBLE);
  1144. if (TopSetBtn.getVisibility() == View.INVISIBLE) {
  1145. WpadUtil.ViewMove(TopManualBtn, 1019, 0);
  1146. }
  1147. }
  1148. }
  1149. }
  1150. /* ================================================================================================
  1151. * [Screen] Section
  1152. ================================================================================================ */
  1153. /**
  1154. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  1155. * Override 사용하여 Screen 변경을 처리한다.<br>
  1156. *
  1157. * @param nScreenId - 변경할 Screen ID
  1158. * @return (boolean) true : 성공, false : 실패
  1159. */
  1160. @Override
  1161. protected boolean onChangeScreen(int nScreenId) {
  1162. super.onChangeScreen(nScreenId);
  1163. return setChangeScreen(nScreenId, false);
  1164. }
  1165. /**
  1166. * Screen 등록자<br>
  1167. * ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  1168. *
  1169. * @param nScreenId - 변경할 Screen ID
  1170. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  1171. * @return (boolean) true : 성공, false : 실패
  1172. */
  1173. public boolean setChangeScreen(int nScreenId, boolean OnlyRemove) {
  1174. LOG_INFO("[setChangeScreen] OnlyRemove [" + OnlyRemove + "], CurrentLayoutId(mCurrentScreenId) [" + mCurrentScreenId + "], NextLayoutId(nScreenId) [" + nScreenId + "]");
  1175. if (!OnlyRemove && mCurrentScreenId == nScreenId) {
  1176. Log.w(TAG, "[setChangeScreen] mCurrentScreenId is same as nScreenId");
  1177. setFinishTimerCreate(Common.FINISH_TIME_START_SCREEN);
  1178. return true;
  1179. }
  1180. // 1. 현재 Layout 삭제
  1181. if (mCurrentScreenId > 0) {
  1182. ScreenLayout.removeAllViews();
  1183. super.setCurrentScreen(null);
  1184. }
  1185. if (OnlyRemove) return true;
  1186. mCurrentScreenId = nScreenId;
  1187. // 2. 새로운 Layout 표시
  1188. try {
  1189. switch (nScreenId) {
  1190. case API_Menu.SubMenuCall.Door:
  1191. setTitleText(API_Menu.SubMenuCall.Name_Door);
  1192. ScreenTalkFront = new TalkFront(this, ScreenLayout);
  1193. super.setCurrentScreen(ScreenTalkFront);
  1194. break;
  1195. case API_Menu.SubMenuCall.Lobby:
  1196. setTitleText(API_Menu.SubMenuCall.Name_Lobby);
  1197. ScreenTalkLobby = new TalkLobby(this, ScreenLayout);
  1198. super.setCurrentScreen(ScreenTalkLobby);
  1199. break;
  1200. case API_Menu.SubMenuCall.Guard:
  1201. setTitleText(API_Menu.SubMenuCall.Name_Guard);
  1202. ScreenTalkGuard = new TalkGuard(this, ScreenLayout);
  1203. super.setCurrentScreen(ScreenTalkGuard);
  1204. break;
  1205. case API_Menu.SubMenuCall.Neighbor:
  1206. setTitleText(API_Menu.SubMenuCall.Name_Neighbor);
  1207. ScreenTalkResidence = new TalkResidence(this, ScreenLayout);
  1208. super.setCurrentScreen(ScreenTalkResidence);
  1209. break;
  1210. case API_Menu.SubMenuCall.PSTN:
  1211. setTitleText(API_Menu.SubMenuCall.Name_PSTN);
  1212. ScreenTalkPSTN = new TalkPSTN(this, ScreenLayout, mWallPadAPI);
  1213. super.setCurrentScreen(ScreenTalkPSTN);
  1214. break;
  1215. case API_Menu.SubMenuCall.CallList:
  1216. setTitleText(API_Menu.SubMenuCall.Name_CallList);
  1217. ScreenInquiryCallHistory = new InquiryCallHistory(this, ScreenLayout);
  1218. super.setCurrentScreen(ScreenInquiryCallHistory);
  1219. break;
  1220. case API_Menu.SubMenuCall.Visitor:
  1221. setTitleText(API_Menu.SubMenuCall.Name_Visitor);
  1222. ScreenInquiryVisitorPictureHistory = new InquiryVisitorPictureHistory(this, ScreenLayout);
  1223. super.setCurrentScreen(ScreenInquiryVisitorPictureHistory);
  1224. break;
  1225. case ID.SCREEN.SCREEN_VISITORPICTUREVIEWER:
  1226. ScreenVisitorPictureViewer = new VisitorPictureViewer(this, ScreenLayout);
  1227. super.setCurrentScreen(ScreenVisitorPictureViewer);
  1228. break;
  1229. case ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD:
  1230. setTitleText(API_Menu.SubMenuCall.Name_Door);
  1231. ScreenTalkFrontSub = new TalkFront_SubWallPad(this, ScreenLayout);
  1232. super.setCurrentScreen(ScreenTalkFrontSub);
  1233. break;
  1234. case ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD:
  1235. setTitleText(API_Menu.SubMenuCall.Name_Lobby);
  1236. ScreenTalkLobbySub = new TalkLobby_SubWallPad(this, ScreenLayout);
  1237. super.setCurrentScreen(ScreenTalkLobbySub);
  1238. break;
  1239. case ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD:
  1240. setTitleText(API_Menu.SubMenuCall.Name_Guard);
  1241. ScreenTalkGuardSub = new TalkGuard_SubWallPad(this, ScreenLayout);
  1242. super.setCurrentScreen(ScreenTalkGuardSub);
  1243. break;
  1244. case ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD:
  1245. setTitleText(API_Menu.SubMenuCall.Name_Neighbor);
  1246. ScreenResidenceSub = new TalkResidence_SubWallPad(this, ScreenLayout);
  1247. super.setCurrentScreen(ScreenResidenceSub);
  1248. break;
  1249. case ID.SCREEN.SCREEN_TALKPSTN_SUBWALLPAD:
  1250. setTitleText(API_Menu.SubMenuCall.Name_PSTN);
  1251. ScreenPSTNSub = new TalkPSTN_SubWallPad(this, ScreenLayout);
  1252. super.setCurrentScreen(ScreenPSTNSub);
  1253. break;
  1254. default:
  1255. Log.e(TAG, "[setChangeScreen] nScreenId Not found!!! [" + mCurrentScreenId + "]");
  1256. mCurrentScreenId = -1;
  1257. return false;
  1258. }
  1259. } catch (RuntimeException re) {
  1260. LogUtil.errorLogInfo("", TAG, re);
  1261. return false;
  1262. } catch (Exception e) {
  1263. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  1264. //e.printStackTrace();
  1265. LogUtil.errorLogInfo("", TAG, e);
  1266. return false;
  1267. }
  1268. return true;
  1269. }
  1270. private void setTitleText(String setText) {
  1271. if (setText != null)
  1272. TopTitle.setText(setText);
  1273. }
  1274. /**
  1275. * 통화기능 사용여부 판별
  1276. */
  1277. private void getCallFunctionUse() {
  1278. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  1279. bFrontCallUse = devSet.Get_FrontCallUse();
  1280. bLobbyCallUse = devSet.Get_LobbyCallUse();
  1281. bGuardCallUse = devSet.Get_GuardCallUse();
  1282. bResiCallUse = devSet.Get_ResidenceCallUse();
  1283. bPSTNCallUse = devSet.Get_PSTNCallUse();
  1284. bCallHistoryUse = devSet.Get_CallHistoryUse();
  1285. bVisitorPicUse = devSet.Get_VisitorPicUse();
  1286. devSet.closeDB();
  1287. LOG("[getCallFunctionUse] bFrontCallUse [" + bFrontCallUse + "], bLobbyCallUse [" + bLobbyCallUse + "], bGuardCallUse [" + bGuardCallUse + "], " +
  1288. "bResiCallUse [" + bResiCallUse + "], bPSTNCallUse [" + bPSTNCallUse + "], bCallHistoryUse [" + bCallHistoryUse + "], bVisitorPicUse [" + bVisitorPicUse + "]");
  1289. }
  1290. /* ================================================================================================
  1291. * [Menu Layout] Section
  1292. ================================================================================================ */
  1293. /**
  1294. * 콜 호출에 의한 화면 변경시에만 호출
  1295. **/
  1296. public void changeMenuNScreen(int nMenuID) {
  1297. try {
  1298. LOG("[changeMenuNScreen] nMenuID [" + nMenuID + "]");
  1299. int nScreenId;
  1300. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  1301. switch (nMenuID) {
  1302. case ID.MENU.MENU_TALKFRONT:
  1303. nScreenId = API_Menu.SubMenuCall.Door;
  1304. break;
  1305. case ID.MENU.MENU_TALKLOBBY:
  1306. nScreenId = API_Menu.SubMenuCall.Lobby;
  1307. break;
  1308. case ID.MENU.MENU_TALKGUARD:
  1309. nScreenId = API_Menu.SubMenuCall.Guard;
  1310. break;
  1311. case ID.MENU.MENU_TALKRESIDENCE:
  1312. nScreenId = API_Menu.SubMenuCall.Neighbor;
  1313. break;
  1314. case ID.MENU.MENU_TALKPSTN:
  1315. nScreenId = API_Menu.SubMenuCall.PSTN;
  1316. break;
  1317. case ID.MENU.MENU_INQUIRYCALLHISTORY:
  1318. nScreenId = API_Menu.SubMenuCall.CallList;
  1319. break;
  1320. case ID.MENU.MENU_INQUIRYVISITORPIC:
  1321. nScreenId = API_Menu.SubMenuCall.Visitor;
  1322. break;
  1323. default:
  1324. nScreenId = -1;
  1325. break;
  1326. }
  1327. }
  1328. else {
  1329. switch (nMenuID) {
  1330. case ID.MENU.MENU_TALKFRONT:
  1331. nScreenId = ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD;
  1332. break;
  1333. case ID.MENU.MENU_TALKLOBBY:
  1334. nScreenId = ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD;
  1335. break;
  1336. case ID.MENU.MENU_TALKGUARD:
  1337. nScreenId = ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD;
  1338. break;
  1339. case ID.MENU.MENU_TALKRESIDENCE:
  1340. nScreenId = ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD;
  1341. break;
  1342. case ID.MENU.MENU_TALKPSTN:
  1343. nScreenId = ID.SCREEN.SCREEN_TALKPSTN_SUBWALLPAD;
  1344. break;
  1345. default:
  1346. nScreenId = -1;
  1347. break;
  1348. }
  1349. }
  1350. if (nScreenId > 0) {
  1351. setChangeScreen(nScreenId, false);
  1352. }
  1353. else LOG_WARN("[changeMenuNScreen] nScreen id is less than zero!");
  1354. } catch (RuntimeException re) {
  1355. LogUtil.errorLogInfo("", TAG, re);
  1356. } catch (Exception e) {
  1357. Log.e(TAG, "[Exception] changeMenuNScreen(int nMenuID)");
  1358. //e.printStackTrace();
  1359. LogUtil.errorLogInfo("", TAG, e);
  1360. }
  1361. }
  1362. private int getScreenId(CALLTYPE eCallType) {
  1363. try {
  1364. Log.d(TAG, "[getScreenId]");
  1365. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  1366. if (eCallType == CALLTYPE.FRONT) return API_Menu.SubMenuCall.Door;
  1367. else if (eCallType == CALLTYPE.LOBBY) return API_Menu.SubMenuCall.Lobby;
  1368. else if (eCallType == CALLTYPE.GUARD) return API_Menu.SubMenuCall.Guard;
  1369. else if (eCallType == CALLTYPE.RESIDENCE) return API_Menu.SubMenuCall.Neighbor;
  1370. else if (eCallType == CALLTYPE.PSTN) return API_Menu.SubMenuCall.PSTN;
  1371. else if (eCallType == CALLTYPE.HISTORY_CALL) return API_Menu.SubMenuCall.CallList;
  1372. else if (eCallType == CALLTYPE.HISTORY_VISITORPIC) return API_Menu.SubMenuCall.Visitor;
  1373. else return API_Menu.SubMenuCall.Guard;
  1374. }
  1375. else {
  1376. if (eCallType == CALLTYPE.FRONT) return ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD;
  1377. else if (eCallType == CALLTYPE.LOBBY) return ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD;
  1378. else if (eCallType == CALLTYPE.GUARD) return ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD;
  1379. else if (eCallType == CALLTYPE.RESIDENCE) return ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD;
  1380. else if (eCallType == CALLTYPE.PSTN) return ID.SCREEN.SCREEN_TALKPSTN_SUBWALLPAD;
  1381. else return ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD;
  1382. }
  1383. } catch (RuntimeException re) {
  1384. LogUtil.errorLogInfo("", TAG, re);
  1385. return API_Menu.SubMenuCall.Guard;
  1386. } catch (Exception e) {
  1387. Log.e(TAG, "[Exception] getScreenId");
  1388. //e.printStackTrace();
  1389. LogUtil.errorLogInfo("", TAG, e);
  1390. return API_Menu.SubMenuCall.Guard;
  1391. }
  1392. }
  1393. private int getConvertScreenId(int nScreenId) {
  1394. try {
  1395. switch (nScreenId) {
  1396. case ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD:
  1397. return API_Menu.SubMenuCall.Door;
  1398. case ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD:
  1399. return API_Menu.SubMenuCall.Lobby;
  1400. case ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD:
  1401. return API_Menu.SubMenuCall.Guard;
  1402. case ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD:
  1403. return API_Menu.SubMenuCall.Neighbor;
  1404. default:
  1405. return API_Menu.SubMenuCall.Guard;
  1406. }
  1407. } catch (RuntimeException re) {
  1408. LogUtil.errorLogInfo("", TAG, re);
  1409. return API_Menu.SubMenuCall.Guard;
  1410. } catch (Exception e) {
  1411. Log.e(TAG, "[Exception] int getConvertScreenId(int nScreenId)");
  1412. //e.printStackTrace();
  1413. LogUtil.errorLogInfo("", TAG, e);
  1414. return API_Menu.SubMenuCall.Guard;
  1415. }
  1416. }
  1417. private Menu StartMenuSetting() {
  1418. Log.d(TAG, "[StartMenuSetting]");
  1419. Menu mMenu = new Menu();
  1420. Intent mIntent = getIntent();
  1421. strCallOwner = mIntent.getStringExtra(CALLTRIGGER.CALLOWNER);
  1422. strCallEvent = mIntent.getStringExtra(CALLTRIGGER.CALLEVENTTYPE);
  1423. strCallType = mIntent.getStringExtra(CALLTRIGGER.CALLTYPE);
  1424. strRemoteInfo = mIntent.getStringExtra(CALLTRIGGER.REMOTEINFO);
  1425. int nStartScreenId = API_Menu.SubMenuCall.Guard;
  1426. Log.d(TAG, "[StartMenuSetting] strCallOwner [" + strCallOwner + "], strCallEvent [" + strCallEvent + "], " + "strCallType [" + strCallType + "], strRemoteInfo [" + strRemoteInfo + "]");
  1427. if (strCallEvent != null && strCallType != null) {
  1428. nStartScreenId = getScreenId(CALLTYPE.getCALLTYPE(strCallType));
  1429. Log.d(TAG, "[StartMenuSetting] strCallEvent [" + strCallEvent + "], nStartScreenId [" + nStartScreenId + "]");
  1430. }
  1431. mMenu.StartId = nStartScreenId;
  1432. mMenu.Opiton = -1;
  1433. return mMenu;
  1434. }
  1435. /**
  1436. * 메뉴 레이아웃 생성
  1437. **/
  1438. private void OpenMenuLayout() {
  1439. Log.d(TAG, "[OpenMenuLayout] MenuOpen [" + MenuOpen + "]");
  1440. if (MenuOpen) {
  1441. return;
  1442. }
  1443. if (menuListDataClass == null) {
  1444. return;
  1445. }
  1446. //0. 현재 ID 및 리스트 불러오기
  1447. String Title = null;
  1448. String TempChildName = null;
  1449. int ChooseGroup = 0;
  1450. int ChooseChild = 0;
  1451. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  1452. Title = API_Menu.GetGroupNameByID((mCurrentScreenId / 1000) * 1000);
  1453. for (int i = 0; i < menuListDataClass.arrayGroup.size(); i++) {
  1454. if (menuListDataClass.arrayGroup.get(i).equals(Title)) {
  1455. ChooseGroup = i;
  1456. break;
  1457. }
  1458. }
  1459. for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) {
  1460. if (menuListDataClass.idMappingTable[i].Id == mCurrentScreenId) {
  1461. TempChildName = menuListDataClass.idMappingTable[i].Name;
  1462. break;
  1463. } else if (ID.SCREEN.SCREEN_VISITORPICTUREVIEWER == mCurrentScreenId) {
  1464. // 방문자사진 상세보기 화면에서 메뉴 버튼 클릭 기능 구현 seulki
  1465. Title = API_Menu.SubMenuCall.Name;
  1466. TempChildName = API_Menu.SubMenuCall.Name_Visitor;
  1467. break;
  1468. }
  1469. }
  1470. }
  1471. else {
  1472. int convertScreenId = getConvertScreenId(mCurrentScreenId);
  1473. Title = API_Menu.GetGroupNameByID((convertScreenId / 1000) * 1000);
  1474. LOG("[OpenMenuLayout] mCurrentScreenId [" + convertScreenId + "], Title [" + Title + "]");
  1475. for (int i = 0; i < menuListDataClass.arrayGroup.size(); i++) {
  1476. if (menuListDataClass.arrayGroup.get(i).equals(Title)) {
  1477. ChooseGroup = i;
  1478. break;
  1479. }
  1480. }
  1481. for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) {
  1482. if (menuListDataClass.idMappingTable[i].Id == mCurrentScreenId) {
  1483. TempChildName = menuListDataClass.idMappingTable[i].Name;
  1484. break;
  1485. }
  1486. }
  1487. }
  1488. if (TempChildName == null) {
  1489. Log.e(TAG, "[OpenMenuLayout] TempChildName == null");
  1490. return;
  1491. }
  1492. for (int i = 0; i < menuListDataClass.arrayChild.get(Title).size(); i++) {
  1493. Log.d(TAG, "[OpenMenuLayout] menuListDataClass.arrayChild.get(Title).get(i): " + menuListDataClass.arrayChild.get(Title).get(i));
  1494. if (menuListDataClass.arrayChild.get(Title).get(i).equals(TempChildName)) {
  1495. ChooseChild = i;
  1496. break;
  1497. }
  1498. }
  1499. //1. 기존 화면 투명도 변경
  1500. TopLayout.setAlpha(0.5f);
  1501. ScreenLayout.setAlpha(0.5f);
  1502. // 모티터링중 메뉴오픈시 겹침현상 해결 -> FRONT SurfaceView INVISIBLE
  1503. if (FrontVideoSurface != null) {
  1504. FrontVideoSurface.setVisibility(View.INVISIBLE);
  1505. }
  1506. //2. Layout 생성 및 처리 이벤트 등록
  1507. MenuLayout = new RelativeLayout(this);
  1508. WpadUtil.LayoutRegistration(AllLayout, MenuLayout, screenWidth, screenHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.MENU);
  1509. MenuLayout.setOnTouchListener(new Button.OnTouchListener() {
  1510. @Override
  1511. public boolean onTouch(View v, MotionEvent event) {
  1512. if (event.getAction() == MotionEvent.ACTION_UP) {
  1513. setFinishTimerReset();
  1514. CloseMenuLayout();
  1515. }
  1516. return true;
  1517. }
  1518. });
  1519. //3. 배경 이미지 생성 및 에니메이션 등록
  1520. MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.MENU.IMAGE.BACKGROUND);
  1521. TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0);
  1522. anim.setDuration(200);
  1523. anim.setInterpolator(new AccelerateInterpolator());
  1524. MenuLayout.setAnimation(anim);
  1525. ViewRegistration(MenuLayout, MenuBackground, 0, 0);
  1526. //4. 타이틀 등록
  1527. MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, fontSize, true, ID.TOP.TEXT.TITLE);
  1528. ViewRegistration(MenuLayout, MenuTitle, 133, 15);
  1529. MenuTitle.setText(Title);
  1530. //5. 종료 버튼 등록
  1531. MenuClose = new WpadImageView(this, TOUCH_KIND.BUTTON, 80, 80, R.drawable.topbar_icon_close_normal, R.drawable.topbar_icon_close_pressed, ID.MENU.BUTTON.CLOSE);
  1532. MenuClose.setTouchDelayMs(1000);
  1533. ViewRegistration(MenuLayout, MenuClose, 380, 15);
  1534. //6. 리스트뷰 초기화 및 등록
  1535. mListView = new ExpandableListView(this);
  1536. ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690));
  1537. mListView.setLayoutParams(params);
  1538. mListView.setX(WpadScale.getWidth(0));
  1539. mListView.setY(WpadScale.getHeight(112));
  1540. mListView.setBackgroundColor(Color.BLACK);
  1541. mListView.setId(ID.MENU.VIEW.LISTVIEW);
  1542. mListView.setGroupIndicator(null);
  1543. mListView.setDividerHeight(0);
  1544. mListView.setDivider(null);
  1545. mListView.setFocusable(true);
  1546. mListView.setSmoothScrollbarEnabled(true);
  1547. mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED);
  1548. mListView.setScrollbarFadingEnabled(true);
  1549. MenuLayout.addView(mListView);
  1550. adptMain = new Menu_AdptMain(this, menuListDataClass.arrayGroup, menuListDataClass.arrayChild, ChooseGroup, ChooseChild);
  1551. mListView.setAdapter(adptMain);
  1552. //7. 선택된 그룹 열기
  1553. mListView.setSelectedGroup(ChooseGroup);
  1554. mListView.expandGroup(ChooseGroup);
  1555. // 8. 리스트뷰 터치 이벤트 등록
  1556. mListView.setOnTouchListener(new View.OnTouchListener() {
  1557. @Override
  1558. public boolean onTouch(View v, MotionEvent event) {
  1559. if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
  1560. (event.getAction() == MotionEvent.ACTION_UP)) {
  1561. WpadActivity.setFinishTimerReset();
  1562. }
  1563. return false;
  1564. }
  1565. });
  1566. // 9. 그룹 터치 이벤트 등록
  1567. mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
  1568. @Override
  1569. public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
  1570. LOG_INFO("group click = " + groupPosition);
  1571. WpadActivity.setFinishTimerReset();
  1572. return false;
  1573. }
  1574. });
  1575. /*
  1576. // 10. 차일드 터치 이벤트 등록
  1577. mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
  1578. @Override
  1579. public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
  1580. LOG_INFO("onChildClick");
  1581. LOG_INFO("groupPosition = " + groupPosition);
  1582. LOG_INFO("childPosition = " + childPosition);
  1583. WpadActivity.setFinishTimerReset();
  1584. return false;
  1585. }
  1586. });
  1587. */
  1588. // 11. 그룹 열리는 경우 이벤트
  1589. mListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  1590. @Override
  1591. public void onGroupExpand(int groupPosition) {
  1592. LOG_INFO("groupPosition Open Event = " + groupPosition);
  1593. mSound.Play(SND.effect.TOUCH_LATCHED);
  1594. WpadActivity.setFinishTimerReset();
  1595. }
  1596. });
  1597. // 12. 그룹 닫히는 경우 이벤트
  1598. mListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  1599. @Override
  1600. public void onGroupCollapse(int groupPosition) {
  1601. LOG_INFO("groupPosition Close Event = " + groupPosition);
  1602. mSound.Play(SND.effect.TOUCH_LATCHED);
  1603. WpadActivity.setFinishTimerReset();
  1604. }
  1605. });
  1606. // 13. MenuOpen True 설정
  1607. MenuOpen = true;
  1608. }
  1609. /**
  1610. * 메뉴 layout 닫힘 처리
  1611. **/
  1612. private void CloseMenuLayout() {
  1613. Log.d(TAG, "[CloseMenuLayout] MenuOpen [" + MenuOpen + "]");
  1614. if (!MenuOpen) {
  1615. return;
  1616. }
  1617. // 메뉴오픈시 INVISIBLE 처리했던 FRONT SurfaceView VISIBLE
  1618. if (FrontVideoSurface != null) {
  1619. FrontVideoSurface.setVisibility(View.VISIBLE);
  1620. }
  1621. TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0);
  1622. anim.setDuration(200);
  1623. anim.setInterpolator(new AccelerateInterpolator());
  1624. anim.setAnimationListener(new Animation.AnimationListener() {
  1625. @Override
  1626. public void onAnimationStart(Animation animation) {
  1627. MenuOpen = false;
  1628. }
  1629. @Override
  1630. public void onAnimationRepeat(Animation animation) {
  1631. }
  1632. @Override
  1633. public void onAnimationEnd(Animation animation) {
  1634. AllLayout.removeView(MenuLayout);
  1635. TopLayout.setAlpha(1.0f);
  1636. ScreenLayout.setAlpha(1.0f);
  1637. }
  1638. });
  1639. MenuLayout.startAnimation(anim);
  1640. }
  1641. /**
  1642. * 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출)
  1643. **/
  1644. public static void SetListViewGroupExpand_Collapse(int GroupId, boolean ExpandEnable) {
  1645. if (ExpandEnable) {
  1646. mListView.expandGroup(GroupId);
  1647. } else {
  1648. mListView.collapseGroup(GroupId);
  1649. }
  1650. }
  1651. /**
  1652. * Menu정보가 DB에 없을 경우 불러올 스크린 로딩
  1653. *
  1654. * @return MenuListDataClass 타입의 초기정보
  1655. **/
  1656. private MenuListDataClass LoadDefaultMenuList() {
  1657. MenuListDataClass Temp_menuListDataClass = new MenuListDataClass();
  1658. Temp_menuListDataClass.SetArrayGroup(API_Menu.SubMenuCall.Name);
  1659. ArrayList<String> arrayList = new ArrayList<String>();
  1660. int ChildCount = 0;
  1661. //[수정필요]
  1662. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작)
  1663. arrayList.add(API_Menu.SubMenuCall.Name_Door);
  1664. ChildCount++;
  1665. arrayList.add(API_Menu.SubMenuCall.Name_Lobby);
  1666. ChildCount++;
  1667. arrayList.add(API_Menu.SubMenuCall.Name_Guard);
  1668. ChildCount++;
  1669. arrayList.add(API_Menu.SubMenuCall.Name_Neighbor);
  1670. ChildCount++;
  1671. Temp_menuListDataClass.SetArrayChild(API_Menu.SubMenuCall.Name, arrayList);
  1672. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝)
  1673. Temp_menuListDataClass.idMappingTable = new ChildIDMapping[ChildCount];
  1674. for (int i = 0; i < ChildCount; i++) {
  1675. Temp_menuListDataClass.idMappingTable[i] = new ChildIDMapping();
  1676. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(시작)
  1677. if (arrayList.get(i).equals(API_Menu.SubMenuCall.Name_Door)) {
  1678. // Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCall.Door;
  1679. Temp_menuListDataClass.idMappingTable[i].Id = ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD;
  1680. Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCall.Name_Door;
  1681. } else if (arrayList.get(i).equals(API_Menu.SubMenuCall.Name_Lobby)) {
  1682. // Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCall.Lobby;
  1683. Temp_menuListDataClass.idMappingTable[i].Id = ID.SCREEN.SCREEN_TALKLOBBY_SUBWALLPAD;
  1684. Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCall.Name_Lobby;
  1685. } else if (arrayList.get(i).equals(API_Menu.SubMenuCall.Name_Guard)) {
  1686. // Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCall.Guard;
  1687. Temp_menuListDataClass.idMappingTable[i].Id = ID.SCREEN.SCREEN_TALKGUARD_SUBWALLPAD;
  1688. Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCall.Name_Guard;
  1689. } else if (arrayList.get(i).equals(API_Menu.SubMenuCall.Name_Neighbor)) {
  1690. // Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCall.Neighbor;
  1691. Temp_menuListDataClass.idMappingTable[i].Id = ID.SCREEN.SCREEN_TALKRESIDENCE_SUBWALLPAD;
  1692. Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCall.Name_Neighbor;
  1693. }
  1694. LOG("[LoadDefaultMenuList] Temp_menuListDataClass.idMappingTable[" + i + "].id = " + Temp_menuListDataClass.idMappingTable[i].Id);
  1695. LOG("[LoadDefaultMenuList] Temp_menuListDataClass.idMappingTable[" + i + "].Name = " + Temp_menuListDataClass.idMappingTable[i].Name);
  1696. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(끝)
  1697. }
  1698. return Temp_menuListDataClass;
  1699. }
  1700. /**
  1701. * Menu Event intent filter 등록
  1702. **/
  1703. private void reg_Receiver() {
  1704. try {
  1705. IntentFilter filter = new IntentFilter();
  1706. filter.addAction("MENU_EVENT");
  1707. registerReceiver(mWallPadAlertBR, filter);
  1708. filter = new IntentFilter();
  1709. filter.addAction(define.NOTIFY_DAIL);
  1710. filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH");
  1711. registerReceiver(mWallPadJogBR, filter);
  1712. } catch (RuntimeException re) {
  1713. LogUtil.errorLogInfo("", TAG, re);
  1714. } catch (Exception e) {
  1715. //e.printStackTrace();
  1716. LogUtil.errorLogInfo("", TAG, e);
  1717. }
  1718. }
  1719. /**
  1720. * 조그버튼 입력 받을 시 처리
  1721. **/
  1722. BroadcastReceiver mWallPadJogBR = new BroadcastReceiver() {
  1723. @Override
  1724. public void onReceive(Context context, Intent intent) {
  1725. WpadActivity.setFinishTimerReset();
  1726. }
  1727. };
  1728. /**
  1729. * 메뉴에서 버튼 터치 처리
  1730. **/
  1731. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  1732. @Override
  1733. public void onReceive(Context context, Intent intent) {
  1734. int groupPosition = intent.getIntExtra("groupPosition", -1);
  1735. int childPosition = intent.getIntExtra("childPosition", -1);
  1736. // 메뉴 터치에 의해 현관화면 진입시 모니터링을 바로 시작하기 위한 플래그 설정
  1737. // if (childPosition == 0) {
  1738. // if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) Global.bFrontMonitoring = true;
  1739. // else Global.bFrontMonitoring_SubWallPad = true;
  1740. // } else {
  1741. // if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) Global.bFrontMonitoring = false;
  1742. // else Global.bFrontMonitoring_SubWallPad = false;
  1743. // }
  1744. LOG_INFO("[mWallPadAlertBR] bEnablePSTN [" + Global.bEnablePSTN + "]");
  1745. if (bLobbyCallUse && (childPosition == 1)) return; // 로비메뉴 화면전환 없음
  1746. if (bPSTNCallUse && !Global.bEnablePSTN) return; // 국선통화 모뎀초기화 안될 경우 화면전환 없음
  1747. if ((groupPosition >= 0) && (childPosition >= 0)) {
  1748. if (MenuOpen) {
  1749. mSound.Play(SND.effect.TOUCH_LATCHED);
  1750. CloseMenuLayout();
  1751. if (menuListDataClass == null) {
  1752. return;
  1753. }
  1754. String childName = menuListDataClass.arrayChild.get(menuListDataClass.arrayGroup.get(groupPosition)).get(childPosition);
  1755. for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) {
  1756. if (menuListDataClass.idMappingTable[i].Name.equals(childName)) {
  1757. API_Menu api_Menu = new API_Menu();
  1758. int TempId = api_Menu.GetMyGroupID(getApplicationContext().getPackageName());
  1759. int ChildId = menuListDataClass.idMappingTable[i].Id;
  1760. int ChildGroupId = (ChildId / 1000) * 1000;
  1761. if (ConfigValues.eWallPadType == WALLPADTYPE.SUB) ChildGroupId = (getConvertScreenId(ChildId) / 1000) * 1000;
  1762. Log.i(TAG, "[mWallPadAlertBR] Child Id [" + ChildId + "], ChildGroupId [" + ChildGroupId + "]");
  1763. if (TempId == 0) {
  1764. return;
  1765. }
  1766. if (ChildGroupId == TempId) {
  1767. //해당 APP 내에서 스크린 전환 필요
  1768. boolean bResult = setChangeScreen(ChildId, false);
  1769. if (bResult) {
  1770. if (API_Menu.SubMenuCall.Door == ChildId) {
  1771. // 현관통화
  1772. if (!bBlockFrontCall) {
  1773. if (mCallController.mCallInfo.getFRONT() == CALLSTATUS.IDLE) {
  1774. setBlockFrontCall();
  1775. if (mCallController != null) mCallController.CallScenarioManager(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, null, null, null);
  1776. else Log.w(TAG, "[mWallPadAlertBR] mCallController is null!!");
  1777. }
  1778. else {
  1779. Log.w(TAG, "[mWallPadAlertBR] Front call ignored!!! getFRONT() [" + mCallController.mCallInfo.getFRONT() + "]");
  1780. }
  1781. }
  1782. else {
  1783. Log.w(TAG, "[mWallPadAlertBR] Front call ignored!!! bBlockFrontCall [" + bBlockFrontCall + "]");
  1784. }
  1785. }
  1786. }
  1787. else {
  1788. int nScreenID = API_Menu.SubMenuCall.Guard;
  1789. if (!bGuardCallUse) {
  1790. if (bFrontCallUse) nScreenID = API_Menu.SubMenuCall.Door;
  1791. else if (bResiCallUse) nScreenID = API_Menu.SubMenuCall.Neighbor;
  1792. else if (bPSTNCallUse) nScreenID = API_Menu.SubMenuCall.PSTN;
  1793. else if (bCallHistoryUse) nScreenID = API_Menu.SubMenuCall.CallList;
  1794. else if (bVisitorPicUse) nScreenID = API_Menu.SubMenuCall.Visitor;
  1795. }
  1796. setChangeScreen(nScreenID, false);
  1797. }
  1798. WpadActivity.setFinishTimerReset();
  1799. }
  1800. else {
  1801. //외부 앱 호출 후, 본 APP Finish 필요
  1802. api_Menu.startSubScreenActivity(getApplicationContext(), menuListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupId));
  1803. Intent mIntent = new Intent();
  1804. mIntent.putExtra("Finish_Kind", "HomeButton");
  1805. MainActivity.this.setResult(RESULT_OK, mIntent);
  1806. finish();
  1807. }
  1808. break;
  1809. }
  1810. }
  1811. }
  1812. }
  1813. }
  1814. };
  1815. // TAB 버튼 이벤트 -> MENU 버튼 이벤트 (2017.11.20 SEULKI)
  1816. public void setMenuBTNEnable(boolean bEnable) {
  1817. try {
  1818. LOG("[setMenuBTNEnable] bEnable: " + bEnable);
  1819. if (bEnable) TopMenuBtn.setButtonEventOffDisable();
  1820. else TopMenuBtn.setButtonEventOffEnable();
  1821. } catch (RuntimeException re) {
  1822. LogUtil.errorLogInfo("", TAG, re);
  1823. } catch (Exception e) {
  1824. Log.e(TAG, "[Exception] setMenuBTNEnable(boolean bEnable)");
  1825. //e.printStackTrace();
  1826. LogUtil.errorLogInfo("", TAG, e);
  1827. }
  1828. }
  1829. /**
  1830. * 디바이스 서비스 APP 을 체크하여 실행되어있지 않을시 실행시킨다.
  1831. */
  1832. private void checkDevService() {
  1833. try {
  1834. class checkDeviceService extends Thread {
  1835. @Override
  1836. public void run() {
  1837. super.run();
  1838. boolean DevServiceExist = false;
  1839. ActivityManager mActivityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1840. List<ActivityManager.RunningServiceInfo> mRunningServiceInfo = mActivityManager.getRunningServices(1000);
  1841. for (int i = 0; i < mRunningServiceInfo.size(); i++) {
  1842. ActivityManager.RunningServiceInfo rsi = mRunningServiceInfo.get(i);
  1843. if (rsi.service.getPackageName().equals("com.artncore.deviceservice")) {
  1844. Log.d(TAG, "[checkDevService] DeviceService already running!");
  1845. DevServiceExist = true;
  1846. break;
  1847. }
  1848. }
  1849. Log.d(TAG, "[checkDevService] DevServiceExist: " + DevServiceExist);
  1850. if (!DevServiceExist) {
  1851. Log.d(TAG, "[checkDevService] DeviceService manually started!!!");
  1852. Intent intent = new Intent("wallpaddevservice.ServiceMain");
  1853. startService(intent);
  1854. }
  1855. }
  1856. }
  1857. checkDeviceService th_checkDeviceService = new checkDeviceService();
  1858. th_checkDeviceService.run();
  1859. // boolean DevServiceExist = false;
  1860. //
  1861. // ActivityManager mActivityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1862. // List<ActivityManager.RunningServiceInfo> mRunningServiceInfo = mActivityManager.getRunningServices(1000);
  1863. //
  1864. // for (int i = 0; i < mRunningServiceInfo.size(); i++) {
  1865. // ActivityManager.RunningServiceInfo rsi = mRunningServiceInfo.get(i);
  1866. // if (rsi.service.getPackageName().equals("com.artncore.deviceservice")) {
  1867. // Log.d(TAG, "[checkDevService] DeviceService already running!");
  1868. // DevServiceExist = true;
  1869. // break;
  1870. // }
  1871. // }
  1872. //
  1873. // Log.d(TAG, "[checkDevService] DevServiceExist: " + DevServiceExist);
  1874. // if (!DevServiceExist) {
  1875. // Log.d(TAG, "[checkDevService] DeviceService StartManal");
  1876. // Intent intent = new Intent("wallpaddevservice.ServiceMain");
  1877. // startService(intent);
  1878. //
  1879. // try {
  1880. // Thread.sleep(3000);
  1881. // } catch (Exception e) {
  1882. // Log.e(TAG, "[Exception] checkDevService.sleep()");
  1883. // e.printStackTrace();
  1884. // }
  1885. // }
  1886. } catch (RuntimeException re) {
  1887. LogUtil.errorLogInfo("", TAG,re);
  1888. } catch (Exception e) {
  1889. Log.e(TAG, "[Exception] checkDevService");
  1890. //e.printStackTrace();
  1891. LogUtil.errorLogInfo("", TAG, e);
  1892. }
  1893. }
  1894. public boolean initIOInterface() {
  1895. try {
  1896. LOG("[initIOInterface] ");
  1897. // I/O 제어를 위한 라이브러리 사용
  1898. mIOInterface = new IOInterface(ConfigValues.DEVICE_BOARDTYPE, mWallPadAPI);
  1899. return true;
  1900. } catch (RuntimeException re) {
  1901. LogUtil.errorLogInfo("", TAG, re);
  1902. return false;
  1903. } catch (Exception e) {
  1904. Log.e(TAG, "[Exception] initIOInterface()");
  1905. //e.printStackTrace();
  1906. LogUtil.errorLogInfo("", TAG, e);
  1907. return false;
  1908. }
  1909. }
  1910. public boolean initCallEngine() {
  1911. try {
  1912. LOG("[initCallEngine]");
  1913. mCallController = new CallController(mContext, mWallPadAPI);
  1914. if (ConfigValues.bRemoteCall || ConfigValues.bReliefCall) {
  1915. mAudioRecordController = new AudioRecordController(mContext);
  1916. if (ConfigValues.bRemoteCall) mVideoController = new VideoController(mContext);
  1917. }
  1918. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  1919. if (ConfigValues.bPSTNEnable) mPSTNController = new PSTNController(mContext);
  1920. if (ConfigValues.bSubPhoneEnable) mSubPhoneController = new SubPhoneController(mContext);
  1921. if (ConfigValues.bRemoteCall) {
  1922. mDataSender = new DataSender();
  1923. mRemoteCallController = new RemoteCallController(mContext);
  1924. }
  1925. }
  1926. else {
  1927. mSubWallPadController = new SubWallPadController(mContext);
  1928. if (ConfigValues.eSubWallPadPSTNType == SUBWALLPAD_PSTNTYPE.DIRECT) {
  1929. mPSTNController = new PSTNController(mContext);
  1930. LOG_WARN("[initCallEngine] PSTNController is run!!");
  1931. }
  1932. }
  1933. initVideoSurfaceLayout();
  1934. return true;
  1935. } catch (RuntimeException re) {
  1936. LogUtil.errorLogInfo("", TAG, re);
  1937. return false;
  1938. } catch (Exception e) {
  1939. Log.e(TAG, "[Exception] initCallEngine()");
  1940. //e.printStackTrace();
  1941. LogUtil.errorLogInfo("", TAG, e);
  1942. return false;
  1943. }
  1944. }
  1945. public boolean releaseCallEngine() {
  1946. try {
  1947. LOG("[releaseCallEngine]");
  1948. // Call Engine End!
  1949. removeVideoSurfaceLayout();
  1950. if (mVideoController != null) mVideoController.releaseVideoController();
  1951. mCallController.releaseCallEventListener();
  1952. mCallController.releaseCallController();
  1953. if (mAudioRecordController != null) mAudioRecordController.releaseAudioRecordController();
  1954. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  1955. if (ConfigValues.bPSTNEnable) mPSTNController.releasePSTNController();
  1956. if (ConfigValues.bSubPhoneEnable) mSubPhoneController.releaseSubPhoneController();
  1957. if (ConfigValues.bRemoteCall) {
  1958. mRemoteCallController.releaseRemoteCallController();
  1959. mDataSender.interrupt();
  1960. mDataSender = null;
  1961. }
  1962. }
  1963. else {
  1964. mSubWallPadController.releaseSubWallPadController();
  1965. }
  1966. return true;
  1967. } catch (RuntimeException re) {
  1968. LogUtil.errorLogInfo("", TAG, re);
  1969. return false;
  1970. } catch (Exception e) {
  1971. Log.e(TAG, "[Exception] releaseCallEngine()");
  1972. //e.printStackTrace();
  1973. LogUtil.errorLogInfo("", TAG, e);
  1974. return false;
  1975. }
  1976. }
  1977. public boolean initCallHistoryDB() {
  1978. try {
  1979. LOG("[initCallHistoryDB]");
  1980. mCallHistoryManager = new CallHistoryManager();
  1981. return mCallHistoryManager.initCallHistory(mContext);
  1982. } catch (RuntimeException re) {
  1983. LogUtil.errorLogInfo("", TAG, re);
  1984. return false;
  1985. } catch (Exception e) {
  1986. Log.e(TAG, "[Exception] initCallHistoryDB()");
  1987. //e.printStackTrace();
  1988. LogUtil.errorLogInfo("", TAG, e);
  1989. return false;
  1990. }
  1991. }
  1992. public boolean releaseCallHistoryDB() {
  1993. try {
  1994. LOG("[releaseCallHistoryDB]");
  1995. if (mCallHistoryManager != null) {
  1996. return mCallHistoryManager.releaseCallHistory();
  1997. }
  1998. return false;
  1999. } catch (RuntimeException re) {
  2000. LogUtil.errorLogInfo("", TAG, re);
  2001. return false;
  2002. } catch (Exception e) {
  2003. Log.e(TAG, "[Exception] releaseCallHistoryDB()");
  2004. //e.printStackTrace();
  2005. LogUtil.errorLogInfo("", TAG, e);
  2006. return false;
  2007. }
  2008. }
  2009. public boolean initVisitorPictureHistoryDB() {
  2010. try {
  2011. LOG("[initVisitorPictureHistoryDB]");
  2012. mVisitorPictureHistoryManager = new VisitorPictureHistoryManager();
  2013. return mVisitorPictureHistoryManager.initVisitorPictureHistory(mContext);
  2014. } catch (RuntimeException re) {
  2015. LogUtil.errorLogInfo("", TAG, re);
  2016. return false;
  2017. } catch (Exception e) {
  2018. Log.e(TAG, "[Exception] initVisitorPictureHistoryDB()");
  2019. //e.printStackTrace();
  2020. LogUtil.errorLogInfo("", TAG, e);
  2021. return false;
  2022. }
  2023. }
  2024. public boolean releaseVisitorPictureHistoryDB() {
  2025. try {
  2026. LOG("[releaseVisitorPictureHistoryDB]");
  2027. if (mVisitorPictureHistoryManager != null) {
  2028. return mVisitorPictureHistoryManager.releaseVisitorPictureHistory();
  2029. }
  2030. return false;
  2031. } catch (RuntimeException re) {
  2032. LogUtil.errorLogInfo("", TAG, re);
  2033. return false;
  2034. } catch (Exception e) {
  2035. Log.e(TAG, "[Exception] releaseVisitorPictureHistoryDB()");
  2036. //e.printStackTrace();
  2037. LogUtil.errorLogInfo("", TAG, e);
  2038. return false;
  2039. }
  2040. }
  2041. private boolean send_check_sip_activation_request(final String strTargetIP) {
  2042. try {
  2043. Request_check_sip_activation check_sip_activation = new Request_check_sip_activation(mContext);
  2044. if (check_sip_activation.send_check_sip_activation(strTargetIP, null)) {
  2045. check_sip_activation.setResultCtrl(new RetProci() {
  2046. @Override
  2047. public void ProcSuccess() {
  2048. LOG_INFO("[send_check_sip_activation_request] ProcSuccess()");
  2049. mCallController.onSubPhoneEvent(CALLOWNER.KITCHEN_TV_01, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, strTargetIP, null);
  2050. // MainActivity.mCallController.mSIPInterface.requestCallForwardToStun(MainActivity.mCallController.makeCallForwarInfo(strTargetIP));
  2051. }
  2052. @Override
  2053. public void ProcError() {
  2054. LOG_INFO("[send_check_sip_activation_request] ProcError()");
  2055. mCallController.onSubPhoneEvent(CALLOWNER.KITCHEN_TV_01, CALLEVENTTYPE.REJECT_BUSY_CALL, CALLTYPE.FRONT, strTargetIP, null);
  2056. // MainActivity.mCallController.mSIPInterface.cancelCallForwardToStun();
  2057. }
  2058. @Override
  2059. public void ProcDoing() {
  2060. LOG_INFO("[send_check_sip_activation_request] ProcDoing()");
  2061. }
  2062. });
  2063. return true;
  2064. }
  2065. } catch (RuntimeException re) {
  2066. LogUtil.errorLogInfo("", TAG, re);
  2067. } catch (Exception e) {
  2068. Log.e(TAG, "[Exception] send_check_sip_activation_request(String strTargetIP, String strMessage)");
  2069. //e.printStackTrace();
  2070. LogUtil.errorLogInfo("", TAG, e);
  2071. MainActivity.mCallController.mSIPInterface.cancelCallForwardToStun();
  2072. }
  2073. return false;
  2074. }
  2075. String strCallOwner = "NONE";
  2076. String strCallEvent = "NONE";
  2077. String strCallType = "NONE";
  2078. String strRemoteInfo = "NONE";
  2079. private void generateCallEvent() {
  2080. try {
  2081. LOG_INFO("[generateCallEvent] ConfigValues.eWallPadType [" + ConfigValues.eWallPadType + "], strCallOwner [" + strCallOwner + "], strCallEvent [" + strCallEvent + "], strCallType [" + strCallType + "], strRemoteInfo [" + strRemoteInfo + "]");
  2082. if (strCallEvent.equalsIgnoreCase("NONE")) setMenuBTNEnable(true);
  2083. else setMenuBTNEnable(false);
  2084. if (strCallOwner != null && strCallEvent != null && strCallType != null) {
  2085. CALLOWNER callowner = CALLOWNER.getCALLOWNER(strCallOwner);
  2086. CALLTYPE calltype = CALLTYPE.getCALLTYPE(strCallType);
  2087. CALLEVENTTYPE calleventtype = CALLEVENTTYPE.getCALLEVENTTYPE(strCallEvent);
  2088. Log.i(TAG, "[generateCallEvent] callowner [" + callowner + "], calltype [" + calltype + "], calleventtype [" + calleventtype + "]");
  2089. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  2090. // 메인월패드
  2091. if (callowner == CALLOWNER.NONE) {
  2092. if (calltype == CALLTYPE.FRONT) {
  2093. if (calleventtype == CALLEVENTTYPE.RECEIVE_CALL) {
  2094. String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2095. if (mCallController != null) mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, strRemoteSIPID, null);
  2096. //if (mCallController != null) mCallController.CallScenarioManager(callowner, calleventtype, calltype, null, null, null);
  2097. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2098. }
  2099. else {
  2100. Log.w(TAG, "[generateCallEvent] not supported callevent!! -> " + calleventtype);
  2101. }
  2102. }
  2103. else if (calltype == CALLTYPE.PSTN) {
  2104. if (calleventtype == CALLEVENTTYPE.RECEIVE_CALL) {
  2105. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  2106. if (mCallController != null) mCallController.onPSTNEvent(CALLEVENTTYPE.RECEIVE_CALL, null, null);
  2107. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2108. if (ConfigValues.bPSTNEnable && ConfigValues.bARSEnable && ConfigValues.bUnoccupiedMode) {
  2109. sendHandlerMsgDelayed(HANDLERMSG.SEND_PSTN_ARS_MODE, 0, 0, 3000);
  2110. }
  2111. }
  2112. else {
  2113. if (mPSTNController != null) mPSTNController.receivePSTNRing();
  2114. else Log.w(TAG, "[generateCallEvent] mPSTNController is null!!");
  2115. }
  2116. }
  2117. else {
  2118. Log.w(TAG, "[generateCallEvent] not supported callevent!! -> " + calleventtype);
  2119. }
  2120. }
  2121. else {
  2122. if (calleventtype == CALLEVENTTYPE.RECEIVE_CALL) {
  2123. String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2124. if (mCallController != null) mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, strRemoteSIPID, null);
  2125. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2126. }
  2127. else {
  2128. Log.w(TAG, "[generateCallEvent] not supported callevent!! -> " + calleventtype);
  2129. }
  2130. Log.w(TAG, "[generateCallEvent] not supported calltype!! -> " + calltype);
  2131. RemoteIDInfo.strIP = strRemoteInfo;
  2132. }
  2133. }
  2134. else if (callowner == CALLOWNER.WALLPAD) {
  2135. if (calltype == CALLTYPE.FRONT) {
  2136. if (calleventtype == CALLEVENTTYPE.REQUEST_FRONT_MONITORING) {
  2137. if (mCallController != null) {
  2138. mCallController.mCallInfo.setCallOwner(callowner);
  2139. // strRemoteInfo = "10.1.0.11";
  2140. // String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2141. // RemoteIDInfo.strIP = strRemoteInfo;
  2142. //
  2143. // if (send_check_sip_activation_request(strRemoteInfo))
  2144. // mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, strRemoteSIPID, null);
  2145. // else
  2146. // Log.d(TAG, callowner.toString() + "REQUEST_FRONT_MONITORING check_sip_activation ERROR");
  2147. mCallController.CallScenarioManager(callowner, calleventtype, calltype, null, null, null);
  2148. }
  2149. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2150. }
  2151. }
  2152. else if (calltype == CALLTYPE.PSTN) {
  2153. RemoteIDInfo.bAutoCall = true;
  2154. RemoteIDInfo.strPSTNInfo = strRemoteInfo;
  2155. if (mCallController != null) {
  2156. mCallController.mCallInfo.setCallOwner(callowner);
  2157. mCallController.CallScenarioManager(callowner, calleventtype, calltype, null, null, null);
  2158. }
  2159. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2160. }
  2161. // else if (calltype == CALLTYPE.LOBBY) {
  2162. // if (mCallController != null) {
  2163. // mCallController.mCallInfo.setCallOwner(callowner);
  2164. // mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, null, null);
  2165. // }
  2166. // }
  2167. }
  2168. else if (callowner == CALLOWNER.MOBILE) {
  2169. if (calltype == CALLTYPE.FRONT) {
  2170. // [방문객원격통화] 스마트폰에서 현관모니터링 요청
  2171. if (calleventtype == CALLEVENTTYPE.REQUEST_FRONT_MONITORING) {
  2172. if (mCallController != null) {
  2173. mCallController.mCallInfo.setCallOwner(callowner);
  2174. strRemoteInfo = "10.1.0.11";
  2175. String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2176. RemoteIDInfo.strIP = strRemoteInfo;
  2177. if (send_check_sip_activation_request(strRemoteInfo))
  2178. mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, strRemoteSIPID, null);
  2179. else
  2180. Log.d(TAG, callowner.toString() + "REQUEST_FRONT_MONITORING check_sip_activation ERROR");
  2181. }
  2182. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2183. }
  2184. }
  2185. else if (calltype == CALLTYPE.GUARD) {
  2186. // [방문객원격통화] 스마트폰에서 경비발신 요청
  2187. if (calleventtype == CALLEVENTTYPE.TRYING_CALL) {
  2188. if (mCallController != null) {
  2189. mCallController.mCallInfo.setCallOwner(callowner);
  2190. mCallController.tryMoIPCall(CALLTYPE.GUARD, RemoteIDInfo.strDong, RemoteIDInfo.strHo);
  2191. }
  2192. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2193. }
  2194. }
  2195. else if (calltype == CALLTYPE.RESIDENCE) {
  2196. // [방문객원격통화] 모바일에서 홈뷰어 요청
  2197. if (calleventtype == CALLEVENTTYPE.REQUEST_FRONT_MONITORING) {
  2198. if (mCallController != null) {
  2199. mCallController.mCallInfo.setCallOwner(callowner);
  2200. mCallController.CallScenarioManager(callowner, calleventtype, calltype, null, null, null);
  2201. }
  2202. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2203. }
  2204. }
  2205. }
  2206. else if (Global.getKitchenTVIdx(callowner) >= 0 || Global.getBathPhoneIdx(callowner) >= 0 || callowner == CALLOWNER.SUB_WALLPAD || Global.getBathTVIdx(callowner) >= 0) {
  2207. if (calltype == CALLTYPE.FRONT) {
  2208. if (mCallController != null)
  2209. {
  2210. strRemoteInfo = "10.1.0.11";
  2211. String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2212. RemoteIDInfo.strIP = strRemoteInfo;
  2213. send_check_sip_activation_request(strRemoteInfo);
  2214. //mCallController.onSubPhoneEvent(callowner, calleventtype, calltype, null, null);
  2215. // if (send_check_sip_activation_request(strRemoteInfo))
  2216. // mCallController.onSubPhoneEvent(callowner, calleventtype, calltype, strRemoteSIPID, null);
  2217. // else
  2218. // Log.d(TAG, callowner.toString() + "REQUEST_FRONT_MONITORING check_sip_activation ERROR");
  2219. }
  2220. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2221. }
  2222. else if (calltype == CALLTYPE.GUARD || calleventtype == CALLEVENTTYPE.TRYING_CALL) {
  2223. if (mCallController != null) mCallController.onSubPhoneEvent(callowner, calleventtype, calltype, strRemoteInfo, null);
  2224. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2225. }
  2226. else if (calltype == CALLTYPE.RESIDENCE || calleventtype == CALLEVENTTYPE.REQUEST_RESIDENCE_CALL) {
  2227. if (mCallController != null) mCallController.onSubPhoneEvent(callowner, calleventtype, calltype, strRemoteInfo, null);
  2228. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2229. }
  2230. else {
  2231. Log.w(TAG, "[generateCallEvent] nor supported calltype and callevent!! -> " + calltype + "/" + calleventtype);
  2232. }
  2233. }
  2234. else {
  2235. Log.w(TAG, "[generateCallEvent] not supported callowner!! -> " + callowner);
  2236. }
  2237. }
  2238. else {
  2239. // 서브월패드
  2240. if (callowner == CALLOWNER.NONE) {
  2241. if (calltype == CALLTYPE.FRONT || calltype == CALLTYPE.LOBBY || calltype == CALLTYPE.GUARD || calltype == CALLTYPE.RESIDENCE) {
  2242. if (calleventtype == CALLEVENTTYPE.RECEIVE_CALL) {
  2243. if (mCallController != null) mCallController.onSubWallPadEvent(callowner, calleventtype, calltype, null, null);
  2244. else Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2245. }
  2246. else Log.w(TAG, "[generateCallEvent] not supported calleventtype!! -> " + calleventtype);
  2247. }
  2248. // else if(calltype == CALLTYPE.HISTORY_CALL)
  2249. // {
  2250. // strRemoteInfo = "10.1.0.110";
  2251. // String strRemoteSIPID = mCallController.makeSIPID(strRemoteInfo);
  2252. // RemoteIDInfo.strIP = strRemoteInfo;
  2253. //
  2254. // if (send_check_sip_activation_request(strRemoteInfo))
  2255. // if (mCallController != null) mCallController.CallScenarioManager(callowner, calleventtype, calltype, strRemoteInfo, strRemoteSIPID, null);
  2256. // else
  2257. // Log.d(TAG, callowner.toString() + "REQUEST_FRONT_MONITORING check_sip_activation ERROR");
  2258. // }
  2259. else {
  2260. Log.w(TAG, "[generateCallEvent] not supported calltype!! -> " + callowner);
  2261. RemoteIDInfo.strIP = strRemoteInfo;
  2262. }
  2263. }
  2264. else if (callowner == CALLOWNER.SUB_WALLPAD) {
  2265. if (calleventtype == CALLEVENTTYPE.REQUEST_FRONT_MONITORING) {
  2266. if (mCallController != null) {
  2267. mCallController.mCallInfo.setCallOwner(callowner);
  2268. mCallController.onSubWallPadEvent(callowner, calleventtype, calltype, null, null);
  2269. mSubWallPadController.sendRequestFrontMonitoring(CALLOWNER.SUB_WALLPAD, CALLTYPE.FRONT);
  2270. }
  2271. else {
  2272. Log.w(TAG, "[generateCallEvent] mCallController is null!!");
  2273. }
  2274. }
  2275. }
  2276. else {
  2277. Log.w(TAG, "[generateCallEvent] not supported callowner!! -> " + callowner);
  2278. }
  2279. }
  2280. }
  2281. else {
  2282. Log.w(TAG, "[generateCallEvent] strCallOwner, strCallEvent, strCallType are nul!!");
  2283. }
  2284. } catch (RuntimeException re) {
  2285. LogUtil.errorLogInfo("", TAG, re);
  2286. } catch (Exception e) {
  2287. Log.e(TAG, "[Exception] generateCallEvent()");
  2288. //e.printStackTrace();
  2289. LogUtil.errorLogInfo("", TAG, e);
  2290. }
  2291. }
  2292. int nNoticeTextColor_White = Color.WHITE;
  2293. int nNoticeTextColor_Orange = Color.parseColor("#FF8C00");
  2294. int nNoticeTextColor = nNoticeTextColor_Orange;
  2295. /**
  2296. * SEULKI, 2020.09.15
  2297. * 모바일 통화중 알림
  2298. * 방문객원격통화 모바일 통화중 상태를 사용자에게 알리기 위해, 화면 상단에 "모바일 통화종"이라는 문구를 표시한다.
  2299. * 모바일 통화중 알림 문구는 색을 반전하며 표시된다.
  2300. */
  2301. static long lRemoteConnectionPeriod = 0;
  2302. static int REMOTECALL_CONNECT_TIMEOUT = 1000 * 60; // 통화 시간 최대 1분
  2303. boolean bRemoteCallProcessNoticeRun = false;
  2304. private void startRemoteCallProcessNotice() {
  2305. try {
  2306. Log.v(TAG, "[startRemoteCallProcessNotice] bRemoteCallProcessNoticeRun [" + bRemoteCallProcessNoticeRun + "]");
  2307. if (mRemoteCallProcessNoticeThread == null && !bRemoteCallProcessNoticeRun) {
  2308. bRemoteCallProcessNoticeRun = true;
  2309. mRemoteCallProcessNoticeThread = new RemoteCallProcessNoticeThread();
  2310. mRemoteCallProcessNoticeThread.start();
  2311. }
  2312. else Log.v(TAG, "[startRemoteCallProcessNotice] mRemoteCallProcessNoticeThread is not null!!!");
  2313. } catch (RuntimeException re) {
  2314. LogUtil.errorLogInfo("", TAG, re);
  2315. } catch (Exception e) {
  2316. Log.e(TAG, "[Exception] startRemoteCallProcessNotice()");
  2317. //e.printStackTrace();
  2318. LogUtil.errorLogInfo("", TAG, e);
  2319. }
  2320. }
  2321. private void stopRemoteCallProcessNotice() {
  2322. try {
  2323. Log.v(TAG, "[stopRemoteCallProcessNotice] bRemoteCallProcessNoticeRun [" + bRemoteCallProcessNoticeRun + "]");
  2324. if (mRemoteCallProcessNoticeThread != null || bRemoteCallProcessNoticeRun) {
  2325. lRemoteConnectionPeriod = -999;
  2326. bRemoteCallProcessNoticeRun = false;
  2327. mRemoteCallProcessNoticeThread = null;
  2328. }
  2329. else Log.v(TAG, "[stopRemoteCallProcessNotice] mRemoteCallProcessNoticeThread is null!!!");
  2330. } catch (RuntimeException re) {
  2331. LogUtil.errorLogInfo("", TAG, re);
  2332. } catch (Exception e) {
  2333. Log.e(TAG, "[Exception] stopRemoteCallProcessNotice()");
  2334. //e.printStackTrace();
  2335. LogUtil.errorLogInfo("", TAG, e);
  2336. }
  2337. }
  2338. public void showRemoteCallNoticeText(boolean bRun) {
  2339. try {
  2340. Log.i(TAG, "[showRemoteCallNoticeText] bRun [" + bRun + "]");
  2341. if (bRun) {
  2342. TopRemoteCallNotice.setText("모바일 통화중");
  2343. TopRemoteCallNotice.setVisibility(View.VISIBLE);
  2344. startRemoteCallProcessNotice();
  2345. }
  2346. else {
  2347. TopRemoteCallNotice.setText("");
  2348. TopRemoteCallNotice.setVisibility(View.INVISIBLE);
  2349. stopRemoteCallProcessNotice();
  2350. }
  2351. } catch (RuntimeException re) {
  2352. LogUtil.errorLogInfo("", TAG, re);
  2353. } catch (Exception e) {
  2354. Log.e(TAG, "[Exception] showRemoteCallNoticeText(boolean bRun)");
  2355. //e.printStackTrace();
  2356. LogUtil.errorLogInfo("", TAG, e);
  2357. }
  2358. }
  2359. private RemoteCallProcessNoticeThread mRemoteCallProcessNoticeThread;
  2360. private class RemoteCallProcessNoticeThread extends Thread {
  2361. public RemoteCallProcessNoticeThread() {
  2362. Log.i(TAG, "============ [RemoteCallProcessNoticeThread()] ============");
  2363. }
  2364. public void run() {
  2365. try {
  2366. Log.v(TAG, "[RemoteCallProcessNoticeThread().run()] bRemoteCallProcessNoticeRun [" + bRemoteCallProcessNoticeRun + "]");
  2367. lRemoteConnectionPeriod = System.currentTimeMillis() + REMOTECALL_CONNECT_TIMEOUT;
  2368. while ((System.currentTimeMillis() < lRemoteConnectionPeriod) && bRemoteCallProcessNoticeRun) {
  2369. try {
  2370. if (bRemoteCallProcessNoticeRun) Thread.sleep(500); // 500ms에 한번씩 색 반전
  2371. } catch (InterruptedException e) {
  2372. Log.e(TAG, "[RemoteCallProcessNoticeThread] Thread.sleep(500)");
  2373. //e.printStackTrace();
  2374. LogUtil.errorLogInfo("", TAG, e);
  2375. }
  2376. if (nNoticeTextColor == nNoticeTextColor_Orange) {
  2377. // Log.i(TAG, "[StrangerProcessNoticeThread().run().while()] ===== white =====");
  2378. nNoticeTextColor = nNoticeTextColor_White;
  2379. }
  2380. else {
  2381. // Log.i(TAG, "[RemoteCallProcessNoticeThread().run().while()] ===== orange =====");
  2382. nNoticeTextColor = nNoticeTextColor_Orange;
  2383. }
  2384. sendHandlerMsg(HANDLERMSG.CHANGE_REMOTECALL_NOTICE_COLOR, 0, 0);
  2385. }
  2386. bRemoteCallProcessNoticeRun = false;
  2387. Log.i(TAG, "[RemoteCallProcessNoticeThread().run()] ===== while end =====");
  2388. } catch (RuntimeException re) {
  2389. LogUtil.errorLogInfo("", TAG, re);
  2390. } catch (Exception e) {
  2391. Log.e(TAG, "[Exception] RemoteCallProcessNoticeThread.run()");
  2392. //e.printStackTrace();
  2393. LogUtil.errorLogInfo("", TAG, e);
  2394. }
  2395. }
  2396. }
  2397. /* ================================================================================================
  2398. * 히든 메뉴 -> 통화시험모드 진입
  2399. ================================================================================================ */
  2400. private void startHideMenu() {
  2401. try {
  2402. TopBackground.setImageResource(0);
  2403. TopBackground.setBackgroundColor(Color.RED);
  2404. mSound.Play(SND.call.CALLSTART);
  2405. super.setFinishTimerDestroy();
  2406. Log.i(TAG, "================================");
  2407. Log.i(TAG, "[startHideMenu] START !!!!!");
  2408. Log.i(TAG, "================================");
  2409. mCallController.set1stCallTimer(CALLTYPE.FRONT, 99999);
  2410. if (SampleModeTitle == null) {
  2411. SampleModeTitle = new WpadTextView(mContext, false, 200, 72, Gravity.CENTER, Color.DKGRAY, Common.fontsize._26_DEFAULT, true, 0);
  2412. ViewRegistration(TopLayout, SampleModeTitle, 316, 17);
  2413. }
  2414. SampleModeTitle.setText("[통화시험모드]");
  2415. } catch (RuntimeException re) {
  2416. LogUtil.errorLogInfo("", TAG, re);
  2417. } catch (Exception e) {
  2418. Log.e(TAG, "[Exception] startHideMenu()");
  2419. //e.printStackTrace();
  2420. LogUtil.errorLogInfo("", TAG, e);
  2421. }
  2422. }
  2423. /* ================================================================================================
  2424. * 원격지 영상
  2425. ================================================================================================ */
  2426. public void initRemoteVideoSurfaceLayout() {
  2427. try {
  2428. LOG_INFO("[initRemoteVideoSurfaceLayout] RemoteVideoLayout = " + RemoteVideoLayout);
  2429. if (RemoteVideoLayout != null) {
  2430. RemoteVideoSurface.getHolder().removeCallback(RemoteVideoCallback);
  2431. RemoteVideoLayout.removeAllViews();
  2432. RemoteVideoLayout = null;
  2433. }
  2434. RemoteVideoLayout = new RelativeLayout(mContext);
  2435. WpadUtil.LayoutRegistration(SurfaceLayout, RemoteVideoLayout, screenWidth, screenHeight - topHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.REMOTEVIDEO);
  2436. RemoteVideoSurface = new SurfaceView(mContext);
  2437. // RemoteVideoHolder = RemoteVideoSurface.getHolder();
  2438. WpadRelativeLayoutParams RemoteVideoParams;
  2439. if (bFFMPEGEnable) {
  2440. RemoteVideoParams = new WpadRelativeLayoutParams(708, 540);
  2441. // RemoteVideoParams.setMargins(107, 112, 0, 0);
  2442. RemoteVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  2443. }
  2444. else {
  2445. RemoteVideoParams = new WpadRelativeLayoutParams(1000, 800);
  2446. RemoteVideoParams.setMargins(95, 112, 0, 0);
  2447. }
  2448. RemoteVideoLayout.addView(RemoteVideoSurface, RemoteVideoParams);
  2449. RemoteVideoSurface.getHolder().addCallback(RemoteVideoCallback);
  2450. } catch (RuntimeException re) {
  2451. LogUtil.errorLogInfo("", TAG, re);
  2452. } catch (Exception e) {
  2453. Log.e(TAG, "[Exception] initRemoteVideoSurfaceLayout()");
  2454. //e.printStackTrace();
  2455. LogUtil.errorLogInfo("", TAG, e);
  2456. }
  2457. }
  2458. public void showRemoteVideo(boolean bShow, boolean bResidenceCall) {
  2459. try {
  2460. LOG_INFO("[showRemoteVideo] bShow [" + bShow + "], bResidenceCall [" + bResidenceCall + "]");
  2461. if (RemoteVideoSurface == null) {
  2462. LOG_WARN("[showRemoteVideo] RemoteVideoSurface is null!!!");
  2463. return;
  2464. }
  2465. WpadRelativeLayoutParams RemoteVideoParams;
  2466. if (bFFMPEGEnable) {
  2467. if (bShow) {
  2468. if (bResidenceCall) {
  2469. RemoteVideoParams = new WpadRelativeLayoutParams(720, 540);
  2470. RemoteVideoParams.setMargins(144, 112, 0, 0);
  2471. }
  2472. else {
  2473. RemoteVideoParams = new WpadRelativeLayoutParams(708, 540);
  2474. RemoteVideoParams.setMargins(107, 112, 0, 0);
  2475. }
  2476. }
  2477. else {
  2478. RemoteVideoParams = new WpadRelativeLayoutParams(708, 540);
  2479. RemoteVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  2480. }
  2481. }
  2482. else {
  2483. if (bShow) {
  2484. RemoteVideoParams = new WpadRelativeLayoutParams(720, 540);
  2485. RemoteVideoParams.setMargins(144, 112, 0, 0);
  2486. }
  2487. else {
  2488. RemoteVideoParams = new WpadRelativeLayoutParams(720, 540);
  2489. RemoteVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  2490. }
  2491. }
  2492. RemoteVideoSurface.setLayoutParams(RemoteVideoParams);
  2493. } catch (RuntimeException re) {
  2494. LogUtil.errorLogInfo("", TAG, re);
  2495. } catch (Exception e) {
  2496. Log.e(TAG, "[Exception] showRemoteVideo(boolean bShow)");
  2497. //e.printStackTrace();
  2498. LogUtil.errorLogInfo("", TAG, e);
  2499. }
  2500. }
  2501. public void removeRemoteVideoSurfaceLayout() {
  2502. try {
  2503. // LOG_INFO("[removeRemoteVideoSurfaceLayout] RemoteVideoSurface = " + RemoteVideoSurface + ", RemoteVideoLayout = " + RemoteVideoLayout);
  2504. if (RemoteVideoLayout != null) {
  2505. RemoteVideoSurface.getHolder().removeCallback(RemoteVideoCallback);
  2506. RemoteVideoLayout.removeAllViews();
  2507. RemoteVideoLayout = null;
  2508. }
  2509. else Log.d(TAG, "[removeRemoteVideoSurfaceLayout] RemoteVideoLayout is null!");
  2510. // if (RemoteVideoSurface != null) {
  2511. // RemoteVideoSurface.setVisibility(View.GONE);
  2512. // RemoteVideoSurface.getHolder().removeCallback(RemoteVideoCallback);
  2513. // RemoteVideoSurface = null;
  2514. // }
  2515. //
  2516. // if (RemoteVideoLayout != null) {
  2517. // RemoteVideoLayout.setVisibility(View.GONE);
  2518. // RemoteVideoLayout.removeAllViews();
  2519. // RemoteVideoLayout = null;
  2520. // }
  2521. } catch (RuntimeException re) {
  2522. LogUtil.errorLogInfo("", TAG, re);
  2523. } catch (Exception e) {
  2524. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  2525. //e.printStackTrace();
  2526. LogUtil.errorLogInfo("", TAG, e);
  2527. }
  2528. }
  2529. private Callback RemoteVideoCallback = new Callback() {
  2530. @Override
  2531. public void surfaceCreated(SurfaceHolder holder) {
  2532. LOG_INFO("[RemoteVideoCallback] surfaceCreated!!");
  2533. if (bFFMPEGEnable) {
  2534. mCallController.mVideoJNI.setRemoteSurfaceview(holder.getSurface(), 708, 540);
  2535. }
  2536. }
  2537. @Override
  2538. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  2539. LOG_INFO("[RemoteVideoCallback] surfaceChanged!!");
  2540. }
  2541. @Override
  2542. public void surfaceDestroyed(SurfaceHolder holder) {
  2543. LOG_INFO("[RemoteVideoCallback] surfaceDestroyed!!");
  2544. if (RemoteVideoSurface != null) {
  2545. LOG_INFO("[RemoteVideoCallback] RemoteVideoSurface is not null!!");
  2546. RemoteVideoSurface.getHolder().removeCallback(RemoteVideoCallback);
  2547. }
  2548. }
  2549. };
  2550. public void displayRemoteID(String strRemoteID) {
  2551. try {
  2552. LOG("[displayRemoteID] strRemoteID = " + strRemoteID);
  2553. if (strRemoteID != null) {
  2554. // strRemoteID에 따른 좌표 적용 (2017.11.22 SEULKI)
  2555. String strBlank = " ";
  2556. if (strRemoteID.contains("로비")) {
  2557. LOG_INFO("[displayRemoteID] LOBBY");
  2558. } else if (strRemoteID.contains("동") && (strRemoteID.contains("호"))) {
  2559. LOG_INFO("[displayRemoteID] NEIGHBOR");
  2560. strRemoteID = strRemoteID.replace(strRemoteID, strBlank + strRemoteID);
  2561. } else if (strRemoteID.contains("경비")) {
  2562. LOG_INFO("[displayRemoteID] GUARD");
  2563. }
  2564. TXT_REMOTE_ID.setText(strRemoteID);
  2565. TXT_REMOTE_ID.setVisibility(View.VISIBLE);
  2566. } else {
  2567. TXT_REMOTE_ID.setText("");
  2568. TXT_REMOTE_ID.setVisibility(View.INVISIBLE);
  2569. }
  2570. } catch (RuntimeException re) {
  2571. LogUtil.errorLogInfo("", TAG, re);
  2572. } catch (Exception e) {
  2573. Log.e(TAG, "[Exception] displayRemoteID(strRemoteID)");
  2574. //e.printStackTrace();
  2575. LogUtil.errorLogInfo("", TAG, e);
  2576. }
  2577. }
  2578. public void displayRemoteID(CALLTYPE eCallType, CALLSTATUS eCallStatus) {
  2579. try {
  2580. LOG("[displayRemoteID] eCallType [" + eCallType + "], eCallStatus[" + eCallStatus + "]");
  2581. String strTarget = "";
  2582. String strInfoMent = "";
  2583. String strCalled = " 호출입니다.";
  2584. String strCalling = " 호출중입니다.";
  2585. String strTalking = " 통화중입니다.";
  2586. if (eCallStatus == CALLSTATUS.CALLED) strInfoMent = strCalled;
  2587. else if (eCallStatus == CALLSTATUS.TRYING_CALL || eCallStatus == CALLSTATUS.CALLING) strInfoMent = strCalling;
  2588. else if (eCallStatus == CALLSTATUS.TALKING) strInfoMent = strTalking;
  2589. if (eCallType == CALLTYPE.LOBBY) strTarget = "공동현관";
  2590. else if (eCallType == CALLTYPE.GUARD) strTarget = "경비실";
  2591. if ((!strTarget.equals("")) && (!strInfoMent.equals(""))) {
  2592. TXT_REMOTE_ID.setText(strTarget.concat(strInfoMent));
  2593. TXT_REMOTE_ID.setVisibility(View.VISIBLE);
  2594. } else {
  2595. TXT_REMOTE_ID.setText("");
  2596. TXT_REMOTE_ID.setVisibility(View.INVISIBLE);
  2597. }
  2598. } catch (RuntimeException re) {
  2599. LogUtil.errorLogInfo("", TAG, re);
  2600. } catch (Exception e) {
  2601. //e.printStackTrace();
  2602. LogUtil.errorLogInfo("", TAG, e);
  2603. Log.e(TAG, "[Exception] displayRemoteID(CALLTYPE eCallType, CALLSTATUS eCallStatus)");
  2604. }
  2605. }
  2606. /* ================================================================================================
  2607. * 내 영상
  2608. ================================================================================================ */
  2609. public Camera mMyCamera;
  2610. public void initMyVideoSurfaceLayout() {
  2611. try {
  2612. // LOG_INFO("[initMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  2613. if (MyVideoLayout != null) {
  2614. MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  2615. MyVideoLayout.removeAllViews();
  2616. MyVideoLayout = null;
  2617. }
  2618. MyVideoLayout = new RelativeLayout(mContext);
  2619. WpadUtil.LayoutRegistration(SurfaceLayout, MyVideoLayout, screenWidth, screenHeight - topHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.MYVIDEO);
  2620. MyVideoSurface = new SurfaceView(mContext);
  2621. // MyVideoHolder = MyVideoSurface.getHolder();
  2622. WpadRelativeLayoutParams MyVideoParams = new WpadRelativeLayoutParams(280, 210);
  2623. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  2624. MyVideoLayout.addView(MyVideoSurface, MyVideoParams);
  2625. MyVideoSurface.getHolder().addCallback(MyVideoCallback);
  2626. MyVideoSurface.setZOrderOnTop(true);
  2627. } catch (RuntimeException re) {
  2628. LogUtil.errorLogInfo("", TAG, re);
  2629. } catch (Exception e) {
  2630. Log.e(TAG, "[Exception] initMyVideoSurfaceLayout()");
  2631. //e.printStackTrace();
  2632. LogUtil.errorLogInfo("", TAG, e);
  2633. }
  2634. }
  2635. public void removeMyVideoSurfaceLayout() {
  2636. try {
  2637. LOG_INFO("[removeMyVideoSurfaceLayout] MyVideoSurface = " + MyVideoSurface + ", MyVideoLayout = " + MyVideoLayout);
  2638. if (MyVideoLayout != null) {
  2639. // MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  2640. MyVideoLayout.removeAllViews();
  2641. MyVideoLayout = null;
  2642. }
  2643. // if (MyVideoSurface != null) {
  2644. // MyVideoSurface.setVisibility(View.GONE);
  2645. // MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  2646. // MyVideoSurface = null;
  2647. // }
  2648. //
  2649. // if (MyVideoLayout != null) {
  2650. // MyVideoLayout.setVisibility(View.GONE);
  2651. // MyVideoLayout.removeAllViews();
  2652. // MyVideoLayout = null;
  2653. // }
  2654. } catch (RuntimeException re) {
  2655. LogUtil.errorLogInfo("", TAG, re);
  2656. } catch (Exception e) {
  2657. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  2658. //e.printStackTrace();
  2659. LogUtil.errorLogInfo("", TAG, e);
  2660. }
  2661. }
  2662. public void showMyVideo(boolean bShow, boolean bMobile) {
  2663. try {
  2664. LOG_INFO("[showMyVideo] bShow [" + bShow + "], bMobile [" + bMobile + "]");
  2665. if (MyVideoSurface == null) {
  2666. LOG_WARN("[showMyVideo] MyVideoSurface is null!!!");
  2667. return;
  2668. }
  2669. WpadRelativeLayoutParams MyVideoParams;
  2670. if (bShow) {
  2671. if (bMobile) { // 방문객원격통화 홈뷰어일 경우
  2672. MyVideoParams = new WpadRelativeLayoutParams(720, 540);
  2673. } else {
  2674. MyVideoParams = new WpadRelativeLayoutParams(280, 210);
  2675. }
  2676. MyVideoParams.setMargins(144, 112, 0, 0);
  2677. MyVideoSurface.setLayoutParams(MyVideoParams);
  2678. }
  2679. else {
  2680. MyVideoParams = new WpadRelativeLayoutParams(280, 210);
  2681. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  2682. MyVideoSurface.setLayoutParams(MyVideoParams);
  2683. }
  2684. if (mCallController.mSIPInterface != null)
  2685. mCallController.mSIPInterface.showMyVideo(bShow);
  2686. } catch (RuntimeException re) {
  2687. LogUtil.errorLogInfo("", TAG, re);
  2688. } catch (Exception e) {
  2689. Log.e(TAG, "[Exception] showMyVideo(boolean bShow)");
  2690. //e.printStackTrace();
  2691. LogUtil.errorLogInfo("", TAG, e);
  2692. }
  2693. }
  2694. public void finishMyVideo() {
  2695. try {
  2696. LOG_INFO("[finishMyVideo]");
  2697. if (mCallController.mSIPInterface != null)
  2698. mCallController.mSIPInterface.videoSet(false, false, false);
  2699. // mCallController.mVideoJNI.setComposite(false);
  2700. showMyVideo(false, false);
  2701. removeMyVideoSurfaceLayout();
  2702. } catch (RuntimeException re) {
  2703. LogUtil.errorLogInfo("", TAG, re);
  2704. } catch (Exception e) {
  2705. Log.e(TAG, "[Exception] finishMyVideo()");
  2706. //e.printStackTrace();
  2707. LogUtil.errorLogInfo("", TAG, e);
  2708. }
  2709. }
  2710. private Callback MyVideoCallback = new Callback() {
  2711. @Override
  2712. public void surfaceCreated(SurfaceHolder holder) {
  2713. try {
  2714. LOG_INFO("[MyVideoCallback] surfaceCreated!!");
  2715. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT
  2716. || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  2717. mIOInterface.ctrlWallPadCamPower(true);
  2718. boolean bAOS7 = false; // 한국생산(다담, AOS 6.0.1)과 중국생산(사니코, 7.1.1) 구분 (true: 중국생산, false: 한국생산)
  2719. if (Build.VERSION.SDK_INT > 23) bAOS7 = true;
  2720. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101) {
  2721. if (bAOS7) {
  2722. // AOS 7.1.1
  2723. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); // 확인완료 (JEFF, 2020.09.02)
  2724. }
  2725. else {
  2726. // AOS 6.0.1
  2727. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  2728. }
  2729. }
  2730. else {
  2731. if (bAOS7) {
  2732. /**
  2733. * 확인완료 (JEFF, 2020.09.02)
  2734. * IHN-1020B-I, IHN-D101-I, IHN-1010-I
  2735. * IHN-HS101-I (SEULKI, 2021.05.11)
  2736. */
  2737. // AOS 7.1.1
  2738. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1020B_I && !Global.getCompareBSPVersion("2020.09.08")) mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  2739. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101_I && !Global.getCompareBSPVersion("2020.06.11")) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  2740. else mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  2741. }
  2742. else {
  2743. /**
  2744. * 확인완료 (JEFF, 2020.09.02)
  2745. * IHN-1010, IHN-HS101
  2746. */
  2747. // AOS 6.0.1
  2748. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); // 확인완료 (JEFF, 2020.09.02)
  2749. }
  2750. }
  2751. Camera.Parameters params = mMyCamera.getParameters();
  2752. params.setPictureSize(320, 240);
  2753. mMyCamera.setParameters(params);
  2754. mMyCamera.setPreviewDisplay(holder);
  2755. }
  2756. else {
  2757. LOG_WARN("[MyVideoCallback] surfaceCreated!! -> NOT Supported ConfigValues.DEVICE_BOARDTYPE [" + ConfigValues.DEVICE_BOARDTYPE + "]");
  2758. }
  2759. } catch (RuntimeException re) {
  2760. LogUtil.errorLogInfo("", TAG, re);
  2761. } catch (Exception e) {
  2762. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  2763. //e.printStackTrace();
  2764. LogUtil.errorLogInfo("", TAG, e);
  2765. }
  2766. }
  2767. @Override
  2768. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  2769. try {
  2770. LOG_INFO("[MyVideoCallback] surfaceChanged!!");
  2771. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT
  2772. || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  2773. mMyCamera.startPreview();
  2774. if (!bFFMPEGEnable && Common.OPTION_TAB_ANMI_ENABLE) {
  2775. Animation Anmi = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.screen_on);
  2776. MyVideoLayout.startAnimation(Anmi);
  2777. }
  2778. } else {
  2779. LOG_WARN("[MyVideoCallback] surfaceChanged!! -> NOT Supported ConfigValues.DEVICE_BOARDTYPE [" + ConfigValues.DEVICE_BOARDTYPE + "]");
  2780. }
  2781. } catch (RuntimeException re) {
  2782. LogUtil.errorLogInfo("", TAG, re);
  2783. } catch (Exception e) {
  2784. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceChanged(SurfaceHolder holder, int format, int width, int height)");
  2785. //e.printStackTrace();
  2786. LogUtil.errorLogInfo("", TAG, e);
  2787. }
  2788. }
  2789. @Override
  2790. public void surfaceDestroyed(SurfaceHolder holder) {
  2791. try {
  2792. LOG_INFO("[MyVideoCallback] surfaceDestroyed!!");
  2793. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT
  2794. || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  2795. mIOInterface.ctrlWallPadCamPower(false);
  2796. if (mMyCamera != null) {
  2797. mMyCamera.stopPreview();
  2798. mMyCamera.release();
  2799. mMyCamera = null;
  2800. }
  2801. } else {
  2802. LOG_WARN("[MyVideoCallback] surfaceDestroyed!! -> NOT Supported ConfigValues.DEVICE_BOARDTYPE [" + ConfigValues.DEVICE_BOARDTYPE + "]");
  2803. }
  2804. } catch (RuntimeException re) {
  2805. LogUtil.errorLogInfo("", TAG, re);
  2806. } catch (Exception e) {
  2807. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  2808. //e.printStackTrace();
  2809. LogUtil.errorLogInfo("", TAG, e);
  2810. }
  2811. }
  2812. };
  2813. /* ================================================================================================
  2814. * 현관카메라 영상
  2815. ================================================================================================ */
  2816. public Camera mFrontCamera;
  2817. public boolean initFrontVideoLayout() {
  2818. try {
  2819. Log.d(TAG, "[initFrontVideoLayout] front camera");
  2820. FrontVideoLayout = new RelativeLayout(mContext);
  2821. WpadUtil.LayoutRegistration(SurfaceLayout, FrontVideoLayout, screenWidth, screenHeight - topHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.FRONTVIDEO);
  2822. FrontVideoSurface = new SurfaceView(mContext);
  2823. FrontVideoHolder = FrontVideoSurface.getHolder();
  2824. WpadRelativeLayoutParams FrontVideoParams;
  2825. FrontVideoParams = new WpadRelativeLayoutParams(720, 540);
  2826. FrontVideoParams.setMargins(1300, 112, 0, 0);
  2827. FrontVideoLayout.addView(FrontVideoSurface, FrontVideoParams);
  2828. showFrontVideo(false);
  2829. FrontVideoSurface.getHolder().addCallback(FrontVideoCallback);
  2830. FrontVideoSurface.setZOrderOnTop(true);
  2831. return true;
  2832. } catch (RuntimeException re) {
  2833. LogUtil.errorLogInfo("", TAG, re);
  2834. return false;
  2835. } catch (Exception e) {
  2836. Log.e(TAG, "[Exception] initFrontVideoLayout()");
  2837. //e.printStackTrace();
  2838. LogUtil.errorLogInfo("", TAG, e);
  2839. return false;
  2840. }
  2841. }
  2842. public boolean removeFrontVideoLayout() {
  2843. try {
  2844. // LOG_INFO("[removeFrontVideoLayout] FrontVideoSurface = " + FrontVideoSurface + ", FrontVideoLayout = " + FrontVideoLayout);
  2845. if (FrontVideoSurface != null) {
  2846. FrontVideoSurface.setVisibility(View.GONE);
  2847. FrontVideoSurface.getHolder().removeCallback(FrontVideoCallback);
  2848. FrontVideoSurface = null;
  2849. }
  2850. if (FrontVideoLayout != null) {
  2851. FrontVideoLayout.setVisibility(View.GONE);
  2852. FrontVideoLayout.removeAllViews();
  2853. FrontVideoLayout = null;
  2854. }
  2855. return true;
  2856. } catch (RuntimeException re) {
  2857. LogUtil.errorLogInfo("", TAG, re);
  2858. return false;
  2859. } catch (Exception e) {
  2860. Log.e(TAG, "[Exception] removeFrontVideoLayout()");
  2861. //e.printStackTrace();
  2862. LogUtil.errorLogInfo("", TAG, e);
  2863. return false;
  2864. }
  2865. }
  2866. public void initFrontVideo() {
  2867. try {
  2868. LOG("[initFrontVideo]");
  2869. FrontVideoLayout = new RelativeLayout(mContext);
  2870. WpadUtil.LayoutRegistration(SurfaceLayout, FrontVideoLayout, screenWidth, screenHeight - topHeight, 0, 0, ID.MAINACTIVITY.LAYOUT.FRONTVIDEO);
  2871. FrontVideoSurface = new SurfaceView(mContext);
  2872. FrontVideoHolder = FrontVideoSurface.getHolder();
  2873. WpadRelativeLayoutParams FrontVideoParams;
  2874. FrontVideoParams = new WpadRelativeLayoutParams(720, 540);
  2875. FrontVideoParams.setMargins(95, 112, 0, 0);
  2876. FrontVideoLayout.addView(FrontVideoSurface, FrontVideoParams);
  2877. FrontVideoLayout.setVisibility(View.INVISIBLE);
  2878. } catch (RuntimeException re) {
  2879. LogUtil.errorLogInfo("", TAG, re);
  2880. } catch (Exception e) {
  2881. Log.e(TAG, "[Exception] initFrontVideo()");
  2882. //e.printStackTrace();
  2883. LogUtil.errorLogInfo("", TAG, e);
  2884. }
  2885. }
  2886. private Callback FrontVideoCallback = new Callback() {
  2887. @Override
  2888. public void surfaceCreated(SurfaceHolder holder) {
  2889. try {
  2890. LOG_INFO("[FrontVideoCallback] front camera surfaceCreated!!");
  2891. boolean bAOS7 = false; // 한국생산(다담, AOS 6.0.1)과 중국생산(사니코, 7.1.1) 구분 (true: 중국생산, false: 한국생산)
  2892. if (Build.VERSION.SDK_INT > 23) bAOS7 = true;
  2893. Log.d(TAG, "[FrontVideoCallback] ConfigValues.DEVICE_MODELTYPE [" + ConfigValues.DEVICE_MODELTYPE + "], ConfigValues.eFrontCameraType [" + ConfigValues.eFrontCameraType + "], bAOS7 [" + bAOS7 + "]");
  2894. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101) {
  2895. if (bAOS7) {
  2896. // AOS 7.1.1
  2897. mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); // 확인완료 (JEFF, 2020.09.02)
  2898. }
  2899. else {
  2900. // AOS 6.0.1
  2901. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.HD) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  2902. else mFrontCamera = Camera.open();
  2903. }
  2904. }
  2905. else {
  2906. if (bAOS7) {
  2907. /**
  2908. * 확인완료 (JEFF, 2020.09.02)
  2909. * IHN-1020B-I, IHN-D101-I, IHN-1010 (중국)
  2910. * IHN-HS101-I (SEULKI, 2021.05.11)
  2911. */
  2912. // AOS 7.1.1
  2913. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1020B_I && !Global.getCompareBSPVersion("2020.09.08")) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  2914. else if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101_I && !Global.getCompareBSPVersion("2020.06.11")) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  2915. else mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  2916. }
  2917. else {
  2918. /**
  2919. * 확인완료 (JEFF, 2020.09.02)
  2920. * IHN-1010, IHN-HS101
  2921. */
  2922. // AOS 6.0.1
  2923. mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); // 확인완료 (JEFF, 2020.09.02)
  2924. }
  2925. }
  2926. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.HD) {
  2927. Camera.Parameters params = mFrontCamera.getParameters();
  2928. params.setPictureSize(1280, 720);
  2929. mFrontCamera.setParameters(params);
  2930. }
  2931. else {
  2932. Camera.Parameters params = mFrontCamera.getParameters();
  2933. params.setPictureSize(640, 480);
  2934. mFrontCamera.setParameters(params);
  2935. }
  2936. mFrontCamera.setPreviewDisplay(holder);
  2937. mFrontCamera.setErrorCallback(FrontVideoErrorCallback);
  2938. } catch (RuntimeException re) {
  2939. LogUtil.errorLogInfo("", TAG, re);
  2940. } catch (Exception e) {
  2941. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  2942. //e.printStackTrace();
  2943. LogUtil.errorLogInfo("", TAG, e);
  2944. }
  2945. }
  2946. @Override
  2947. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  2948. try {
  2949. LOG_INFO("[FrontVideoCallback] surfaceChanged!!");
  2950. if (mFrontCamera != null) {
  2951. mFrontCamera.startPreview();
  2952. }
  2953. //add KSJ
  2954. if(mCurrentScreenId != ID.SCREEN.SCREEN_TALKFRONT_SUBWALLPAD) {
  2955. Handler mHandler = new Handler();
  2956. mHandler.postDelayed(new Runnable() {
  2957. public void run() {
  2958. // 시간 지난 후 실행할 코딩
  2959. showFrontVideo(true);
  2960. }
  2961. }, 500); // 0.5초후
  2962. }
  2963. if (Common.OPTION_TAB_ANMI_ENABLE) {
  2964. Animation Anmi = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.screen_on);
  2965. FrontVideoLayout.startAnimation(Anmi);
  2966. }
  2967. } catch (RuntimeException re) {
  2968. LogUtil.errorLogInfo("", TAG, re);
  2969. } catch (Exception e) {
  2970. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceChanged(SurfaceHolder holder)");
  2971. //e.printStackTrace();
  2972. LogUtil.errorLogInfo("", TAG, e);
  2973. }
  2974. }
  2975. @Override
  2976. public void surfaceDestroyed(SurfaceHolder holder) {
  2977. try {
  2978. LOG_INFO("[FrontVideoCallback] surfaceDestroyed!!");
  2979. if (mFrontCamera != null) {
  2980. mFrontCamera.stopPreview();
  2981. mFrontCamera.release();
  2982. mFrontCamera = null;
  2983. }
  2984. } catch (RuntimeException re) {
  2985. LogUtil.errorLogInfo("", TAG, re);
  2986. } catch (Exception e) {
  2987. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  2988. //e.printStackTrace();
  2989. LogUtil.errorLogInfo("", TAG, e);
  2990. }
  2991. }
  2992. };
  2993. private ErrorCallback FrontVideoErrorCallback = new ErrorCallback() {
  2994. @Override
  2995. public void onError(int error, Camera camera) {
  2996. switch (error) {
  2997. case Camera.CAMERA_ERROR_SERVER_DIED:
  2998. Log.e(TAG, "[FrontVideoErrorCallback] CAMERA_ERROR_SERVER_DIED");
  2999. camera.stopPreview();
  3000. camera.setPreviewCallback(null);
  3001. camera.release();
  3002. camera = null;
  3003. break;
  3004. case Camera.CAMERA_ERROR_UNKNOWN:
  3005. Log.e(TAG, "[FrontVideoErrorCallback] CAMERA_ERROR_UNKNOWN");
  3006. break;
  3007. }
  3008. }
  3009. };
  3010. public void showFrontVideo(boolean bShow) {
  3011. try {
  3012. LOG_INFO("[showFrontVideo] bShow [" + bShow + "]");
  3013. if (FrontVideoSurface == null) {
  3014. LOG_WARN("[showFrontVideo] FrontVideoSurface is null!!!");
  3015. return;
  3016. }
  3017. WpadRelativeLayoutParams FrontVideoParams;
  3018. FrontVideoParams = new WpadRelativeLayoutParams(720, 540);
  3019. if (bShow) FrontVideoParams.setMargins(95, 112, 0, 0);
  3020. else FrontVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  3021. FrontVideoSurface.setLayoutParams(FrontVideoParams);
  3022. } catch (RuntimeException re) {
  3023. LogUtil.errorLogInfo("", TAG, re);
  3024. } catch (Exception e) {
  3025. Log.e(TAG, "[Exception] showFrontVideo(boolean bShow)");
  3026. //e.printStackTrace();
  3027. LogUtil.errorLogInfo("", TAG, e);
  3028. }
  3029. }
  3030. /** 사진 암호화 관련 */
  3031. public static final String ALGORITHM = "AES";
  3032. public static final String TRANSFORMATION = ALGORITHM + "/ECB/PKCS5Padding";
  3033. public static final String VISITOR_PICTURE_ENCRYPT_KEY = "VISITOR_PICTURE_ENCRYPT_KEY";
  3034. private Cipher initCryptConfig(int mode) {
  3035. Cipher cipher = null;
  3036. try {
  3037. byte[] hKey = getAESKey();
  3038. if (hKey != null) {
  3039. cipher = Cipher.getInstance(TRANSFORMATION);
  3040. SecretKeySpec key = new SecretKeySpec(hKey, ALGORITHM);
  3041. cipher.init(mode, key);
  3042. }
  3043. } catch (RuntimeException re) {
  3044. LogUtil.errorLogInfo("", TAG, re);
  3045. } catch (Exception e) {
  3046. Log.e(TAG, "[Exception] initCryptConfig(int mode)");
  3047. //e.printStackTrace();
  3048. LogUtil.errorLogInfo("", TAG, e);
  3049. }
  3050. return cipher;
  3051. }
  3052. private byte[] getAESKey() {
  3053. byte[] hKeyData = null;
  3054. try {
  3055. String strKey = VISITOR_PICTURE_ENCRYPT_KEY.substring(0, 16);
  3056. hKeyData = new byte[16];
  3057. byte[] b = strKey.getBytes("UTF-8");
  3058. int len = b.length;
  3059. if (len > hKeyData.length) {
  3060. len = hKeyData.length;
  3061. }
  3062. System.arraycopy(b, 0, hKeyData, 0, len);
  3063. return hKeyData;
  3064. } catch (RuntimeException re) {
  3065. LogUtil.errorLogInfo("", TAG, re);
  3066. } catch (Exception e) {
  3067. Log.e(TAG, "[Exception] getAESKey()");
  3068. //e.printStackTrace();
  3069. LogUtil.errorLogInfo("", TAG, e);
  3070. }
  3071. return hKeyData;
  3072. }
  3073. public void encryptPictureFile(File sourceFile) {
  3074. InputStream input = null;
  3075. OutputStream output = null;
  3076. try {
  3077. // LOG("[encryptPictureFile] sourceFile [" + sourceFile.getPath() + "]");
  3078. Cipher cipher = initCryptConfig(Cipher.ENCRYPT_MODE);
  3079. if (cipher != null) {
  3080. input = new BufferedInputStream(new FileInputStream(sourceFile));
  3081. LOG("[encryptPictureFile] input.available [" + input.available() + "]");
  3082. output = new BufferedOutputStream(new FileOutputStream(define.VISITOR_PICTURE_LOCATION + "/ENCRYPTED_" + sourceFile.getName()));
  3083. byte[] buffer = new byte[1024];
  3084. int read = -1;
  3085. while((read = input.read(buffer)) != -1) {
  3086. output.write(cipher.update(buffer, 0, read));
  3087. }
  3088. output.write(cipher.doFinal());
  3089. sourceFile.delete(); // 암호화하기 이전 파일은 삭제
  3090. } else {
  3091. LOG_WARN("[encryptPictureFile] cipher is null!");
  3092. }
  3093. } catch (RuntimeException re) {
  3094. LogUtil.errorLogInfo("", TAG, re);
  3095. } catch (Exception e) {
  3096. Log.e(TAG, "[Exception] encryptPictureFile(Fie sourceFile)");
  3097. //e.printStackTrace();
  3098. LogUtil.errorLogInfo("", TAG, e);
  3099. } finally {
  3100. if (output != null) {
  3101. try { output.close(); } catch (IOException ie) { Log.e(TAG, "[Exception] encryptPictureFile.output.close"); }
  3102. }
  3103. if (input != null) {
  3104. try { input.close(); } catch (IOException ie) { Log.e(TAG, "[Exception] encryptPictureFile.input.close"); }
  3105. }
  3106. }
  3107. }
  3108. /**
  3109. * 방문자사진 복호화 기능 수행
  3110. * @param sourceFile 암호화된 파일 (/sdcrad/Bestin/VisitorPicture/ 폴더에 저장)
  3111. * @param destFile 복호화 파일 (/sdcrad/Bestin/VisitorPicture/Decrypt/ 폴더에 저장)
  3112. * @return destFile (사진을 복호화하여 파일 리턴)
  3113. */
  3114. public File decryptPictureFile(File sourceFile, File destFile) {
  3115. InputStream input = null;
  3116. OutputStream output = null;
  3117. try {
  3118. if (sourceFile.exists()) {
  3119. Cipher cipher = initCryptConfig(Cipher.DECRYPT_MODE);
  3120. if (cipher != null) {
  3121. input = new BufferedInputStream(new FileInputStream(sourceFile));
  3122. LOG("[decryptPictureFile] input.available [" + input.available() + "]");
  3123. output = new BufferedOutputStream(new FileOutputStream(destFile.getPath()));
  3124. byte[] buffer = new byte[1024];
  3125. int read = -1;
  3126. while ((read = input.read(buffer)) != -1) {
  3127. output.write(cipher.update(buffer, 0, read));
  3128. }
  3129. output.write(cipher.doFinal());
  3130. return destFile;
  3131. } else {
  3132. LOG_WARN("[decryptPictureFile] cipher is null!");
  3133. }
  3134. } else {
  3135. // LOG("[decryptPictureFile] Do not need to decrypt File!! [" + destFile.getPath() + "]");
  3136. return new File(define.VISITOR_PICTURE_LOCATION + "/" + destFile.getName()); // 기존에 암호화 안되어 저장했던 사진은 복호화 하면 안됨
  3137. }
  3138. } catch (RuntimeException re) {
  3139. LogUtil.errorLogInfo("", TAG, re);
  3140. } catch (Exception e) {
  3141. Log.e(TAG, "[Exception] decryptPictureFile(File sourceFile, File destFile)");
  3142. //e.printStackTrace();
  3143. LogUtil.errorLogInfo("", TAG, e);
  3144. } finally {
  3145. if (output != null) {
  3146. try { output.close(); } catch (IOException ie) { Log.e(TAG, "[Exception] decryptPictureFile.output.close"); }
  3147. }
  3148. if (input != null) {
  3149. try { input.close(); } catch (IOException ie) { Log.e(TAG, "[Exception] decryptPictureFile.input.close"); }
  3150. }
  3151. }
  3152. return null;
  3153. }
  3154. int camOpenCheckCnt1 = 0, camOpenCheckCnt2 = 0, camOpenCheckCnt3 = 0, camOpenCheckCnt4 = 0;
  3155. int handlerMaxCnt = 100;
  3156. /**
  3157. * 현관카메라 OPEN CHECK Handler!!!
  3158. */
  3159. public Handler mFrontCamOpenCheckHandler = new Handler() {
  3160. @Override
  3161. public void handleMessage(Message msg) {
  3162. LOG("[mFrontCamOpenCheckHandler] msg.what = " + msg.what);
  3163. if (msg.what == 0) {
  3164. camOpenCheckCnt1++;
  3165. if (camOpenCheckCnt1 > handlerMaxCnt) {
  3166. Log.w(TAG, "[mFrontCamOpenCheckHandler] camOpenCheckCnt1 is over!! [" + camOpenCheckCnt1 + "]");
  3167. mFrontCamOpenCheckHandler.removeMessages(0);
  3168. mFrontCamOpenCheckHandler.removeMessages(1);
  3169. } else {
  3170. if (mFrontCamera != null)
  3171. mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(1, 100);
  3172. else mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(0, 100);
  3173. }
  3174. } else if (msg.what == 1) {
  3175. // ************ 카메라 밝기 조절!! ************
  3176. Log.d(TAG, "[mFrontCamOpenCheckHandler] [CAMERA OPEN] ctrlCameraBrightness");
  3177. Global.ctrlCameraBrightness(nBrightness);
  3178. } else if (msg.what == 2) {
  3179. camOpenCheckCnt2++;
  3180. if (camOpenCheckCnt2 > handlerMaxCnt) {
  3181. Log.w(TAG, "[mFrontCamOpenCheckHandler] camOpenCheckCnt2 is over!! [" + camOpenCheckCnt2 + "]");
  3182. mFrontCamOpenCheckHandler.removeMessages(2);
  3183. mFrontCamOpenCheckHandler.removeMessages(3);
  3184. } else {
  3185. if (mFrontCamera != null) mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(3, 100);
  3186. else mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(2, 100);
  3187. }
  3188. } else if (msg.what == 3) {
  3189. // ************ 스마트현관카메라 영상 녹화 시작!! ************
  3190. } else if (msg.what == 4) {
  3191. camOpenCheckCnt3++;
  3192. if (camOpenCheckCnt3 > handlerMaxCnt) {
  3193. Log.w(TAG, "[mFrontCamOpenCheckHandler] camOpenCheckCnt3 is over!! [" + camOpenCheckCnt3 + "]");
  3194. mFrontCamOpenCheckHandler.removeMessages(4);
  3195. mFrontCamOpenCheckHandler.removeMessages(5);
  3196. } else {
  3197. if (mFrontCamera != null) mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(5, 100);
  3198. else mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(4, 100);
  3199. }
  3200. } else if (msg.what == 5) {
  3201. // ************ 서브폰 현관 TV Out 시작!! (IHN-D101 PR2000K / 대외향월패드 기본 현관카메라 호출시) ************
  3202. Log.d(TAG, "[mFrontCamOpenCheckHandler] [CAMERA OPEN] SubPhone TV OUT");
  3203. sendHandlerMsg(HANDLERMSG.SHOW_FRONTCAM_SUBPHONE, 0, 0);
  3204. if (ConfigValues.bRemoteCall) {
  3205. ((MainActivity) mContext).mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(6, 100); // camera open check, Subphone TVout 이후 encoderStartOperation 시작 (방문객 원격통화 사용할 경우)
  3206. }
  3207. } else if (msg.what == 6) {
  3208. camOpenCheckCnt4++;
  3209. if (camOpenCheckCnt4 > handlerMaxCnt) {
  3210. Log.w(TAG, "[mFrontCamOpenCheckHandler] camOpenCheckCnt4 is over!! [" + camOpenCheckCnt4 + "]");
  3211. mFrontCamOpenCheckHandler.removeMessages(6);
  3212. mFrontCamOpenCheckHandler.removeMessages(7);
  3213. } else {
  3214. if (mFrontCamera != null) mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(7, 100);
  3215. else mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(6, 100);
  3216. }
  3217. } else if (msg.what == 7) {
  3218. // ************방문객 원격통화 인코딩 시작!! ************
  3219. Log.d(TAG, "[mFrontCamOpenCheckHandler] [CAMERA OPEN] encoderStart");
  3220. startVideoEncoding(true, true, true); // 모바일로 현관 영상 전송 (방문객 원격통화)
  3221. }
  3222. }
  3223. };
  3224. // ============================== 영상 ==============================
  3225. public void startVideoEncoding(boolean bSet, boolean bEncoding, boolean bDecoding) {
  3226. try {
  3227. Log.d(TAG, "[startVideoEncoding] bSet [" + bSet + "], bEncoding [" + bEncoding + "], bDecoding [" + bDecoding + "]");
  3228. if (mVideoController == null) Log.w(TAG, "[startVideoEncoding] mVideoController is null!");
  3229. if (mVideoController != null) {
  3230. mVideoController.startVideoEncoding(bSet, bEncoding, bDecoding);
  3231. }
  3232. } catch (RuntimeException re) {
  3233. LogUtil.errorLogInfo("", TAG, re);
  3234. } catch (Exception e) {
  3235. Log.e(TAG, "[Exception] startVideoEncoding(boolean bSet, boolean bEncoding, boolean bDecoding)");
  3236. //e.printStackTrace();
  3237. LogUtil.errorLogInfo("", TAG, e);
  3238. }
  3239. }
  3240. int apiCheckCnt1 = 0, apiCheckCnt2 = 0, apiCheckCnt3 = 0;
  3241. protected Handler mWallPadApiCheckHandler = new Handler() {
  3242. public void handleMessage(Message msg) {
  3243. if (msg.what == 0) {
  3244. apiCheckCnt1++;
  3245. if (apiCheckCnt1 > (handlerMaxCnt * 10)) {
  3246. Log.w(TAG, "[mFrontCamOpenCheckHandler] apiCheckCnt1 is over!! [" + apiCheckCnt1 + "]");
  3247. mWallPadApiCheckHandler.removeMessages(0);
  3248. mWallPadApiCheckHandler.removeMessages(1);
  3249. } else {
  3250. if (mWallPadAPI != null) {
  3251. if (mWallPadAPI.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  3252. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  3253. }
  3254. else {
  3255. Log.w(TAG, "[mFrontCamOpenCheckHandler] mWallPadAPI is null!!!");
  3256. }
  3257. }
  3258. } else if (msg.what == 1) {
  3259. // 스마트현관카메라 API 로딩
  3260. Log.d(TAG, "[mWallPadApiCheckHandler.handleMessage] Handler finish!! mTempCurrentScreenId [" + mTempCurrentScreenId + "]");
  3261. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTKEY_EXTERNAL || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_HS || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_DW) {
  3262. smartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  3263. }
  3264. boolean result = setChangeScreen(mTempCurrentScreenId, false);
  3265. if (!result) {
  3266. int nScreenID = API_Menu.SubMenuCall.Guard;
  3267. if (!bGuardCallUse) {
  3268. if (bFrontCallUse) nScreenID = API_Menu.SubMenuCall.Door;
  3269. else if (bResiCallUse) nScreenID = API_Menu.SubMenuCall.Neighbor;
  3270. else if (bPSTNCallUse) nScreenID = API_Menu.SubMenuCall.PSTN;
  3271. else if (bCallHistoryUse) nScreenID = API_Menu.SubMenuCall.CallList;
  3272. else if (bVisitorPicUse) nScreenID = API_Menu.SubMenuCall.Visitor;
  3273. }
  3274. setChangeScreen(nScreenID, false);
  3275. }
  3276. } else if (msg.what == 2) {
  3277. apiCheckCnt2++;
  3278. if (apiCheckCnt2 > (handlerMaxCnt * 10)) {
  3279. Log.w(TAG, "[mFrontCamOpenCheckHandler] apiCheckCnt2 is over!! [" + apiCheckCnt2 + "]");
  3280. mWallPadApiCheckHandler.removeMessages(2);
  3281. mWallPadApiCheckHandler.removeMessages(3);
  3282. } else {
  3283. if (mWallPadAPI != null) {
  3284. if (mWallPadAPI.Check_Connect())
  3285. mWallPadApiCheckHandler.sendEmptyMessageDelayed(3, 10);
  3286. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(2, 10);
  3287. }
  3288. }
  3289. } else if (msg.what == 3) {
  3290. // 거실조명 API 로딩
  3291. sdbLivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  3292. Log.d(TAG, "[mWallPadApiCheckHandler.handleMessage] ---------- sdbLivingRoomLightAPI is connected!!! ----------");
  3293. } else if (msg.what == 4) {
  3294. apiCheckCnt3++;
  3295. if (apiCheckCnt3 > (handlerMaxCnt * 10)) {
  3296. Log.w(TAG, "[mFrontCamOpenCheckHandler] apiCheckCnt3 is over!! [" + apiCheckCnt3 + "]");
  3297. mWallPadApiCheckHandler.removeMessages(4);
  3298. mWallPadApiCheckHandler.removeMessages(5);
  3299. } else {
  3300. if (mWallPadAPI != null) {
  3301. if (mWallPadAPI.Check_Connect())
  3302. mWallPadApiCheckHandler.sendEmptyMessageDelayed(5, 10);
  3303. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(4, 10);
  3304. }
  3305. }
  3306. } else if (msg.what == 5) {
  3307. // 지문인식 API 로딩
  3308. fpDlockAPI = mWallPadAPI.Get_FP_DLockController();
  3309. Log.d(TAG, "[mWallPadApiCheckHandler.handleMessage] ---------- fpDlockAPI is connected!!! ----------");
  3310. }
  3311. }
  3312. };
  3313. int pathCheckCnt1 = 0, pathCheckCnt2 = 0;
  3314. public Handler mCallPathCheckHandler = new Handler() {
  3315. public void handleMessage(Message msg) {
  3316. try {
  3317. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT) {
  3318. if (msg.what == 0) {
  3319. pathCheckCnt1++;
  3320. if (pathCheckCnt1 > 200) {
  3321. Log.w(TAG, "[mCallPathCheckHandler] pathCheckCnt1 is over!! [" + pathCheckCnt1 + "]");
  3322. sendHandlerMsg(HANDLERMSG.RECOVER_SYSTEM_VOLUME, 0, 0);
  3323. mCallPathCheckHandler.removeMessages(0);
  3324. mCallPathCheckHandler.removeMessages(1);
  3325. } else {
  3326. if (mCallController.getTalkPath() == CALLPATH.DOORMUSIC)
  3327. mCallPathCheckHandler.sendEmptyMessageDelayed(1, 50);
  3328. else mCallPathCheckHandler.sendEmptyMessageDelayed(0, 50);
  3329. }
  3330. } else if (msg.what == 1) {
  3331. Log.d(TAG, "[mCallPathCheckHandler.handleMessage] Handler finish!! CALLPATH [" + mCallController.getTalkPath() + "]");
  3332. mIOInterface.ctrlSetTalkPathDoor();
  3333. sendHandlerMsg(HANDLERMSG.PLAY_DINGDONG, 0, 0); // [띵똥시나리오] 1. 현관카메라 띵똥~
  3334. } else if (msg.what == 2) {
  3335. pathCheckCnt2++;
  3336. if (pathCheckCnt2 > 200) {
  3337. Log.w(TAG, "[mCallPathCheckHandler] pathCheckCnt2 is over!! [" + pathCheckCnt2 + "]");
  3338. sendHandlerMsg(HANDLERMSG.RECOVER_SYSTEM_VOLUME, 0, 0);
  3339. mCallPathCheckHandler.removeMessages(2);
  3340. mCallPathCheckHandler.removeMessages(3);
  3341. } else {
  3342. if (mCallController.getTalkPath() == CALLPATH.NORMAL)
  3343. mCallPathCheckHandler.sendEmptyMessageDelayed(3, 50);
  3344. else mCallPathCheckHandler.sendEmptyMessageDelayed(2, 50);
  3345. }
  3346. } else if (msg.what == 3) {
  3347. Log.d(TAG, "[mCallPathCheckHandler.handleMessage] Handler finish!! CALLPATH [" + mCallController.getTalkPath() + "]");
  3348. CALLSTATUS eCallStatus = mCallController.mCallInfo.getFRONT();
  3349. Log.d(TAG, "[mCallPathCheckHandler.handleMessage] eCallStatus [" + eCallStatus + "]");
  3350. if (eCallStatus == CALLSTATUS.CALLED) {
  3351. sendHandlerMsg(HANDLERMSG.RECOVER_SYSTEM_VOLUME, 0, 0);
  3352. sendHandlerMsgDelayed(HANDLERMSG.PLAY_FRONT_BELL, 0, 0, 200); // [띵똥시나리오] 3. W/P에서 현관호출음
  3353. sendHandlerMsgDelayed(HANDLERMSG.SET_TALK_BTN_ENABLE, 0, 0, 1000);
  3354. }
  3355. }
  3356. }
  3357. } catch (RuntimeException re) {
  3358. LogUtil.errorLogInfo("", TAG, re);
  3359. } catch (Exception e) {
  3360. Log.e(TAG, "[Exception] mCallPathCheckHandler.handleMessage()");
  3361. //e.printStackTrace();
  3362. LogUtil.errorLogInfo("", TAG, e);
  3363. sendHandlerMsg(HANDLERMSG.RECOVER_SYSTEM_VOLUME, 0, 0);
  3364. }
  3365. }
  3366. };
  3367. public boolean saveFrontPicture() {
  3368. try {
  3369. LOG_INFO("[saveFrontPicture]");
  3370. if (mFrontCamera != null) {
  3371. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101 || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I
  3372. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K_I
  3373. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I_OCF) {
  3374. mFrontCamera.takePicture(null, null, mPicture_IHND101);
  3375. }
  3376. else {
  3377. mFrontCamera.takePicture(null, null, mPicture);
  3378. }
  3379. return true;
  3380. } else {
  3381. Log.w(TAG, "[saveFrontPicture] mFrontCamera is null!");
  3382. return false;
  3383. }
  3384. } catch (RuntimeException re) {
  3385. LogUtil.errorLogInfo("", TAG, re);
  3386. return false;
  3387. } catch (Exception e) {
  3388. Log.e(TAG, "[Exception] saveFrontPicture()");
  3389. //e.printStackTrace();
  3390. LogUtil.errorLogInfo("", TAG, e);
  3391. return false;
  3392. }
  3393. }
  3394. Camera.PictureCallback mPicture = new Camera.PictureCallback() {
  3395. @Override
  3396. public void onPictureTaken(byte[] data, Camera camera) {
  3397. // JPEG 이미지가 byte[] 형태로 들어옵니다.
  3398. try {
  3399. if (mCallController.strVisitorPicturePath != null) {
  3400. File mFile = new File(mCallController.strVisitorPicturePath);
  3401. Bitmap mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
  3402. if (mBitmap != null) {
  3403. mBitmap = getResizedBitmap(mBitmap, 325, 245);
  3404. mBitmap = cropBitmap(mBitmap);
  3405. // LOG("[onPictureTaken] After Resize!! mBitmap.Width [" + mBitmap.getWidth() + "], mBitmap.Height [" + mBitmap.getHeight() + "]");
  3406. FileOutputStream mFileOutputStream = new FileOutputStream(mFile);
  3407. if (!Version.getGatewayUsage() || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I
  3408. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I_2443 || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_1010GL_I_6410) {
  3409. if (Build.VERSION.SDK_INT > 23) { // 대외향 모델 중 AOS 7.1인 모델에 적용
  3410. LOG("[onPictureTaken] apply YUV");
  3411. byte [] yuv = getNV21(mBitmap.getWidth(), mBitmap.getHeight(), mBitmap);
  3412. int[] anRGB8888 = decodeYUV420SP(yuv, mBitmap.getWidth(), mBitmap.getHeight());
  3413. mBitmap = Bitmap.createBitmap(anRGB8888, mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
  3414. mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
  3415. }
  3416. }
  3417. else {
  3418. mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
  3419. }
  3420. mFileOutputStream.flush();
  3421. mFileOutputStream.close();
  3422. // 검은화면(카메라 고장 또는 영상 출력빠짐)일 경우 이미지 교체
  3423. long fileSize = mFile.length();
  3424. if (fileSize < 2000) {
  3425. LOG_WARN("[onPictureTaken] fileSize is less than 2000 KB [" + fileSize + "]");
  3426. mFile.delete();
  3427. InputStream input = getResources().openRawResource(R.drawable.box_no_image);
  3428. mFileOutputStream = new FileOutputStream(mFile);
  3429. byte[] hData = new byte[1024];
  3430. int length = 0;
  3431. while ((length = input.read(hData)) > 0) {
  3432. // Log.d(TAG, "[onPictureTaken] length [" + length + "]");
  3433. mFileOutputStream.write(hData, 0, length);
  3434. }
  3435. mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
  3436. mFileOutputStream.flush();
  3437. mFileOutputStream.close();
  3438. input.close();
  3439. }
  3440. // encryptPictureFile(mFile); // TODO 추후 적용!!! 홈넷 AAA등급 인증을 위한 사진 암호화
  3441. if (mFrontCamera != null) mFrontCamera.startPreview();
  3442. } else {
  3443. Log.w(TAG, "[onPictureTaken] mBitmap is null!");
  3444. }
  3445. } else {
  3446. Log.w(TAG, "[onPictureTaken] strVisitorPicturePath is null!");
  3447. }
  3448. } catch (FileNotFoundException e) {
  3449. Log.e(TAG, "[FileNotFoundException] File not found: " + e.getMessage());
  3450. //e.printStackTrace();
  3451. LogUtil.errorLogInfo("", TAG, e);
  3452. mCallController.strVisitorPicturePath = null;
  3453. } catch (IOException e) {
  3454. Log.e(TAG, "[IOException] Error accessing file: " + e.getMessage());
  3455. //e.printStackTrace();
  3456. LogUtil.errorLogInfo("", TAG, e);
  3457. mCallController.strVisitorPicturePath = null;
  3458. } catch (Exception e) {
  3459. Log.e(TAG, "[Exception] onPictureTaken(byte[] data, Camera camera)");
  3460. //e.printStackTrace();
  3461. LogUtil.errorLogInfo("", TAG, e);
  3462. mCallController.strVisitorPicturePath = null;
  3463. }
  3464. }
  3465. };
  3466. Camera.PictureCallback mPicture_IHND101 = new Camera.PictureCallback() {
  3467. @Override
  3468. public void onPictureTaken(byte[] data, Camera camera) {
  3469. // JPEG 이미지가 byte[] 형태로 들어옵니다.
  3470. try {
  3471. if (mCallController.strVisitorPicturePath != null) {
  3472. File mFile = new File(mCallController.strVisitorPicturePath);
  3473. Bitmap mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
  3474. if (mBitmap != null) {
  3475. FileOutputStream mFileOutputStream = new FileOutputStream(mFile);
  3476. mBitmap = postprocTakenIMG(mBitmap);
  3477. mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
  3478. Log.i(TAG, "[mPicture_IHND101.onPictureTaken] Width [" + mBitmap.getWidth() + "], Height [" + mBitmap.getHeight() + "]");
  3479. mFileOutputStream.flush();
  3480. mFileOutputStream.close();
  3481. // 검은화면(카메라 고장 또는 영상 출력빠짐)일 경우 이미지 교체
  3482. long fileSize = mFile.length();
  3483. if (fileSize < 2000) {
  3484. LOG_WARN("[mPicture_IHND101] fileSize is less than 2000 KB [" + fileSize + "]");
  3485. mFile.delete();
  3486. InputStream input = getResources().openRawResource(R.drawable.box_no_image);
  3487. mFileOutputStream = new FileOutputStream(mFile);
  3488. byte[] hData = new byte[1024];
  3489. int length = 0;
  3490. while ((length = input.read(hData)) > 0) {
  3491. mFileOutputStream.write(hData, 0, length);
  3492. }
  3493. mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
  3494. mFileOutputStream.flush();
  3495. mFileOutputStream.close();
  3496. input.close();
  3497. }
  3498. // encryptPictureFile(mFile); // TODO 추후 적용!!! 홈넷 AAA등급 인증을 위한 사진 암호화
  3499. if (mFrontCamera != null) mFrontCamera.startPreview();
  3500. }
  3501. else {
  3502. Log.w(TAG, "[mPicture_IHND101] mBitmap is null!");
  3503. }
  3504. }
  3505. else {
  3506. Log.w(TAG, "[mPicture_IHND101] strVisitorPicturePath is null!");
  3507. }
  3508. } catch (FileNotFoundException e) {
  3509. Log.e(TAG, "[FileNotFoundException] File not found: " + e.getMessage());
  3510. //e.printStackTrace();
  3511. LogUtil.errorLogInfo("", TAG, e);
  3512. mCallController.strVisitorPicturePath = null;
  3513. } catch (IOException e) {
  3514. Log.e(TAG, "[IOException] Error accessing file: " + e.getMessage());
  3515. //e.printStackTrace();
  3516. LogUtil.errorLogInfo("", TAG, e);
  3517. mCallController.strVisitorPicturePath = null;
  3518. } catch (Exception e) {
  3519. Log.e(TAG, "[Exception] mPicture_IHND101.onPictureTaken(byte[] data, Camera camera)");
  3520. //e.printStackTrace();
  3521. LogUtil.errorLogInfo("", TAG, e);
  3522. mCallController.strVisitorPicturePath = null;
  3523. }
  3524. }
  3525. };
  3526. public Bitmap reverseIMGColor(Bitmap bitmap) {
  3527. try {
  3528. int [] argb = new int[bitmap.getWidth() * bitmap.getHeight()];
  3529. byte [] yuv = getNV21(bitmap.getWidth(), bitmap.getHeight(), bitmap);
  3530. int[] anRGB8888 = decodeYUV420SP(yuv, bitmap.getWidth(), bitmap.getHeight());
  3531. return Bitmap.createBitmap(anRGB8888, bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
  3532. } catch (RuntimeException re) {
  3533. LogUtil.errorLogInfo("", TAG, re);
  3534. return null;
  3535. } catch (Exception e) {
  3536. Log.e(TAG, "[Exception] reverseIMGColor(Bitmap bitmap)");
  3537. //e.printStackTrace();
  3538. LogUtil.errorLogInfo("", TAG, e);
  3539. return null;
  3540. }
  3541. }
  3542. public Bitmap flipTakenIMG(Bitmap bitmap) {
  3543. try {
  3544. Matrix matrix = new Matrix();
  3545. if (ConfigValues.bSmartIOTCamFlip) matrix.setScale(-1, 1);
  3546. else matrix.setScale(1, 1);
  3547. return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
  3548. } catch (RuntimeException re) {
  3549. LogUtil.errorLogInfo("", TAG, re);
  3550. return null;
  3551. } catch (Exception e) {
  3552. Log.e(TAG, "[Exception] flipTakenIMG(Bitmap bitmap)");
  3553. //e.printStackTrace();
  3554. LogUtil.errorLogInfo("", TAG, e);
  3555. return null;
  3556. }
  3557. }
  3558. public Bitmap cropBitmap(Bitmap Original) {
  3559. try {
  3560. Bitmap Result;
  3561. Log.w(TAG, "[cropBitmap] ConfigValues.eFrontCameraType [" + ConfigValues.eFrontCameraType + "]");
  3562. if (Build.VERSION.SDK_INT > 23) {
  3563. // AOS 7.1.1 (메이드인랩 BSP)
  3564. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT) {
  3565. Matrix matrix = new Matrix();
  3566. if (ConfigValues.bSmartIOTCamFlip) matrix.setScale(-1, 1);
  3567. else matrix.setScale(1, 1);
  3568. Result = Bitmap.createBitmap(Original, 5, 5, 320, 240, matrix, true);
  3569. }
  3570. else {
  3571. Result = Bitmap.createBitmap(Original, 5, 5, 320, 240);
  3572. }
  3573. }
  3574. else {
  3575. // AOS 6.0.1 (다담 BSP)
  3576. Log.i(TAG, "[cropBitmap] Width [" + Original.getWidth() + "], Height [" + Original.getHeight() + "]");
  3577. Result = Bitmap.createBitmap(Original, 5, 5, 320, 240);
  3578. }
  3579. if (Result != Original) Original.recycle();
  3580. return Result;
  3581. } catch (RuntimeException re) {
  3582. LogUtil.errorLogInfo("", TAG, re);
  3583. return null;
  3584. } catch (Exception e) {
  3585. Log.e(TAG, "[Exception] cropBitmap(Bitmap Original)");
  3586. //e.printStackTrace();
  3587. LogUtil.errorLogInfo("", TAG, e);
  3588. return null;
  3589. }
  3590. }
  3591. boolean bOriginalSize = false; // true: 원래 사이즈로 저장, false: 수정된 사이즈(320, 240)로 저장
  3592. int nFixedIMGSize_Width = 320;
  3593. int nFixedIMGSize_Height = 240;
  3594. public Bitmap postprocTakenIMG(Bitmap Original) {
  3595. try {
  3596. Bitmap Result;
  3597. if (Build.VERSION.SDK_INT > 23) {
  3598. // AOS 7.1.1 (메이드인랩 BSP)
  3599. if (bOriginalSize) {
  3600. Result = Bitmap.createScaledBitmap(Original, Original.getWidth() + 5, Original.getHeight() + 5, false);
  3601. Result = Bitmap.createBitmap(Result, 5, 5, Original.getWidth(), Original.getHeight());
  3602. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.HD) {
  3603. // 스마트IoT현관카메라의 경우 사진 색반전 코드 적용 (JEFF, 2020.08.11)
  3604. Result = reverseIMGColor(Result);
  3605. }
  3606. }
  3607. else {
  3608. Result = getResizedBitmap(Original, nFixedIMGSize_Width + 5, nFixedIMGSize_Height + 5);
  3609. Result = Bitmap.createBitmap(Result, 5, 5, nFixedIMGSize_Width, nFixedIMGSize_Height);
  3610. Result = reverseIMGColor(Result);
  3611. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.HD) {
  3612. // 스마트IoT현관카메라의 경우 사진 색반전 코드 적용 (JEFF, 2020.08.11)
  3613. Result = flipTakenIMG(Result);
  3614. }
  3615. }
  3616. }
  3617. else {
  3618. // AOS 6.0.1 (다담 BSP)
  3619. if (bOriginalSize) {
  3620. Result = Bitmap.createScaledBitmap(Original, Original.getWidth() + 5, Original.getHeight() + 5, false);
  3621. Result = Bitmap.createBitmap(Result, 5, 5, Original.getWidth(), Original.getHeight());
  3622. }
  3623. else {
  3624. Result = getResizedBitmap(Original, nFixedIMGSize_Width + 5, nFixedIMGSize_Height + 5);
  3625. Result = Bitmap.createBitmap(Result, 5, 5, nFixedIMGSize_Width, nFixedIMGSize_Height);
  3626. }
  3627. }
  3628. if (Result != Original) Original.recycle();
  3629. return Result;
  3630. } catch (RuntimeException re) {
  3631. LogUtil.errorLogInfo("", TAG, re);
  3632. return null;
  3633. } catch (Exception e) {
  3634. Log.e(TAG, "[Exception] postprocTakenIMG(Bitmap Original)");
  3635. //e.printStackTrace();
  3636. LogUtil.errorLogInfo("", TAG, e);
  3637. return null;
  3638. }
  3639. }
  3640. public Bitmap getResizedBitmap(Bitmap bitmap, int nNewWidth, int nNewHeight) {
  3641. try {
  3642. int nWidth = bitmap.getWidth();
  3643. int nHeight = bitmap.getHeight();
  3644. float scaleWidth = ((float) nNewWidth) / nWidth;
  3645. float scaleHeight = ((float) nNewHeight) / nHeight;
  3646. Matrix mMatrix = new Matrix();
  3647. mMatrix.postScale(scaleWidth, scaleHeight);
  3648. return Bitmap.createBitmap(bitmap, 0, 0, nWidth, nHeight, mMatrix, false);
  3649. } catch (RuntimeException re) {
  3650. LogUtil.errorLogInfo("", TAG, re);
  3651. return null;
  3652. } catch (Exception e) {
  3653. Log.e(TAG, "[Exception] getResizedBitmap(Bitmap bitmap, int nNewWidth, int nNewHeight)");
  3654. //e.printStackTrace();
  3655. LogUtil.errorLogInfo("", TAG, e);
  3656. return null;
  3657. }
  3658. }
  3659. public int[] decodeYUV420SP(byte[] yuv420sp,int width,int height) {
  3660. try {
  3661. final int frameSize = width * height;
  3662. int[] anPixels = new int[frameSize];
  3663. for (int j =0, yp =0; j < height; j++) {
  3664. int uvp = frameSize + (j >>1) * width, u =0, v =0;
  3665. for (int i =0; i < width; i++, yp++) {
  3666. int y = (0xff & ((int) yuv420sp[yp])) -16;
  3667. if (y <0) y =0;
  3668. if ((i &1) ==0) {
  3669. v = (0xff & yuv420sp[uvp++]) -128;
  3670. u = (0xff & yuv420sp[uvp++]) -128;
  3671. }
  3672. int y1192 =1192 * y;
  3673. int r = (y1192 +1634 * v);
  3674. int g = (y1192 -833 * v -400 * u);
  3675. int b = (y1192 +2066 * u);
  3676. if (r <0) r =0;else if (r >262143) r =262143;
  3677. if (g <0) g =0;else if (g >262143) g =262143;
  3678. if (b <0) b =0;else if (b >262143) b =262143;
  3679. anPixels[yp] =0xff000000 | ((r <<6) &0xff0000) | ((g >>2) &0xff00) | ((b >>10) &0xff);
  3680. }
  3681. }
  3682. return anPixels;
  3683. } catch (RuntimeException re) {
  3684. LogUtil.errorLogInfo("", TAG, re);
  3685. return null;
  3686. } catch (Exception e) {
  3687. Log.e(TAG, "[Exception] decodeYUV420SP(byte[] yuv420sp,int width,int height)");
  3688. //e.printStackTrace();
  3689. LogUtil.errorLogInfo("", TAG, e);
  3690. return null;
  3691. }
  3692. }
  3693. byte [] getNV21(int inputWidth, int inputHeight, Bitmap scaled) {
  3694. try {
  3695. int [] argb = new int[inputWidth * inputHeight];
  3696. scaled.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);
  3697. byte [] yuv = new byte[inputWidth*inputHeight*3/2];
  3698. yuv = encodeYUV420SP(argb, inputWidth, inputHeight);
  3699. scaled.recycle();
  3700. return yuv;
  3701. } catch (RuntimeException re) {
  3702. LogUtil.errorLogInfo("", TAG, re);
  3703. return null;
  3704. } catch (Exception e) {
  3705. Log.e(TAG, "[Exception] getNV21(int inputWidth, int inputHeight, Bitmap scaled)");
  3706. //e.printStackTrace();
  3707. LogUtil.errorLogInfo("", TAG, e);
  3708. return null;
  3709. }
  3710. }
  3711. byte [] encodeYUV420SP(int[] argb, int width, int height) {
  3712. try {
  3713. final int frameSize = width * height;
  3714. byte [] yuv = new byte[width*height*3/2];
  3715. int yIndex = 0;
  3716. int uvIndex = frameSize;
  3717. int a, R, G, B, Y, U, V;
  3718. int index = 0;
  3719. for (int j = 0; j < height; j++) {
  3720. for (int i = 0; i < width; i++) {
  3721. a = (argb[index] & 0xff000000) >> 24; // a is not used obviously
  3722. R = (argb[index] & 0xff0000) >> 16;
  3723. G = (argb[index] & 0xff00) >> 8;
  3724. B = (argb[index] & 0xff) >> 0;
  3725. // well known RGB to YUV algorithm
  3726. Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
  3727. //U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
  3728. //V = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128;
  3729. V = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
  3730. U = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128;
  3731. // NV21 has a plane of Y and interleaved planes of VU each sampled by a factor of 2
  3732. // meaning for every 4 Y pixels there are 1 V and 1 U. Note the sampling is every other
  3733. // pixel AND every other scanline.
  3734. yuv[yIndex++] = (byte) ((Y < 0) ? 0 : ((Y > 255) ? 255 : Y));
  3735. if (j % 2 == 0 && index % 2 == 0) {
  3736. yuv[uvIndex++] = (byte)((V<0) ? 0 : ((V > 255) ? 255 : V));
  3737. yuv[uvIndex++] = (byte)((U<0) ? 0 : ((U > 255) ? 255 : U));
  3738. }
  3739. index ++;
  3740. }
  3741. }
  3742. return yuv;
  3743. } catch (RuntimeException re) {
  3744. LogUtil.errorLogInfo("", TAG, re);
  3745. return null;
  3746. } catch (Exception e) {
  3747. Log.e(TAG, "[Exception] encodeYUV420SP(int[] argb, int width, int height)");
  3748. //e.printStackTrace();
  3749. LogUtil.errorLogInfo("", TAG, e);
  3750. return null;
  3751. }
  3752. }
  3753. public boolean getStrangerRecordingManagerSetting() {
  3754. boolean bResult = false;
  3755. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3756. try {
  3757. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  3758. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  3759. mWallpadDeviceSet.closeDB();
  3760. if (nFrontCam[0] == 1) {
  3761. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  3762. if (bRecord) bResult = true;
  3763. else bResult = false;
  3764. }
  3765. else bResult = false;
  3766. }
  3767. else bResult = false;
  3768. } catch (RuntimeException re) {
  3769. LogUtil.errorLogInfo("", TAG, re);
  3770. mWallpadDeviceSet.closeDB();
  3771. }
  3772. catch (Exception e) {
  3773. mWallpadDeviceSet.closeDB();
  3774. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  3775. //e.printStackTrace();
  3776. LogUtil.errorLogInfo("", TAG, e);
  3777. }
  3778. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  3779. return bResult;
  3780. }
  3781. public void ctrlSmartIOTCamStatusMode(byte mode) {
  3782. try {
  3783. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT
  3784. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTKEY_EXTERNAL
  3785. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_HS
  3786. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_DW) {
  3787. LOG("[ctrlSmartIOTCamStatusMode] mode [" + Global.HextoString(mode) + "]");
  3788. if (smartKeyRfDoorAPI != null) smartKeyRfDoorAPI.SetCAMERAmode(mode);
  3789. else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] smartKeyRfDoorAPI is null!!");
  3790. } else {
  3791. Log.w(TAG, "[ctrlSmartIOTCamStatusMode] Not Supported FRONTCAMERA!!");
  3792. }
  3793. } catch (RuntimeException re) {
  3794. LogUtil.errorLogInfo("", TAG, re);
  3795. } catch (Exception e) {
  3796. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  3797. //e.printStackTrace();
  3798. LogUtil.errorLogInfo("", TAG, e);
  3799. }
  3800. }
  3801. public void ctrlSmartIOTCamLEDMode(byte mode) {
  3802. try {
  3803. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTIOT
  3804. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMARTKEY_EXTERNAL
  3805. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_HS
  3806. || ConfigValues.eFrontCameraType == FRONTCAMERATYPE.SMART_DW) {
  3807. LOG("[ctrlSmartIOTCamLEDMode] mode [" + Global.HextoString(mode) + "]");
  3808. if (smartKeyRfDoorAPI != null) smartKeyRfDoorAPI.SetLEDmode(mode);
  3809. else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] smartKeyRfDoorAPI is null!!");
  3810. } else {
  3811. Log.w(TAG, "[ctrlSmartIOTCamLEDMode] Not Supported FRONTCAMERA!!");
  3812. }
  3813. } catch (RuntimeException re) {
  3814. LogUtil.errorLogInfo("", TAG, re);
  3815. } catch (Exception e) {
  3816. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  3817. //e.printStackTrace();
  3818. LogUtil.errorLogInfo("", TAG, e);
  3819. }
  3820. }
  3821. /**
  3822. * 스마트현관카메라 녹화 여부 판별
  3823. */
  3824. private boolean getStrangerRecording() {
  3825. try {
  3826. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  3827. boolean bResult = DBMGR.GetStrangerRecordingOnOff();
  3828. DBMGR.closeDB();
  3829. Log.d(TAG, "[getStrangerRecording] bResult [" + bResult + "]");
  3830. return bResult;
  3831. } catch (RuntimeException re) {
  3832. LogUtil.errorLogInfo("", TAG, re);
  3833. return false;
  3834. } catch (Exception e) {
  3835. Log.e(TAG, "[Exception] getStrangerRecording()");
  3836. //e.printStackTrace();
  3837. LogUtil.errorLogInfo("", TAG, e);
  3838. return false;
  3839. }
  3840. }
  3841. // Surface manager
  3842. public void initVideoSurfaceLayout() {
  3843. try {
  3844. Log.d(TAG, "[initVideoSurfaceLayout] bFFMPEGEnable = " + bFFMPEGEnable);
  3845. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300) {
  3846. mCallController.mVideoJNI.setDecoderInfo_V40(76, 85, 576, 405);
  3847. initFrontVideo();
  3848. }
  3849. else if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40) {
  3850. mCallController.mVideoJNI.setDecoderInfo_V40(76, 85, 576, 405);
  3851. initFrontVideo();
  3852. }
  3853. else if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) {
  3854. mCallController.mVideoJNI.setDecoderInfo_V40(76, 85, 576, 405);
  3855. initFrontVideo();
  3856. }
  3857. else if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT) {
  3858. mCallController.mVideoJNI.setDecoderInfo_V40(76, 85, 576, 405);
  3859. if (bFFMPEGEnable) initRemoteVideoSurfaceLayout();
  3860. initFrontVideo();
  3861. }
  3862. else {
  3863. LOG_WARN("[initVideoSurfaceLayout] NOT Supported BOARDTYPE [" + ConfigValues.DEVICE_BOARDTYPE + "]");
  3864. }
  3865. } catch (RuntimeException re) {
  3866. LogUtil.errorLogInfo("", TAG, re);
  3867. } catch (Exception e) {
  3868. Log.e(TAG, "[Exception] initVideoSurfaceLayout()");
  3869. //e.printStackTrace();
  3870. LogUtil.errorLogInfo("", TAG, e);
  3871. }
  3872. }
  3873. public void removeVideoSurfaceLayout() {
  3874. try {
  3875. Log.i(TAG, "[removeVideoSurfaceLayout] start!!");
  3876. if (bFFMPEGEnable) {
  3877. mCallController.mVideoJNI.SWDecoderClose(2);
  3878. mCallController.mVideoJNI.decoderStopOperation();
  3879. }
  3880. removeRemoteVideoSurfaceLayout();
  3881. removeMyVideoSurfaceLayout();
  3882. removeFrontVideoLayout();
  3883. } catch (RuntimeException re) {
  3884. LogUtil.errorLogInfo("", TAG, re);
  3885. } catch (Exception e) {
  3886. Log.e(TAG, "[Exception] removeVideoSurfaceLayout()");
  3887. //e.printStackTrace();
  3888. LogUtil.errorLogInfo("", TAG, e);
  3889. }
  3890. }
  3891. private void getCallTimeoutEnable() {
  3892. try {
  3893. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  3894. boolean bResult = mWallpadDeviceSet.Get_CallAppCallTimeout();
  3895. mWallpadDeviceSet.closeDB();
  3896. Log.d(TAG, "[getCallTimeoutEnable] bResult [" + bResult + "]");
  3897. if (bResult) {
  3898. Log.i(TAG, "[getCallTimeoutEnable] Call timeout : Normal mode");
  3899. mCallController.mCTT.setTalkNormalMode();
  3900. } else {
  3901. Log.i(TAG, "[getCallTimeoutEnable] Call timeout : Test mode");
  3902. mCallController.mCTT.setTalkTestMode();
  3903. SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.DKGRAY, Common.fontsize._26_DEFAULT, true, 0);
  3904. ViewRegistration(TopLayout, SampleModeTitle, 316, 17);
  3905. SampleModeTitle.setText("[통화시험모드]");
  3906. }
  3907. } catch (RuntimeException re) {
  3908. LogUtil.errorLogInfo("", TAG, re);
  3909. } catch (Exception e) {
  3910. Log.e(TAG, "[Exception] getCallTimeoutEnable()");
  3911. //e.printStackTrace();
  3912. LogUtil.errorLogInfo("", TAG, e);
  3913. }
  3914. }
  3915. public enum MAINEVENT {
  3916. BTN_HOME,
  3917. BTN_HOME_MOBILE
  3918. }
  3919. public interface MainEventListener {
  3920. public void onMainTouchEvent(MAINEVENT eEvent);
  3921. }
  3922. MainEventListener mMainEventListener;
  3923. public void setMainEventListener(MainEventListener MEL) {
  3924. mMainEventListener = MEL;
  3925. }
  3926. public void releaseMainEventListener() {
  3927. mMainEventListener = null;
  3928. }
  3929. // MainActivity Handler
  3930. public final class HANDLERMSG {
  3931. public final static int RELEASE_TOPMENUBTN_BLOCK = 10;
  3932. public final static int CHECK_RECEIVINGCALL = 100;
  3933. public final static int REMOVE_VIDEO_COVER = 110;
  3934. public final static int SHOW_VIDEO_COVER = 120;
  3935. public final static int CLEAR_ALL_CALL = 130;
  3936. public final static int TAKE_PICTURE_FRONT = 140;
  3937. public final static int CHANGESCREEN = 260;
  3938. public final static int CHANGESCREEN_FRONT = 261;
  3939. public final static int CHANGESCREEN_LOBBY = 262;
  3940. public final static int CHANGESCREEN_GUARD = 263;
  3941. public final static int CHANGESCREEN_RESIDENCE = 264;
  3942. public final static int CHANGESCREEN_PSTN = 265;
  3943. public final static int INIT_FRONTVIDEO = 310;
  3944. public final static int REMOVE_FRONTVIDEO = 311;
  3945. public final static int SHOW_FRONTVIDEO = 312;
  3946. public final static int CTRL_FRONTVIDEO_BRIGHTNESS = 313;
  3947. public final static int SET_TEMPSYSTEM_VOLUME = 400;
  3948. public final static int RECOVER_SYSTEM_VOLUME = 410;
  3949. public final static int SET_DTMF_VOLUME = 420;
  3950. public final static int SET_RELIEFCALL_VOLUME = 430;
  3951. public final static int SET_DINGDONG_VOLUME = 440;
  3952. public final static int SETTALKPATH_DOORMUSIC = 450;
  3953. public final static int SHOW_FRONTCAM_SUBPHONE = 500;
  3954. public final static int CHANGE_STRANGER_NOTICE_COLOR = 600;
  3955. public final static int CHANGE_REMOTECALL_NOTICE_COLOR = 650;
  3956. public final static int SEND_REQUEST_PSTN_STATUS = 700;
  3957. public final static int SEND_HOOK_ON = 710;
  3958. public final static int SEND_PSTN_ARS_MODE = 720;
  3959. public final static int PLAY_DINGDONG = 800;
  3960. public final static int STOP_DINGDONG = 810;
  3961. public final static int PLAY_FRONT_BELL = 820;
  3962. public final static int SET_TALK_BTN_ENABLE = 830;
  3963. public final static int CHECK_WALLPAD_CAMERA = 840;
  3964. public final static int SEND_SUBWALLPAD_MOIP_FINISH = 850;
  3965. public final static int RELEASE_BLOCK_FRONTCALL = 996;
  3966. public final static int REFRESH_HOMEICON = 997;
  3967. public final static int FINISH_WALLPADCALL = 998;
  3968. public final static int FINISH_ACTIVITY = 999;
  3969. }
  3970. int nBrightness = 0;
  3971. public Handler MainHandler = new Handler(Looper.getMainLooper()) {
  3972. public void handleMessage(Message msg) {
  3973. LOG("[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  3974. switch (msg.what) {
  3975. case HANDLERMSG.RELEASE_TOPMENUBTN_BLOCK:
  3976. bBlockTopMenuBTN = false;
  3977. break;
  3978. case HANDLERMSG.CHECK_RECEIVINGCALL:
  3979. generateCallEvent();
  3980. break;
  3981. case HANDLERMSG.REMOVE_VIDEO_COVER:
  3982. break;
  3983. case HANDLERMSG.SHOW_VIDEO_COVER:
  3984. break;
  3985. case HANDLERMSG.CLEAR_ALL_CALL:
  3986. // mCallController.mCallInfo.resetAllCallInfo();
  3987. // finishActivity();
  3988. // mCallController.mCallInfo.resetAllCallInfo();
  3989. setFinishTimerCreate(Common.FINISH_TIME_ALL_CALL_CLEAR);
  3990. break;
  3991. case HANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  3992. bBlockFrontCall = false;
  3993. break;
  3994. case HANDLERMSG.TAKE_PICTURE_FRONT:
  3995. break;
  3996. case HANDLERMSG.CHANGESCREEN:
  3997. if (msg.arg1 == HANDLERMSG.CHANGESCREEN_FRONT) {
  3998. changeMenuNScreen(ID.MENU.MENU_TALKFRONT);
  3999. }
  4000. else if (msg.arg1 == HANDLERMSG.CHANGESCREEN_LOBBY) {
  4001. changeMenuNScreen(ID.MENU.MENU_TALKLOBBY);
  4002. }
  4003. else if (msg.arg1 == HANDLERMSG.CHANGESCREEN_GUARD) {
  4004. changeMenuNScreen(ID.MENU.MENU_TALKGUARD);
  4005. }
  4006. else if (msg.arg1 == HANDLERMSG.CHANGESCREEN_RESIDENCE) {
  4007. changeMenuNScreen(ID.MENU.MENU_TALKRESIDENCE);
  4008. }
  4009. else if (msg.arg1 == HANDLERMSG.CHANGESCREEN_PSTN) {
  4010. changeMenuNScreen(ID.MENU.MENU_TALKPSTN);
  4011. }
  4012. else {
  4013. LOG("[MainHandler] Invalid Screen Info!!");
  4014. }
  4015. break;
  4016. case HANDLERMSG.INIT_FRONTVIDEO:
  4017. initFrontVideoLayout();
  4018. break;
  4019. case HANDLERMSG.REMOVE_FRONTVIDEO:
  4020. removeFrontVideoLayout();
  4021. break;
  4022. case HANDLERMSG.SHOW_FRONTVIDEO:
  4023. showFrontVideo(true);
  4024. break;
  4025. case HANDLERMSG.CTRL_FRONTVIDEO_BRIGHTNESS:
  4026. nBrightness = msg.arg1;
  4027. Log.d(TAG, "[CTRL_FRONTVIDEO_BRIGHTNESS] nBrightness: " + nBrightness);
  4028. if (mFrontCamOpenCheckHandler != null) mFrontCamOpenCheckHandler.sendEmptyMessage(0); // camera open check를 위한 핸들러 구현 (seulki)
  4029. else Log.w(TAG, "[MainHandler] mFrontCamOpenCheckHandler is null!! -> HANDLERMSG.CTRL_FRONTVIDEO_BRIGHTNESS");
  4030. break;
  4031. case HANDLERMSG.SET_TEMPSYSTEM_VOLUME:
  4032. if (mAudioManager != null) {
  4033. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nTempSysVolume, 0);
  4034. Log.d(TAG, "[MainHandler SET_TEMP_SYSTEM_VOLUME] Volume: " + mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
  4035. }
  4036. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.SET_TEMPSYSTEM_VOLUME");
  4037. break;
  4038. case HANDLERMSG.RECOVER_SYSTEM_VOLUME:
  4039. // 통화 종료 후 시스템 볼륨 원복 seulki
  4040. if (nSysVolume > 0) {
  4041. if (mAudioManager != null) {
  4042. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSysVolume, 0);
  4043. Log.d(TAG, "[MainHandler RECOVER_SYSTEM_VOLUME] Volume: " + mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
  4044. }
  4045. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.RECOVER_SYSTEM_VOLUME");
  4046. }
  4047. break;
  4048. case HANDLERMSG.SET_DTMF_VOLUME:
  4049. // IHN-1010 에서는 DTMF 발신시 볼륨 11로 셋팅
  4050. if (mAudioManager != null) {
  4051. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nTempDTMFVolume, 0);
  4052. Log.d(TAG, "[MainHandler SET_DTMF_SYSTEM_VOLUME] Volume: " + mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
  4053. }
  4054. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.SET_DTMF_VOLUME");
  4055. break;
  4056. case HANDLERMSG.SET_RELIEFCALL_VOLUME:
  4057. // 안심통화시(오디오모드 19) 볼륨 11로 셋팅
  4058. if (mAudioManager != null) {
  4059. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nTempReliefVolume, 0);
  4060. Log.d(TAG, "[MainHandler SET_RELIEFCALL_VOLUME] Volume: " + mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
  4061. }
  4062. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.SET_RELIEFCALL_VOLUME");
  4063. break;
  4064. case HANDLERMSG.SET_DINGDONG_VOLUME:
  4065. // 현관띵똥시 볼륨 12로 셋팅 / 효성카메라(IDC-HS100)일 경우 10
  4066. int nVolume = nTempDingDongVolume;
  4067. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101 || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_HS101_I) {
  4068. if (ConfigValues.eFrontCameraType == FRONTCAMERATYPE.BASIC) {
  4069. nVolume = nTempDingDongVolume_IDCHS100;
  4070. }
  4071. }
  4072. if (mAudioManager != null) {
  4073. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  4074. Log.d(TAG, "[MainHandler SET_DINGDONG_VOLUME] Volume: " + mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
  4075. }
  4076. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.SET_DINGDONG_VOLUME");
  4077. break;
  4078. case HANDLERMSG.SETTALKPATH_DOORMUSIC:
  4079. Log.d(TAG, "[MainHandler] SETTALKPATH_DOORMUSIC");
  4080. if (mCallController != null) mCallController.setTalkPath(CALLPATH.DOORMUSIC);
  4081. break;
  4082. case HANDLERMSG.SHOW_FRONTCAM_SUBPHONE:
  4083. if (mCallController != null) mCallController.selectVideoSourceToSubPhone(CALLTYPE.FRONT, false);
  4084. else Log.w(TAG, "[MainHandler] mCallController is null!! -> HANDLERMSG.SHOW_FRONTCAM_SUBPHONE");
  4085. break;
  4086. case HANDLERMSG.CHANGE_STRANGER_NOTICE_COLOR:
  4087. if (TopStrangerRecodingNotice != null) TopStrangerRecodingNotice.setTextColor(nNoticeTextColor);
  4088. else Log.w(TAG, "[MainHandler] TopStrangerRecodingNotice is null!! -> HANDLERMSG.CHANGE_STRANGER_NOTICE_COLOR");
  4089. break;
  4090. case HANDLERMSG.CHANGE_REMOTECALL_NOTICE_COLOR:
  4091. if (TopRemoteCallNotice != null) TopRemoteCallNotice.setTextColor(nNoticeTextColor);
  4092. else Log.w(TAG, "[MainHandler] TopRemoteCallNotice is null!! -> HANDLERMSG.CHANGE_REMOTECALL_NOTICE_COLOR");
  4093. break;
  4094. case HANDLERMSG.SEND_REQUEST_PSTN_STATUS:
  4095. if (mPSTNController != null) mPSTNController.sendGetPSTNPath();
  4096. else Log.w(TAG, "[MainHandler] mPSTNController is null!! -> HANDLERMSG.SEND_REQUEST_PSTN_STATUS");
  4097. break;
  4098. case HANDLERMSG.SEND_HOOK_ON:
  4099. if (mPSTNController != null) mPSTNController.sendHookOn();
  4100. else Log.w(TAG, "[MainHandler] mPSTNController is null!! -> HANDLERMSG.SEND_HOOK_ON");
  4101. break;
  4102. case HANDLERMSG.SEND_PSTN_ARS_MODE:
  4103. if (mCallController != null) mCallController.onPSTNEvent(CALLEVENTTYPE.PSTN_RING, null, null);
  4104. else Log.w(TAG, "[MainHandler] mCallController is null!! -> HANDLERMSG.SEND_PSTN_ARS_MODE");
  4105. break;
  4106. case HANDLERMSG.PLAY_DINGDONG:
  4107. Log.d(TAG, "[MainHandler] PLAY_DINGDONG");
  4108. int time = 0;
  4109. if (mSound != null) time = mSound.PlayMent(SND.call.DINGDONG);
  4110. LOG("[MainHandler] time [" + time + "]");
  4111. if (time < 0) time = 2088;
  4112. sendHandlerMsgDelayed(HANDLERMSG.STOP_DINGDONG, 0, 0, time + 500); // [띵똥시나리오] 2. 띵똥 stop / 패스 변경
  4113. break;
  4114. case HANDLERMSG.STOP_DINGDONG:
  4115. Log.d(TAG, "[MainHandler] STOP_DINGDONG");
  4116. if (mIOInterface != null) mIOInterface.ctrlSetTalkPathNormal();
  4117. if (mAudioManager != null) mAudioManager.setMode(AudioManager.MODE_NORMAL);
  4118. else Log.w(TAG, "[MainHandler] mAudioManager is null!! -> HANDLERMSG.STOP_DINGDONG");
  4119. if (mCallPathCheckHandler != null) mCallPathCheckHandler.sendEmptyMessage(2);
  4120. else Log.w(TAG, "[MainHandler] mCallPathCheckHandler is null!! -> HANDLERMSG.STOP_DINGDONG");
  4121. break;
  4122. case HANDLERMSG.PLAY_FRONT_BELL:
  4123. LOG("[MainHandler] PLAY_FRONT_BELL");
  4124. Global.playMelodyRepeat(CALLTYPE.FRONT);
  4125. break;
  4126. case HANDLERMSG.SET_TALK_BTN_ENABLE:
  4127. Log.d(TAG, "[MainHandler] SET_TALK_BTN_ENABLE");
  4128. // if (TalkFront.BTN_TALK != null) TalkFront.BTN_TALK.setButtonEventOffDisable();
  4129. // else Log.w(TAG, "[MainHandler] TalkFront.BTN_TALK is null!! -> HANDLERMSG.SET_TALK_BTN_ENABLE");
  4130. break;
  4131. case HANDLERMSG.REFRESH_HOMEICON:
  4132. bBlockHomeBTN = false;
  4133. break;
  4134. case HANDLERMSG.FINISH_WALLPADCALL:
  4135. finishWallPadCall();
  4136. break;
  4137. case HANDLERMSG.FINISH_ACTIVITY:
  4138. finishActivity();
  4139. break;
  4140. case IGW300CMD.AUDIO_OFF:
  4141. Log.d(TAG, "[MainHandler] AUDIO_OFF ms.arg1 [" + msg.arg1 + "]");
  4142. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.OFF);
  4143. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300CMD.AUDIO_OFF");
  4144. break;
  4145. case IGW300CMD.AUDIO_PSTN_WALLPAD:
  4146. Log.d(TAG, "[MainHandler] AUDIO_PSTN_WALLPAD");
  4147. Log.d(TAG, "[MainHandler] ConfigValues.DEVICE_MODELTYPE [" + ConfigValues.DEVICE_MODELTYPE + "]");
  4148. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101 || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I
  4149. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K_I
  4150. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I_OCF)
  4151. {
  4152. sendPSTNRingEndBR();
  4153. }
  4154. else {
  4155. Log.d(TAG, "[MainHandler] ConfigValues.DEVICE_MODELTYPE [" + ConfigValues.DEVICE_MODELTYPE + "]");
  4156. }
  4157. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.WPAD_TEL);
  4158. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300CMD.AUDIO_PSTN_WALLPAD");
  4159. break;
  4160. case IGW300CMD.AUDIO_PSTN_SUBPHONE:
  4161. Log.d(TAG, "[MainHandler] AUDIO_PSTN_SUBPHONE");
  4162. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.SUB_TEL);
  4163. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300CMD.AUDIO_PSTN_SUBPHONE");
  4164. break;
  4165. case IGW300CMD.AUDIO_FRONT_WALLPAD:
  4166. Log.d(TAG, "[MainHandler] AUDIO_FRONT_WALLPAD");
  4167. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.WPAD_DOOR);
  4168. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300CMD.AUDIO_FRONT_WALLPAD");
  4169. break;
  4170. case IGW300CMD.AUDIO_FRONT_SUBPHONE:
  4171. Log.d(TAG, "[MainHandler] AUDIO_FRONT_SUBPHONE");
  4172. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.SUB_DOOR);
  4173. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300CMD.AUDIO_FRONT_SUBPHONE");
  4174. break;
  4175. case IGW300CMD.AUDIO_MOIP_SUBPHONE:
  4176. Log.d(TAG, "[MainHandler] AUDIO_MOIP_SUBPHONE");
  4177. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.MOIP_SUB);
  4178. break;
  4179. case IGW300CMD.AUDIO_PSTN_REJECT:
  4180. Log.d(TAG, "[MainHandler] AUDIO_PSTN_REJECT");
  4181. if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101 || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I
  4182. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101K_I
  4183. || ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101_I_OCF) {
  4184. sendPSTNRingEndBR();
  4185. }
  4186. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.WPAD_TEL);
  4187. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300API.TEL_PATH.WPAD_TEL");
  4188. try { Thread.sleep(500); }
  4189. catch (InterruptedException e) {
  4190. //e.printStackTrace();
  4191. LogUtil.errorLogInfo("", TAG, e);
  4192. }
  4193. if (mIOInterface != null) mIOInterface.IGW300_CallPathCtrl(IGW300API.TEL_PATH.OFF);
  4194. else Log.d(TAG, "[MainHandler] mIOInterface is null!! -> IGW300API.TEL_PATH.OFF");
  4195. break;
  4196. case HANDLERMSG.SEND_SUBWALLPAD_MOIP_FINISH:
  4197. Intent mIntent = new Intent();
  4198. mIntent.setAction(Declare.BR.APP_FINISH);
  4199. mContext.sendBroadcast(mIntent);
  4200. break;
  4201. default:
  4202. LOG("MainHandler : " + msg.what);
  4203. break;
  4204. }
  4205. }
  4206. };
  4207. public void sendHandlerMsg(int what, int arg1, int arg2) {
  4208. try {
  4209. LOG("[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  4210. Message HandleMsg = MainHandler.obtainMessage();
  4211. HandleMsg.what = what;
  4212. HandleMsg.arg1 = arg1;
  4213. HandleMsg.arg2 = arg2;
  4214. MainHandler.sendMessage(HandleMsg);
  4215. } catch (RuntimeException re) {
  4216. LogUtil.errorLogInfo("", TAG, re);
  4217. } catch (Exception e) {
  4218. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  4219. //e.printStackTrace();
  4220. LogUtil.errorLogInfo("", TAG, e);
  4221. }
  4222. }
  4223. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
  4224. try {
  4225. LOG("[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  4226. Message HandleMsg = MainHandler.obtainMessage();
  4227. HandleMsg.what = what;
  4228. HandleMsg.arg1 = arg1;
  4229. HandleMsg.arg2 = arg2;
  4230. MainHandler.sendMessageDelayed(HandleMsg, delay);
  4231. } catch (RuntimeException re) {
  4232. LogUtil.errorLogInfo("", TAG, re);
  4233. } catch (Exception e) {
  4234. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  4235. //e.printStackTrace();
  4236. LogUtil.errorLogInfo("", TAG, e);
  4237. }
  4238. }
  4239. /**
  4240. * JEFF, 2020.01.04
  4241. * IGW-300연동시에는 국선 호출의 시작과 끝만 알려준다.
  4242. * 또한, 월패드에서 통화를 수신한 경우에는 국선 호출의 끝을 알려주지 않으므로
  4243. * 월패드에서 hookon하는 순간 국선 호출에 대한 링을 강제로 발생시키는 쓰레드를 종료하기위해 아래의 BR 메시지를 보낸다
  4244. * 수신지는 iMapServer의 mWallPadNotifyBR -> kr.co.icontrols.wallpad.BR_MAIN_NOTI -> Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END
  4245. */
  4246. int NOTICE_PSTN_RING_END = 1025;
  4247. public void sendPSTNRingEndBR() {
  4248. try {
  4249. Log.i(TAG, "[sendPSTNRingEndBR] ===== START =====");
  4250. Intent mIntent = new Intent();
  4251. mIntent.setAction(ACNAME_MAIN_NOTI);
  4252. mIntent.putExtra("KIND", NOTICE_PSTN_RING_END);
  4253. mContext.sendBroadcast(mIntent);
  4254. } catch (RuntimeException re) {
  4255. LogUtil.errorLogInfo("", TAG, re);
  4256. } catch (Exception e) {
  4257. Log.e(TAG, "[Exception] sendPSTNRingEndBR()");
  4258. //e.printStackTrace();
  4259. LogUtil.errorLogInfo("", TAG, e);
  4260. }
  4261. }
  4262. public void setBlockFrontCall() {
  4263. try {
  4264. bBlockFrontCall = true;
  4265. MainHandler.removeMessages(HANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  4266. ((MainActivity) mContext).sendHandlerMsgDelayed(HANDLERMSG.RELEASE_BLOCK_FRONTCALL, 0, 0, 3000);
  4267. } catch (RuntimeException re) {
  4268. LogUtil.errorLogInfo("", TAG, re);
  4269. } catch (Exception e) {
  4270. Log.e(TAG, "[Exception] setBlockFrontCall()");
  4271. //e.printStackTrace();
  4272. LogUtil.errorLogInfo("", TAG, e);
  4273. }
  4274. }
  4275. private String KIND = "KIND";
  4276. private boolean getBusinessSampleMode() {
  4277. try {
  4278. // 영업샘플모드인 경우, LCD를 항상 ON 시켜 놓는다.
  4279. WallpadSalesSampleData mWallpadSalesSampleData = new WallpadSalesSampleData(mContext);
  4280. int nMode = mWallpadSalesSampleData.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SLEEP);
  4281. mWallpadSalesSampleData.closeDB();
  4282. if (nMode == 0) return true;
  4283. else return false;
  4284. } catch (RuntimeException re) {
  4285. LogUtil.errorLogInfo("", TAG, re);
  4286. return false;
  4287. } catch (Exception e) {
  4288. Log.e(TAG, "[Exception] getBusinessSampleMode()");
  4289. //e.printStackTrace();
  4290. LogUtil.errorLogInfo("", TAG, e);
  4291. return false;
  4292. }
  4293. }
  4294. private void getLCDReverse() {
  4295. try {
  4296. if (mIOInterface.getBoardRevision() != 0) bLCDReverse = true;
  4297. else bLCDReverse = false;
  4298. } catch (RuntimeException re) {
  4299. LogUtil.errorLogInfo("", TAG, re);
  4300. bLCDReverse = false;
  4301. } catch (Exception e) {
  4302. Log.e(TAG, "[Exception] getLCDReverse()");
  4303. //e.printStackTrace();
  4304. LogUtil.errorLogInfo("", TAG, e);
  4305. bLCDReverse = false;
  4306. }
  4307. }
  4308. private void notifyAppFinish() {
  4309. try {
  4310. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  4311. int nAlarmStatus = SetData.GetAlarmStatus();
  4312. SetData.closeDB();
  4313. LOG("[notifyAppFinish] nAlarmStatus [" + nAlarmStatus + "]");
  4314. Intent intent = new Intent(ACNAME_MAIN_NOTI, null);
  4315. intent.putExtra(KIND, Declare.BR.APK_EXIT_MAIN_CHECK);
  4316. getContext().sendBroadcast(intent);
  4317. } catch (RuntimeException re) {
  4318. LogUtil.errorLogInfo("", TAG, re);
  4319. } catch (Exception e) {
  4320. Log.e(TAG, "[Exception] notifyAppFinish()");
  4321. //e.printStackTrace();
  4322. LogUtil.errorLogInfo("", TAG, e);
  4323. }
  4324. }
  4325. private void notifyCallAppFinish() {
  4326. try {
  4327. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  4328. int nAlarmStatus = SetData.GetAlarmStatus();
  4329. SetData.closeDB();
  4330. LOG("[notifyCallAppFinish] nAlarmStatus [" + nAlarmStatus + "]");
  4331. Intent intent = new Intent(ACNAME_MAIN_NOTI, null);
  4332. intent.putExtra(KIND, Declare.BR.NOTI_CALLAPP_FINISHING);
  4333. getContext().sendBroadcast(intent);
  4334. } catch (RuntimeException re) {
  4335. LogUtil.errorLogInfo("", TAG, re);
  4336. } catch (Exception e) {
  4337. Log.e(TAG, "[Exception] notifyCallAppFinish()");
  4338. //e.printStackTrace();
  4339. LogUtil.errorLogInfo("", TAG, e);
  4340. }
  4341. }
  4342. boolean bBlockFrontCall = false; // 현관통화가 종료되고 통화앱이 종료되기까지 시간이 걸리므로 플래그를 세워 일정시간 현관콜을 막는다.
  4343. BroadcastReceiver mMainExtraEventReceiver = new BroadcastReceiver() {
  4344. String TAG = "MainExtraEventReceiver";
  4345. @Override
  4346. public void onReceive(Context context, Intent intent) {
  4347. try {
  4348. String strAction = intent.getAction();
  4349. Log.d(this.TAG, "[onReceive] strAction [" + strAction + "]");
  4350. if (strAction.equals(Declare.BR.APP_FINISH)) {
  4351. mIOInterface.ctrlPopupGUI(true);
  4352. mCallController.setTalkPath(CALLPATH.NORMAL); // Finish BR 수신시 통화패스 Normal로 변경
  4353. if (mMainEventListener != null) {
  4354. String strCallOwner = intent.getStringExtra(CALLTRIGGER.CALLOWNER);
  4355. Log.d(this.TAG, "[onReceive] strCallOwner [" + strCallOwner + "]");
  4356. if (strCallOwner!= null) {
  4357. if (strCallOwner.equals("MOBILE")) mMainEventListener.onMainTouchEvent(MAINEVENT.BTN_HOME_MOBILE);
  4358. } else {
  4359. mMainEventListener.onMainTouchEvent(MAINEVENT.BTN_HOME);
  4360. }
  4361. }
  4362. else {
  4363. finishWallPadCall();
  4364. }
  4365. }
  4366. else if (strAction.equals(Declare.BR.WALLPAD_ALERT)) {
  4367. Log.d(this.TAG, "[onReceive] strAction [" + strAction + "]");
  4368. int nKind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  4369. if (nKind == Declare.BR.NOTIFY_ALARM_FIRED) finishWallPadCall();
  4370. }
  4371. else if (strAction.equals(Declare.BR.EVENT_DEVICE_CONTROL)) {
  4372. KeyEvent mKeyEvent = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  4373. Log.i(this.TAG, "[onReceive] mKeyEvent : " + mKeyEvent + ", mKeyEvent.getKeyCode() : " + mKeyEvent.getKeyCode());
  4374. if (mKeyEvent.getKeyCode() == Declare.BTN.TALK || mKeyEvent.getKeyCode() == Declare.BTN.TALK_V40) {
  4375. // if (mCallController.mCallInfo.getFRONT() == CALLSTATUS.IDLE && !bBlockFrontCall) {
  4376. // setBlockFrontCall();
  4377. // mCallController.onFrontEvent(CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT);
  4378. // }
  4379. // else Log.w(this.TAG, "[onReceive] Front call ignored!!! [" + mCallController.mCallInfo.getFRONT() + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  4380. }
  4381. else if (mKeyEvent.getKeyCode() == Declare.BTN.FRONT || mKeyEvent.getKeyCode() == Declare.BTN.FRONT_V40) {
  4382. Log.i(this.TAG, "[onReceive] mKeyEvent.getKeyCode() : " + mKeyEvent.getKeyCode());
  4383. if (!bBlockFrontCall) {
  4384. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT) {
  4385. if (mCallController.mCallInfo.getIDLECnt() == mCallController.mCallInfo.IDLECNT_MAX) {
  4386. sendHandlerMsg(HANDLERMSG.SET_DINGDONG_VOLUME, 0, 0); // 현관띵똥 볼륨 고정(시스템 볼륨 따라가지 않도록)
  4387. sendHandlerMsg(HANDLERMSG.SETTALKPATH_DOORMUSIC, 0, 0);
  4388. mCallPathCheckHandler.sendEmptyMessage(0); // 통화앱이 실행되어 있으나 통화상태가 아닌 경우에도 띵똥 소리 나야함 (메인앱에서 현관 호출 BR 수신이 불가하므로 통화앱에서 처리)
  4389. }
  4390. }
  4391. if (mCallController.mCallInfo.getFRONT() == CALLSTATUS.IDLE) {
  4392. setBlockFrontCall();
  4393. mCallController.onFrontEvent(CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT);
  4394. }
  4395. else {
  4396. Log.w(this.TAG, "[onReceive] Front call ignored!!! getFRONT() [" + mCallController.mCallInfo.getFRONT() + "]");
  4397. }
  4398. }
  4399. else {
  4400. Log.w(this.TAG, "[onReceive] Front call ignored!!! bBlockFrontCall [" + bBlockFrontCall + "]");
  4401. }
  4402. }
  4403. else if (mKeyEvent.getKeyCode() == Declare.BTN.IGW300_PSTN_RING_START) {
  4404. /**
  4405. * JEFF, 2020.01.04
  4406. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  4407. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  4408. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  4409. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  4410. */
  4411. if (mPSTNController != null) mPSTNController.sendMsgToLocalService(PSTNHANDLERMSG.RECEIVE_RING, null);
  4412. // if (ConfigValues.DEVICE_MODELTYPE == MODEL_TYPE.IHN_D101) {
  4413. // if (mPSTNController != null) mPSTNController.sendMsgToLocalService(PSTNHANDLERMSG.RECEIVE_RING, null);
  4414. // }
  4415. }
  4416. else if (mKeyEvent.getKeyCode() == Declare.BTN.IGW300_PSTN_RING_END) {
  4417. if (mPSTNController != null) mPSTNController.sendMsgToLocalService(PSTNHANDLERMSG.RECEIVE_RING_END, null);
  4418. }
  4419. else if (mKeyEvent.getKeyCode() == Declare.BTN.PSTN_RING_V40) {
  4420. if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT) {
  4421. if (mPSTNController != null) mPSTNController.sendMsgToLocalService(PSTNHANDLERMSG.RECEIVE_RING, null);
  4422. }
  4423. }
  4424. }
  4425. else if (strAction.equals(define.NOTIFY_ACNAME)) {
  4426. int kind = intent.getIntExtra(define.NOTIBR_KIND,0);
  4427. if (kind == define.NOTIFY_FINISH_FRONT_DINGDONG) {
  4428. // 메인 App으로 부터 띵똥 종료 BR 수신 받을 경우 현관 호출음 재생
  4429. sendHandlerMsgDelayed(HANDLERMSG.PLAY_FRONT_BELL, 0, 0, 200);
  4430. sendHandlerMsgDelayed(HANDLERMSG.SET_TALK_BTN_ENABLE, 0, 0, 200);
  4431. }
  4432. }
  4433. else if (strAction.equals(Declare.BR.BR_SHOW_REMOTEVIEW_TRUE)) {
  4434. mCallController.onShowRemoteVideo(true);
  4435. }
  4436. else if (strAction.equals(Declare.BR.BR_SHOW_REMOTEVIEW_FALSE)) {
  4437. mCallController.onShowRemoteVideo(false);
  4438. }
  4439. } catch (RuntimeException re) {
  4440. LogUtil.errorLogInfo("", TAG, re);
  4441. } catch (Exception e) {
  4442. Log.e(this.TAG, "[Exception] onReceive(Context context, Intent intent)");
  4443. //e.printStackTrace();
  4444. LogUtil.errorLogInfo("", TAG, e);
  4445. }
  4446. }
  4447. };
  4448. private void registerBRReceiver() {
  4449. try {
  4450. LOG_INFO("[registerBRReceiver] ========== START ==========");
  4451. IntentFilter mIntentFilter = new IntentFilter();
  4452. mIntentFilter.addAction(Declare.BR.APP_FINISH);
  4453. mIntentFilter.addAction(Declare.BR.WALLPAD_ALERT);
  4454. mIntentFilter.addAction(Declare.BR.EVENT_DEVICE_CONTROL);
  4455. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  4456. mIntentFilter.addAction(Declare.BR.VISITOR_REMOTE_CALL);
  4457. mIntentFilter.addAction(Declare.BR.BR_SHOW_REMOTEVIEW_TRUE);
  4458. mIntentFilter.addAction(Declare.BR.BR_SHOW_REMOTEVIEW_FALSE);
  4459. registerReceiver(mMainExtraEventReceiver, mIntentFilter, null, null);
  4460. mIntentFilter = new IntentFilter();
  4461. mIntentFilter.addAction("MENU_EVENT");
  4462. registerReceiver(mWallPadAlertBR, mIntentFilter);
  4463. mIntentFilter = new IntentFilter();
  4464. mIntentFilter.addAction(define.NOTIFY_DAIL);
  4465. mIntentFilter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH");
  4466. registerReceiver(mWallPadJogBR, mIntentFilter);
  4467. } catch (RuntimeException re) {
  4468. LogUtil.errorLogInfo("", TAG, re);
  4469. } catch (Exception e) {
  4470. Log.e(TAG, "[Exception] registerBRReceiver()");
  4471. //e.printStackTrace();
  4472. LogUtil.errorLogInfo("", TAG, e);
  4473. }
  4474. }
  4475. private void unregisterBRReceiver() {
  4476. try {
  4477. LOG_INFO("[unregisterBRReceiver] ========== START ==========");
  4478. unregisterReceiver(mMainExtraEventReceiver);
  4479. unregisterReceiver(mWallPadAlertBR);
  4480. unregisterReceiver(mWallPadJogBR);
  4481. } catch (RuntimeException re) {
  4482. LogUtil.errorLogInfo("", TAG, re);
  4483. } catch (Exception e) {
  4484. Log.e(TAG, "[Exception] unregisterBRReceiver()");
  4485. //e.printStackTrace();
  4486. LogUtil.errorLogInfo("", TAG, e);
  4487. }
  4488. }
  4489. private void registerWallPadCallLiveBRReceiver() {
  4490. try {
  4491. LOG_INFO("[registerWallPadCallLiveBRReceiver] ========== START ==========");
  4492. IntentFilter mIntentFilter = new IntentFilter();
  4493. mIntentFilter.addAction(Declare.BR.BR_REQUEST_WALLPADCALL_LIVE);
  4494. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  4495. } catch (RuntimeException re) {
  4496. LogUtil.errorLogInfo("", TAG, re);
  4497. } catch (Exception e) {
  4498. Log.e(TAG, "[Exception] registerWallPadCallLiveBRReceiver()");
  4499. //e.printStackTrace();
  4500. LogUtil.errorLogInfo("", TAG, e);
  4501. }
  4502. }
  4503. private void unregisterWallPadCallLiveBRReceiver() {
  4504. try {
  4505. LOG_INFO("[unregisterBRReceiver] ========== START ==========");
  4506. unregisterReceiver(WallPadCallLiveBRCheck);
  4507. } catch (RuntimeException re) {
  4508. LogUtil.errorLogInfo("", TAG, re);
  4509. } catch (Exception e) {
  4510. Log.e(TAG, "[Exception] unregisterWallPadCallLiveBRReceiver()");
  4511. //e.printStackTrace();
  4512. LogUtil.errorLogInfo("", TAG, e);
  4513. }
  4514. }
  4515. /**
  4516. * 부재중 방문자 사진을 단지서버에 전송할때
  4517. * 해당 BR을 전송하여 메인App에서 방문자 사진의 전송을 처리한다.
  4518. * 통화 App이 종료되는 시간 안에 전송을 완료하기 어려움
  4519. */
  4520. public void sendBRMissedVisitorPicture(String strDong, String strHo, String[] strMissedCallPicURI) {
  4521. try {
  4522. Log.i(TAG, "[sendBRMissedVisitorPicture] strDong [" + strDong + "], strHo [" + strHo + "], strMissedCallPicURI.length [" + strMissedCallPicURI.length + "]");
  4523. Intent mIntent = new Intent();
  4524. mIntent.setAction(ACNAME_MAIN_NOTI);
  4525. mIntent.putExtra(KIND, Declare.BR.REQ_UPLOAD_MISSEDVISITORPIC);
  4526. mIntent.putExtra("DONG", strDong);
  4527. mIntent.putExtra("HO", strHo);
  4528. mIntent.putExtra("CNT", strMissedCallPicURI.length);
  4529. for (int i = 0; i < strMissedCallPicURI.length; i++) {
  4530. Log.i(TAG, "[sendBRMissedVisitorPicture] strMissedCallPicURI[" + i + "] = [" + strMissedCallPicURI[i] + "]");
  4531. mIntent.putExtra("URI_" + i, strMissedCallPicURI[i]);
  4532. }
  4533. getContext().sendBroadcast(mIntent);
  4534. } catch (RuntimeException re) {
  4535. LogUtil.errorLogInfo("", TAG, re);
  4536. } catch (Exception e) {
  4537. Log.e(TAG, "[Exception] sendBRMissedVisitorPicture(String strDong, String strHo, String[] strMissedCallPicURI)");
  4538. //e.printStackTrace();
  4539. LogUtil.errorLogInfo("", TAG, e);
  4540. }
  4541. }
  4542. boolean bFinishing = false;
  4543. public void finishWallPadCall() {
  4544. try {
  4545. LOG("[finishWallPadCall] bFinishing [" + bFinishing + "]");
  4546. if (bFinishing) {
  4547. return;
  4548. }
  4549. bFinishing = true;
  4550. sendBlockSIPCallBR();
  4551. notifyCallAppFinish();
  4552. if (sdbLivingRoomLightAPI != null) {
  4553. Log.d(TAG, "[finishWallPadCall] sdbLivingRoomLightAPI.SetWifiModuleOnOff [TRUE]");
  4554. sdbLivingRoomLightAPI.SetWifiModuleOnOff(true);
  4555. sdbLivingRoomLightAPI = null;
  4556. }
  4557. Global.stopMelodyRepeat();
  4558. Global.ctrlLCDOnOff(false);
  4559. if (ConfigValues.eWallPadType == WALLPADTYPE.MAIN) {
  4560. /**
  4561. * 아래와 같은 증상으로 인해 주석처리 함 (JEFF, 2020.04.02)
  4562. * 1. 국선 호출수신/통화중 홈버튼 눌러서 종료되는 경우 hook on, hook off가 반복되는 증상
  4563. * - 내선 전화 사용시 플래시 효과가 되어 버림
  4564. * 2. 국선 통화중 홈버튼 눌러서 종료시 PSTN 릴레이 딸각하는 소리가 두번 들림
  4565. */
  4566. // if (ConfigValues.bPSTNEnable) {
  4567. // mPSTNController.sendReject();
  4568. // mPSTNController.sendHookOffDelay();
  4569. // }
  4570. }
  4571. else {
  4572. if (ConfigValues.eSubWallPadPSTNType == SUBWALLPAD_PSTNTYPE.DIRECT) {
  4573. mPSTNController.sendReject();
  4574. mPSTNController.sendHookOffDelay();
  4575. }
  4576. }
  4577. ctrlSmartIOTCamStatusMode(SmartRFCamStatusMode.STATUS_OFF);
  4578. ctrlSmartIOTCamLEDMode(SmartRFCamLEDMode.LED_OFF);
  4579. // if (mIOInterface != null) {
  4580. // mIOInterface.releaseIOInterface();
  4581. // mIOInterface = null;
  4582. // }
  4583. sendHandlerMsgDelayed(HANDLERMSG.FINISH_ACTIVITY, 0, 0, 500);
  4584. } catch (RuntimeException re) {
  4585. LogUtil.errorLogInfo("", TAG, re);
  4586. } catch (Exception e) {
  4587. Log.e(TAG, "[Exception] finishWallPadCall()");
  4588. //e.printStackTrace();
  4589. LogUtil.errorLogInfo("", TAG, e);
  4590. }
  4591. }
  4592. public void finishActivity() {
  4593. try {
  4594. LOG_INFO("[finishActivity]");
  4595. super.finish();
  4596. // setCallAppRunning(false);
  4597. } catch (RuntimeException re) {
  4598. LogUtil.errorLogInfo("", TAG, re);
  4599. } catch (Exception e) {
  4600. Log.e(TAG, "[Exception] finishActivity()");
  4601. //e.printStackTrace();
  4602. LogUtil.errorLogInfo("", TAG, e);
  4603. }
  4604. }
  4605. /**
  4606. * 통화 앱 실행 여부 판별 임시 코드
  4607. */
  4608. public void setCallAppRunning(boolean bRunning) {
  4609. try {
  4610. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4611. DBMGR.SetCallAPKStatus(bRunning);
  4612. DBMGR.closeDB();
  4613. } catch (RuntimeException re) {
  4614. LogUtil.errorLogInfo("", TAG, re);
  4615. } catch (Exception e) {
  4616. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  4617. //e.printStackTrace();
  4618. LogUtil.errorLogInfo("", TAG, e);
  4619. }
  4620. }
  4621. public boolean getCallAppRunning() {
  4622. boolean bRunning = false;
  4623. try {
  4624. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4625. bRunning = DBMGR.GetCallAPKStatusRunning();
  4626. DBMGR.closeDB();
  4627. Log.i(TAG, "[getCallAppRunning] bRunning [" + bRunning + "]");
  4628. } catch (RuntimeException re) {
  4629. LogUtil.errorLogInfo("", TAG, re);
  4630. } catch (Exception e) {
  4631. Log.e(TAG, "[Exception] getCallAppRunning()");
  4632. //e.printStackTrace();
  4633. LogUtil.errorLogInfo("", TAG, e);
  4634. }
  4635. return bRunning;
  4636. }
  4637. /**
  4638. * 통화 앱 꼬임시 임시 보완 코드
  4639. */
  4640. public void killCallProcess() {
  4641. try {
  4642. LOG_INFO("[killCallProcess]");
  4643. finishWallPadCall();
  4644. int pid = android.os.Process.myPid();
  4645. android.os.Process.killProcess(pid);
  4646. } catch (RuntimeException re) {
  4647. LogUtil.errorLogInfo("", TAG, re);
  4648. } catch (Exception e) {
  4649. Log.e(TAG, "[Exception] killCallProcess()");
  4650. //e.printStackTrace();
  4651. LogUtil.errorLogInfo("", TAG, e);
  4652. }
  4653. }
  4654. /** 메모리 체크 코드 **/
  4655. public void checkMemoryUsage() {
  4656. try {
  4657. Runtime.getRuntime().gc();
  4658. long totalMem = Runtime.getRuntime().totalMemory();
  4659. long freeMem = Runtime.getRuntime().freeMemory();
  4660. long usedMem = totalMem - freeMem;
  4661. Log.e(TAG, "**************** [checkMemoryUsage] *************");
  4662. Log.e(TAG, "************ TOTAL MEM : " + totalMem + " bytes ***********");
  4663. Log.e(TAG, "************ FREE MEM : " + freeMem + " bytes ***********");
  4664. Log.e(TAG, "************ USED MEM : " + usedMem + " bytes ***********");
  4665. Log.e(TAG, "*************************************************");
  4666. } catch (RuntimeException re) {
  4667. LogUtil.errorLogInfo("", TAG, re);
  4668. } catch (Exception e) {
  4669. Log.e(TAG, "[Exception] checkMemoryUsage()");
  4670. //e.printStackTrace();
  4671. LogUtil.errorLogInfo("", TAG, e);
  4672. }
  4673. }
  4674. private void sendWallPadCallLiveBR_ACK() {
  4675. try {
  4676. // Log.i(TAG, "[sendWallPadCallLiveBR_ACK] ===== START =====");
  4677. Intent mIntent = new Intent();
  4678. mIntent.setAction(Declare.BR.BR_ACK_WALLPADCALL_LIVE);
  4679. mIntent.putExtra("WALLPADCALL_VIEW", mCurrentScreenId);
  4680. getApplicationContext().sendBroadcast(mIntent);
  4681. } catch (RuntimeException re) {
  4682. LogUtil.errorLogInfo("", TAG, re);
  4683. } catch (Exception e) {
  4684. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_ACK()");
  4685. //e.printStackTrace();
  4686. LogUtil.errorLogInfo("", TAG, e);
  4687. }
  4688. }
  4689. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  4690. @Override
  4691. public void onReceive(Context context, Intent intent) {
  4692. try {
  4693. String strActionName = intent.getAction();
  4694. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  4695. if (strActionName.equals(Declare.BR.BR_REQUEST_WALLPADCALL_LIVE)) {
  4696. // Log.e(TAG,"[WallPadCallLiveBRCheck] Common.BR_ACK_WALLPADCALL_LIVE");
  4697. sendWallPadCallLiveBR_ACK();
  4698. }
  4699. else {
  4700. Log.w(TAG,"[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  4701. }
  4702. } catch (RuntimeException re) {
  4703. LogUtil.errorLogInfo("", TAG, re);
  4704. } catch (Exception e) {
  4705. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  4706. //e.printStackTrace();
  4707. LogUtil.errorLogInfo("", TAG, e);
  4708. }
  4709. }
  4710. };
  4711. private void sendBlockSIPCallBR() {
  4712. try {
  4713. Log.i(TAG, "[sendBlockSIPCallBR] ===== START =====");
  4714. Intent mIntent = new Intent();
  4715. mIntent.setAction(Declare.BR.BR_BLOCK_SIPCALL);
  4716. getApplicationContext().sendBroadcast(mIntent);
  4717. } catch (RuntimeException re) {
  4718. LogUtil.errorLogInfo("", TAG, re);
  4719. } catch (Exception e) {
  4720. Log.e(TAG, "[Exception] sendBlockSIPCallBR()");
  4721. //e.printStackTrace();
  4722. LogUtil.errorLogInfo("", TAG, e);
  4723. }
  4724. }
  4725. /**
  4726. * Sound PlayMent 시험용 코드 (JEFF, 2020.03.09)
  4727. */
  4728. private static MediaPlayer mMentMediaPlayer = null;
  4729. private static final String SOUND_PATH_ROOT = "/system/media/audio/wallpad/";
  4730. @SuppressLint("HandlerLeak")
  4731. public static int PlayMent_JeffTest(int SND_index) {
  4732. FileInputStream fileInputStream = null;
  4733. try {
  4734. StopMent();
  4735. String filepath = getFilePath(SND_index);
  4736. if (filepath == null) {
  4737. Log.e(TAG, "[PlayMent_JeffTest] - SND_index Not Found FilePath !!! (" + SND_index + ")");
  4738. return -1;
  4739. }
  4740. Log.i(TAG, "[PlayMent_JeffTest] - filepath [" + filepath + "]");
  4741. mMentMediaPlayer = new MediaPlayer();
  4742. fileInputStream = null;
  4743. try {
  4744. fileInputStream = new FileInputStream(filepath);
  4745. FileDescriptor fileDescriptor = fileInputStream.getFD();
  4746. mMentMediaPlayer.setDataSource(fileDescriptor);
  4747. // mMentMediaPlayer.setDataSource(filepath);
  4748. } catch (RuntimeException re) {
  4749. LogUtil.errorLogInfo("", TAG,re);
  4750. return -2;
  4751. } catch (Exception e) {
  4752. Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->setDataSource : " + e);
  4753. return -2;
  4754. }
  4755. finally {
  4756. if(fileInputStream!=null)
  4757. fileInputStream.close();
  4758. fileInputStream = null;
  4759. }
  4760. try {
  4761. mMentMediaPlayer.prepare();
  4762. } catch (RuntimeException re) {
  4763. LogUtil.errorLogInfo("", TAG, re);
  4764. return -3;
  4765. } catch (Exception e) {
  4766. Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->prepare : " + e);
  4767. return -3;
  4768. }
  4769. float PlayVolume = getPlayVolume(AudioManager.STREAM_MUSIC);
  4770. if(PlayVolume < 0) PlayVolume = 1;
  4771. mMentMediaPlayer.setVolume(PlayVolume, PlayVolume);
  4772. mMentMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
  4773. try {
  4774. mMentMediaPlayer.start();
  4775. } catch (RuntimeException re) {
  4776. LogUtil.errorLogInfo("", TAG, re);
  4777. return -4;
  4778. } catch (Exception e) {
  4779. Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->start : " + e);
  4780. return -4;
  4781. }
  4782. return mMentMediaPlayer.getDuration();
  4783. } catch (RuntimeException re) {
  4784. LogUtil.errorLogInfo("", TAG, re);
  4785. return -5;
  4786. } catch (Exception e) {
  4787. Log.e(TAG, "[Exception] PlayMent_JeffTest(int SND_index, int volume_kind)");
  4788. //e.printStackTrace();
  4789. LogUtil.errorLogInfo("", TAG, e);
  4790. return -5;
  4791. }
  4792. }
  4793. public static int PlayMent_JeffTest2(int SND_index) {
  4794. try {
  4795. StopMent();
  4796. String filepath = getFilePath(SND_index);
  4797. if (filepath == null) {
  4798. Log.e(TAG, "[PlayMent_JeffTest] - SND_index Not Found FilePath !!! (" + SND_index + ")");
  4799. return -1;
  4800. }
  4801. Log.i(TAG, "[PlayMent_JeffTest] - filepath [" + filepath + "]");
  4802. mMentMediaPlayer = new MediaPlayer();
  4803. mMentMediaPlayer.setDataSource(filepath);
  4804. mMentMediaPlayer.prepare();
  4805. mMentMediaPlayer.start();
  4806. // mMentMediaPlayer = new MediaPlayer();
  4807. // FileInputStream fileInputStream = null;
  4808. // try {
  4809. // fileInputStream = new FileInputStream(filepath);
  4810. // FileDescriptor fileDescriptor = fileInputStream.getFD();
  4811. // mMentMediaPlayer.setDataSource(fileDescriptor);
  4812. // fileInputStream.close();
  4813. //
  4814. //// mMentMediaPlayer.setDataSource(filepath);
  4815. // } catch (Exception e) {
  4816. // Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->setDataSource : " + e);
  4817. // return -2;
  4818. // }
  4819. //
  4820. // try {
  4821. // mMentMediaPlayer.prepare();
  4822. // } catch (Exception e) {
  4823. // Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->prepare : " + e);
  4824. // return -3;
  4825. // }
  4826. //
  4827. // float PlayVolume = getPlayVolume(AudioManager.STREAM_MUSIC);
  4828. // if(PlayVolume < 0) PlayVolume = 1;
  4829. //
  4830. // mMentMediaPlayer.setVolume(PlayVolume, PlayVolume);
  4831. // mMentMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
  4832. // try {
  4833. // mMentMediaPlayer.start();
  4834. // } catch (RuntimeException re) {
  4835. // LogUtil.errorLogInfo("", TAG, re);
  4836. // } catch (Exception e) {
  4837. // Log.e(TAG, "[ExceptionError] - PlayMent_JeffTest->start : " + e);
  4838. // return -4;
  4839. // }
  4840. return mMentMediaPlayer.getDuration();
  4841. } catch (RuntimeException re) {
  4842. LogUtil.errorLogInfo("", TAG, re);
  4843. return -5;
  4844. } catch (Exception e) {
  4845. Log.e(TAG, "[Exception] PlayMent_JeffTest(int SND_index, int volume_kind)");
  4846. //e.printStackTrace();
  4847. LogUtil.errorLogInfo("", TAG, e);
  4848. return -5;
  4849. }
  4850. }
  4851. public static boolean StopMent() {
  4852. if (mMentMediaPlayer == null) return false;
  4853. mMentMediaPlayer.stop();
  4854. mMentMediaPlayer.release();
  4855. mMentMediaPlayer = null;
  4856. return true;
  4857. }
  4858. /**
  4859. * 사운드파일 상수(SND)로 하여 실제 사운드파일 Path 를 리턴한다.<br>
  4860. * 내부메소드<br>
  4861. *
  4862. * @param index - 사운드 INDEX ({@link SND})
  4863. * @return null 일경우 잘못된 index , null 이 아닐경우 FilePath
  4864. */
  4865. private static String getFilePath(int index) {
  4866. String FileName = null;
  4867. switch (index) {
  4868. // [number]
  4869. case SND.number.NUM0: FileName = "number/0.wav"; break;
  4870. case SND.number.NUM1: FileName = "number/1.wav"; break;
  4871. case SND.number.NUM2: FileName = "number/2.wav"; break;
  4872. case SND.number.NUM3: FileName = "number/3.wav"; break;
  4873. case SND.number.NUM4: FileName = "number/4.wav"; break;
  4874. case SND.number.NUM5: FileName = "number/5.wav"; break;
  4875. case SND.number.NUM6: FileName = "number/6.wav"; break;
  4876. case SND.number.NUM7: FileName = "number/7.wav"; break;
  4877. case SND.number.NUM8: FileName = "number/8.wav"; break;
  4878. case SND.number.NUM9: FileName = "number/9.wav"; break;
  4879. // [effect]
  4880. case SND.effect.BUTTON: FileName = "effect/button.wav"; break;
  4881. case SND.effect.TOUCH_LATCHED: FileName = "effect/touch-latched.wav"; break;
  4882. case SND.effect.TOUCH_UNLATCHED: FileName = "effect/touch-unlatched.wav"; break;
  4883. case SND.effect.EFFECT1: FileName = "effect/effect1.wav"; break;
  4884. case SND.effect.END_2_MONO: FileName = "effect/end_2_mono.wav"; break;
  4885. case SND.effect.WARNING005: FileName = "effect/Warning005.wav"; break;
  4886. // [setting]
  4887. case SND.setting.DONG: FileName = "setting/dong.wav"; break;
  4888. case SND.setting.HO: FileName = "setting/ho.wav"; break;
  4889. case SND.setting.HOUR: FileName = "setting/Hour.wav"; break;
  4890. case SND.setting.MINUTE: FileName = "setting/Minute.wav"; break;
  4891. case SND.setting.SETTING: FileName = "setting/Setting.wav"; break;
  4892. case SND.setting.RETRY_ACTION: FileName = "setting/RetryAction.wav"; break;
  4893. case SND.setting.RETRY_INPUT: FileName = "setting/RetryInput.wav"; break;
  4894. // [bell]
  4895. case SND.bell.FRONT: FileName = "bell/Bell_Front.wav"; break;
  4896. case SND.bell.GUARDROOM: FileName = "bell/Bell_GuardRoom.wav"; break;
  4897. case SND.bell.LOBBY: FileName = "bell/Bell_Lobby.wav"; break;
  4898. case SND.bell.NEIGHBOOR: FileName = "bell/Bell_Neighboor.wav"; break;
  4899. case SND.bell.PSTN: FileName = "bell/Bell_Pstn.wav"; break;
  4900. case SND.bell.ALRAM: FileName = "bell/Alram.wav"; break;
  4901. case SND.bell.MONINGCALL_01: FileName = "bell/MoningCall01.wav"; break;
  4902. case SND.bell.MONINGCALL_02: FileName = "bell/MoningCall02.wav"; break;
  4903. case SND.bell.MONINGCALL_03: FileName = "bell/MoningCall03.wav"; break;
  4904. // [call]
  4905. case SND.call.CALL_VOIP: FileName = "call/callVOIP.wav"; break;
  4906. case SND.call.CALLSTART: FileName = "call/CallStart.wav"; break;
  4907. case SND.call.DINGDONG: FileName = "call/DingDong.wav"; break;
  4908. case SND.call.FRONTCALL: FileName = "call/FrontCallSound.wav"; break;
  4909. case SND.call.RING_BUSY: FileName = "call/RingBusy.wav"; break;
  4910. case SND.call.CONNECT_SUBPHONE: FileName = "call/ConnectSubPhone.wav"; break;
  4911. case SND.call.RECEIVE_CALL: FileName = "call/MoipCallReceiveSound.wav"; break;
  4912. case SND.call.SEND_CALL: FileName = "call/MoipCallSendSound.wav"; break;
  4913. case SND.call.BUSY_TRY_LATER: FileName = "call/BusyTryLater.wav"; break;
  4914. // [elevator]
  4915. case SND.elevator.CALL: FileName = "elevator/CallElevator.wav"; break;
  4916. case SND.elevator.DN_ARRIVED: FileName = "elevator/ElevatorArrived.wav"; break;
  4917. case SND.elevator.UP_ARRIVED: FileName = "elevator/MoveUp.wav"; break;
  4918. case SND.elevator.ORG_ARRIVED: FileName = "elevator/ORG_ElevatorArrived.wav"; break;
  4919. // [emergency]
  4920. case SND.emergency.DEFAULT: FileName = "emergency/Emergency.wav"; break;
  4921. case SND.emergency.ALARM: FileName = "emergency/EmergencyAram.wav"; break;
  4922. case SND.emergency.INVASION: FileName = "emergency/EmergencyInvasion.wav"; break;
  4923. case SND.emergency.RELEASE_COMEBACK:FileName = "emergency/EmergencyRelease_Comeback.wav"; break;
  4924. case SND.emergency.COMEBACK: FileName = "emergency/Comeback_Emergency.wav"; break;
  4925. case SND.emergency.SIRLEN1: FileName = "emergency/sirlen1.wav"; break;
  4926. case SND.emergency.STOP_SIREN: FileName = "emergency/StopSiren.wav"; break;
  4927. case SND.emergency.SILENT: FileName = "emergency/silent.wav"; break;
  4928. // [mode]
  4929. case SND.mode.NORMALMODE_COMEBACK: FileName = "mode/NormalModeComeback.wav"; break;
  4930. case SND.mode.HOME_DEVICE_CHECK: FileName = "mode/HomeDeviceCheck.wav"; break;
  4931. case SND.mode.INMODE_SETTING: FileName = "mode/InModeSetting.wav"; break;
  4932. case SND.mode.OUTMODE_SETTING: FileName = "mode/OutModeSetting.wav"; break;
  4933. case SND.mode.OUTMODE_SETTING_LOW: FileName = "mode/OutModeSetting_low.wav"; break;
  4934. case SND.mode.SENSOR_INVASION: FileName = "mode/SensorInvasion.wav"; break;
  4935. case SND.mode.SENSORMOTION_RELEASE: FileName = "mode/SensorMotion_Release.wav"; break;
  4936. case SND.mode.START_2_MONO: FileName = "mode/start_2_mono.wav"; break;
  4937. case SND.mode.VISITOR_OUTMODERUN: FileName = "mode/Visitor_OutModeRun.wav"; break;
  4938. case SND.mode.CAR_ARRIVED: FileName = "mode/ArrivedCar.wav"; break;
  4939. case SND.mode.BOX_ARRIVED: FileName = "mode/BoxArrived.wav"; break;
  4940. case SND.mode.OPENDOOR: FileName = "mode/OpenDoor.wav"; break;
  4941. // [ars_ment]
  4942. case SND.ars_ment.ARS1_1: FileName = "ars_ment/ARS1_1.wav"; break;
  4943. case SND.ars_ment.ARS1_2: FileName = "ars_ment/ARS1_2.wav"; break;
  4944. case SND.ars_ment.ARS1_3: FileName = "ars_ment/ARS1_3.wav"; break;
  4945. case SND.ars_ment.ARS1_4: FileName = "ars_ment/ARS1_4.wav"; break;
  4946. case SND.ars_ment.ARS2_3: FileName = "ars_ment/ARS2_3.wav"; break;
  4947. case SND.ars_ment.ARS2_3_NOLIGHT: FileName = "ars_ment/ARS2_3_NoLight.wav"; break;
  4948. case SND.ars_ment.ARS3_3: FileName = "ars_ment/ARS3_3.wav"; break;
  4949. case SND.ars_ment.ARS3_4: FileName = "ars_ment/ARS3_4.wav"; break;
  4950. case SND.ars_ment.ARS3_6: FileName = "ars_ment/ARS3_6.wav"; break;
  4951. case SND.ars_ment.ARS4_1: FileName = "ars_ment/ARS4_1.wav"; break;
  4952. case SND.ars_ment.ARS4_3: FileName = "ars_ment/ARS4_3.wav"; break;
  4953. case SND.ars_ment.ARS4_4: FileName = "ars_ment/ARS4_4.wav"; break;
  4954. case SND.ars_ment.ARS5_1: FileName = "ars_ment/ARS5_1.wav"; break;
  4955. case SND.ars_ment.ARS5_2: FileName = "ars_ment/ARS5_2.wav"; break;
  4956. case SND.ars_ment.ARS6_1: FileName = "ars_ment/ARS6_1.wav"; break;
  4957. case SND.ars_ment.ARS7_1: FileName = "ars_ment/ARS7_1.wav"; break;
  4958. case SND.ars_ment.ARS8_1: FileName = "ars_ment/ARS8_1.wav"; break;
  4959. case SND.ars_ment.ARS9_1: FileName = "ars_ment/ARS9_1.wav"; break;
  4960. case SND.ars_ment.ARS9_2: FileName = "ars_ment/ARS9_2.wav"; break;
  4961. // [lobby]
  4962. case SND.lobby.BELL_01: FileName = "lobby/bell_01.ogg"; break;
  4963. case SND.lobby.BELL_02: FileName = "lobby/bell_02.ogg"; break;
  4964. case SND.lobby.BELL_03: FileName = "lobby/bell_03.ogg"; break;
  4965. case SND.lobby.BELL_04: FileName = "lobby/bell_04.ogg"; break;
  4966. case SND.lobby.BELL_05: FileName = "lobby/bell_05.ogg"; break;
  4967. case SND.lobby.BELL_06: FileName = "lobby/bell_06.ogg"; break;
  4968. case SND.lobby.BOOTING: FileName = "lobby/booting.ogg"; break;
  4969. case SND.lobby.BUSYTRYLATER: FileName = "lobby/busytrylater.ogg"; break;
  4970. case SND.lobby.BUTTON: FileName = "lobby/button.ogg"; break;
  4971. case SND.lobby.CALLED: FileName = "lobby/callend.ogg"; break;
  4972. case SND.lobby.CALLSTART: FileName = "lobby/callstart.ogg"; break;
  4973. case SND.lobby.CONFIRMSETTING: FileName = "lobby/confirmsetting.ogg"; break;
  4974. case SND.lobby.DOOROPEN: FileName = "lobby/dooropen.ogg"; break;
  4975. case SND.lobby.INPUTFAIL: FileName = "lobby/inputfail.ogg"; break;
  4976. case SND.lobby.PACKAGEARRIVED: FileName = "lobby/packagearrived.ogg"; break;
  4977. case SND.lobby.RESULTOK: FileName = "lobby/resultok.ogg"; break;
  4978. case SND.lobby.RETRYINPUT: FileName = "lobby/retryinput.ogg"; break;
  4979. case SND.lobby.SETTING: FileName = "lobby/setting.ogg"; break;
  4980. case SND.lobby.TRYLATER: FileName = "lobby/trylater.ogg"; break;
  4981. // [guard]
  4982. case SND.guard.BELL_01: FileName = "guard/bell_01.ogg"; break;
  4983. case SND.guard.BELL_02: FileName = "guard/bell_02.ogg"; break;
  4984. case SND.guard.BELL_03: FileName = "guard/bell_03.ogg"; break;
  4985. case SND.guard.BELL_04: FileName = "guard/bell_04.ogg"; break;
  4986. case SND.guard.BELL_05: FileName = "guard/bell_05.ogg"; break;
  4987. case SND.guard.BELL_06: FileName = "guard/bell_06.ogg"; break;
  4988. case SND.guard.BOOTING: FileName = "guard/booting.ogg"; break;
  4989. case SND.guard.BREAK: FileName = "guard/break.ogg"; break;
  4990. case SND.guard.BUSYTRYLATER: FileName = "guard/busytrylater.ogg"; break;
  4991. case SND.guard.BUTTON: FileName = "guard/button.ogg"; break;
  4992. case SND.guard.CALLEND: FileName = "guard/callend.ogg"; break;
  4993. case SND.guard.CALLRECEIVED: FileName = "guard/callreceived.ogg"; break;
  4994. case SND.guard.CALLSTART: FileName = "guard/callstart.ogg"; break;
  4995. case SND.guard.CONFIRMSETTING: FileName = "guard/confirmsetting.ogg"; break;
  4996. case SND.guard.DOOROPEN: FileName = "guard/dooropen.ogg"; break;
  4997. case SND.guard.EMER_COM: FileName = "guard/emer_com.ogg"; break;
  4998. case SND.guard.EMERGENCY: FileName = "guard/emergency.ogg"; break;
  4999. case SND.guard.FIRE: FileName = "guard/fire.ogg"; break;
  5000. case SND.guard.GAS: FileName = "guard/gas.ogg"; break;
  5001. case SND.guard.INPUTFAIL: FileName = "guard/inputfail.ogg"; break;
  5002. case SND.guard.PACKAGEARRIVED: FileName = "guard/packagearrived.ogg"; break;
  5003. case SND.guard.RELEASE: FileName = "guard/release.ogg"; break;
  5004. case SND.guard.RESULTOK: FileName = "guard/resultok.ogg"; break;
  5005. case SND.guard.RETRYINPUT: FileName = "guard/retryinput.ogg"; break;
  5006. case SND.guard.SETTING: FileName = "guard/setting.ogg"; break;
  5007. case SND.guard.TRYLATER: FileName = "guard/trylater.ogg"; break;
  5008. case SND.guard.NOSOUND: FileName = "guard/no_sound.ogg"; break;
  5009. default:
  5010. Log.e(TAG, "[Error] getFileName - Index Not Found!!! (" + index + ")");
  5011. break;
  5012. }
  5013. if (FileName == null) return null;
  5014. Log.e(TAG, "[getFileName] Filepath (" + SOUND_PATH_ROOT + FileName + ")");
  5015. return (String)(SOUND_PATH_ROOT + FileName);
  5016. }
  5017. /**
  5018. * 사운드 출력할 볼륨 레벨을 정의한다.
  5019. */
  5020. public static final class VOLUME_KIND {
  5021. /**
  5022. * 안드로이드에서 제공하는 기본 볼륨 음량 테이블을 정의한다.
  5023. */
  5024. public static final class stream {
  5025. /**
  5026. * 알람 음량
  5027. */
  5028. public final static int ALARM = AudioManager.STREAM_ALARM;
  5029. /**
  5030. * DTMP 출력시 음량
  5031. */
  5032. public final static int DTMF = AudioManager.STREAM_DTMF;
  5033. /**
  5034. * 음악, 동영상, 게임 및 기타 미디어 재생 음량
  5035. */
  5036. public final static int MUSIC = AudioManager.STREAM_MUSIC;
  5037. /**
  5038. * 알림 음량
  5039. */
  5040. public final static int NOTIFICATION = AudioManager.STREAM_NOTIFICATION;
  5041. /**
  5042. * 벨소리 음량
  5043. */
  5044. public final static int RING = AudioManager.STREAM_RING;
  5045. /**
  5046. * 시스템 음량
  5047. */
  5048. public final static int SYSTEM = AudioManager.STREAM_SYSTEM;
  5049. /**
  5050. * 통화 대기음 음량
  5051. */
  5052. public final static int VOICE_CALL = AudioManager.STREAM_VOICE_CALL;
  5053. }
  5054. /**
  5055. * 고정된 볼륨을 정의한다. ( MUTE포함 총 15단계)
  5056. */
  5057. public static final class fixed {
  5058. /**
  5059. * BASE 상수 (※ 사용하지 않는다. MUTE와 동일)
  5060. */
  5061. public final static int BASE = 100;
  5062. /**
  5063. * MUTE
  5064. */
  5065. public final static int MUTE = BASE + 0;
  5066. public final static int LEV0 = BASE + 0;
  5067. public final static int LEV1 = BASE + 1;
  5068. public final static int LEV2 = BASE + 2;
  5069. public final static int LEV3 = BASE + 3;
  5070. public final static int LEV4 = BASE + 4;
  5071. public final static int LEV5 = BASE + 5;
  5072. public final static int LEV6 = BASE + 6;
  5073. public final static int LEV7 = BASE + 7;
  5074. public final static int LEV8 = BASE + 8;
  5075. public final static int LEV9 = BASE + 9;
  5076. public final static int LEV10 = BASE + 10;
  5077. public final static int LEV11 = BASE + 11;
  5078. public final static int LEV12 = BASE + 12;
  5079. public final static int LEV13 = BASE + 13;
  5080. public final static int LEV14 = BASE + 14;
  5081. public final static int LEV15 = BASE + 15;
  5082. /**
  5083. * MAX
  5084. */
  5085. public final static int MAX = LEV15;
  5086. }
  5087. }
  5088. /**
  5089. * VOLUME_KIND 값에서 Play 시 사용할 Volume 값을 가져온다. <br>
  5090. *
  5091. * @param volume_kind - 재생시킬 볼륨 ({@link VOLUME_KIND} 참조)
  5092. *
  5093. * @return -1 : volume_kind Out of range , 0f ~ 1f : Play 용 볼륨값
  5094. */
  5095. private static float getPlayVolume(int volume_kind) {
  5096. if (mAudioManager == null) return -1;
  5097. // 1. 범위체크
  5098. int streamNfixed = -1; // 1 : stream , 2 : fixed
  5099. switch (volume_kind) {
  5100. case VOLUME_KIND.stream.ALARM:
  5101. case VOLUME_KIND.stream.DTMF:
  5102. case VOLUME_KIND.stream.MUSIC:
  5103. case VOLUME_KIND.stream.NOTIFICATION:
  5104. case VOLUME_KIND.stream.RING:
  5105. case VOLUME_KIND.stream.SYSTEM:
  5106. case VOLUME_KIND.stream.VOICE_CALL:
  5107. streamNfixed = 1;
  5108. break;
  5109. default:
  5110. if ((volume_kind >= VOLUME_KIND.fixed.LEV0) && (volume_kind <= VOLUME_KIND.fixed.LEV15)) {
  5111. streamNfixed = 2;
  5112. }
  5113. break;
  5114. }
  5115. if (streamNfixed == -1) {
  5116. Log.e(TAG, "[getVolume] Parameters - volume_kind Out of range !!! (" + volume_kind + ")");
  5117. return -1;
  5118. }
  5119. // 2. 볼륨값 계산
  5120. float calcVolume = -1;
  5121. if (streamNfixed == 1) {
  5122. float nowVolume = (float)mAudioManager.getStreamVolume(volume_kind);
  5123. float maxVolume = (float)mAudioManager.getStreamMaxVolume(volume_kind);
  5124. calcVolume = nowVolume / maxVolume;
  5125. //Log.d(TAG, "[getVolume] kind=stream(" + volume_kind + ")" + " nowVolume : " + nowVolume + " / maxVolume : " + maxVolume + " / calcVolume : " + calcVolume);
  5126. }
  5127. else if (streamNfixed == 2) {
  5128. float fixedVolume = (float) volume_kind - VOLUME_KIND.fixed.BASE;
  5129. float maxVolume = (float) VOLUME_KIND.fixed.MAX - VOLUME_KIND.fixed.BASE;
  5130. calcVolume = fixedVolume / maxVolume;
  5131. //Log.d(TAG, "[getVolume] kind=fixed(" + volume_kind + ")" + " fixedVolume : " + fixedVolume + " / maxVolume : " + maxVolume + " / calcVolume : " + calcVolume);
  5132. }
  5133. return calcVolume;
  5134. }
  5135. public void sendSoundPlayRequestBR(int nSoundID) {
  5136. try {
  5137. Intent intent = new Intent();
  5138. intent.setAction(define.NOTIFY_ACNAME);
  5139. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_PLAYMENT);
  5140. intent.putExtra(define.NOTIBR_CONTENT, nSoundID);
  5141. getContext().sendBroadcast(intent);
  5142. } catch (RuntimeException re) {
  5143. LogUtil.errorLogInfo("", TAG, re);
  5144. } catch (Exception e) {
  5145. Log.e(TAG, "[Exception] sendSoundPlayRequestBR(int nSoundID)");
  5146. //e.printStackTrace();
  5147. LogUtil.errorLogInfo("", TAG, e);
  5148. }
  5149. }
  5150. public void setEncodingStopError() {
  5151. try {
  5152. LOG("[setEncodingStopError]");
  5153. WallpadStatusData data = new WallpadStatusData(mContext);
  5154. data.SetCameraEncodingError(true);
  5155. data.closeDB();
  5156. } catch (RuntimeException re) {
  5157. LogUtil.errorLogInfo("", TAG, re);
  5158. } catch (Exception e) {
  5159. Log.e(TAG, "[Exception] setEncodingStopError()");
  5160. //e.printStackTrace();
  5161. LogUtil.errorLogInfo("", TAG, e);
  5162. }
  5163. }
  5164. public void checkEncodingStopError() {
  5165. try {
  5166. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  5167. boolean bError = DBMGR.GetCameraEncodingError();
  5168. LOG("[checkEncodingStopError] bError [" + bError + "]");
  5169. if (bError) {
  5170. if (mCallController.mVideoJNI != null) {
  5171. LOG_WARN("[checkEncodingStopError] mCallController.mVideoJNI.encoderStopOperation()");
  5172. mCallController.mVideoJNI.encoderStopOperation();
  5173. }
  5174. DBMGR.SetCameraEncodingError(false);
  5175. LOG("[checkEncodingStopError] GetCameraEncodingError [" + DBMGR.GetCameraEncodingError() + "]");
  5176. }
  5177. DBMGR.closeDB();
  5178. } catch (RuntimeException re) {
  5179. LogUtil.errorLogInfo("", TAG, re);
  5180. } catch (Exception e) {
  5181. Log.e(TAG, "[Exception] checkEncodingStopError()");
  5182. //e.printStackTrace();
  5183. LogUtil.errorLogInfo("", TAG, e);
  5184. }
  5185. }
  5186. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  5187. private void getResidentSafetyCheckSetting() {
  5188. try {
  5189. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  5190. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  5191. mWallpadDeviceSet.closeDB();
  5192. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  5193. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) Version.setResidentSafety();
  5194. else Version.unsetResidentSafety();
  5195. } catch (RuntimeException re) {
  5196. LogUtil.errorLogInfo("", TAG, re);
  5197. } catch (Exception e) {
  5198. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  5199. //e.printStackTrace();
  5200. LogUtil.errorLogInfo("", TAG, e);
  5201. }
  5202. }
  5203. }