MainActivity.java 273 KB

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