MainActivity.java 276 KB

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