MainActivity.java 503 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193
  1. package kr.co.icontrols.wallpadmain;
  2. import android.annotation.SuppressLint;
  3. import android.app.Activity;
  4. import android.app.ActivityManager;
  5. import android.app.ActivityManager.RunningTaskInfo;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.ServiceConnection;
  12. import android.content.SharedPreferences;
  13. import android.content.pm.PackageInfo;
  14. import android.content.pm.PackageManager;
  15. import android.database.SQLException;
  16. import android.graphics.Color;
  17. import android.hardware.Camera;
  18. import android.media.AudioManager;
  19. import android.media.MediaRecorder;
  20. import android.net.Uri;
  21. import android.net.ethernet.EthernetDevInfo;
  22. import android.net.ethernet.EthernetManager;
  23. import android.os.Build;
  24. import android.os.Bundle;
  25. import android.os.CountDownTimer;
  26. import android.os.Handler;
  27. import android.os.IBinder;
  28. import android.os.Looper;
  29. import android.os.Message;
  30. import android.os.Messenger;
  31. import android.os.PowerManager;
  32. import android.os.RemoteException;
  33. import android.provider.Settings;
  34. import android.util.Log;
  35. import android.view.KeyEvent;
  36. import android.view.MotionEvent;
  37. import android.view.SurfaceHolder;
  38. import android.view.SurfaceView;
  39. import android.view.View;
  40. import android.view.WindowManager;
  41. import android.view.animation.Animation;
  42. import android.view.animation.AnimationUtils;
  43. import android.widget.Button;
  44. import android.widget.ImageView;
  45. import android.widget.RelativeLayout;
  46. import android.widget.TextView;
  47. import android.widget.ViewFlipper;
  48. import com.artncore.WallPadDataMgr.WallpadCallHistoryData;
  49. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  50. import com.artncore.WallPadDataMgr.WallpadParkInfo;
  51. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  52. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  53. import com.artncore.WallPadDataMgr.WallpadStatusData;
  54. import com.artncore.WallPadDataMgr.WallpadVisitorPicData_A20;
  55. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  56. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  57. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSetBackup;
  58. import com.artncore.commons.APIErrorCode;
  59. import com.artncore.commons.DataClasses.CarParkingData;
  60. import com.artncore.commons.define;
  61. import com.artncore.deviceinterface.WallPadInterface;
  62. import com.artncore.wallpadapi.IntLightAPI;
  63. import com.artncore.wallpadapi.LightAPI;
  64. import com.artncore.wallpadapi.MultiSwitchAPI;
  65. import com.artncore.wallpadapi.SdbAPI;
  66. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  67. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  68. import com.artncore.wallpadapi.WallPadAPI;
  69. import com.artncore.wallpadimap.RetProci;
  70. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  71. import com.bumptech.glide.Glide;
  72. import com.bumptech.glide.load.engine.DiskCacheStrategy;
  73. import com.google.gson.Gson;
  74. import com.util.LogUtil;
  75. import com.icontrols.service.control.ILightControlService;
  76. import org.json.JSONException;
  77. import org.json.JSONObject;
  78. import java.io.BufferedReader;
  79. import java.io.BufferedWriter;
  80. import java.io.File;
  81. import java.io.FileInputStream;
  82. import java.io.FileOutputStream;
  83. import java.io.IOException;
  84. import java.io.InputStream;
  85. import java.io.InputStreamReader;
  86. import java.io.ObjectInputStream;
  87. import java.io.ObjectOutputStream;
  88. import java.io.OutputStream;
  89. import java.io.OutputStreamWriter;
  90. import java.net.InetAddress;
  91. import java.net.InetSocketAddress;
  92. import java.net.NetworkInterface;
  93. import java.net.Socket;
  94. import java.sql.Timestamp;
  95. import java.text.SimpleDateFormat;
  96. import java.util.ArrayList;
  97. import java.util.Calendar;
  98. import java.util.Collections;
  99. import java.util.Date;
  100. import java.util.GregorianCalendar;
  101. import java.util.List;
  102. import java.util.regex.Pattern;
  103. import kr.co.icontrols.data.ResultData;
  104. import kr.co.icontrols.v40ioctl.V40IOInterface;
  105. import kr.co.icontrols.wallpadmain.declare.Common;
  106. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  107. import kr.co.icontrols.wallpadmain.declare.DataClasses.IconInfoTable;
  108. import kr.co.icontrols.wallpadmain.declare.ID;
  109. import kr.co.icontrols.wallpadmain.declare.ID_OLD;
  110. import kr.co.icontrols.wallpadmain.declare.LayoutDevice;
  111. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation;
  112. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking;
  113. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking_UPIS;
  114. import kr.co.icontrols.wallpadmain.imap.iMAPElecCarChargingInfo;
  115. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyMeter;
  116. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyModule;
  117. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_Realmeter;
  118. import kr.co.icontrols.wallpadmain.imap.iMAPRemotemeter;
  119. import kr.co.icontrols.wallpadmain.menu.CallSubMenuScreen;
  120. import kr.co.icontrols.wallpadmain.screen.EASYUI_MAIN;
  121. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HA;
  122. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HN;
  123. import kr.co.icontrols.wallpadmain.screen.MAIN;
  124. import kr.co.icontrols.wallpadmain.screen.METROUI_MAIN;
  125. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_01;
  126. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_02;
  127. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_GROUP;
  128. import kr.co.icontrols.wallpadmain.screen.SUB_01;
  129. import kr.co.icontrols.wallpadmain.screen.SUB_02;
  130. import kr.co.icontrols.wallpadmain.util.EnergyAlramPopupMgr;
  131. import kr.co.icontrols.wallpadmain.util.IconManager;
  132. import kr.co.icontrols.wallpadmain.util.MobileProcService;
  133. import kr.co.icontrols.wallpadmain.util.StringUtil;
  134. import kr.co.icontrols.wallpadmain.util.iMapServer;
  135. import kr.co.icontrols.wallpadsupport.Version;
  136. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  137. import kr.co.icontrols.wallpadsupport.WpadActivity;
  138. import kr.co.icontrols.wallpadsupport.WpadRelativeLayoutParams;
  139. import kr.co.icontrols.wallpadsupport.WpadScale;
  140. import kr.co.icontrols.wallpadsupport.WpadSound;
  141. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  142. import kr.co.icontrols.wallpadsupport.WpadUtil;
  143. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_STATE;
  144. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_DETAIL_INFO;
  145. import static android.content.Intent.ACTION_TIME_TICK;
  146. import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
  147. import static com.artncore.commons.define.ALBUM_PICTURE_LOCATION;
  148. import static com.artncore.commons.define.BESTIN_LOCATION;
  149. /**
  150. * @description
  151. * 월패드 [설정기능] 메인화면 이다.<br>
  152. * 상단의 Top 메뉴, [홈] [돌아가기]<br>
  153. * 좌측의 Tab 메뉴, [조명] [난방] [가스] ... 등 선택 메뉴<br>
  154. * 를 여기서 처리한다.
  155. */
  156. public class MainActivity extends WpadActivity {
  157. private final static String TAG = "MainActivity";
  158. private void DebugLogOutput(String s) { if(Common.DEBUG_LOG_ON) Log.d(TAG, s); }
  159. // =================================================================================================
  160. // [[ Declaration ]] region
  161. // =================================================================================================
  162. protected Context mContext = null;
  163. public Context getContext() { return mContext; }
  164. private WallPadAPI mWallPadAPI = null;
  165. public static IOInterface mIOInterface = null;
  166. private int DEVICE_OPERATION_MODE = Common.MODE;
  167. boolean bEasyModeUsage = false;
  168. public static boolean bGoodDesign2020 = false;
  169. // Layout
  170. private RelativeLayout MainLayout; // 메인화면
  171. private RelativeLayout MainScreenLayout;
  172. private RelativeLayout SubLayout_01; // 서브 01 화면
  173. private RelativeLayout SubScreenLayout_01;
  174. private RelativeLayout SubLayout_02; // 서브 02 화면
  175. private RelativeLayout SubScreenLayout_02;
  176. private RelativeLayout EasyMainLayout; // 간편모드 메인화면
  177. private RelativeLayout EasyMainScreenLayout;
  178. private ViewFlipper mViewFlipper;
  179. Animation aniSlideIn, aniSlideOut;
  180. public static ImageView IMG_LCD_KEEPER;
  181. // PopupActivityRun
  182. private static boolean PopupActivityRun = false;
  183. public static boolean getPopupActivityRun() { return PopupActivityRun; }
  184. public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; }
  185. // InfoActivityRun
  186. private static boolean InfoActivityRun = false;
  187. public static boolean getInfoActivityRun() {
  188. Log.d(TAG, "[getInfoActivityRun] InfoActivityRun: " + InfoActivityRun);
  189. return InfoActivityRun;
  190. }
  191. public static void setInfoActivityRun(boolean run) {
  192. InfoActivityRun = run;
  193. if (!InfoActivityRun) resetCurrentInfoScreenID();
  194. }
  195. // Menu & TabData
  196. private Menu mMenu = null;
  197. // private TabData mTabData = null;
  198. // CurrentScreenId
  199. private int mCurrentScreenId = -1;
  200. private int mTempCurrentScreenId = -1;
  201. private static int mCurrentInfoScreenId = -1;
  202. // Screen
  203. private MAIN MainScreen = null;
  204. private SUB_01 SUB_01Screen = null;
  205. private SUB_02 SUB_02Screen = null;
  206. private METROUI_MAIN MetroUI_MainScreen = null;
  207. private METROUI_SUB_01 MetroUI_SUB_01Screen = null;
  208. private METROUI_SUB_02 MetroUI_SUB_02Screen = null;
  209. private METROUI_SUB_GROUP MetroUI_SUB_GroupScreen = null;
  210. private HYOSUNGUI_MAIN_HN Hyosung_HN_MainScreen = null;
  211. private HYOSUNGUI_MAIN_HA Hyosung_HA_MainScreen = null;
  212. private EASYUI_MAIN EasyUI_MainScreen = null;
  213. // 메뉴 리스트 처리 및 서브 스크린 호출
  214. public CallSubMenuScreen m_CallSubMenuScreen = null;
  215. ///////////////////////////// AnC 메인어플에서 사용되는 변수 모음
  216. int LastTimeSync = 0;
  217. boolean HomeCTROn = true;
  218. //int PSTNStatus = 0;
  219. int MAINStatus = 0;
  220. public static final int MAIN_NORMAL = 0;
  221. public static final int MAIN_WAIT_SETIP = 1;
  222. static boolean Alert_App_On = false;
  223. byte bootupretryCNT = 0;
  224. static final int MAX_BOOTUP_RETRY_COUNT = 1200;
  225. ScheduleManager SCManager;
  226. boolean SYSTEM_TIME_SET = false;
  227. static boolean CALLSVCSTARTED = false;
  228. public Thread mThread_getAppsVersion = null;
  229. ///////////////////////////// end
  230. // 거실조명 제어드라이버
  231. private IntLightAPI mIntLightAPI = null;
  232. // 에너지미터 제어드라이버
  233. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null;
  234. private SdbAPI mSdbAPI = null;
  235. // 멀티스위치 제어 드라이버
  236. private MultiSwitchAPI m_MultiSwitch = null;
  237. // 대외향 거실 스위치 드라이버
  238. private LightAPI m_LightCtrl = null;
  239. private boolean m_ModelHouseSleepModeRelease = false;
  240. // 거동수상자 녹화 관련 변수
  241. private ImageView IMG_NOTICE_STRANGER_RECORD;
  242. private TextView TXT_NOTICE_STRANGER_RECORD;
  243. private Button BTN_STRANGER_RECORD_VIEW, BTN_STRANGER_RECORD_CANCEL;
  244. private int RECORD_TIME = 0;
  245. private CountDownTimer mRecordTimer;
  246. private int mCurRecordTime = 0;
  247. public static boolean bRecordStatus = false; // 거동수상자 녹화중 판별 플래그
  248. private final String VIDEO_TEMP_PATH = define.BESTIN_LOCATION + "VisitorVideo.mp4";
  249. private final String VISITOR_VIDEO_PATH = define.VISITOR_VIDEO_LOCATION;
  250. private final String VISITOR_VIDEO_TEMP_PATH = define.VISITOR_VIDEO_LOCATION + "temp/";
  251. private final static int VISITOR_VIDEO_MAX_COUNT = 20; // 방문자영상 최대 개수
  252. private MediaRecorder mMediaRecorder;
  253. public static boolean bRecordDelay = false; // 거동수상자 녹화 후 일정시간 녹화 막음 플래그
  254. Handler recordDelayHandler = new Handler() {
  255. @Override
  256. public void handleMessage(Message msg) {
  257. bRecordDelay = false;
  258. }
  259. };
  260. //주차정보 관련 변수
  261. public static boolean bUseofNot_ParkingInfo = false;
  262. public static int nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  263. private String ParkingServerIP = null;
  264. private int ParkingServerPort = 10000;
  265. private int cGetParkingMin = 18;
  266. private boolean bSetMSG_GetParkingInfo = false;
  267. iMAPCarParking iMAPcarParking;
  268. iMAPCarParking_UPIS iMapcarParking_UPIS;
  269. //일정 알림 관련 변수
  270. private int AlarmScheduleCount = 0;
  271. private String AlarmScheduleString = null;
  272. private boolean bAlarmScheduleString = false;
  273. //전기차 충전 관련 변수
  274. iMAPElecCarChargingInfo imapElecCarChargingInfo;
  275. //제로 에너지 하우스 관련 변수
  276. private boolean bUseofNot_ZeroEnergyHouseInfo = false;
  277. private int cGetZeroEnergyHouseMin = 12;
  278. iMAPEnergyServer_Realmeter iMAPenergyServer_Realmeter;
  279. iMAPEnergyServer_EnergyMeter iMAPenergyServer_EnergyMeter;
  280. iMAPEnergyServer_EnergyModule iMAPenergyServer_EnergyModule;
  281. String DayofLastSecond = "2000-01-01 00:00:00";
  282. boolean DayofLastBoolean = false;
  283. //에너지관리서버 관련 변수
  284. private boolean bUseofNot_EnergyServer = false;
  285. //에너지 알람 발생 관련 변수
  286. private boolean bUseofNot_EnergyAlarm = false;
  287. private boolean ResultGetIntent = false;
  288. private String elect_target = "Error";
  289. private String elect_used = "Error";
  290. private String elect_info = "Error";
  291. private String water_target = "Error";
  292. private String water_used = "Error";
  293. private String water_info = "Error";
  294. private String gas_target = "Error";
  295. private String gas_used = "Error";
  296. private String gas_info = "Error";
  297. private String hotwater_target = "Error";
  298. private String hotwater_used = "Error";
  299. private String hotwater_info = "Error";
  300. private String heating_target = "Error";
  301. private String heating_used = "Error";
  302. private String heating_info = "Error";
  303. /**
  304. * 월패드 이벤트 알림 관련 변수
  305. */
  306. // 스마트 우편, 전기차 충전 사용 여부
  307. public static boolean bSmartPostUsage = false, bElecVehicleUsage = false;
  308. // 부재중 전화, 방문객 사진, 공지사항, 택배, 스마트 우편, 전기차 충전 이벤트 개수
  309. public static int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0, nElecVehicleChangingCnt = 0;
  310. // 끝
  311. IconManager mIconManager;
  312. public IconInfoTable mIconInfoTable;
  313. public static int nShortcutCnt = 0;
  314. public static int nShortcutMax = 12;
  315. public static int nShortcutCnt_HS = 0;
  316. public static int nShortcutMax_HS = 9;
  317. public static int nShortcutCnt_Metro = 0;
  318. public static int nShortcutMax_Metro = 3;
  319. int nIconsOnSubScreen = 24;
  320. public static List<WallpadStatusData.WidgetItem> MainScreenShortcutList;
  321. public static List<WallpadStatusData.WidgetItem> HSScreenShortcutList;
  322. public static List<WallpadStatusData.WidgetItem> MetroScreenShortcutList;
  323. // 조명상태를 관리하기 위한 클래스
  324. public static class LightInfo {
  325. public class Preset {
  326. public class Lights {
  327. public String ONOFF = "none";
  328. public int DIM = 0;
  329. public int COLOR = 0;
  330. public Lights() {
  331. ONOFF = "none";
  332. DIM = 0;
  333. COLOR = 0;
  334. }
  335. }
  336. public Lights[] mLights;
  337. public Preset() {
  338. mLights = new Lights[9]; // 0번지는 프리셋별 그룹제어 설정값 (조명 1~8)
  339. for (int i = 0; i < mLights.length; i++) {
  340. mLights[i] = new Lights();
  341. }
  342. }
  343. }
  344. public Preset[] mPreset;
  345. public int nLightPresetNo;
  346. public LightInfo() {
  347. mPreset = new Preset[9]; // 0번지는 전체제어 설정값 (프리셋 1~8)
  348. for (int i = 0; i < mPreset.length; i++) {
  349. mPreset[i] = new Preset();
  350. }
  351. nLightPresetNo = 0;
  352. }
  353. }
  354. public static LightInfo mLightInfo;
  355. public String BR_CTRL_LIGHT_LIVINGROOM = "kr.co.icontrols.wallpadglobalscreen.BR_CTRL_LIGHT_LIVINGROOM";
  356. public static WpadSound mSound;
  357. public void getLivinglightPreset() {
  358. try {
  359. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  360. String[] strEntireValue = mWallpadStatusData.getLivinglightModeCtrlEntireValue();
  361. mWallpadStatusData.closeDB();
  362. Log.i(TAG, "[getLivinglightPreset] strEntireValue.length = " + strEntireValue.length);
  363. for (int i = 0; i < strEntireValue.length; i++) {
  364. Log.i(TAG, "[getLivinglightPreset] strEntireValue[" + i + "] = " + strEntireValue[i]);
  365. }
  366. } catch (RuntimeException re) {
  367. LogUtil.errorLogInfo("", TAG, re);
  368. }
  369. catch (Exception e) {
  370. Log.e(TAG, "[Exception] getLivinglightPreset()");
  371. LogUtil.errorLogInfo("", TAG, e);
  372. }
  373. }
  374. public void initLivinglightPreset() {
  375. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  376. try {
  377. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  378. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  379. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  380. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-D101");
  381. for (int i = 1; i < 5; i++) {
  382. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  383. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  384. String[] strParse = strPreset.split(":");
  385. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  386. if (i == 1) {
  387. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  388. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  389. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  390. }
  391. else if (i == 2) {
  392. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  393. mLightInfo.mPreset[i].mLights[0].DIM = 3;
  394. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  395. }
  396. else if (i == 3) {
  397. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  398. mLightInfo.mPreset[i].mLights[0].DIM = 1;
  399. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  400. }
  401. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  402. }
  403. else {
  404. mLightInfo.mPreset[i].mLights[0].ONOFF = strParse[0];
  405. mLightInfo.mPreset[i].mLights[0].DIM = Integer.parseInt(strParse[1]);
  406. mLightInfo.mPreset[i].mLights[0].COLOR = Integer.parseInt(strParse[2]);
  407. }
  408. }
  409. }
  410. else if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  411. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-1010(-I)");
  412. if (getKCCDimmingCtrl()) {
  413. for (int i = 1; i < 5; i++) {
  414. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  415. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  416. String[] strParse = strPreset.split(":");
  417. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  418. if (i == 1) {
  419. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  420. mLightInfo.mPreset[i].mLights[0].DIM = 10;
  421. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  422. }
  423. else if (i == 2) {
  424. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  425. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  426. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  427. }
  428. else if (i == 3) {
  429. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  430. mLightInfo.mPreset[i].mLights[0].DIM = 5;
  431. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  432. }
  433. else if (i == 4) {
  434. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  435. mLightInfo.mPreset[i].mLights[0].DIM = 2;
  436. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  437. }
  438. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  439. }
  440. else {
  441. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  442. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].ONOFF);
  443. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].DIM);
  444. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].COLOR);
  445. }
  446. }
  447. }
  448. }
  449. } catch (RuntimeException re) {
  450. LogUtil.errorLogInfo("", TAG, re);
  451. }
  452. catch (Exception e) {
  453. Log.e(TAG, "[Exception] initLivinglightPreset()");
  454. LogUtil.errorLogInfo("", TAG, e);
  455. }
  456. mWallpadStatusData.closeDB();
  457. }
  458. private boolean getKCCDimmingCtrl() {
  459. try {
  460. Log.i(TAG, "[getKCCDimmingCtrl] ========== START ==========");
  461. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  462. int nEnable = mWallpadDeviceSet.GetDeviceSetted("KCC디밍제어기");
  463. mWallpadDeviceSet.closeDB();
  464. Log.i(TAG, "[getKCCDimmingCtrl] nEnable [" + nEnable + "]");
  465. if (nEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  466. Log.i(TAG, "[getKCCDimmingCtrl] Enabled");
  467. return true;
  468. }
  469. else {
  470. Log.i(TAG, "[getKCCDimmingCtrl] Disabled");
  471. return false;
  472. }
  473. } catch (RuntimeException re) {
  474. LogUtil.errorLogInfo("", TAG, re);
  475. return false;
  476. }
  477. catch (Exception e) {
  478. Log.e(TAG, "[Exception] setKCCDimmingCtrl()");
  479. LogUtil.errorLogInfo("", TAG, e);
  480. return false;
  481. }
  482. }
  483. private void initEscapeLadderDownSend() {
  484. try {
  485. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  486. if(deviceSet!=null)
  487. {
  488. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  489. boolean ladderDownRecv = deviceSet.GetEscapeLadderDownRecv(); // 기존 '피난사다리입하수신' 설정정보 (더이상 사용하지 않음 2021.01.28)\
  490. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownRecv [" + ladderDownRecv + "]");
  491. if (ladderDownRecv) {
  492. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_NONE) {
  493. Log.d(TAG, "[initEscapeLadderDownSend] ===== first setting =====");
  494. deviceSet.setEscapeLadderDownSend(WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER); // 신규 /'피난사다리전송' 설정정보 '윗집'
  495. } else {
  496. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownSend [" + ladderDownSend + "]");
  497. }
  498. }
  499. deviceSet.closeDB();
  500. }
  501. } catch (RuntimeException re) {
  502. LogUtil.errorLogInfo("", TAG, re);
  503. } catch (Exception e) {
  504. Log.e(TAG, "[Exception] initEscapeLadderDownSend()");
  505. LogUtil.errorLogInfo("", TAG, e);
  506. }
  507. }
  508. public void CallSubMenuScreen(int screenID) {
  509. if (screenID >= ID.LINKEDSCREEN.SubMenuAddService.Notice && screenID <= ID.LINKEDSCREEN.SubMenuAddService.ElecCar) m_CallSubMenuScreen.callStartAddServiceAPK(screenID);
  510. else if (screenID >= ID.LINKEDSCREEN.SubMenuEnergy.RealTimeCheckMeter && screenID <= ID.LINKEDSCREEN.SubMenuEnergy.IEnergy) m_CallSubMenuScreen.callStartEnergyAPK(screenID);
  511. }
  512. private void restoreSystemVolume() {
  513. try {
  514. String strCurrentTopPackage = getTopActivity();
  515. Log.i(TAG, "[restoreSystemVolume] strCurrentTopPackage = " + strCurrentTopPackage);
  516. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  517. int nSavedVolume = wdb.GetWallPadMasterVolume();
  518. wdb.closeDB();
  519. final AudioManager audioManager = (AudioManager)this.getContext().getSystemService(this.getContext().AUDIO_SERVICE);
  520. int nCurrentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  521. audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume , 0);
  522. Log.i(TAG, "[restoreSystemVolume] #Before# nCurrentVolume = " + nCurrentVolume + ", #After# nSavedVolume = " + nSavedVolume);
  523. } catch (RuntimeException re) {
  524. LogUtil.errorLogInfo("", TAG, re);
  525. }
  526. catch (Exception e) {
  527. Log.e(TAG, "[Exception] restoreSystemVolume()");
  528. LogUtil.errorLogInfo("", TAG, e);
  529. }
  530. }
  531. // =================================================================================================
  532. // [[ Activity Life Cycle ]] region
  533. // =================================================================================================
  534. /**
  535. * Activity Constructors
  536. */
  537. @Override
  538. protected void onCreate(Bundle savedInstanceState) {
  539. super.onCreate(savedInstanceState);
  540. Log.i(TAG, "[onCreate] ========== START ==========");
  541. Log.w(TAG, "[onCreate] Start to check booting status!!!");
  542. Runtime mRuntime = Runtime.getRuntime();
  543. Process mProcess;
  544. int iDelayCount = 0;
  545. while (true) {
  546. try {
  547. String cmd = "getprop dev.bootcomplete";
  548. mProcess = mRuntime.exec(cmd);
  549. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  550. String line;
  551. String strResult = null;
  552. while ((line = br.readLine()) != null) {
  553. strResult = line;
  554. }
  555. if (strResult!=null && strResult.equals("1")) {
  556. File sdcard = new File("/storage/emulated/0");
  557. if(sdcard.exists() == true) {
  558. iDelayCount = 0;
  559. Thread.sleep(1000);
  560. break;
  561. }
  562. }
  563. {
  564. iDelayCount++;
  565. Thread.sleep(100);
  566. }
  567. if (iDelayCount > 400) {
  568. cmd = "setprop persist.sys.reboot 1";
  569. mProcess = mRuntime.exec(cmd);
  570. }
  571. } catch (RuntimeException re) {
  572. LogUtil.errorLogInfo("", TAG, re);
  573. }
  574. catch (Exception e) {
  575. Log.e(TAG, "[Exception] Checking device booting status -> Unable to execute top command");
  576. e.fillInStackTrace();
  577. LogUtil.errorLogInfo("", TAG, e);
  578. }
  579. }
  580. Log.w(TAG, "[onCreate] Device booting completed!!");
  581. Log.i(TAG, "[onCreate] Wallpad model name [" + Version.getModelType() + "]");
  582. if (Common.DIAGNOSTIC_MODE) {
  583. Log.i(TAG, "------------------ [START - DIAGNOSTIC_MODE] -------------------");
  584. setNetworkAddr( 2, 1, 3);
  585. }
  586. // @ AutoScale 설정 - 1.
  587. if (WpadScale.getWidthPixels() == 800 && WpadScale.getHeightPixels() == 480) {
  588. // 800x480 일 경우에만 AutoScale 을 설정한다.
  589. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  590. WpadScale.setAutoScale(true);
  591. }
  592. else if (WpadScale.getWidthPixels() == 1366 && WpadScale.getHeightPixels() == 768) {
  593. // 800x480 일 경우에만 AutoScale 을 설정한다.
  594. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  595. WpadScale.setAutoScale(true);
  596. WpadScale.changeAutoScaleValue(1024, 600);
  597. }
  598. // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
  599. if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600)) {
  600. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  601. }
  602. else if ((WpadScale.getWidthPixels() == 1280) && (WpadScale.getHeightPixels() == 800)) {
  603. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
  604. }
  605. else if ((WpadScale.getWidthPixels() == 800) && (WpadScale.getHeightPixels() == 480)) {
  606. Common.SCREEN_TYPE = Common.SCREEN_TYPE_800x480;
  607. }
  608. else if ((WpadScale.getWidthPixels() == 1366) && (WpadScale.getHeightPixels() == 768)) {
  609. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  610. }
  611. Log.d(TAG, "[onCreate] SCREEN_TYPE: " + Common.SCREEN_TYPE);
  612. super.setFinishBrEnable(false);
  613. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  614. LayoutDevice.InitGetScreenSize(this.getWindowManager(), getApplicationContext() );
  615. try {
  616. // 최초 DB 폴더가 생성되어 있지 않으면 폴더를 생성하도록 한다.
  617. File dbhome = new File(wallpaddbmgr.dblocation);
  618. Log.d(TAG, "[Create] - Step0.3 : dbhome path [" + dbhome.getPath() + "]");
  619. if (dbhome.exists() == false) {
  620. dbhome.mkdir();
  621. Log.d(TAG, "[Create] - Step0.3 : Make DB Folder");
  622. }
  623. else {
  624. Log.d(TAG, "[Create] - Step0.3 : DB exists");
  625. }
  626. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  627. if (mWallpadStatusData != null) {
  628. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open OK");
  629. mWallpadStatusData.closeDB();
  630. }
  631. else {
  632. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open FAIL");
  633. }
  634. } catch (RuntimeException re) {
  635. LogUtil.errorLogInfo("", TAG, re);
  636. }
  637. catch (Exception e) {
  638. LogUtil.errorLogInfo("", TAG, e);
  639. }
  640. DebugLogOutput("[Create] - Step0.5 : WallpadStatusData end");
  641. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  642. checkISSEnergyType();
  643. runDeviceService();
  644. if (Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  645. DebugLogOutput("[Create] This is the OCF WallPad!!!");
  646. runOcfService();
  647. }
  648. //vip
  649. runMultiControlService();
  650. WallpadStatusData dbMGR = new WallpadStatusData(this.getContext());
  651. wallpaddbmgr.AddressSet addrSet = dbMGR.getAddressMGR();
  652. dbMGR.closeDB();
  653. String strHo = addrSet.Ho;
  654. //Log.d("TEST1", "strHo " + strHo);
  655. if(!strHo.contains("NONE"))
  656. {
  657. myIP = addrSet.IPAddress;
  658. ho = Integer.valueOf(strHo.substring(0,1));
  659. }
  660. //vip
  661. // 1. 변수 초기화
  662. DebugLogOutput("[Create] - Step1 : EMData Create");
  663. PopupActivityRun = false;
  664. InfoActivityRun = false;
  665. mContext = this;
  666. setCallAppRunning(false); // 메인앱 초기화시 통화앱 미실행값을 DB에 저장
  667. // 2. 자동 종료 셋팅
  668. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  669. // 3. API 호출
  670. DebugLogOutput("[Create] - Step3 : API Call");
  671. // 3.1. mWallPadAPI 생성
  672. try {
  673. mWallPadAPI = new WallPadAPI(this);
  674. } catch (RuntimeException re) {
  675. LogUtil.errorLogInfo("", TAG, re);
  676. }
  677. catch (Exception e) {
  678. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  679. LogUtil.errorLogInfo("", TAG, e);
  680. }
  681. initIOInterface(mWallPadAPI);
  682. Common.CurrentBoardType = mIOInterface.getBoardType(Version.getModelType());
  683. mIOInterface.initCameraOnOFF();
  684. mIOInterface.getCameraOnOFF();
  685. DebugLogOutput("[Create] - Step3.5 : API Call end");
  686. if (Common.GetDeviceSampleMode(this)) {
  687. Log.d(TAG, "[Create] OperationMode = MODE_BUSINESS_SAMPLE");
  688. DEVICE_OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  689. }
  690. else {
  691. Log.d(TAG, "[Create] OperationMode = MODE_NOMAL");
  692. DEVICE_OPERATION_MODE = Common.MODE_NOMAL;
  693. }
  694. // 분전반 정보 가져오기
  695. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  696. Common.CurrentDistributionPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  697. mWallpadDeviceSet.closeDB();
  698. // 4. Layout registration
  699. DebugLogOutput("[Create] - Step4 : Layout registration");
  700. Common.eGUIType = checkGUIType(this.getContext());
  701. Log.i(TAG, "[Create] eGUIType = " + Common.eGUIType);
  702. mIconManager = new IconManager(mContext, mWallPadAPI);
  703. if (mIconManager == null) {
  704. Log.w(TAG, "[Create] mIconManager is null!!");
  705. }
  706. mIconInfoTable = mIconManager.getAvailableIcons();
  707. if (mIconInfoTable == null) {
  708. Log.w(TAG, "[Create] mIconInfoTable is null!!");
  709. }
  710. else {
  711. Log.i(TAG, "[Create] mIconInfoTable.getCnt() = " + mIconInfoTable.getCnt());
  712. }
  713. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  714. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  715. deviceSet.closeDB();
  716. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  717. if (!bSupport) {
  718. mWallpadStatusData.SetEasyModeUxUse(false);
  719. }
  720. bEasyModeUsage = bSupport & mWallpadStatusData.GetEasyModeUxUse();
  721. mWallpadStatusData.closeDB();
  722. // Sound API 등록
  723. mSound = new WpadSound(this);
  724. // 메인화면 레이아웃
  725. MainLayout = new RelativeLayout(this);
  726. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  727. MainLayout.setLayoutParams(params);
  728. MainLayout.setId(ID_OLD.main.layout.ALL);
  729. super.setAllLayoutRegistration(MainLayout);
  730. // 메인화면 스크린 레이아웃
  731. MainScreenLayout = new RelativeLayout(this);
  732. WpadUtil.LayoutRegistration(MainLayout, MainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  733. if (getWallPadCameraUsage() && (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT)) {
  734. Log.i(TAG, "[Create] SurfaceLayout Registration!!!");
  735. SurfaceLayout = new RelativeLayout(this);
  736. WpadUtil.LayoutRegistration(MainLayout, SurfaceLayout, WpadScale.getWidthPixels(), WpadScale.getWidthPixels(), 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  737. }
  738. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) nIconsOnSubScreen = 24;
  739. // else if (eGUIType == GUI_TYPE.METRO) nIconsOnSubScreen = 15;
  740. else nIconsOnSubScreen = 24;
  741. // 서브화면 1 레이아웃
  742. if (mIconInfoTable.getCnt() > 0) {
  743. SubLayout_01 = new RelativeLayout(this);
  744. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  745. SubLayout_01.setLayoutParams(params);
  746. SubLayout_01.setId(ID_OLD.main.layout.ALL);
  747. super.setAllLayoutRegistration(SubLayout_01);
  748. // 서브화면 1 스크린 레이아웃
  749. SubScreenLayout_01 = new RelativeLayout(this);
  750. WpadUtil.LayoutRegistration(SubLayout_01, SubScreenLayout_01, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  751. }
  752. // 서브화면 2 레이아웃
  753. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  754. SubLayout_02 = new RelativeLayout(this);
  755. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  756. SubLayout_02.setLayoutParams(params);
  757. SubLayout_02.setId(ID_OLD.main.layout.ALL);
  758. super.setAllLayoutRegistration(SubLayout_02);
  759. // 서브화면 2 스크린 레이아웃
  760. SubScreenLayout_02 = new RelativeLayout(this);
  761. WpadUtil.LayoutRegistration(SubLayout_02, SubScreenLayout_02, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  762. }
  763. // 간편모드 메인화면 레이아웃
  764. if (bEasyModeUsage) {
  765. EasyMainLayout = new RelativeLayout(this);
  766. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  767. EasyMainLayout.setLayoutParams(params);
  768. EasyMainLayout.setId(ID_OLD.main.layout.ALL);
  769. super.setAllLayoutRegistration(EasyMainLayout);
  770. // 간편모드 메인화면 스크린 레이아웃
  771. EasyMainScreenLayout = new RelativeLayout(this);
  772. WpadUtil.LayoutRegistration(EasyMainLayout, EasyMainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  773. }
  774. m_ModelHouseSleepModeRelease= Common.GetModelHouseSleepModeRelease(this);
  775. Log.d(TAG, " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% =====> GetModelHouseSleepModeRelease :" + m_ModelHouseSleepModeRelease);
  776. if (m_ModelHouseSleepModeRelease) {
  777. mLCD_SleepHandler.sendEmptyMessageDelayed(0, (30 * 1000));
  778. }
  779. // 5. Top Menu - ImageView registration
  780. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  781. // 6. Tab Menu - ImageView registration
  782. restoreSystemVolume();
  783. initProximitySensor();
  784. // 서브 스크린 호출하기 위한 메뉴 리스트 관리 클래스
  785. m_CallSubMenuScreen = new CallSubMenuScreen( this , mWallPadAPI);
  786. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  787. // 메인화면 3가지 등록으로 인해 변경
  788. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  789. // EasyUI_MainScreen = new EASYUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  790. }
  791. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  792. MetroUI_MainScreen = new METROUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  793. }
  794. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  795. Hyosung_HN_MainScreen = new HYOSUNGUI_MAIN_HN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  796. }
  797. else {
  798. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  799. }
  800. DebugLogOutput("[Create] - Step6 : Main Screen registration");
  801. // 7. Draw
  802. DebugLogOutput("[Create] - Step7 : setContentView");
  803. try {
  804. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  805. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  806. else setContentView(R.layout.main_2);
  807. }
  808. else if (Common.eGUIType == Common.GUI_TYPE.METRO) setContentView(R.layout.main_metro);
  809. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) setContentView(R.layout.main_hyosung);
  810. else {
  811. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  812. else setContentView(R.layout.main_2);
  813. }
  814. if (bEasyModeUsage) setContentView(R.layout.main_easy);
  815. // setContentView(R.layout.main);
  816. // 메인화면 3가지로 슬라이딩 방식으로 구현하기 위하여 뷰플리퍼를 사용하여 처리
  817. mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
  818. if (mViewFlipper != null) {
  819. if (MainLayout != null) mViewFlipper.addView(MainLayout);
  820. if (SubLayout_01 != null) mViewFlipper.addView(SubLayout_01);
  821. if (SubLayout_02 != null && Common.eGUIType == Common.GUI_TYPE.STANDARD) mViewFlipper.addView(SubLayout_02);
  822. if (EasyMainLayout != null && bEasyModeUsage) mViewFlipper.addView(EasyMainLayout);
  823. DebugLogOutput("[Create] - Step8 : Add Flipper !!! ");
  824. }
  825. } catch (RuntimeException re) {
  826. LogUtil.errorLogInfo("", TAG, re);
  827. }
  828. catch (Exception e) {
  829. LogUtil.errorLogInfo("", TAG, e);
  830. }
  831. registerBroadcastReceiver();
  832. Check_Upgrade_File();
  833. //앱 버전정보 DB저장
  834. try {
  835. Log.d(TAG, "mThread_getAppsVersion Start!! ");
  836. if (mThread_getAppsVersion== null) {
  837. mThread_getAppsVersion = new getInstalledPackageInfo();
  838. mThread_getAppsVersion.start();
  839. }
  840. else {
  841. Log.w(TAG, "mThread_getAppsVersion is null!!");
  842. }
  843. Log.d(TAG, "mThread_getAppsVersion End!! ");
  844. } catch (RuntimeException re) {
  845. LogUtil.errorLogInfo("", TAG, re);
  846. }
  847. catch (Exception e) {
  848. LogUtil.errorLogInfo("", TAG, e);
  849. }
  850. try {
  851. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  852. AddressSet addc = SetData.getAddressMGR();
  853. AddressSetBackup addc_Backup = SetData.getAddressMGR_Backup();
  854. overridePendingTransition(0, 0);
  855. if (!isSystemIPSet()) {
  856. Log.w(TAG, "[onCreate] The IP Address of OS is not set!");
  857. startManagerSettingSetAddress();
  858. }
  859. else if (addc.Dong.equals("NONE") || addc.Ho.equals("NONE")) {
  860. Log.w(TAG, "[onCreate] The info. of resi. is not set! [primary db]");
  861. if (addc_Backup.Dong.equals("NONE") || addc_Backup.Ho.equals("NONE")) {
  862. Log.w(TAG, "[onCreate] The info. of resi. is not set! [secondary db]");
  863. startManagerSettingSetAddress();
  864. }
  865. else {
  866. addc.setAddress(addc_Backup.Dong, addc_Backup.Ho);
  867. addc.setIPAddress(addc_Backup.IPAddress);
  868. m_IPActivity = true;
  869. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  870. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [secondary db]");
  871. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  872. startService(intent);
  873. //impaserver에 멀티 정보 제공을 위해 통신으로 추가
  874. bindService(new Intent(this, iMapServer.class), mConnection, Context.BIND_AUTO_CREATE);
  875. mIsBound = true;
  876. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  877. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  878. startService(intentMobile);
  879. }
  880. MAINStatus = MAIN_NORMAL;
  881. }
  882. }
  883. else {
  884. m_IPActivity = true;
  885. if (!addc.IPAddress.equals("NONE")) {
  886. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [primary db]");
  887. Intent intent = new Intent(this, iMapServer.class);
  888. startService(intent);
  889. //impaserver에 멀티 정보 제공을 위해 통신으로 추가
  890. bindService(new Intent(this, iMapServer.class), mConnection, Context.BIND_AUTO_CREATE);
  891. mIsBound = true;
  892. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  893. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  894. startService(intentMobile);
  895. }
  896. MAINStatus = MAIN_NORMAL;
  897. }
  898. SetData.closeDB();
  899. } catch (RuntimeException re) {
  900. LogUtil.errorLogInfo("", TAG, re);
  901. }
  902. catch (Exception e) {
  903. Log.e(TAG, "[Exception] check device addresses(ip, resi. info.)");
  904. LogUtil.errorLogInfo("", TAG, e);
  905. }
  906. //주차정보 사용여부 체크
  907. getParkedVehicleLocationSysInfo();
  908. //전기차 정보 가져오기
  909. GetElectricCarInfo();
  910. //에너지관리서버 사용여부 가져오기
  911. GetEnergyServerInfo();
  912. //에너지 알람 사용여부 가져오기
  913. GetEnergyAlarm();
  914. //통화타임아웃 초기화
  915. setCallAppTimeoutAsDefault();
  916. //카카오홈 사용 여부 체크(카카오홈)
  917. boolean isUseKakao = getKakaoHomeCheck();
  918. if(isUseKakao)
  919. {
  920. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  921. if (wdb != null) {
  922. Log.d(TAG, "[DB SAVE]-WallpadStatusData.ALARM_STOP ");
  923. if(wdb.GetAlarmStatus() != WallpadStatusData.GUARD_OUT)
  924. {
  925. Handler mHandler = new Handler();
  926. mHandler.postDelayed(mLaunchTaskKakao, 500);
  927. mHandler = null;
  928. }
  929. wdb.closeDB();
  930. }
  931. }
  932. try {
  933. mWallPadApiCheckHandler.sendEmptyMessage(0);
  934. // Checker.sendEmptyMessageDelayed(0, 1000);
  935. } catch (RuntimeException re) {
  936. LogUtil.errorLogInfo("", TAG, re);
  937. }
  938. catch (Exception e) {
  939. LogUtil.errorLogInfo("", TAG, e);
  940. }
  941. // sip 서비스 실행 옮김
  942. Log.d(TAG, "[onCreate] startCallService start");
  943. try {
  944. runCallServices startCallService = new runCallServices();
  945. startCallService.start();
  946. } catch (RuntimeException re) {
  947. LogUtil.errorLogInfo("", TAG, re);
  948. }
  949. catch (Exception e) {
  950. LogUtil.errorLogInfo("", TAG, e);
  951. }
  952. Log.d(TAG, "[onCreate] startCallService end");
  953. try {
  954. // 부팅하고 나서 업그레이드 상태를 false 로 해주지 않으면 통화 수신이 안됨
  955. // 꼭 들어가야 함
  956. // 전체 정전시험시 단지서버도 재부팅은 하나 로긴을 하지 않으면 그시간동안 세대기가 보낸 부트업 메세지를 못 받기 때문에....단말기 시간을 재 셋팅해주도록 한다.
  957. Calendar cal = new GregorianCalendar();
  958. String timedata = String.format("%04d",cal.get(Calendar.YEAR))+"."+String.format("%02d",cal.get(Calendar.MONTH)+1)+"."+String.format("%02d",cal.get(Calendar.DAY_OF_MONTH))+"."+String.format("%02d",cal.get(Calendar.HOUR_OF_DAY))+"."+String.format("%02d",cal.get(Calendar.MINUTE))+"."+String.format("%02d",cal.get(Calendar.SECOND));
  959. WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  960. wpd.SetUpgradeState(false);
  961. wpd.SetLastHeartbeat(timedata);
  962. wpd.closeDB();
  963. } catch (RuntimeException re) {
  964. LogUtil.errorLogInfo("", TAG, re);
  965. }
  966. catch (Exception e) {
  967. LogUtil.errorLogInfo("", TAG, e);
  968. }
  969. try {
  970. Calendar m_CurCalendar = Calendar.getInstance();
  971. //CurYear , CurMonth, CurDate, CurHour, CurMin, CurSecond;
  972. int CurYear = m_CurCalendar.get(Calendar.YEAR);
  973. if (CurYear < 2018) {
  974. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  975. DBMGR.setSystemTime(2018, 8, 1, 13, 0, 0);
  976. DBMGR.closeDB();
  977. }
  978. } catch (RuntimeException re) {
  979. LogUtil.errorLogInfo("", TAG, re);
  980. }
  981. catch (Exception e) {
  982. LogUtil.errorLogInfo("", TAG, e);
  983. }
  984. mLightInfo = new LightInfo();
  985. getLivinglightPreset();
  986. initLivinglightPreset();
  987. getLivinglightPreset();
  988. initEscapeLadderDownSend();
  989. setPageIndicator();
  990. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 10000);
  991. try {
  992. int getSleepTime = Settings.System.getInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT);
  993. int mSleepModeTime = (getSleepTime / 1000);
  994. Log.d(TAG, "[Create] mSleepModeTime [" + mSleepModeTime + "]");
  995. if (mSleepModeTime <= 30) {
  996. Log.d(TAG, "[Create] Reset mSleepModeTime ===== [" + mSleepModeTime + "] =====");
  997. Settings.System.putInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT, 28 * 1000); // 백라이트 off와 앱 종료가 동시에 일어나면 월패드가 비정상 종료되므로 수정 (2021.04.06 메이드인랩 김수진 선임 요청)
  998. }
  999. } catch (Settings.SettingNotFoundException e) {
  1000. e.printStackTrace();
  1001. }
  1002. try {
  1003. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  1004. // BSP 수정으로 인하여 해당 코드 삭제 (2021.02.24, SEULKI)
  1005. // // 월패드 카메라 녹색 노이즈 시험 코드 (월패드 부팅시 월패드 카메라 영상을 잠시 띄운후 없앤다. JEFF/2020.01.21.01)
  1006. // /**
  1007. // * 부팅시 카메라 서비스 정상동작 여부를 확인한다. (Edited by jeff, 2020.09.08)
  1008. // */
  1009. // sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK, 0, 0, 0); // 5초후 월패드 카메라를 초기화 한다. (그냥 화면밖에 영상을 잠시 띄우고 5초뒤에 없앤다.)
  1010. } catch (RuntimeException re) {
  1011. LogUtil.errorLogInfo("", TAG, re);
  1012. }
  1013. catch (Exception e) {
  1014. LogUtil.errorLogInfo("", TAG, e);
  1015. }
  1016. if (bKakaoiEnable) {
  1017. Log.i(TAG, "[onCreate] ========== Kakao function enabled ==========");
  1018. startKakaoiFloatingBTN();
  1019. }
  1020. // forceCtrlStrangerRecordingUserSettingDisable(false);
  1021. getLCDKeeperUsage();
  1022. // 거주자 안전확인 서비스 사용여부 확인하고, 화면 WallPadSupport Lib.에 관련 설정을 한다.
  1023. getResidentSafetyCheckSetting();
  1024. Log.i(TAG, "[onCreate] ==================== onCreate end ====================");
  1025. }
  1026. private void setKaKaOWallPadSerialNumber(String SerialNumber)
  1027. {
  1028. SharedPreferences prefs = mContext.getSharedPreferences("KaKaO", Context.MODE_PRIVATE);
  1029. SharedPreferences.Editor editor = prefs.edit();
  1030. editor.putString("Serial", SerialNumber);
  1031. editor.commit();
  1032. }
  1033. private String getKaKaOWallPadSerialNumber()
  1034. {
  1035. SharedPreferences prefs = mContext.getSharedPreferences("KaKaO", Context.MODE_PRIVATE);
  1036. String serial = prefs.getString("Serial", "");
  1037. return serial;
  1038. }
  1039. private String MakeKaKaOWallPadSerialNumber()
  1040. {
  1041. WallpadDeviceSet devset = new WallpadDeviceSet(mContext);
  1042. String[] SiteCode = devset.GetSettingData("site_code");
  1043. devset.closeDB();
  1044. String code = "" ;
  1045. if ((SiteCode != null) && SiteCode.length > 1) {
  1046. code = SiteCode[1];
  1047. }
  1048. WallpadStatusData DBMGR = new WallpadStatusData(this.getContext());
  1049. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  1050. DBMGR.closeDB();
  1051. String strDong = addr.Dong;
  1052. String strHo = addr.Ho;
  1053. String strType = "wallpad";
  1054. for (int i = 4 - strDong.length(); i > 0; i--) {
  1055. strDong = "0" + strDong;
  1056. }
  1057. for (int i = 4 - strHo.length(); i > 0; i--) {
  1058. strHo = "0" + strHo;
  1059. }
  1060. String strPostNumber = "01";
  1061. String serial = code + "_"
  1062. + strType + "_"
  1063. + strDong + "_"
  1064. + strHo + "_"
  1065. + strPostNumber
  1066. ;
  1067. Log.d(TAG, " makeSipID() ret : " + serial);
  1068. //여기서 공통된 Preference 선언해서 저장
  1069. SharedPreferences sharedPreference = this.getSharedPreferences("KaKaOData", Context.MODE_MULTI_PROCESS | Context.MODE_WORLD_READABLE);
  1070. SharedPreferences.Editor editor = sharedPreference.edit();
  1071. editor.putString("Serial",serial);
  1072. editor.commit();
  1073. return serial;
  1074. }
  1075. /**
  1076. * 카카오 실행 관련 핸들러
  1077. */
  1078. private Runnable mLaunchTaskKakao = new Runnable() {
  1079. public void run() {
  1080. String Packagename = "com.hdc_icontrols.kakao.stage";
  1081. //Handler를 이용하여 Timer 사용
  1082. Intent mainIntent = mContext.getPackageManager().getLaunchIntentForPackage(Packagename);
  1083. if (mainIntent != null) {
  1084. String serial = getKaKaOWallPadSerialNumber();
  1085. if(serial.equals(""))
  1086. {
  1087. serial = MakeKaKaOWallPadSerialNumber();
  1088. setKaKaOWallPadSerialNumber(serial);
  1089. }
  1090. else {
  1091. String[] serial_data = serial.split("_");
  1092. if(serial_data!=null)
  1093. {
  1094. if(serial_data.length != 5)
  1095. {
  1096. //다시 만들어야 함
  1097. serial = MakeKaKaOWallPadSerialNumber();
  1098. setKaKaOWallPadSerialNumber(serial);
  1099. }
  1100. else if(serial_data.length == 5)
  1101. {
  1102. //ip정보(동,호 정보)
  1103. WallpadStatusData DBMGR = new WallpadStatusData(mContext);
  1104. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  1105. DBMGR.closeDB();
  1106. String strDong = addr.Dong;//3번쨰
  1107. String strHo = addr.Ho;//4번쨰
  1108. for (int i = 4 - strDong.length(); i > 0; i--) {
  1109. strDong = "0" + strDong;
  1110. }
  1111. for (int i = 4 - strHo.length(); i > 0; i--) {
  1112. strHo = "0" + strHo;
  1113. }
  1114. if(!serial_data[2].equals(strDong) || !serial_data[3].equals(strHo))
  1115. {
  1116. //다시 만들어야 함
  1117. serial = MakeKaKaOWallPadSerialNumber();
  1118. setKaKaOWallPadSerialNumber(serial);
  1119. }
  1120. }
  1121. }
  1122. }
  1123. mainIntent.putExtra("SeriaData", serial);
  1124. mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1125. startActivity(mainIntent);
  1126. };
  1127. }
  1128. };
  1129. private int nLCDKeeperType = WallpadDeviceSet.LCDKEEPER_NONE;
  1130. private String getLCDKeeperType(int nLCDKeeperType) {
  1131. try {
  1132. Log.i(TAG, "[getLCDKeeperUsage] nLCDKeeperType [" + nLCDKeeperType + "]");
  1133. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_NONE) return "LCDKEEPER_NONE";
  1134. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) return "LCDKEEPER_PROTECT";
  1135. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) return "LCDKEEPER_RECOVER";
  1136. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) return "LCDKEEPER_PROTECT_RECOVER";
  1137. else return "UNKNOWN";
  1138. } catch (RuntimeException re) {
  1139. LogUtil.errorLogInfo("", TAG, re);
  1140. return "ERROR";
  1141. }
  1142. catch (Exception e) {
  1143. Log.e(TAG, "[Exception] getLCDKeeperType(int nLCDKeeperType)");
  1144. LogUtil.errorLogInfo("", TAG, e);
  1145. return "ERROR";
  1146. }
  1147. }
  1148. private boolean bLCDKeeperUsage = false;
  1149. private void getLCDKeeperUsage() {
  1150. try {
  1151. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  1152. nLCDKeeperType = mWallpadDeviceSet.getLCDKeeperUsage();
  1153. mWallpadDeviceSet.closeDB();
  1154. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  1155. bLCDKeeperUsage = true;
  1156. }
  1157. Log.i(TAG, "[getLCDKeeperUsage] bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  1158. } catch (RuntimeException re) {
  1159. LogUtil.errorLogInfo("", TAG, re);
  1160. }
  1161. catch (Exception e) {
  1162. Log.e(TAG, "[Exception] getLCDKeeperUsage()");
  1163. LogUtil.errorLogInfo("", TAG, e);
  1164. }
  1165. }
  1166. public boolean isSystemIPSet() {
  1167. try {
  1168. Log.i(TAG, "[isSystemIPSet] START!");
  1169. String strResult = "";
  1170. if (Build.VERSION.SDK_INT > 23) {
  1171. // Android 7
  1172. strResult = getIPAddress();
  1173. }
  1174. else {
  1175. // Android 6
  1176. if(NetworkInterface.getByName("eth0")!=null)
  1177. {
  1178. String strNetInfo = NetworkInterface.getByName("eth0").toString();
  1179. Log.i(TAG, "[isSystemIPSet] strNetInfo : " + strNetInfo + "]");
  1180. strNetInfo.trim();
  1181. String[] Parse_01 = strNetInfo.split("\\]");
  1182. // for (int i = 0; i < Parse_01.length; i++) {
  1183. // LOG_DEBUG("[getDeviceIPAddress] Parse_01[" + i + "] : " + Parse_01[i]);
  1184. // }
  1185. String[] Parse_02 = Parse_01[Parse_01.length - 1].split("\\/");
  1186. // for (int i = 0; i < Parse_02.length; i++) {
  1187. // LOG_DEBUG("[getDeviceIPAddress] Parse_02[" + i + "] : " + Parse_02[i]);
  1188. // }
  1189. strResult = Parse_02[1];
  1190. }
  1191. }
  1192. Log.i(TAG, "[isSystemIPSet] DONE! [IP Address : " + strResult + "]");
  1193. Pattern mPattern = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
  1194. return mPattern.matcher(strResult).matches();
  1195. } catch (RuntimeException re) {
  1196. LogUtil.errorLogInfo("", TAG, re);
  1197. return false;
  1198. }
  1199. catch (Exception e) {
  1200. Log.e(TAG, "[Exception] isSystemIPSet()");
  1201. LogUtil.errorLogInfo("", TAG, e);
  1202. return false;
  1203. }
  1204. }
  1205. public static String getIPAddress() {
  1206. try {
  1207. List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
  1208. for (NetworkInterface intf : interfaces) {
  1209. List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
  1210. for (InetAddress addr : addrs) {
  1211. if (!addr.isLoopbackAddress()) {
  1212. String sAddr = addr.getHostAddress();
  1213. //boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
  1214. boolean isIPv4 = sAddr.indexOf(':')<0;
  1215. if (isIPv4)
  1216. return sAddr;
  1217. }
  1218. }
  1219. }
  1220. } catch (RuntimeException re) {
  1221. LogUtil.errorLogInfo("", TAG, re);
  1222. }
  1223. catch (Exception e) {
  1224. Log.e(TAG, "[Exception] isSystemIPSet()");
  1225. LogUtil.errorLogInfo("", TAG, e);
  1226. }
  1227. return "";
  1228. }
  1229. public void initIOInterface(WallPadAPI wallpadapi) {
  1230. try {
  1231. mIOInterface = new IOInterface(getContext(), wallpadapi);
  1232. } catch (RuntimeException re) {
  1233. LogUtil.errorLogInfo("", TAG, re);
  1234. }
  1235. catch (Exception e) {
  1236. Log.e(TAG, "[Exception] initIOInterface(WallPadAPI wallpadapi)");
  1237. LogUtil.errorLogInfo("", TAG, e);
  1238. }
  1239. }
  1240. public void checkDongHoSetting() {
  1241. try {
  1242. Log.d(TAG, "[checkDongHoSetting] ========== START ==========");
  1243. boolean IP_ExpansionSettingFlag = false;
  1244. EthernetDevInfo info = new EthernetDevInfo();
  1245. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  1246. AddressSet addc = mWallpadStatusData.getAddressMGR();
  1247. mWallpadStatusData.SetCallAPKStatus(false);
  1248. mWallpadStatusData.closeDB();
  1249. if (addc.Dong!=null && !addc.Dong.equals("NONE") && addc.Ho!=null&& !addc.Ho.equals("NONE") && addc.IPAddress!=null&& !addc.IPAddress.equals("NONE")) {
  1250. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL && Version.getModelType() == MODEL_TYPE.IHN_1020B_A
  1251. && Version.getModelType() == MODEL_TYPE.IHN_1020SA_A && Version.getModelType() == MODEL_TYPE.IHN_750) {
  1252. // LH 게이트웨이 때문에 위치 옮김 제어 서비스 보다 먼저 처리
  1253. if(addc.IPAddress!=null)
  1254. {
  1255. String[] iptbl = addc.IPAddress.split("[.]");
  1256. Log.d(TAG, "[checkDongHoSetting] Mac Set -> IP : " + addc.IPAddress +", Length : " + iptbl.length);
  1257. // BSP에서 초기 이더넷 비활성화시 jni 맥 셋팅시 메인어플 다이~~
  1258. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1259. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1260. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_DISABLED!!!");
  1261. if (IP_ExpansionSettingFlag == true) {
  1262. mEthManager.UpdateEthDevInfo(info);
  1263. }
  1264. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1265. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1266. if (iptbl.length == 4) {
  1267. String macadd = String.format("00:%02x:%02x:%02x:%02x:00", Integer.parseInt(iptbl[0]),Integer.parseInt(iptbl[1]), Integer.parseInt(iptbl[2]), Integer.parseInt(iptbl[3]));
  1268. Log.d(TAG, "[checkDongHoSetting] Mac Set "+macadd);
  1269. try {
  1270. WallPadInterface wpdifc = new WallPadInterface();
  1271. wpdifc.setMacAddr(macadd);
  1272. } catch (RuntimeException re) {
  1273. LogUtil.errorLogInfo("", TAG, re);
  1274. }
  1275. catch (Exception ex) {
  1276. //ex.printStackTrace();
  1277. LogUtil.errorLogInfo("", TAG, ex);
  1278. }
  1279. Log.d(TAG, "[checkDongHoSetting] -----------------------------------MacSet");
  1280. }
  1281. else {
  1282. Log.d(TAG,"[checkDongHoSetting] -----------------------------------Mac iptbl.length fail !!");
  1283. }
  1284. //EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1285. //mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1286. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1287. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1288. }
  1289. }
  1290. }
  1291. } catch (RuntimeException re) {
  1292. LogUtil.errorLogInfo("", TAG, re);
  1293. }
  1294. catch (Exception e) {
  1295. Log.e(TAG, "[Exception] checkDongHoSetting()");
  1296. LogUtil.errorLogInfo("", TAG, e);
  1297. }
  1298. }
  1299. public void registerSubScreen() {
  1300. try {
  1301. if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  1302. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1303. }
  1304. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  1305. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1306. }
  1307. else {
  1308. if (mIconInfoTable.getCnt() > 0) {
  1309. if (SUB_01Screen == null && SubScreenLayout_01 != null ) SUB_01Screen = new SUB_01(getContext() , SubScreenLayout_01, mWallPadAPI);
  1310. }
  1311. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  1312. if (SUB_02Screen == null && SubScreenLayout_02 != null ) SUB_02Screen = new SUB_02(getContext() , SubScreenLayout_02, mWallPadAPI);
  1313. }
  1314. if (bEasyModeUsage) {
  1315. if (EasyUI_MainScreen == null && EasyMainScreenLayout != null ) EasyUI_MainScreen = new EASYUI_MAIN(getContext() , EasyMainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  1316. }
  1317. }
  1318. // restoreSystemVolume();
  1319. SCManager = new ScheduleManager();
  1320. } catch (RuntimeException re) {
  1321. LogUtil.errorLogInfo("", TAG, re);
  1322. }
  1323. catch (Exception e) {
  1324. Log.w(TAG, "[registerSubScreen] registerSubScreen()");
  1325. LogUtil.errorLogInfo("", TAG, e);
  1326. }
  1327. }
  1328. public void moveNextPage() {
  1329. try {
  1330. Log.d(TAG, "[moveNextPage] ===== START =====");
  1331. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_right);
  1332. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_left);
  1333. mViewFlipper.setInAnimation(aniSlideIn);
  1334. mViewFlipper.setOutAnimation(aniSlideOut);
  1335. mViewFlipper.showNext();
  1336. } catch (RuntimeException re) {
  1337. LogUtil.errorLogInfo("", TAG, re);
  1338. }
  1339. catch (Exception e) {
  1340. Log.e(TAG, "[Exception] moveNextPage()");
  1341. LogUtil.errorLogInfo("", TAG, e);
  1342. }
  1343. }
  1344. public void movePreviousPage() {
  1345. try {
  1346. Log.d(TAG, "[movePreviousPage] ===== START =====");
  1347. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_left);
  1348. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_right);
  1349. mViewFlipper.setInAnimation(aniSlideIn);
  1350. mViewFlipper.setOutAnimation(aniSlideOut);
  1351. mViewFlipper.showPrevious();
  1352. } catch (RuntimeException re) {
  1353. LogUtil.errorLogInfo("", TAG, re);
  1354. }
  1355. catch (Exception e) {
  1356. Log.e(TAG, "[Exception] moveNextPage()");
  1357. LogUtil.errorLogInfo("", TAG, e);
  1358. }
  1359. }
  1360. boolean bScreenCheck = false;
  1361. int nSubScreenTimeout = 20, SCREENTIMEOUT = 20;
  1362. public void checkMainPage() {
  1363. try {
  1364. if (!bScreenCheck) {
  1365. nSubScreenTimeout = SCREENTIMEOUT;
  1366. return;
  1367. }
  1368. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1369. if (nViewFlipperIndex != 0) {
  1370. if (nSubScreenTimeout > 0) {
  1371. nSubScreenTimeout--;
  1372. }
  1373. else {
  1374. nSubScreenTimeout = SCREENTIMEOUT;
  1375. mViewFlipper.setDisplayedChild(0);
  1376. }
  1377. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1378. }
  1379. else {
  1380. if (nSubScreenTimeout <= 0) {
  1381. nSubScreenTimeout = SCREENTIMEOUT;
  1382. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1383. }
  1384. }
  1385. } catch (RuntimeException re) {
  1386. LogUtil.errorLogInfo("", TAG, re);
  1387. }
  1388. catch (Exception e) {
  1389. Log.e(TAG, "[Exception] checkMainPage()");
  1390. LogUtil.errorLogInfo("", TAG, e);
  1391. }
  1392. }
  1393. String strWallPadMainPakageName = "kr.co.icontrols.wallpadmain";
  1394. private boolean isPackageTop(String strPackageName) {
  1395. try {
  1396. ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  1397. Log.i(TAG, "[isPackageTop] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "]");
  1398. if (Build.VERSION.SDK_INT > 23) {
  1399. // Android 7
  1400. List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
  1401. for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
  1402. if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
  1403. for (String activeProcess : processInfo.pkgList) {
  1404. if (activeProcess.equals(strPackageName)) {
  1405. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1406. return true;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. }
  1412. else {
  1413. // Android 6
  1414. List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1415. ComponentName componentInfo = taskInfo.get(0).topActivity;
  1416. if (componentInfo.getPackageName().equals(strPackageName)) {
  1417. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1418. return true;
  1419. }
  1420. }
  1421. } catch (RuntimeException re) {
  1422. LogUtil.errorLogInfo("", TAG, re);
  1423. }
  1424. catch (Exception e) {
  1425. Log.e(TAG, "[Exception] isPackageTop(String strPackageName)");
  1426. LogUtil.errorLogInfo("", TAG, e);
  1427. }
  1428. return false;
  1429. }
  1430. // 부팅시에는 최초 DB에서 값을 읽어와서 변경하도록 한다.
  1431. private boolean m_SetBookMarkMainScreen = false;
  1432. private int m_CheckBookMarkReturnCount = 0 ;
  1433. private final int BOOKMARK_SCREEN_RETURN_CHECK_TIME = 30;
  1434. private boolean m_thisAcitivityRusume = false;
  1435. // 즐겨찾기 메인화면을 항상 고정해서 쓸것인지 설정하는 함수
  1436. public void SetBookMarkMainScreen(boolean Set)
  1437. {
  1438. m_SetBookMarkMainScreen = Set;
  1439. try
  1440. {
  1441. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  1442. if( wdb != null )
  1443. {
  1444. if( Set == true )
  1445. {
  1446. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_BOOKMARK_SCREEN);
  1447. }
  1448. else
  1449. {
  1450. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_DEFAULT_SCREEN);
  1451. }
  1452. wdb.closeDB();
  1453. }
  1454. }
  1455. catch (RuntimeException re) {
  1456. LogUtil.errorLogInfo("", TAG, re);
  1457. }
  1458. catch (Exception e )
  1459. {
  1460. LogUtil.errorLogInfo("", TAG, e);
  1461. }
  1462. }
  1463. public boolean CheckCurrentEnergyScreen()
  1464. {
  1465. int currentView = mViewFlipper.getDisplayedChild();
  1466. Log.d(TAG, "-------> currentView : " + currentView);
  1467. if( currentView == 1)
  1468. return true;
  1469. else
  1470. return false;
  1471. }
  1472. private int nTouchDownPosX = 0;
  1473. private int nTouchUpPosX = 0;
  1474. @Override
  1475. public boolean dispatchTouchEvent(MotionEvent ev) {
  1476. boolean bReturn = false;
  1477. //Log.d("Move" , "dispatchTouchEvent-----------1");
  1478. try {
  1479. if (ev.getAction() == MotionEvent.ACTION_DOWN) {
  1480. nTouchDownPosX = (int)ev.getX();
  1481. }
  1482. else if (ev.getAction() == MotionEvent.ACTION_UP) {
  1483. nTouchUpPosX = (int)ev.getX();
  1484. Log.d(TAG, "[dispatchTouchEvent] nTouchDownPosX [" + nTouchDownPosX + "], nTouchUpPosX [" + nTouchUpPosX + "]");
  1485. if (nTouchUpPosX < nTouchDownPosX - 50) {
  1486. moveNextPage();
  1487. setPageIndicator();
  1488. }
  1489. else if (nTouchUpPosX > nTouchDownPosX + 50) {
  1490. movePreviousPage();
  1491. setPageIndicator();
  1492. }
  1493. nTouchDownPosX = nTouchUpPosX;
  1494. }
  1495. } catch (RuntimeException re) {
  1496. LogUtil.errorLogInfo("", TAG, re);
  1497. }
  1498. catch (Exception e) {
  1499. Log.e(TAG, "[Exception] dispatchTouchEvent(MotionEvent ev)");
  1500. LogUtil.errorLogInfo("", TAG, e);
  1501. }
  1502. bReturn = super.dispatchTouchEvent(ev);
  1503. return bReturn;
  1504. }
  1505. private void setPageIndicator() {
  1506. try {
  1507. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1508. int nChildCnt = mViewFlipper.getChildCount();
  1509. Log.d(TAG, "[setPageIndicator] nViewFlipperIndex [" + nViewFlipperIndex + "], nChildCnt [" + nChildCnt + "]");
  1510. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  1511. Log.d(TAG, "[setPageIndicator] eGUIType == GUI_TYPE.STANDARD");
  1512. ImageView[] IMG_INDICATOR;
  1513. if (bEasyModeUsage) IMG_INDICATOR = new ImageView[] { (ImageView) findViewById(R.id.pageindex_main), (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2), (ImageView) findViewById(R.id.pageindex_easymain) };
  1514. else IMG_INDICATOR = new ImageView[] { (ImageView) findViewById(R.id.pageindex_main), (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1515. for (int i = 0; i < nChildCnt; i++) {
  1516. if (i == nViewFlipperIndex) {
  1517. if (i == 0) IMG_INDICATOR[i].setSelected(true);
  1518. else IMG_INDICATOR[i].setSelected(true);
  1519. }
  1520. else {
  1521. if (i == 0) IMG_INDICATOR[i].setSelected(false);
  1522. else IMG_INDICATOR[i].setSelected(false);
  1523. }
  1524. }
  1525. }
  1526. // else if (eGUIType == GUI_TYPE.METRO) {
  1527. // ImageView[] IMG_INDICATOR = { (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1528. // if (nViewFlipperIndex == 0) {
  1529. // for (int i = 0; i < nChildCnt; i++) {
  1530. // if (i != 0) IMG_INDICATOR[i - 1].setVisibility(View.INVISIBLE);
  1531. // }
  1532. // }
  1533. // else {
  1534. // for (int i = 0; i < nChildCnt; i++) {
  1535. // if (i != 0) {
  1536. // IMG_INDICATOR[i - 1].setVisibility(View.VISIBLE);
  1537. // if (i == nViewFlipperIndex) IMG_INDICATOR[i - 1].setSelected(true);
  1538. // else IMG_INDICATOR[i - 1].setSelected(false);
  1539. // }
  1540. // }
  1541. // }
  1542. // }
  1543. } catch (RuntimeException re) {
  1544. LogUtil.errorLogInfo("", TAG, re);
  1545. }
  1546. catch (Exception e) {
  1547. Log.e(TAG, "[Exception] setPageIndicator()");
  1548. LogUtil.errorLogInfo("", TAG, e);
  1549. }
  1550. }
  1551. /**
  1552. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  1553. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  1554. * 본 딜레이 코드를 임시로 적용한다.
  1555. */
  1556. @SuppressLint("HandlerLeak")
  1557. protected Handler mWallPadApiCheckHandler = new Handler()
  1558. {
  1559. @SuppressLint("HandlerLeak")
  1560. @Override
  1561. public void handleMessage(Message msg)
  1562. {
  1563. if (msg.what == 0) {
  1564. if (mWallPadAPI != null) {
  1565. if (mWallPadAPI.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  1566. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  1567. }
  1568. }
  1569. else if (msg.what == 1) {
  1570. // 현산향
  1571. AutoIGALStatusReleaseSinario();
  1572. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  1573. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1574. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1575. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  1576. mSdbAPI = mWallPadAPI.Get_SdbController();
  1577. if (mSdb_LivingRoomLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1578. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Success !");
  1579. if (mSdbAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1580. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Success !");
  1581. // ChangeLEDButtonLevel();
  1582. }
  1583. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1584. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  1585. mIntLightAPI = mWallPadAPI.Get_IntLightController();
  1586. if (mIntLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1587. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Success !");
  1588. // ChangeLEDButtonLevel();
  1589. }
  1590. else {
  1591. // 대외향
  1592. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  1593. int[] retArray = devDB.Get_Light_info();
  1594. devDB.closeDB();
  1595. if (retArray!= null && retArray[0] == 1) {
  1596. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  1597. // 거실 스위치
  1598. m_LightCtrl = mWallPadAPI.Get_LightController();
  1599. if (m_LightCtrl == null) Log.d(TAG , "Get_LightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1600. else Log.d(TAG , "Get_LightController Success !");
  1601. }
  1602. else {
  1603. // 멀티스위치
  1604. m_MultiSwitch = mWallPadAPI.Get_MultiSwitchController();
  1605. if (m_MultiSwitch == null) Log.d(TAG , "Get_MultiSwitchController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1606. else Log.d(TAG , "Get_MultiSwitchController Success !");
  1607. }
  1608. }
  1609. }
  1610. // 스마트현관카메라
  1611. if (getDoorCamType() == WallpadDeviceSet.DOORTYPE_IOT_SMART || getDoorCamType() == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || getDoorCamType() == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  1612. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  1613. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  1614. Log.i(TAG, "[mWallPadApiCheckHandler] ret [" + ret + "]");
  1615. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (상태 Off, LED Off)
  1616. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  1617. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  1618. }
  1619. }
  1620. else if (msg.what == 10) {
  1621. // 부트업 실패시 5초 간격으로 보내도록 수정
  1622. Log.d(TAG , "NOTIFY_SENDBOOTUP_FAIL Retry!!!!");
  1623. Intent Newintent = new Intent();
  1624. Newintent.setAction(define.NOTIFY_ACNAME);
  1625. Newintent.putExtra(define.NOTIBR_KIND,Common.DEVICE_BOOTUP_RETRY);
  1626. sendBroadcast(Newintent);
  1627. }
  1628. }
  1629. };
  1630. private void ChangeLEDButtonLevel()
  1631. {
  1632. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  1633. {
  1634. try
  1635. {
  1636. String filename = "/sdcard/led_button_reset.txt";
  1637. File savefile = new File(filename);
  1638. Log.d(TAG, "8888888888888888888888 savefile : " + savefile.exists());
  1639. if(savefile.exists())
  1640. {
  1641. Log.d(TAG, "try file is exist... ");
  1642. if( mIntLightAPI != null)
  1643. {
  1644. int ret = mIntLightAPI.LedBrightCtrl((byte)0x01);
  1645. if( ret >= 0 )
  1646. {
  1647. WallpadStatusData wd = new WallpadStatusData( getApplicationContext());
  1648. wd.SetLEDButtonBrightnessLevel(1); // DB 저장이 실패하게 되면 초기값을 2로 셋팅하기 때문에 다시 한번 셋팅해준다.
  1649. int level = wd.GetLEDButtonBrightnessLevel();
  1650. wd.closeDB();
  1651. Log.d(TAG, "88888888 button brightness Level 1 == " + level);
  1652. WallpadStatusData wd1 = new WallpadStatusData( getApplicationContext());
  1653. wd1.SetLEDButtonBrightnessLevel(1);
  1654. level = wd1.GetLEDButtonBrightnessLevel();
  1655. wd1.closeDB();
  1656. FileDelete(savefile);//.delete();
  1657. // 생산 기술팀 요청사항
  1658. // LED 버튼 보디 교체로 레벨이 너무 밝아 디폴트값 변경을 요청함 ,,
  1659. Log.d(TAG, "8888888888888888888888 button brightness Level 1 == " + level);
  1660. }
  1661. }
  1662. }
  1663. }
  1664. catch (RuntimeException re) {
  1665. LogUtil.errorLogInfo("", TAG, re);
  1666. }
  1667. catch (Exception e )
  1668. {
  1669. LogUtil.errorLogInfo("", TAG, e);
  1670. }
  1671. }
  1672. }
  1673. private void AutoIGALStatusReleaseSinario()
  1674. {
  1675. // 에너지미터 설정에 따라 조명 상태 변경시 일괄소등 해제 처리 시나리오를 설정하도록 한다.
  1676. // 일괄소등 해제 시나리오 적용시...
  1677. try
  1678. {
  1679. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  1680. int setIparkEnergy = devset.Get_Energy_Devices_Info();
  1681. Log.d(TAG , "Get_IPark_Energy_Info bSet: setIparkEnergy : " + setIparkEnergy);
  1682. if( setIparkEnergy == 1 )
  1683. {
  1684. mWallPadAPI.SetAutoIGALStatusClear(true);
  1685. Log.d(TAG , "AutoIGALStatusReleaseSinario bSet: true");
  1686. }
  1687. devset.closeDB();
  1688. }
  1689. catch (RuntimeException re) {
  1690. LogUtil.errorLogInfo("", TAG, re);
  1691. }
  1692. catch (Exception e )
  1693. {
  1694. Log.e(TAG, e.toString());
  1695. LogUtil.errorLogInfo("", TAG, e);
  1696. }
  1697. }
  1698. /**
  1699. * onDestroy
  1700. */
  1701. @Override
  1702. protected void onDestroy() {
  1703. // 이걸 왜 넣었지?
  1704. setChangeScreen(mCurrentScreenId, true, false);
  1705. unregisterBroadcastReceiver();
  1706. super.setFinishTimerDestroy();
  1707. Log.i(TAG, "*************************************************************");
  1708. Log.i(TAG, "****************** [END - MainActivity] *******************");
  1709. Log.i(TAG, "*************************************************************");
  1710. super.onDestroy();
  1711. }
  1712. /**
  1713. * onResume
  1714. */
  1715. @Override
  1716. protected void onResume() {
  1717. super.onResume();
  1718. m_thisAcitivityRusume = true;
  1719. if (mWallPadAPI != null) {
  1720. if (mWallPadAPI.Check_Connect()) Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = true!!!");
  1721. else Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = false!!!");
  1722. mWallPadAPI.Resume();
  1723. }
  1724. //CallDataChecker();
  1725. try {
  1726. if (m_ModelHouseSleepModeRelease) {
  1727. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  1728. // pm.userActivity(1, true);
  1729. // pm.userActivity(2, true);1qn
  1730. // LCD 항상 ON
  1731. ((Activity)this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  1732. }
  1733. } catch (RuntimeException re) {
  1734. LogUtil.errorLogInfo("", TAG, re);
  1735. }
  1736. catch (Exception e) {
  1737. LogUtil.errorLogInfo("", TAG, e);
  1738. }
  1739. if (MAINStatus == MAIN_WAIT_SETIP) {
  1740. try {
  1741. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  1742. AddressSet addc = SetData.getAddressMGR();
  1743. SetData.closeDB();
  1744. Log.i("MAINSCREEN", "onResume MAIN_WAIT_SETIP "+addc.IPAddress);
  1745. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  1746. Log.i("MAINSCREEN", "onResume Start Server");
  1747. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1748. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1749. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1750. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  1751. Log.w("MAINSCREEN", "Call Start iMapServer");
  1752. startService(intent);
  1753. //impaserver에 멀티 정보 제공을 위해 통신으로 추가
  1754. bindService(new Intent(this, iMapServer.class), mConnection, Context.BIND_AUTO_CREATE);
  1755. mIsBound = true;
  1756. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1757. String[] sitecode = devSet.GetSettingData("site_code");
  1758. try {
  1759. if (sitecode != null) {
  1760. Intent sipServiceLauncher = new Intent ("cm.sip.hns.SIPStun.StartService");
  1761. getApplicationContext().startService(sipServiceLauncher);
  1762. }
  1763. } catch (RuntimeException re) {
  1764. LogUtil.errorLogInfo("", TAG, re);
  1765. }
  1766. catch (Exception e) {
  1767. Common.DebugLog("SIP StartServerice Error!!!!!!!!!!!!!!");
  1768. }
  1769. devSet.closeDB();
  1770. MAINStatus = MAIN_NORMAL;
  1771. }
  1772. } catch (RuntimeException re) {
  1773. LogUtil.errorLogInfo("", TAG, re);
  1774. }
  1775. catch (Exception e ) {
  1776. LogUtil.errorLogInfo("", TAG, e);
  1777. }
  1778. }
  1779. //CheckMainScreen();
  1780. //refreshUserCtr();
  1781. //reloadData();
  1782. try {
  1783. WallPadInterface wpdifc = new WallPadInterface();
  1784. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1785. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1786. wpdifc.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1787. Intent intent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1788. getContext().sendBroadcast(intent);
  1789. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 1000);
  1790. } catch (RuntimeException re) {
  1791. LogUtil.errorLogInfo("", TAG, re);
  1792. }
  1793. catch (Exception e) {
  1794. LogUtil.errorLogInfo("", TAG, e);
  1795. }
  1796. bScreenCheck = true;
  1797. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  1798. }
  1799. protected String getForegroundAPK() {
  1800. try {
  1801. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1802. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1803. ComponentName topActivity=taskInfo.get(0).topActivity;
  1804. String str=topActivity.getPackageName();
  1805. return str;
  1806. } catch (RuntimeException re) {
  1807. LogUtil.errorLogInfo("", TAG, re);
  1808. return " ";
  1809. }
  1810. catch (Exception e) {
  1811. LogUtil.errorLogInfo("", TAG, e);
  1812. return " ";
  1813. }
  1814. }
  1815. /**
  1816. * onPause
  1817. */
  1818. @Override
  1819. protected void onPause() {
  1820. //테스트
  1821. sendMessageToService(4, "111");
  1822. m_thisAcitivityRusume = false;
  1823. if(mWallPadAPI != null) mWallPadAPI.Pause();
  1824. bScreenCheck = false;
  1825. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  1826. super.onPause();
  1827. }
  1828. /* ================================================================================================
  1829. * [BroadcastReceiver] Section
  1830. ================================================================================================ */
  1831. /**
  1832. * BroadcastReceiver.onReceive for [WpadActivity]
  1833. */
  1834. @Override
  1835. protected void onBrReceive(Intent intent) {
  1836. try {
  1837. String strAction = intent.getAction();
  1838. Log.i(TAG, "[onBrReceive] Action [" + strAction + "]");
  1839. if (strAction.equals(BR_CTRL_LIGHT_LIVINGROOM)) {
  1840. Log.d(TAG, "[onBrReceive] (BR) BR_CTRL_LIGHT_LIVINGROOM");
  1841. mLightInfo.nLightPresetNo = 0;
  1842. }
  1843. } catch (RuntimeException re) {
  1844. LogUtil.errorLogInfo("", TAG, re);
  1845. }
  1846. catch (Exception e) {
  1847. Log.e(TAG, "[Exception] onBrReceive(Intent intent)");
  1848. LogUtil.errorLogInfo("", TAG, e);
  1849. }
  1850. super.onBrReceive(intent);
  1851. }
  1852. /* ================================================================================================
  1853. * [Touch & Key Event] Section
  1854. ================================================================================================ */
  1855. /**
  1856. * TouchEvent for [WpadActivity]
  1857. */
  1858. @Override
  1859. protected void onTouchEvent(View v, MotionEvent event) {
  1860. super.onTouchEvent(v, event);
  1861. int TargetId = v.getId();
  1862. int MoveEvent = event.getAction();
  1863. Log.i(TAG, "[onTouchEvent] TargetId [" + TargetId + "], MoveEvent [" + MoveEvent + "]");
  1864. if (MoveEvent == MotionEvent.ACTION_UP) {
  1865. }
  1866. }
  1867. /**
  1868. * H/W Key Event
  1869. */
  1870. @Override
  1871. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1872. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  1873. // sendKeyEventBR(keyCode);
  1874. return super.onKeyDown(keyCode, event);
  1875. }
  1876. @Override
  1877. public boolean onKeyUp(int keyCode, KeyEvent event) {
  1878. // TODO Auto-generated method stub
  1879. Log.i(TAG, "[onKeyUp] keyCode : " + keyCode + ", Action : " + event.getAction());
  1880. return super.onKeyUp(keyCode, event);
  1881. }
  1882. @Override
  1883. public boolean onKeyLongPress(int keyCode, KeyEvent event) {
  1884. // TODO Auto-generated method stub
  1885. DebugLogOutput("onKeyLongPress - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
  1886. return super.onKeyLongPress(keyCode, event);
  1887. }
  1888. /* ================================================================================================
  1889. * [Popup Activity] Section
  1890. ================================================================================================ */
  1891. /**
  1892. * Popup Activity 를 시작시킨다.
  1893. *
  1894. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1895. * @return (boolean) true : 성공, false : 실패
  1896. */
  1897. public boolean StartPopup(int ScreenId){
  1898. try {
  1899. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1900. if (Common.bWallPadCallLive) {
  1901. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1902. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1903. }
  1904. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1905. int AlarmStatus = WsDB.GetAlarmStatus();
  1906. WsDB.closeDB();
  1907. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1908. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1909. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1910. }
  1911. }
  1912. if (getPopupActivityRun()) {
  1913. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1914. else return false;
  1915. }
  1916. else {
  1917. setPopupActivityRun(true);
  1918. Intent intent = new Intent(mContext, PopupActivity.class);
  1919. intent.putExtra("ScreenId", ScreenId);
  1920. overridePendingTransition(0, 0);
  1921. startActivityForResult(intent, 0);
  1922. return true;
  1923. }
  1924. } catch (RuntimeException re) {
  1925. LogUtil.errorLogInfo("", TAG, re);
  1926. return false;
  1927. }
  1928. catch (Exception e) {
  1929. Log.e(TAG, "[Exception] StartPopup(int ScreenId)");
  1930. LogUtil.errorLogInfo("", TAG, e);
  1931. return false;
  1932. }
  1933. }
  1934. /**
  1935. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  1936. *
  1937. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1938. * @param data - 전달할 데이터
  1939. * @return (boolean) true : 성공, false : 실패
  1940. */
  1941. public boolean StartPopup(int ScreenId, Intent data) {
  1942. try {
  1943. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1944. if (Common.bWallPadCallLive) {
  1945. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1946. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1947. }
  1948. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1949. int AlarmStatus = WsDB.GetAlarmStatus();
  1950. WsDB.closeDB();
  1951. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1952. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1953. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1954. }
  1955. }
  1956. if (getPopupActivityRun()) {
  1957. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1958. else return false;
  1959. }
  1960. else {
  1961. setPopupActivityRun(true);
  1962. Intent intent = new Intent(mContext, PopupActivity.class);
  1963. intent.putExtra("ScreenId", ScreenId);
  1964. intent.putExtra("PopupScreenDataIntent", data);
  1965. overridePendingTransition(0, 0);
  1966. startActivityForResult(intent, 0);
  1967. return true;
  1968. }
  1969. } catch (RuntimeException re) {
  1970. LogUtil.errorLogInfo("", TAG, re);
  1971. return false;
  1972. }
  1973. catch (Exception e) {
  1974. Log.e(TAG, "[Exception] StartPopup(int ScreenId, Intent data)");
  1975. LogUtil.errorLogInfo("", TAG, e);
  1976. return false;
  1977. }
  1978. }
  1979. /**
  1980. * Activity Result Reception
  1981. */
  1982. @Override
  1983. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  1984. super.onActivityResult(requestCode, resultCode, data);
  1985. try {
  1986. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  1987. // int screenId = data.getIntExtra("SCREENS", -1);
  1988. // Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@ screenId : " + screenId );
  1989. //if( mViewFlipper)
  1990. if (requestCode == UNINSTALL_REQUEST_CODE) {
  1991. if (resultCode == RESULT_OK) {
  1992. Log.w(TAG, "[onActivityResult] user accepted the uninstall");
  1993. } else if (resultCode == RESULT_CANCELED) {
  1994. Log.w(TAG, "[onActivityResult] user canceled the uninstall");
  1995. } else if (resultCode == RESULT_FIRST_USER) {
  1996. Log.w(TAG, "[onActivityResult] failed to uninstall");
  1997. }
  1998. }
  1999. else {
  2000. if (data != null) {
  2001. int nSenderScreenID = data.getIntExtra(Common.BR_SENDER_SCREEN, -1);
  2002. int nReceiveScreenID = data.getIntExtra(Common.BR_RECEIVE_SCREEN, -1);
  2003. int nCallSubMenuScreen = data.getIntExtra(Common.CALL_SUBMAIN_SCREEN, -1);
  2004. if (nCallSubMenuScreen > 0) {
  2005. CallSubMenuScreen(nCallSubMenuScreen);
  2006. }
  2007. else {
  2008. Log.d(TAG, "[onActivityResult] nSenderScreenID : " + nSenderScreenID + " , nReceiveScreenID : " + nReceiveScreenID );
  2009. if (nSenderScreenID == ID.POPUPS.POPUP_DELETESHORTCUT) {
  2010. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  2011. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  2012. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  2013. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  2014. MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  2015. return;
  2016. }
  2017. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  2018. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  2019. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  2020. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  2021. Hyosung_HN_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  2022. return;
  2023. }
  2024. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  2025. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  2026. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  2027. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  2028. MetroUI_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  2029. return;
  2030. }
  2031. }
  2032. else if (nSenderScreenID == ID.POPUPS.POPUP_ADDSHORTCUT) {
  2033. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  2034. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  2035. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  2036. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  2037. MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  2038. return;
  2039. }
  2040. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  2041. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  2042. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  2043. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  2044. Hyosung_HN_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  2045. return;
  2046. }
  2047. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  2048. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  2049. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  2050. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  2051. MetroUI_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  2052. return;
  2053. }
  2054. }
  2055. else if (nSenderScreenID == ID.POPUPS.POPUP_CONFIGUREPRESET && nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  2056. String strLivinglightPresetInfo = data.getStringExtra(Common.BR_LIVINGLIGHT_PRESET_INFO);
  2057. Log.d(TAG, "[onActivityResult] strLivinglightPresetInfo [" + strLivinglightPresetInfo + "]");
  2058. savePresetValue(strLivinglightPresetInfo);
  2059. return;
  2060. }
  2061. else if ((ID.POPUPS.POPUP_GROUP_CTRL <= nSenderScreenID && nSenderScreenID <= ID.POPUPS.POPUP_GROUP_SETTING) && nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_GROUP) {
  2062. boolean bRun = data.getBooleanExtra(Common.BR_RUN_WIDGET, false);
  2063. int nIconID = data.getIntExtra(Common.BR_RUN_WIDGET_ID, 0);
  2064. Log.d(TAG, "[onPopupResult] bRun [" + bRun + "], nIconID [" + nIconID + "]") ;
  2065. if (bRun) runIcon(nIconID);
  2066. }
  2067. }
  2068. }
  2069. if (resultCode == RESULT_OK) {
  2070. // // 팝업을 종료하고 다른 팝업을 띄울경우가 있다.
  2071. // int screenIdCode = data.getExtras().getInt("CHANGE_POPUP" );
  2072. // int popupKind = data.getExtras().getInt("POPUP_KIND");
  2073. //
  2074. // Log.d(TAG, "@@@ CHANGE_POPUP : " + screenIdCode + " , popupKind : " +popupKind);
  2075. // if( screenIdCode > 0 )
  2076. // {
  2077. // setPopupActivityRun(false);
  2078. // Intent intent = new Intent();
  2079. // intent.putExtra("POPUP_KIND", popupKind );
  2080. // StartPopup(screenIdCode , intent);
  2081. // }
  2082. }
  2083. }
  2084. }
  2085. catch (RuntimeException re) {
  2086. LogUtil.errorLogInfo("", TAG, re);
  2087. }
  2088. catch (Exception e )
  2089. {
  2090. Log.e(TAG, e.toString());
  2091. LogUtil.errorLogInfo("", TAG, e);
  2092. }
  2093. }
  2094. /* ================================================================================================
  2095. * [Info Activity] Section
  2096. ================================================================================================ */
  2097. public static ManualActivity mManualActivity;
  2098. /**
  2099. * Info Activity를 시작시킨다.
  2100. *
  2101. * @param screenId - 매뉴얼 시작시 Screen ID_OLD
  2102. * @return (boolean) true : 성공, false : 실패
  2103. */
  2104. public boolean startManualPopup(int screenId) {
  2105. Log.d(TAG, "[startManualPopup] ScreenId [" + screenId +"], mCurrentInfoScreenId [" + mCurrentInfoScreenId + "]" );
  2106. if (getInfoActivityRun() == true) {
  2107. mCurrentInfoScreenId = screenId;
  2108. return ((WpadActivity)(ManualActivity.getContext())).ChangeScreen(screenId);
  2109. } else {
  2110. if (mCurrentInfoScreenId == screenId) return false;
  2111. mCurrentInfoScreenId = screenId;
  2112. setInfoActivityRun(true);
  2113. Intent intent = new Intent(mContext, ManualActivity.class);
  2114. intent.putExtra("ScreenId", screenId);
  2115. overridePendingTransition(0, 0);
  2116. startActivityForResult(intent, 0);
  2117. return true;
  2118. }
  2119. }
  2120. public static void resetCurrentInfoScreenID() {
  2121. try {
  2122. mCurrentInfoScreenId = -1;
  2123. } catch (RuntimeException re) {
  2124. LogUtil.errorLogInfo("", TAG, re);
  2125. }
  2126. catch (Exception e) {
  2127. Log.e(TAG, "[Exception] resetCurrentInfoScreenID()");
  2128. LogUtil.errorLogInfo("", TAG, e);
  2129. }
  2130. }
  2131. /**
  2132. * 매뉴얼 버튼 사용 유무
  2133. *
  2134. * @return boolean 타입 - true:사용, false:미사용
  2135. */
  2136. public boolean GetManualUse() {
  2137. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  2138. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  2139. devSet.closeDB();
  2140. if (DBinfo != null) {
  2141. if (DBinfo[1].indexOf("사용함") > 0) {
  2142. Log.d(TAG, "[GetManualUse] Use Manual");
  2143. return true;
  2144. }
  2145. else {
  2146. // 미사용
  2147. Log.d(TAG, "[GetManualUse] Not Use Manual");
  2148. return false;
  2149. }
  2150. }
  2151. else {
  2152. //미사용
  2153. return false;
  2154. }
  2155. }
  2156. /* ================================================================================================
  2157. * [Screen] Section
  2158. ================================================================================================ */
  2159. /**
  2160. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  2161. * Override 사용하여 Screen 변경을 처리한다.<br>
  2162. *
  2163. * @param nScreenId - 변경할 Screen ID_OLD
  2164. * @return (boolean) true : 성공, false : 실패
  2165. */
  2166. @Override
  2167. protected boolean onChangeScreen(int nScreenId) {
  2168. super.onChangeScreen(nScreenId);
  2169. return setChangeScreen(nScreenId, false, false);
  2170. }
  2171. /**
  2172. * Screen 등록자<br>
  2173. * MainScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  2174. *
  2175. * @param nScreenId - 변경할 Screen ID_OLD
  2176. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  2177. * @return (boolean) true : 성공, false : 실패
  2178. */
  2179. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove, boolean setAnimation) {
  2180. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  2181. // 1. 현재 Layout 삭제
  2182. boolean remove = false;
  2183. if (mCurrentScreenId > 0) {
  2184. remove = true;
  2185. MainScreenLayout.removeAllViews();
  2186. super.setCurrentScreen(null);
  2187. }
  2188. if (OnlyRemove) return true;
  2189. mCurrentScreenId = nScreenId;
  2190. // 2. 새로운 Layout 표시
  2191. try {
  2192. switch (nScreenId) {
  2193. case ID.SCREENS.SCREEN_MAIN:
  2194. MainScreen = new MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  2195. super.setCurrentScreen(MainScreen);
  2196. break;
  2197. case ID.SCREENS.SCREEN_SUB_01:
  2198. SUB_01Screen = new SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2199. super.setCurrentScreen(SUB_01Screen);
  2200. break;
  2201. case ID.SCREENS.SCREEN_SUB_02:
  2202. SUB_02Screen = new SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2203. super.setCurrentScreen(SUB_02Screen);
  2204. break;
  2205. case ID.SCREENS.SCREEN_METROUI_MAIN:
  2206. MetroUI_MainScreen = new METROUI_MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  2207. super.setCurrentScreen(MetroUI_MainScreen);
  2208. break;
  2209. case ID.SCREENS.SCREEN_METROUI_SUB_01:
  2210. MetroUI_SUB_01Screen = new METROUI_SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2211. super.setCurrentScreen(MetroUI_SUB_01Screen);
  2212. break;
  2213. case ID.SCREENS.SCREEN_METROUI_SUB_02:
  2214. MetroUI_SUB_02Screen = new METROUI_SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2215. super.setCurrentScreen(MetroUI_SUB_02Screen);
  2216. break;
  2217. default:
  2218. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  2219. mCurrentScreenId = -1;
  2220. return false;
  2221. }
  2222. } catch (RuntimeException re) {
  2223. LogUtil.errorLogInfo("", TAG, re);
  2224. return false;
  2225. }
  2226. catch (Exception e) {
  2227. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  2228. return false;
  2229. }
  2230. return true;
  2231. }
  2232. /////////////////////////////////////////////////////////////////////////////////
  2233. private void runDeviceService() {
  2234. try {
  2235. Log.i(TAG, "[runDeviceService] ===== START =====");
  2236. /* 2018.01.30 속초 아이파크 RF현관카메라 연동으로 인하여 수정
  2237. // 우선 제어기기 연동 기능이 없음
  2238. if( Version.getModelType() == Version.MODEL_TYPE.IHN_750 )
  2239. return;
  2240. */
  2241. if (!getIsSubWallpad()) {
  2242. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2243. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2244. Common.DebugLog("[runDeviceService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2245. for (int i = 0; i < RunningAppList.size(); i++) {
  2246. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2247. Common.DebugLog("[runDeviceService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2248. if (RunningAppListInfo.processName.equals("com.artncore.deviceservice")) {
  2249. Log.w(TAG, "[runDeviceService] DevService is already running");
  2250. return;
  2251. }
  2252. }
  2253. Log.i(TAG, "[runDeviceService] Start DevService!!");
  2254. Intent mIntent = new Intent("wallpaddevservice.ServiceMain");
  2255. startService(mIntent);
  2256. }
  2257. else {
  2258. Log.w(TAG, "[runDeviceService] This wallpad is sub-wallpad. not need DevService!!!");
  2259. }
  2260. } catch (RuntimeException re) {
  2261. LogUtil.errorLogInfo("", TAG, re);
  2262. }
  2263. catch (Exception e) {
  2264. Log.e(TAG, "[Exception] runDeviceService()");
  2265. LogUtil.errorLogInfo("", TAG, e);
  2266. }
  2267. }
  2268. private void runOcfService() {
  2269. Log.i(TAG, "[runOcfService] Start LightControlService!!");
  2270. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2271. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2272. Common.DebugLog("[runOcfService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2273. for (int i = 0; i < RunningAppList.size(); i++) {
  2274. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2275. Common.DebugLog("[runOcfService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2276. if (RunningAppListInfo.processName.equals("kr.co.icontrols.ocfservice")) {
  2277. Log.w(TAG, "[runOcfService] DevService is already running");
  2278. return;
  2279. }
  2280. }
  2281. Intent mIntent = new Intent("kr.co.icontrols.ocfservice.LightControlService");
  2282. mIntent.setAction(ILightControlService.class.getName());
  2283. mIntent.putExtra("name", "test");
  2284. startService(mIntent);
  2285. }
  2286. private void runMultiControlService() {
  2287. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2288. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2289. Common.DebugLog("[runMultiControlService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2290. for (int i = 0; i < RunningAppList.size(); i++) {
  2291. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2292. Common.DebugLog("[runMultiControlService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2293. if (RunningAppListInfo.processName.equals("kr.co.icontrols.wallpadmulticontrolservice")) {
  2294. Log.w(TAG, "[runMultiControlService] runMultiControlService is already running");
  2295. return;
  2296. }
  2297. }
  2298. Log.i(TAG, "[runMultiControlService] Start runMultiControlService!!");
  2299. Intent mIntent = new Intent("wallpadmulticontrolservice.DataSenderService");
  2300. startService(mIntent);
  2301. }
  2302. // 통신으로 들어오는 비상버튼 스킵하기 위한 딜레이 체크 변수
  2303. private long EmerCommDelayTime = 0;
  2304. public static String WALLPAD_ALERT = "WALLPAD_ALERT";
  2305. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  2306. @Override
  2307. public void onReceive(Context context, Intent intent) {
  2308. Log.i(TAG, "[mWallPadAlertBR] Receive alert BR");
  2309. String strAction = intent.getAction();
  2310. Log.d(TAG, "[mWallPadAlertBR] strAction [" + strAction + "]");
  2311. if (strAction.equalsIgnoreCase(WALLPAD_ALERT)) {
  2312. int kind = intent.getIntExtra("KIND",0);
  2313. Log.i(TAG, "[mWallPadAlertBR] " + String.format("Receive alert BR [%d][tag:%s]", kind,String.valueOf(Alert_App_On)));
  2314. // 제주 아이파크 스위트현장의 비상발생 증상을 디버깅하기 위한 코드 (JEFF, 2019.09.26)
  2315. // if (kind == 4) {
  2316. // try {
  2317. // byte hFrom = intent.getByteExtra("FROM", (byte) 0xFF);
  2318. // if (hFrom != (byte) 0xFF) {
  2319. // if (hFrom % 10 == 3) {
  2320. // Log.w(TAG, "[mWallPadAlertBR] Emergency from BathPhone!!!");
  2321. // int nDstPort = 10000;
  2322. // sendAlarmOperationToMainServer("10.0.1.1", nDstPort, EMER_STATE.FIRE, EMER_DETAIL_INFO.EMERGENCY_COMM);
  2323. // return;
  2324. // }
  2325. // }
  2326. // } catch (RuntimeException re) {
  2327. // LogUtil.errorLogInfo("", TAG, re);
  2328. // }
  2329. // catch (Exception e) {
  2330. // Log.e(TAG, "[Exception] mWallPadAlertBR - 1");
  2331. // e.printStackTrace();
  2332. // }
  2333. // }
  2334. if (kind == 30) Alert_App_On = true;
  2335. else if (kind == 40) Alert_App_On = false;
  2336. else {
  2337. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2338. int alarmState = wdb.GetAlarmStatus();
  2339. wdb.closeDB();
  2340. if (alarmState == WallpadStatusData.ALARM_ARISE || alarmState == WallpadStatusData.ALARM_STOP) {
  2341. // 알람화면이 현재 실행중이면 스킵
  2342. Log.d(TAG, "Skip BR ==> Current Alarm state : "+ alarmState );
  2343. return;
  2344. }
  2345. if (kind == 4 && ( Math.abs(System.currentTimeMillis()-EmerCommDelayTime) < 1000)) {
  2346. // 통신 비상알람의 경우 중복으로 날라오는 경우가 있어서 필터링
  2347. Log.d(TAG, "Skip BR ==> deleayTime :" + String.valueOf( Math.abs(System.currentTimeMillis()-EmerCommDelayTime)));
  2348. return;
  2349. }
  2350. EmerCommDelayTime = System.currentTimeMillis();
  2351. SendAppFinishReqBR();
  2352. Log.i(TAG, "[mWallPadAlertBR] before Call Alert App");
  2353. int base = 7000;
  2354. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  2355. int Menu_Start_Id = base+21;
  2356. int Menu_Start_Option = 1;
  2357. String Cause = "none";
  2358. if (kind == 1) Cause = "gas";
  2359. else if (kind == 2) Cause = "fire";
  2360. else if (kind == 4) Cause = "emergency_Comm";
  2361. else if (kind == 5) {
  2362. Cause = "heating_Leak";
  2363. Menu_Start_Id = base + 51;
  2364. }
  2365. else {
  2366. Cause = "unknown(" + kind + ")";
  2367. }
  2368. Intent newintent = new Intent(Intent.ACTION_MAIN);
  2369. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2370. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2371. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2372. newintent.putExtra("MENU_DETAIL_INFO", Cause);
  2373. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2374. newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  2375. startActivity(newintent);
  2376. }
  2377. }
  2378. }
  2379. };
  2380. private void sendAlarmOperationToMainServer(String DstIP, int DstPort, EMER_STATE alarm_mode, EMER_DETAIL_INFO cause) {
  2381. Log.d(TAG, "[sendAlarmOperationToMainServer] DstIP [" + DstIP + "], DstPort [" + DstPort + "], alarm_mode [" + EMER_STATE.GetXMLData(alarm_mode) + "], cause [" + EMER_DETAIL_INFO.GetXMLData(cause) + "]");
  2382. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  2383. AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴
  2384. wdb.closeDB();
  2385. final iMAPAlarmOperation imapAlarmOperation = new iMAPAlarmOperation(getContext() , addc);
  2386. imapAlarmOperation.SetServerIPcfg(DstIP, DstPort);
  2387. imapAlarmOperation.DoWork(alarm_mode, cause);
  2388. imapAlarmOperation.SetRetCtr(new RetProci(){
  2389. @Override
  2390. public void ProcSuccess() {
  2391. // TODO Auto-generated method stub
  2392. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcSuccess()");
  2393. String result = imapAlarmOperation.GetAttributeVal(0, "result");
  2394. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2395. if (result.equalsIgnoreCase("ok")) {
  2396. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2397. }
  2398. }
  2399. @Override
  2400. public void ProcError() {
  2401. // TODO Auto-generated method stub
  2402. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcError() -> " + APIErrorCode.GetLogPrefix());
  2403. }
  2404. @Override
  2405. public void ProcDoing() {
  2406. // TODO Auto-generated method stub
  2407. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcDoing()");
  2408. }
  2409. });
  2410. }
  2411. private String getMainVersion() {
  2412. return this.getAppVersion();
  2413. }
  2414. private int m_LiveImapServer = 0;
  2415. private int m_LiveMainActivity = 0;
  2416. private boolean m_IPActivity = false;
  2417. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  2418. @Override
  2419. public void onReceive(Context context, Intent intent) {
  2420. String strAction = intent.getAction();
  2421. int item = 0;
  2422. Log.i(TAG, "[mWallPadNotifyBR] strAction [" + strAction + "]");
  2423. if (strAction.equals(define.NOTIFY_ACNAME)) {
  2424. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2425. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACNAME -> kind : " + kind);
  2426. switch (kind) {
  2427. case define.NOTIFY_GET_ELEC_CHARGE:
  2428. String strState = intent.getStringExtra("sCharging_Status");
  2429. String strCarNum = intent.getStringExtra("sCar_Num");
  2430. String strChargerNum = intent.getStringExtra("sCharger_Num");
  2431. if (strState.equals("start")) {
  2432. try {
  2433. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2434. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2435. SetData.closeDB();
  2436. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2437. } catch (RuntimeException re) {
  2438. LogUtil.errorLogInfo("", TAG, re);
  2439. }
  2440. catch (Exception e) {
  2441. LogUtil.errorLogInfo("", TAG, e);
  2442. }
  2443. // 충전시작
  2444. Intent data = new Intent();
  2445. data.putExtra("CarNum", strCarNum);
  2446. data.putExtra("ChargerNum", strChargerNum);
  2447. data.putExtra("Msg", "충전을 시작합니다.");
  2448. mIOInterface.ctrlLcdWakeUp();
  2449. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2450. }
  2451. else if (strState.equals("stop")) {
  2452. try {
  2453. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2454. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2455. SetData.closeDB();
  2456. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2457. } catch (RuntimeException re) {
  2458. LogUtil.errorLogInfo("", TAG, re);
  2459. }
  2460. catch (Exception e) {
  2461. LogUtil.errorLogInfo("", TAG, e);
  2462. }
  2463. // 충전 종료
  2464. Intent data = new Intent();
  2465. data.putExtra("CarNum", strCarNum);
  2466. data.putExtra("ChargerNum", strChargerNum);
  2467. data.putExtra("Msg", "충전이 종료되었습니다.");
  2468. mIOInterface.ctrlLcdWakeUp();
  2469. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2470. }
  2471. break;
  2472. case define.NOTIFY_INTERLAYTER_NOISE_ALARM:
  2473. if (checkInterFloorNoiseFuncUsage()) {
  2474. mIOInterface.ctrlLcdWakeUp();
  2475. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED);
  2476. }
  2477. break;
  2478. case define.NOTIFY_INTERLAYTER_SENSOR_STATUS_CHANGE :
  2479. if (checkInterFloorNoiseFuncUsage() && checkInterFloorNoiseError()) {
  2480. mIOInterface.ctrlLcdWakeUp();
  2481. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEERROR);
  2482. }
  2483. break;
  2484. case define.NOTIFY_AUTOPICTURE_FINISH:
  2485. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_AUTOPICTURE_FINISH");
  2486. // 전자액자 종료 BR 수신시 LCD ON Flag 제거
  2487. ctrlLCDOnOff(false);
  2488. break;
  2489. case define.NOTIFY_ALARM_CHANGE:
  2490. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ALARM_CHANGE");
  2491. // WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2492. // int nAlarmStatus = SetData.GetAlarmStatus();
  2493. // SetData.closeDB();
  2494. //
  2495. // Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus = " + nAlarmStatus);
  2496. // if (nAlarmStatus == WallpadStatusData.GUARD_IN) {
  2497. // mSound.PlayMent(SND.mode.INMODE_SETTING);
  2498. // }
  2499. // else if (nAlarmStatus == WallpadStatusData.GUARD_OUT) {
  2500. // mSound.PlayMent(SND.mode.OUTMODE_SETTING);
  2501. // }
  2502. // else if (nAlarmStatus == WallpadStatusData.ALARM_NONE) {
  2503. // mSound.PlayMent(SND.mode.NORMALMODE_COMEBACK);
  2504. // }
  2505. break;
  2506. case define.NOTIFY_PLAYMENT:
  2507. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2508. Sound().PlayMent(sndidx);
  2509. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  2510. Log.i(TAG, "[mWallPadNotifyBR] NOTIFY_DEVICE_INIT_COMPLETION: bLCDKeeperUsage [" + bLCDKeeperUsage +"]");
  2511. if (bLCDKeeperUsage) registerLCDKeeper();
  2512. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  2513. registerNoticeStrangerRecord();
  2514. }
  2515. break;
  2516. default:
  2517. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2518. break;
  2519. }
  2520. }
  2521. else if (strAction.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  2522. Log.d(TAG, "[mWallPadNotifyBR] Common.BR_ACK_WALLPADCALL_LIVE");
  2523. return;
  2524. }
  2525. else if (strAction.equals(define.DRIVER_VENTIL_BR)) {
  2526. Log.d(TAG, "[mWallPadNotifyBR] define.DRIVER_VENTIL_BR");
  2527. return;
  2528. }
  2529. else if (strAction.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  2530. try {
  2531. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2532. Log.d(TAG, "[mWallPadNotifyBR] ACNAME_MAIN_NOTI -> kind : " + kind);
  2533. switch (kind) {
  2534. case Common.BR_MAIN_NOTI.ARRIVED_CAR:
  2535. StartPopup(ID.POPUPS.POPUP_VEHICLEARRIVED, intent);
  2536. // StartPopup(ID_OLD.SCREENS.ArrivedCarPopupScreen);
  2537. break;
  2538. case Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL:
  2539. StartPopup(ID.POPUPS.POPUP_PARCELRECEIVED);
  2540. // StartPopup(ID_OLD.SCREENS.DeliveryBox);
  2541. break;
  2542. case Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR:
  2543. StartPopup(ID.POPUPS.POPUP_SMARTKEYEMERGENCY, intent);
  2544. // StartPopup(ID_OLD.SCREENS.SmartKeyAlarmPopupScreen, intent);
  2545. break;
  2546. case Common.BR_MAIN_NOTI.UI_BANDLOCATION_ALARM:
  2547. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM,0);
  2548. Intent mIntent = new Intent();
  2549. mIntent.putExtra(Common.BR_MAIN_NOTI.CARD_NUM, nCardNum);
  2550. StartPopup(ID.POPUPS.POPUP_BANDLOCATIONALARM, mIntent);
  2551. break;
  2552. case Common.BR_MAIN_NOTI.UI_UPDATE_POST:
  2553. StartPopup(ID.POPUPS.POPUP_POSTRECEIVED);
  2554. break;
  2555. case Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER:
  2556. // 알람 상태 확인
  2557. int doorCamType = intent.getIntExtra("DOORCAM_TYPE", -1);
  2558. Intent data = new Intent();
  2559. data.putExtra("DOORCAM_TYPE", doorCamType);
  2560. // StartPopup(ID.POPUPS.POPUP_NOTICESTRANGER, data); // 시나리오 변경: 거동수상자 알림 팝업 삭제 (바로 녹화 시작)
  2561. // 메인 앱으로 BR 전송
  2562. Intent notiIntent = new Intent();
  2563. notiIntent.setAction(define.NOTIFY_ACNAME);
  2564. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ACCEPT_RECORD_STRANGER);
  2565. mContext.sendBroadcast(notiIntent);
  2566. break;
  2567. case Common.BR_MAIN_NOTI.ACCEPT_RECORDING:
  2568. checkRecordTimer();
  2569. int nEmerState = intent.getIntExtra("EMERGENCY_STATE", -1);
  2570. Log.d(TAG, "[mWallPadNotifyBR] nEmerState [" + nEmerState + "], bRecordStatus [" + bRecordStatus + "]");
  2571. // m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door_Record, nEmerState); // 거동수상자 발생시 통화 앱에서 녹화
  2572. if (!bRecordDelay) {
  2573. if (!bRecordStatus) {
  2574. if (nEmerState == WallpadStatusData.GUARD_OUT) {
  2575. Log.d(TAG, "[mWallPadNotifyBR] ===== NOTIFY_GUARD_OUT_RECORDING =====");
  2576. Intent GIntent = new Intent(); // 외출방범 중 거동수상자 녹화 알림 -> 외출방범 앱 종료시 방범 상태를 해제하지 않음
  2577. GIntent.setAction("Alarm Running");
  2578. GIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GUARD_OUT_RECORDING);
  2579. mContext.sendBroadcast(GIntent);
  2580. }
  2581. Common.SendAppFinishReqBR(getApplicationContext());
  2582. startStrangerRecord(); // 시나리오 수정 -> 메인 앱에서 바로 녹화
  2583. }
  2584. } else {
  2585. Log.w(TAG, "[mWallPadNotifyBR] Block Stranger Record!!! bRecordDelay [" + bRecordDelay + "]");
  2586. }
  2587. break;
  2588. case Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN:
  2589. // 거동수상자 녹화 중 현관카메라 호출되는 경우
  2590. Log.d(TAG, "[mWallPadNotifyBR] NOTICE_DOORCAM_BTN === bRecordStatus [" + bRecordStatus + "] ===");
  2591. stopStrangerRecord(true);
  2592. showFrontCam(false);
  2593. runNoticeStrangerRecord(false);
  2594. break;
  2595. case Common.BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN:
  2596. // 거동수상자 녹화 중 하단 LED 버튼을 통해 현관 모니터링 실행되는 경우
  2597. Log.d(TAG, "[mWallPadNotifyBR] NOTICE_FRONT_MONITOR_BTN === bRecordStatus [" + bRecordStatus + "] ===");
  2598. stopStrangerRecord(true);
  2599. runNoticeStrangerRecord(false);
  2600. break;
  2601. case Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN:
  2602. // Camera_ONOFF 설정.
  2603. int ret = mIOInterface.getCameraOnOFF();
  2604. break;
  2605. default:
  2606. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2607. break;
  2608. }
  2609. } catch (RuntimeException re) {
  2610. LogUtil.errorLogInfo("", TAG, re);
  2611. }
  2612. catch (Exception e) {
  2613. e.toString();
  2614. }
  2615. return;
  2616. }
  2617. else if(strAction.equals(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER )) {
  2618. int kind = intent.getIntExtra(BR_MAIN_LIVE_CHECKER.KIND,0);
  2619. Log.d(TAG, "[mWallPadNotifyBR] BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER -> kind : " + kind + ", m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity + "]");
  2620. if (kind == BR_MAIN_LIVE_CHECKER.IMAP_SERVER) {
  2621. Log.d(TAG, "[mWallPadNotifyBR] received Imap Server Live !");
  2622. m_LiveImapServer++;
  2623. }
  2624. else if( kind == BR_MAIN_LIVE_CHECKER.MAIN_ACTIVITY) {
  2625. Log.d(TAG, "[mWallPadNotifyBR] received Main Activity Live !");
  2626. m_LiveMainActivity++;
  2627. if (m_IPActivity == false) {
  2628. Log.d(TAG, "[mWallPadNotifyBR] IP is not set");
  2629. m_LiveImapServer++;
  2630. }
  2631. }
  2632. Log.d(TAG, "[mWallPadNotifyBR] m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity +"]");
  2633. return;
  2634. }
  2635. int kind = intent.getIntExtra("KIND",0);
  2636. Log.d(TAG, "MainActivity mWallPadNotifyBR Receive Notify BR "+kind+" "/*+electr.isActive()*/);
  2637. switch (kind) {
  2638. case define.NOTIFY_ELE_MOVE:
  2639. // if (electr!= null /*&& electr.isActive()*/)
  2640. // {
  2641. // Log.i("MAINSCREEN", "Receive NOTIFY_ELE_MOVE");
  2642. // electr.updateUI(intent.getStringExtra("FLOOR"), intent.getByteExtra("UPDOWN",(byte)-1));
  2643. // }
  2644. break;
  2645. case define.NOTIFY_ELE_ARRIVAL_UP:
  2646. Log.i("AIDLTEST", "Receive NOTIFY_ELE_ARRIVAL_UP");
  2647. Sound().Play(SND.elevator.UP_ARRIVED);
  2648. break;
  2649. case define.NOTIFY_ELE_ARRIVAL_DOWN:
  2650. try {
  2651. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  2652. int eleinfo = devset.Get_Elevator_Info();
  2653. devset.closeDB();
  2654. if (WallpadDeviceSet.ELEVATOR_SIMPLE == eleinfo) Sound().Play(SND.elevator.ORG_ARRIVED);
  2655. else if (WallpadDeviceSet.ELEVATOR_FLOOR == eleinfo) Sound().Play(SND.elevator.DN_ARRIVED);
  2656. } catch (RuntimeException re) {
  2657. LogUtil.errorLogInfo("", TAG, re);
  2658. }
  2659. catch (Exception e) {
  2660. LogUtil.errorLogInfo("", TAG, e);
  2661. }
  2662. break;
  2663. case define.NOTIFY_UPDATE_START:
  2664. try {
  2665. String updateFile = intent.getStringExtra("PATH");
  2666. Log.i("WALLPADAPI","Call Update App :" + updateFile);
  2667. if (updateFile==null) return;
  2668. ComponentName cn = new ComponentName("com.telechips.android.systemupdater","com.telechips.android.systemupdater.SystemUpdate");
  2669. Intent Uintent = new Intent(Intent.ACTION_MAIN);
  2670. Uintent.addCategory(Intent.CATEGORY_LAUNCHER);
  2671. Uintent.putExtra("updatefile",updateFile);
  2672. Uintent.setComponent(cn);
  2673. startActivity(Uintent);
  2674. } catch (RuntimeException re) {
  2675. LogUtil.errorLogInfo("", TAG, re);
  2676. }
  2677. catch (Exception e) {
  2678. LogUtil.errorLogInfo("", TAG, e);
  2679. }
  2680. break;
  2681. case define.NOTIFY_DEVSERVICE_START:
  2682. mWallPadAPI = new WallPadAPI(getApplicationContext());
  2683. break;
  2684. case define.NOTIFY_DEVICECONNECTED:
  2685. //DevLockCtr.ReleaseLock(define.DEVICE_LOCK_SVC_INIT);
  2686. break;
  2687. case define.NOTIFY_SENDBOOTUP_FAIL:
  2688. // 부트업 실패시 5초 간격으로 다시 시도하도록 수정.
  2689. mWallPadApiCheckHandler.sendEmptyMessageDelayed(10, 10000);
  2690. break;
  2691. case define.NOTIFY_IMAPSERVER_START:
  2692. case Common.DEVICE_BOOTUP_RETRY:
  2693. Log.i(TAG, "Try Send Boot up MSG kind : " + kind );
  2694. bootupretryCNT++;
  2695. if (bootupretryCNT > MAX_BOOTUP_RETRY_COUNT) break;
  2696. try {
  2697. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2698. if (SetData != null) {
  2699. // AnC 기존 코드는 네트워크 연결이 안된경우 DB Close를 50회를 안 하도록 되어있어서 수정함.
  2700. String strServerIP = SetData.GetServerIP();
  2701. int nServerPort = SetData.GetServerPort();
  2702. String svrVersion = SetData.GetServerVer();
  2703. Log.d(TAG, "DB Server Version : " + svrVersion );
  2704. if (svrVersion == null) svrVersion = "1.0";
  2705. //설정정보 버전 가져오기
  2706. StringBuilder result = new StringBuilder();
  2707. result.append(SetData.GetSettingVer());
  2708. SetData.closeDB();
  2709. String Setting_Version = result.toString();
  2710. Log.i(TAG, "Setting's Version :"+Setting_Version);
  2711. boolean mNewDanjiServer = false;
  2712. try {
  2713. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2714. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2715. wallpadDeviceSet.closeDB();
  2716. } catch (RuntimeException re) {
  2717. LogUtil.errorLogInfo("", TAG, re);
  2718. mNewDanjiServer = false;
  2719. }
  2720. catch (Exception e) {
  2721. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2722. LogUtil.errorLogInfo("", TAG, e);
  2723. mNewDanjiServer = false;
  2724. }
  2725. if (mNewDanjiServer == true) {
  2726. // DB 값하고 , 신형단지서버 사용 설정이 동일 하다면 DB값을 전달한다.
  2727. // 나중에 2.X 이상 버전이 갱신될 경우를 위해서
  2728. }
  2729. else {
  2730. svrVersion = "1.0";
  2731. }
  2732. //Main App 버전정보 가져오기
  2733. WallPadiMAPNotifyAPI notify = new WallPadiMAPNotifyAPI(getApplicationContext());
  2734. notify.SetSocketWaitCount(3000);
  2735. notify.SetServerIPcfg(strServerIP, nServerPort);
  2736. notify.Send_Device_BootUP(getMainVersion(), Setting_Version , svrVersion );
  2737. }
  2738. } catch (RuntimeException re) {
  2739. LogUtil.errorLogInfo("", TAG, re);
  2740. Intent Newintent = new Intent();
  2741. Newintent.setAction(define.NOTIFY_ACNAME);
  2742. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2743. sendBroadcast(Newintent);
  2744. }
  2745. catch (Exception e) {
  2746. LogUtil.errorLogInfo("", TAG, e);
  2747. Intent Newintent = new Intent();
  2748. Newintent.setAction(define.NOTIFY_ACNAME);
  2749. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2750. sendBroadcast(Newintent);
  2751. }
  2752. break;
  2753. case define.NOTIFY_SUBDEVCALLBUSY:
  2754. /*
  2755. callbtn = (Button)findViewById(R.id.Callbtn);
  2756. callbtn.setBackgroundResource(R.drawable.but_call_on);
  2757. MAIN_CALL_LOCK = true;
  2758. */
  2759. break;
  2760. case define.NOTIFY_SUBDEVCALLEND:
  2761. /*
  2762. callbtn = (Button)findViewById(R.id.Callbtn);
  2763. callbtn.setBackgroundResource(R.drawable.but_call);
  2764. MAIN_CALL_LOCK = false;
  2765. */
  2766. break;
  2767. case define.NOTIFY_UPDATECALLDATA:
  2768. try{
  2769. String[] UpdateCallData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2770. Log.i(APIErrorCode.GetLogPrefix(),"Receive NOTIFY_UPDATECALLDATA "+UpdateCallData[0]+";"+UpdateCallData[1]);
  2771. int IncallCnt = 0;
  2772. int VisitorCNT = 0;
  2773. try {
  2774. IncallCnt = Integer.parseInt(UpdateCallData[0]);
  2775. VisitorCNT = Integer.parseInt(UpdateCallData[1]);
  2776. } catch (RuntimeException re) {
  2777. LogUtil.errorLogInfo("", TAG, re);
  2778. }
  2779. catch (Exception e) {
  2780. LogUtil.errorLogInfo("", TAG, e);
  2781. }
  2782. } catch (RuntimeException re) {
  2783. LogUtil.errorLogInfo("", TAG, re);
  2784. }
  2785. catch (Exception e) {
  2786. LogUtil.errorLogInfo("", TAG, e);
  2787. }
  2788. break;
  2789. case define.NOTIFY_UPDATENOTICE:
  2790. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATENOTICE ");
  2791. try {
  2792. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2793. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2794. SetData.closeDB();
  2795. if (soundOut) {
  2796. Sound().PlayMent(SND.effect.EFFECT1);
  2797. }
  2798. mIOInterface.ctrlLcdWakeUp();
  2799. } catch (RuntimeException re) {
  2800. LogUtil.errorLogInfo("", TAG, re);
  2801. }
  2802. catch (Exception e) { LogUtil.errorLogInfo("", TAG, e);
  2803. }
  2804. break;
  2805. case define.NOTIFY_UPDATEPARCEL:
  2806. try {
  2807. String type = intent.getStringExtra(define.NOTIBR_CONTENT);
  2808. int itemcnt = intent.getIntExtra("REMAIN_CNT",-1);
  2809. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2810. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2811. if (itemcnt !=-1) SetData.SetParcelCNT(itemcnt);
  2812. SetData.closeDB();
  2813. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARCEL itemcnt : " + itemcnt);
  2814. // if (soundOut) {
  2815. // if (type.equals("parcel_in")) {
  2816. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2817. // pm.userActivity(1, true);
  2818. // Sound().PlayMent(SND.mode.BOX_ARRIVED);
  2819. // }
  2820. // }
  2821. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL");
  2822. Intent Newintent = new Intent();
  2823. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2824. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL);
  2825. getApplicationContext().sendBroadcast(Newintent);
  2826. //NoticeIconOnoff(true);
  2827. } catch (RuntimeException re) {
  2828. LogUtil.errorLogInfo("", TAG, re);
  2829. }
  2830. catch (Exception e) {
  2831. LogUtil.errorLogInfo("", TAG, e);
  2832. }
  2833. // if (type.equals("parcel_in"))
  2834. // {
  2835. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2836. // pm.userActivity(1, true);
  2837. // PlayNotiSound(WpadSound.SND.mode.BOX_ARRIVED);
  2838. // }
  2839. //
  2840. // if (itemcnt!=-1){
  2841. // if (itemcnt > 0)
  2842. // ParcelIconOnoff(true);
  2843. // else
  2844. // ParcelIconOnoff(false);
  2845. // WallpadStatusData ParData = new WallpadStatusData(getApplicationContext());
  2846. // ParData.SetParcelCNT(itemcnt);
  2847. // ParData.closeDB();
  2848. // if (ParcelMGR!=null) ParcelMGR.updateParcel();
  2849. // }
  2850. break;
  2851. case define.NOTIFY_UPDATEPOST:
  2852. try {
  2853. int nItemCnt = intent.getIntExtra("ITEM",-1);
  2854. Log.d(TAG, "[UI_UPDATE_POST] nItemCnt [" + nItemCnt + "]");
  2855. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2856. if (nItemCnt != -1) SetData.SetPostCNT(nItemCnt);
  2857. SetData.closeDB();
  2858. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPOST nItemCnt : " + nItemCnt);
  2859. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_POST");
  2860. Intent Newintent = new Intent();
  2861. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2862. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_POST);
  2863. getApplicationContext().sendBroadcast(Newintent);
  2864. } catch (RuntimeException re) {
  2865. LogUtil.errorLogInfo("", TAG, re);
  2866. }
  2867. catch (Exception e) {
  2868. Log.e(TAG, "[Exception] mWallPadNotifyBR.onReceive()");
  2869. LogUtil.errorLogInfo("", TAG, e);
  2870. }
  2871. break;
  2872. case define.NOTIFY_UPDATEPARKING:
  2873. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARKING ");
  2874. /*
  2875. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  2876. List<String[]> parkList = parkdb.GetParkInfo();
  2877. if(parkList != null)
  2878. {
  2879. for(int j= 0; j<parkList.size(); j++)
  2880. {
  2881. for(int i = 0; i<4; i++)
  2882. {
  2883. Common.DebugLog("parkList.get("+j+")["+i+"]:"+ parkList.get(j)[i]);
  2884. }
  2885. }
  2886. }
  2887. parkdb.closeDB();
  2888. */
  2889. break;
  2890. case define.NOTIFY_DEVICEREBOOT:
  2891. try {
  2892. //[Model]
  2893. // if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  2894. // // A20
  2895. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  2896. // pm.userActivity(8, true);
  2897. // }
  2898. // else if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2899. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2900. // V40
  2901. V40IOInterface mV40IOInterface = new V40IOInterface();
  2902. mV40IOInterface.setV40Reboot(5);
  2903. }
  2904. else {
  2905. // TCC8935
  2906. SendAppFinishReqBR();
  2907. ComponentName cnA = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2908. intent = new Intent(Intent.ACTION_MAIN);
  2909. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2910. intent.putExtra("updatesystem", "no");
  2911. intent.putExtra("updateapp", " no ");
  2912. intent.putExtra("rebootcmd", "reboot");
  2913. intent.setComponent(cnA);
  2914. startActivity(intent);
  2915. }
  2916. } catch (RuntimeException re) {
  2917. LogUtil.errorLogInfo("", TAG, re);
  2918. }
  2919. catch (Exception e) {
  2920. LogUtil.errorLogInfo("", TAG, e);
  2921. }
  2922. break;
  2923. case define.NOTIFY_DEVICEDEEPSLEEP:
  2924. try {
  2925. Log.d(TAG, "[mWallPadAlertBR] NOTIFY_DEVICEDEEPSLEEP");
  2926. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  2927. String[] getstate = sdb.GetSystemUpdateStatus();
  2928. for (int i = 0; i < getstate.length; i++) {
  2929. Log.d(TAG, "[mWallPadAlertBR] getstate[" + i + "] = " + getstate[i]);
  2930. }
  2931. if (getstate[0].equalsIgnoreCase("SET")) {
  2932. sdb.SetSystemUpdate(null, null);
  2933. sdb.SetUpgradeState(true);
  2934. ComponentName cnn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2935. intent = new Intent(Intent.ACTION_MAIN);
  2936. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2937. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2938. intent.putExtra("updatesystem", getstate[1]);
  2939. intent.putExtra("updateapp", getstate[2]);
  2940. intent.setComponent(cnn);
  2941. Log.e("MAINSCREEN","Call Upgrade Request BSP : "+getstate[1]+" APP : "+getstate[2]);
  2942. startActivity(intent);
  2943. }
  2944. sdb.closeDB();
  2945. } catch (RuntimeException re) {
  2946. LogUtil.errorLogInfo("", TAG, re);
  2947. }
  2948. catch (Exception e) {
  2949. LogUtil.errorLogInfo("", TAG, e);
  2950. }
  2951. break;
  2952. case define.NOTIFY_SYSTEMTIMESETTED:
  2953. try {
  2954. Common.DebugLog("MainActivity ---------- > define.NOTIFY_SYSTEMTIMESETTED");
  2955. Calendar caldata = new GregorianCalendar();
  2956. // refreshdate(caldata);
  2957. // refreshclock(caldata);
  2958. if (SYSTEM_TIME_SET == false) {
  2959. SYSTEM_TIME_SET = true;
  2960. if (SCManager != null) {
  2961. if (SCManager.isSetted != true) SCManager.refreshSchedule();
  2962. }
  2963. }
  2964. } catch (RuntimeException re) {
  2965. LogUtil.errorLogInfo("", TAG, re);
  2966. }
  2967. catch (Exception e) {
  2968. LogUtil.errorLogInfo("", TAG, e);
  2969. }
  2970. break;
  2971. case define.NOTIFY_SCHEDULEUPDATED:
  2972. // item = intent.getIntExtra("ITEM",0);
  2973. // if (item == ScheduleManager.SCHEDULE_TYPE_SCHEDULER && SYSTEM_TIME_SET)
  2974. // SCManager.refreshSchedulerData();
  2975. // else if (item == ScheduleManager.SCHEDULE_TYPE_SYSRESET && SYSTEM_TIME_SET)
  2976. // SCManager.refreshsysreset();
  2977. // else if (item == ScheduleManager.SCHEDULE_TYPE_MORNINGCALL && SYSTEM_TIME_SET)
  2978. // SCManager.refreshMorningCall();
  2979. // break;
  2980. case define.NOTIFY_ALARMSTAUSCHANGED:
  2981. try {
  2982. item = intent.getIntExtra("ITEM",0);
  2983. if (item == WallpadStatusData.GUARD_OUT) {
  2984. int base = 8000;
  2985. int [] Menu_Id_List = { base+11};
  2986. int Menu_Start_Id = base+11;
  2987. int Menu_Start_Option = -1;
  2988. Intent iintent = new Intent(Intent.ACTION_MAIN);
  2989. iintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2990. iintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2991. iintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2992. iintent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  2993. startActivity(iintent);
  2994. }
  2995. else if (item == WallpadStatusData.GUARD_IN) {
  2996. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2997. // Button callBtn = (Button)findViewById(R.id.GuardBtn);
  2998. // callBtn.setBackgroundResource((SettData.GetAlarmStatus() == WallpadStatusData.GUARD_IN)?R.drawable.but_guard_on:R.drawable.but_guard);
  2999. SettData.closeDB();
  3000. }
  3001. } catch (RuntimeException re) {
  3002. LogUtil.errorLogInfo("", TAG, re);
  3003. }
  3004. catch (Exception e) {
  3005. LogUtil.errorLogInfo("", TAG, e);
  3006. }
  3007. break;
  3008. case define.NOTIFY_ENERGYUPDATE:
  3009. try
  3010. {
  3011. Calendar caldata = new GregorianCalendar();
  3012. String[] getData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  3013. String checkDate = String.format("%04d%02d%02d",caldata.get(Calendar.YEAR),caldata.get(Calendar.MONTH)+1,caldata.get(Calendar.DAY_OF_MONTH));
  3014. WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  3015. energyData.SetEnergyData(intent.getStringExtra(define.NOTIBR_CONTENT));
  3016. energyData.SetEnergyCheckDate(checkDate);
  3017. energyData.closeDB();
  3018. //if (NeedCheckEnergy)
  3019. // CheckEnergyUsage(getData);
  3020. // if (EnergyMGR!=null)
  3021. // EnergyMGR.UpdateData(getData);
  3022. }
  3023. catch (RuntimeException re) {
  3024. LogUtil.errorLogInfo("", TAG, re);
  3025. }
  3026. catch (Exception e )
  3027. {
  3028. LogUtil.errorLogInfo("", TAG, e);
  3029. }
  3030. break;
  3031. case define.NOTIFY_STARTEFRAME:
  3032. try
  3033. {
  3034. Log.w("MAINSCREEN"," Receive NOTIFY_STARTEFRAME Start StartAutoPictureAPP ");
  3035. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  3036. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar()))
  3037. {
  3038. if (!SettData.StartAutoPictureAPP())
  3039. {
  3040. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3041. // pm.userActivity(3, true);
  3042. }
  3043. }
  3044. else
  3045. {
  3046. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3047. // pm.userActivity(3, true);
  3048. }
  3049. SettData.closeDB();
  3050. }
  3051. catch (RuntimeException re) {
  3052. LogUtil.errorLogInfo("", TAG, re);
  3053. }
  3054. catch (Exception e )
  3055. {
  3056. LogUtil.errorLogInfo("", TAG, e);
  3057. }
  3058. break;
  3059. case define.NOTIFY_ADDDEVICELOCK:
  3060. Log.w("MAINSCREEN"," Receive NOTIFY_ADDDEVICELOCK Start ");
  3061. //DevLockCtr.AddLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  3062. break;
  3063. case define.NOTIFY_RELEASEDEVICELOCK:
  3064. Log.w("MAINSCREEN"," Receive NOTIFY_RELEASEDEVICELOCK Start ");
  3065. //DevLockCtr.ReleaseLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  3066. break;
  3067. case define.NOTIFY_PLAYMENT:
  3068. {
  3069. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  3070. Sound().PlayMent(sndidx);
  3071. if (sndidx == WpadSound.SND.elevator.CALL) {
  3072. byte floorInfo = intent.getByteExtra(define.NOTIBR_FLOOR,(byte)0);
  3073. Log.e("MANUAL_MAIN", " PLAY MENT Get Ele Call : "+floorInfo);
  3074. }
  3075. }
  3076. break;
  3077. case define.NOTIFY_ENERGY_DATA:
  3078. {
  3079. try
  3080. {
  3081. Log.w("MAINSCREEN"," Receive NOTIFY_ENERGY DATA Start ");
  3082. //에너지 데이터 개수 - 3종 또는 5종
  3083. EnergyAlramPopupMgr.m_EnergyInfoCount = intent.getIntExtra(Common.ENERGY_INTENT_ENERGY_COUNT, -1);
  3084. Log.w("MAINSCREEN"," ENERGY_INTENT_ENERGY_COUNT :"+ EnergyAlramPopupMgr.m_EnergyInfoCount);
  3085. //에너지 단지서버에서 받아온 시간
  3086. EnergyAlramPopupMgr.m_ReceiveYear = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, -1);
  3087. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_YEAR :"+ EnergyAlramPopupMgr.m_ReceiveYear);
  3088. EnergyAlramPopupMgr.m_ReceiveMonth = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, -1);
  3089. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MONTH :"+ EnergyAlramPopupMgr.m_ReceiveMonth);
  3090. EnergyAlramPopupMgr.m_ReceiveDay = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, -1);
  3091. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_DAY :"+ EnergyAlramPopupMgr.m_ReceiveDay );
  3092. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_HOUR :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, -1));
  3093. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MINUTE :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, -1));
  3094. //전기 에너지 정보
  3095. String Vaule = "";
  3096. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_ELECTRIC);
  3097. if( Vaule != null && Vaule.length() > 0 )
  3098. EnergyAlramPopupMgr.m_Elec_UseValue = Double.parseDouble(Vaule);
  3099. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC);
  3100. if( Vaule != null && Vaule.length() > 0 )
  3101. EnergyAlramPopupMgr.m_Elec_GoalValue = Double.parseDouble(Vaule);
  3102. //수도 에너지 정보
  3103. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_WATER);
  3104. if( Vaule != null && Vaule.length() > 0 )
  3105. EnergyAlramPopupMgr.m_Water_UseValue = Double.parseDouble(Vaule);
  3106. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_WATER);
  3107. if( Vaule != null && Vaule.length() > 0 )
  3108. EnergyAlramPopupMgr.m_Water_GoalValue = Double.parseDouble(Vaule);
  3109. //가스 에너지 정보
  3110. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_GAS);
  3111. if( Vaule != null && Vaule.length() > 0 )
  3112. EnergyAlramPopupMgr.m_Gas_UseValue = Double.parseDouble(Vaule);
  3113. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_GAS);
  3114. if( Vaule != null && Vaule.length() > 0 )
  3115. EnergyAlramPopupMgr.m_Gas_GoalValue = Double.parseDouble(Vaule);
  3116. //온수 에너지 정보
  3117. if( EnergyAlramPopupMgr.m_EnergyInfoCount >= 5 )
  3118. {
  3119. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HOTWATER);
  3120. if( Vaule != null && Vaule.length() > 0 )
  3121. EnergyAlramPopupMgr.m_HotWater_UseValue = Double.parseDouble(Vaule);
  3122. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HOTWATER);
  3123. if( Vaule != null && Vaule.length() > 0 )
  3124. EnergyAlramPopupMgr.m_HotWater_GoalValue = Double.parseDouble(Vaule);
  3125. //난방 에너지 정보
  3126. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HEATING);
  3127. if( Vaule != null && Vaule.length() > 0 )
  3128. EnergyAlramPopupMgr.m_Heating_UseValue = Double.parseDouble(Vaule);
  3129. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HEATING);
  3130. if( Vaule != null && Vaule.length() > 0 )
  3131. EnergyAlramPopupMgr.m_Heating_GoalValue = Double.parseDouble(Vaule);
  3132. }
  3133. }
  3134. catch (RuntimeException re) {
  3135. LogUtil.errorLogInfo("", TAG, re);
  3136. }
  3137. catch (Exception e )
  3138. {
  3139. LogUtil.errorLogInfo("", TAG, e);
  3140. }
  3141. }
  3142. break;
  3143. case define.NOTIFY_GET_CAR_PARKING:
  3144. try
  3145. {
  3146. if(bUseofNot_ParkingInfo == true)
  3147. {
  3148. bSetMSG_GetParkingInfo = true;
  3149. LoadParkingDataFromServer();
  3150. }
  3151. else
  3152. {
  3153. DebugLogOutput("bUseofNot_ParkingInfo == false");
  3154. }
  3155. }
  3156. catch (RuntimeException re) {
  3157. LogUtil.errorLogInfo("", TAG, re);
  3158. }
  3159. catch (Exception e )
  3160. {
  3161. LogUtil.errorLogInfo("", TAG, e);
  3162. }
  3163. break;
  3164. case define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER:
  3165. String tempFromWhere = intent.getStringExtra("FromWhere");
  3166. if(tempFromWhere == null)
  3167. {
  3168. ResultGetIntent = true;
  3169. }
  3170. String tempElect_target = intent.getStringExtra("elect_target");
  3171. if(tempElect_target != null)
  3172. {
  3173. elect_target = tempElect_target;
  3174. }
  3175. String tempElect_used = intent.getStringExtra("elect_used");
  3176. if(tempElect_used != null)
  3177. {
  3178. elect_used = tempElect_used;
  3179. }
  3180. String tempElect_info = intent.getStringExtra("elect_info");
  3181. if(tempElect_info != null)
  3182. {
  3183. elect_info = tempElect_info;
  3184. }
  3185. String tempWater_target = intent.getStringExtra("water_target");
  3186. if(tempWater_target != null)
  3187. {
  3188. water_target = tempWater_target;
  3189. }
  3190. String tempWater_used = intent.getStringExtra("water_used");
  3191. if(tempWater_used != null)
  3192. {
  3193. water_used = tempWater_used;
  3194. }
  3195. String tempWater_info = intent.getStringExtra("water_info");
  3196. if(tempWater_info != null)
  3197. {
  3198. water_info = tempWater_info;
  3199. }
  3200. String tempGas_target = intent.getStringExtra("gas_target");
  3201. if(tempGas_target != null)
  3202. {
  3203. gas_target = tempGas_target;
  3204. }
  3205. String tempGas_used = intent.getStringExtra("gas_used");
  3206. if(tempGas_used != null)
  3207. {
  3208. gas_used = tempGas_used;
  3209. }
  3210. String tempGas_info = intent.getStringExtra("gas_info");
  3211. if(tempGas_info != null)
  3212. {
  3213. gas_info = tempGas_info;
  3214. }
  3215. String tempHotwater_target = intent.getStringExtra("hotwater_target");
  3216. if(tempHotwater_target != null)
  3217. {
  3218. hotwater_target = tempHotwater_target;
  3219. }
  3220. String tempHotwater_used = intent.getStringExtra("hotwater_used");
  3221. if(tempHotwater_used != null)
  3222. {
  3223. hotwater_used = tempHotwater_used;
  3224. }
  3225. String tempHotwater_info = intent.getStringExtra("hotwater_info");
  3226. if(tempHotwater_info != null)
  3227. {
  3228. hotwater_info = tempHotwater_info;
  3229. }
  3230. String tempHeating_target = intent.getStringExtra("heating_target");
  3231. if(tempHeating_target != null)
  3232. {
  3233. heating_target = tempHeating_target;
  3234. }
  3235. String tempHeating_used = intent.getStringExtra("heating_used");
  3236. if(tempHeating_used != null)
  3237. {
  3238. heating_used = tempHeating_used;
  3239. }
  3240. String tempHeatin_info = intent.getStringExtra("heating_info");
  3241. if(tempHeatin_info != null)
  3242. {
  3243. heating_info = tempHeatin_info;
  3244. }
  3245. break;
  3246. case define.NOTIFY_DOORLOCK_OPEN_RECORDING:
  3247. Log.d(TAG, "[mWallPadNotifyBR] NOTIFY_DOORLOCK_OPEN_RECORDING");
  3248. // 통화 중 현관 문열림 알림
  3249. // 거동수상자 녹화 중 현관 통화 문열림이 발생되면 저장된 파일을 삭제한다.
  3250. deleteTempRecordFile();
  3251. break;
  3252. case define.NOTIFY_FRONTCALL_END_RECORDING:
  3253. Log.d(TAG, "[mWallPadNotifyBR] NOTIFY_FRONTCALL_END_RECORDING");
  3254. // 현관 통화 종료 알림
  3255. // 거동수상자 녹화 중 현관 통화가 문열림 없이 종료되면 임시 저장 파일을 옮긴 후 디렉터리 삭제한다.
  3256. moveTempRecordFile();
  3257. break;
  3258. }
  3259. }
  3260. };
  3261. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3262. private void ctrlLCDOnOff(boolean bOn) {
  3263. try {
  3264. if (bOn) {
  3265. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3266. Log.d(TAG, "[ctrlLCDOnOff] Screen On: " + pm.isScreenOn());
  3267. if (getCompareBSPVersion("2020.09.18")) {
  3268. if (!checkLCDOnByCMD()) {
  3269. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3270. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3271. }
  3272. }
  3273. else {
  3274. if (!pm.isScreenOn()) {
  3275. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3276. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3277. }
  3278. }
  3279. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3280. } else
  3281. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3282. } catch (RuntimeException re) {
  3283. LogUtil.errorLogInfo("", TAG, re);
  3284. }
  3285. catch (Exception e) {
  3286. Log.e(TAG, "[Exception] ctrlLCDOnOff(boolean bOn)");
  3287. LogUtil.errorLogInfo("", TAG, e);
  3288. }
  3289. }
  3290. protected void refreshUserCtr() {
  3291. Intent intent = new Intent();
  3292. intent.setAction(define.DRIVER_LIGHT_BR);
  3293. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_LIGHT_BR);
  3294. sendBroadcast(intent);
  3295. intent = new Intent();
  3296. intent.setAction(define.DRIVER_BATCHLIGHT_BR);
  3297. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_BATCHLIGHT_BR);
  3298. sendBroadcast(intent);
  3299. intent = new Intent();
  3300. intent.setAction(define.DRIVER_VENTIL_BR);
  3301. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_VENTIL_BR);
  3302. sendBroadcast(intent);
  3303. // intent = new Intent();
  3304. // intent.setAction(HEATERBR);
  3305. // Log.i("HIGH","StatusChanged BR Send "+HEATERBR);
  3306. // sendBroadcast(intent);
  3307. }
  3308. private void Check_Upgrade_File() {
  3309. try {
  3310. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3311. String[] getstate = sdb.GetSystemUpdateStatus();
  3312. if (getstate[0].equalsIgnoreCase("SET")) {
  3313. for (int i = 1; i < 3; i++) {
  3314. if (!getstate[i].equals("no")) {
  3315. String filePath = "/sdcard/"+getstate[i];
  3316. File updradef = new File(filePath);
  3317. if (updradef.exists()) FileDelete(updradef);//.delete();
  3318. }
  3319. }
  3320. sdb.SetSystemUpdate(null, null);
  3321. }
  3322. sdb.closeDB();
  3323. } catch (RuntimeException re) {
  3324. LogUtil.errorLogInfo("", TAG, re);
  3325. }
  3326. catch (Exception e) {
  3327. Log.e(TAG, "[Exception] Check_Upgrade_File()");
  3328. LogUtil.errorLogInfo("", TAG, e);
  3329. }
  3330. }
  3331. protected void SendAppFinishReqBR() {
  3332. try {
  3333. Log.e("MANUAL_MAIN", "Send Finish BR");
  3334. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3335. // pm.userActivity(1, true);
  3336. // LCD Always ON
  3337. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3338. Intent notiIntent = new Intent();
  3339. notiIntent.setAction(define.BR_APP_FINISH);
  3340. getApplicationContext().sendBroadcast(notiIntent);
  3341. } catch (RuntimeException re) {
  3342. LogUtil.errorLogInfo("", TAG, re);
  3343. }
  3344. catch (Exception e) {
  3345. Log.e(TAG, "[Exception] SendAppFinishReqBR()");
  3346. LogUtil.errorLogInfo("", TAG, e);
  3347. }
  3348. }
  3349. private void registerBroadcastReceiver() {
  3350. try {
  3351. IntentFilter mIntentFilter = new IntentFilter();
  3352. mIntentFilter.addAction("WALLPAD_ALERT");
  3353. registerReceiver(mWallPadAlertBR, mIntentFilter);
  3354. mIntentFilter = new IntentFilter();
  3355. mIntentFilter.addAction("WALLPAD_NOTIFY");
  3356. mIntentFilter.addAction(define.DRIVER_VENTIL_BR);
  3357. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI); // ACC 꺼와 구분되는 Noti 추가
  3358. mIntentFilter.addAction(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER);
  3359. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  3360. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  3361. registerMainActivityBR();
  3362. } catch (RuntimeException re) {
  3363. LogUtil.errorLogInfo("", TAG, re);
  3364. }
  3365. catch (Exception e) {
  3366. Log.e(TAG, "[Exception] registerBroadcastReceiver()");
  3367. LogUtil.errorLogInfo("", TAG, e);
  3368. }
  3369. }
  3370. private void unregisterBroadcastReceiver() {
  3371. try {
  3372. unregisterReceiver(mWallPadAlertBR);
  3373. unregisterReceiver(mWallPadNotifyBR);
  3374. unregisterReceiver(MainActivityBroadcastReceiver);
  3375. } catch (RuntimeException re) {
  3376. LogUtil.errorLogInfo("", TAG, re);
  3377. }
  3378. catch (Exception e) {
  3379. Log.e(TAG, "[Exception] unregisterBroadcastReceiver()");
  3380. LogUtil.errorLogInfo("", TAG, e);
  3381. }
  3382. }
  3383. private void MainScrLog(String msg) {
  3384. Log.e("MAINSCREEN",APIErrorCode.GetLogPrefix()+msg);
  3385. }
  3386. protected void CheckEnv() {
  3387. try {
  3388. File dnDIC = new File(BESTIN_LOCATION);
  3389. if (!dnDIC.exists()) dnDIC.mkdir();
  3390. dnDIC = new File(ALBUM_PICTURE_LOCATION);
  3391. if (!dnDIC.exists()) dnDIC.mkdir();
  3392. } catch (RuntimeException re) {
  3393. LogUtil.errorLogInfo("", TAG, re);
  3394. }
  3395. catch (Exception e) {
  3396. Log.e(TAG, "[Exception] CheckEnv()");
  3397. LogUtil.errorLogInfo("", TAG, e);
  3398. }
  3399. }
  3400. public void FileCopy(String Target, String Source) {
  3401. FileInputStream input = null;
  3402. FileOutputStream output = null;
  3403. try {
  3404. input = new FileInputStream(Source);
  3405. long size = input.available();
  3406. byte buff[] = new byte[(int)size];
  3407. input.read(buff);
  3408. output = new FileOutputStream(Target);
  3409. output.write(buff);
  3410. output.flush();
  3411. } catch (RuntimeException re) {
  3412. LogUtil.errorLogInfo("", TAG, re);
  3413. }
  3414. catch (Exception e ) {
  3415. Log.e(TAG, "[Exception] FileCopy(String Target, String Source)");
  3416. LogUtil.errorLogInfo("", TAG, e);
  3417. }
  3418. finally {
  3419. if(input!=null) {
  3420. try {
  3421. input.close( );
  3422. } catch (IOException e) {
  3423. LogUtil.errorLogInfo("", TAG, e);
  3424. }
  3425. }
  3426. input = null;
  3427. if(output!=null) {
  3428. try {
  3429. output.close();
  3430. } catch (IOException e) {
  3431. LogUtil.errorLogInfo("", TAG, e);
  3432. }
  3433. }
  3434. output = null;
  3435. }
  3436. }
  3437. public void checkEventNotifications() {
  3438. try {
  3439. Log.d(TAG,"[checkEventNotifications] ========== START ==========)");
  3440. // 스마트우편함, 전기차충전 연동 여부 확인
  3441. int nRetElecVehicle = -1;
  3442. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  3443. bSmartPostUsage = mWallpadDeviceSet.Get_SmartPostUse();
  3444. nRetElecVehicle = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  3445. mWallpadDeviceSet.closeDB();
  3446. if (nRetElecVehicle == WallpadDeviceSet.DEV_DATA_ENABLE) bElecVehicleUsage = true;
  3447. else bElecVehicleUsage = false;
  3448. Log.d(TAG, "[checkEventNotifications] bSmartPostUsage [" + bSmartPostUsage + "], nRetElecVehicle [" + nRetElecVehicle + "], bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3449. // 부재중 통화
  3450. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3451. try {
  3452. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3453. } catch (RuntimeException re) {
  3454. LogUtil.errorLogInfo("", TAG, re);
  3455. }
  3456. catch (Exception e) {
  3457. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadCallHistoryData");
  3458. LogUtil.errorLogInfo("", TAG, e);
  3459. }
  3460. mWallpadCallHistoryData.closeDB();
  3461. // 방문자 사진
  3462. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3463. try {
  3464. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3465. } catch (RuntimeException re) {
  3466. LogUtil.errorLogInfo("", TAG, re);
  3467. }
  3468. catch (Exception e) {
  3469. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadVisitorPicData_A20");
  3470. LogUtil.errorLogInfo("", TAG, e);
  3471. }
  3472. mWallpadVisitorPicData_A20.closeDB();
  3473. // 공지사항, 택배, 스마트 우편
  3474. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3475. try {
  3476. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3477. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3478. nPostCnt = mWallpadStatusData.GetPostCNT();
  3479. } catch (RuntimeException re) {
  3480. LogUtil.errorLogInfo("", TAG, re);
  3481. }
  3482. catch (Exception e) {
  3483. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadStatusData");
  3484. LogUtil.errorLogInfo("", TAG, e);
  3485. }
  3486. mWallpadStatusData.closeDB();
  3487. if (0 > nMissedCallCnt) {
  3488. Log.w(TAG,"[checkEventNotifications] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3489. nMissedCallCnt = 0;
  3490. }
  3491. if (0 > nVisitorPicCnt) {
  3492. Log.w(TAG,"[checkEventNotifications] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3493. nVisitorPicCnt = 0;
  3494. }
  3495. if (0 > nNoticeCnt) {
  3496. Log.w(TAG,"[checkEventNotifications] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3497. nNoticeCnt = 0;
  3498. }
  3499. if (0 > nParcelCnt) {
  3500. Log.w(TAG,"[checkEventNotifications] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3501. nParcelCnt = 0;
  3502. }
  3503. if (0 > nPostCnt) {
  3504. Log.w(TAG,"[checkEventNotifications] out of range!! nPostCnt [" + nPostCnt + "]");
  3505. nPostCnt = 0;
  3506. }
  3507. if (0 > nElecVehicleChangingCnt) {
  3508. Log.w(TAG,"[checkEventNotifications] out of range!! nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3509. nElecVehicleChangingCnt = 0;
  3510. }
  3511. if (!bSmartPostUsage) {
  3512. Log.w(TAG,"[checkEventNotifications] bSmartPostUsage is not supported!! -> bSmartPostUsage [" + bSmartPostUsage + "]");
  3513. nPostCnt = 0;
  3514. }
  3515. if (!bElecVehicleUsage) {
  3516. Log.w(TAG,"[checkEventNotifications] bElecVehicleUsage is not supported!! -> bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3517. nElecVehicleChangingCnt = 0;
  3518. }
  3519. Log.d(TAG,"[checkEventNotifications] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "], nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3520. sendEventNotiBR(nMissedCallCnt, nVisitorPicCnt, nNoticeCnt, nParcelCnt, nPostCnt, nElecVehicleChangingCnt);
  3521. Send_NotiSmartSwitch(MainActivity.nNoticeCnt, MainActivity.nParcelCnt, MainActivity.nVisitorPicCnt);
  3522. } catch (RuntimeException re) {
  3523. LogUtil.errorLogInfo("", TAG, re);
  3524. }
  3525. catch (Exception e) {
  3526. Log.e(TAG, "[Exception] checkEventNotifications()");
  3527. LogUtil.errorLogInfo("", TAG, e);
  3528. }
  3529. }
  3530. public String getEventNotificationInfo() {
  3531. try {
  3532. Log.d(TAG,"[getEventNotificationInfo] ========== START ==========)");
  3533. // 부재중 통화, 방문자 사진, 공지사항, 택배
  3534. int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0;
  3535. // 부재중 통화
  3536. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3537. try {
  3538. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3539. } catch (RuntimeException re) {
  3540. LogUtil.errorLogInfo("", TAG, re);
  3541. }
  3542. catch (Exception e) {
  3543. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadCallHistoryData");
  3544. LogUtil.errorLogInfo("", TAG, e);
  3545. }
  3546. mWallpadCallHistoryData.closeDB();
  3547. // 방문자 사진
  3548. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3549. try {
  3550. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3551. } catch (RuntimeException re) {
  3552. LogUtil.errorLogInfo("", TAG, re);
  3553. }
  3554. catch (Exception e) {
  3555. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadVisitorPicData_A20");
  3556. LogUtil.errorLogInfo("", TAG, e);
  3557. }
  3558. mWallpadVisitorPicData_A20.closeDB();
  3559. // 공지사항, 택배
  3560. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3561. try {
  3562. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3563. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3564. nPostCnt = mWallpadStatusData.GetPostCNT();
  3565. } catch (RuntimeException re) {
  3566. LogUtil.errorLogInfo("", TAG, re);
  3567. }
  3568. catch (Exception e) {
  3569. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadStatusData");
  3570. LogUtil.errorLogInfo("", TAG, e);
  3571. }
  3572. mWallpadStatusData.closeDB();
  3573. if (0 > nMissedCallCnt) {
  3574. Log.w(TAG,"[getEventNotificationInfo] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3575. nMissedCallCnt = 0;
  3576. }
  3577. if (0 > nVisitorPicCnt) {
  3578. Log.w(TAG,"[getEventNotificationInfo] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3579. nVisitorPicCnt = 0;
  3580. }
  3581. if (0 > nNoticeCnt) {
  3582. Log.w(TAG,"[getEventNotificationInfo] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3583. nNoticeCnt = 0;
  3584. }
  3585. if (0 > nParcelCnt) {
  3586. Log.w(TAG,"[getEventNotificationInfo] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3587. nParcelCnt = 0;
  3588. }
  3589. if (0 > nPostCnt) {
  3590. Log.w(TAG,"[getEventNotificationInfo] out of range!! nPostCnt [" + nPostCnt + "]");
  3591. nPostCnt = 0;
  3592. }
  3593. Log.d(TAG,"[getEventNotificationInfo] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "]");
  3594. if (bSmartPostUsage) return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt + define.DEVCTR_CMD_SPLITER + nPostCnt;
  3595. else return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt;
  3596. } catch (RuntimeException re) {
  3597. LogUtil.errorLogInfo("", TAG, re);
  3598. return null;
  3599. }
  3600. catch (Exception e) {
  3601. Log.e(TAG, "[Exception] getEventNotificationInfo()");
  3602. LogUtil.errorLogInfo("", TAG, e);
  3603. return null;
  3604. }
  3605. }
  3606. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel) {
  3607. try {
  3608. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "]");
  3609. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice) + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel);
  3610. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3611. Intent mIntent = new Intent();
  3612. mIntent.setAction(define.NOTIFY_ACNAME);
  3613. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3614. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3615. getApplicationContext().sendBroadcast(mIntent);
  3616. } catch (RuntimeException re) {
  3617. LogUtil.errorLogInfo("", TAG, re);
  3618. }
  3619. catch (Exception e) {
  3620. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel)");
  3621. LogUtil.errorLogInfo("", TAG, e);
  3622. }
  3623. }
  3624. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post) {
  3625. try {
  3626. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "]");
  3627. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice) + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel) + define.DEVCTR_CMD_SPLITER + String.valueOf(post);
  3628. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3629. Intent mIntent = new Intent();
  3630. mIntent.setAction(define.NOTIFY_ACNAME);
  3631. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3632. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3633. getApplicationContext().sendBroadcast(mIntent);
  3634. } catch (RuntimeException re) {
  3635. LogUtil.errorLogInfo("", TAG, re);
  3636. }
  3637. catch (Exception e) {
  3638. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post)");
  3639. LogUtil.errorLogInfo("", TAG, e);
  3640. }
  3641. }
  3642. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging) {
  3643. try {
  3644. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "], elecvehiclecharging [" + elecvehiclecharging +"]");
  3645. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice)
  3646. + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel) + define.DEVCTR_CMD_SPLITER + String.valueOf(post) + define.DEVCTR_CMD_SPLITER + String.valueOf(elecvehiclecharging);
  3647. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3648. Intent mIntent = new Intent();
  3649. mIntent.setAction(define.NOTIFY_ACNAME);
  3650. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3651. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3652. getApplicationContext().sendBroadcast(mIntent);
  3653. } catch (RuntimeException re) {
  3654. LogUtil.errorLogInfo("", TAG, re);
  3655. }
  3656. catch (Exception e) {
  3657. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging)");
  3658. LogUtil.errorLogInfo("", TAG, e);
  3659. }
  3660. }
  3661. private void CheckCallData_CalledCountAndVisitorCount() {
  3662. try {
  3663. int Vcount = 0;
  3664. int Ccount = 0;
  3665. try {
  3666. //DB정보 읽어서 처리
  3667. Log.d(TAG,"CheckCallData_CalledCountAndVisitorCount Start");
  3668. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3669. int TempCcount = mWallpadCallHistoryData.RowCallHistoryCountData();
  3670. mWallpadCallHistoryData.closeDB();
  3671. Log.d(TAG,"RowCallHistoryCountData() :" + TempCcount);
  3672. if (TempCcount != -999) {
  3673. Ccount = TempCcount;
  3674. }
  3675. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3676. int TempVcount = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3677. mWallpadVisitorPicData_A20.closeDB();
  3678. Log.d(TAG,"RowVisitorPictureCountData() :" + TempVcount);
  3679. if (TempVcount != -999) {
  3680. Vcount = TempVcount;
  3681. }
  3682. } catch (RuntimeException re) {
  3683. LogUtil.errorLogInfo("", TAG, re);
  3684. }
  3685. catch (Exception e) {
  3686. LogUtil.errorLogInfo("", TAG, e);
  3687. }
  3688. Log.d(TAG," Call Count Check Receive Ccount :" + Ccount + " , Photo Count : " + Vcount );
  3689. String Retdata = String.valueOf(Ccount)+define.DEVCTR_CMD_SPLITER+String.valueOf(Vcount);
  3690. Intent intent = new Intent();
  3691. intent.setAction(define.NOTIFY_ACNAME);
  3692. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3693. intent.putExtra(define.NOTIBR_CONTENT, Retdata);
  3694. getApplicationContext().sendBroadcast(intent);
  3695. } catch (RuntimeException re) {
  3696. LogUtil.errorLogInfo("", TAG, re);
  3697. }
  3698. catch (Exception e) {
  3699. Log.e(TAG, "[Exception] CheckCallData_CalledCountAndVisitorCount()");
  3700. LogUtil.errorLogInfo("", TAG, e);
  3701. }
  3702. }
  3703. class ScheduleManager {
  3704. public static final int SCHEDULE_TYPE_GETINFO = 5000;
  3705. public static final int SCHEDULE_TYPE_MORNINGCALL = 5001;
  3706. public static final int SCHEDULE_TYPE_SCHEDULER = 5002;
  3707. public static final int SCHEDULE_TYPE_SYSRESET = 5003;
  3708. public static final int SCHEDULE_TYPE_NONE = 5004;
  3709. public boolean isSetted = false;
  3710. List<TimeScheduleUnit> SchedulerData = new ArrayList<TimeScheduleUnit>();
  3711. List<TimeScheduleUnit> GeneralData = new ArrayList<TimeScheduleUnit>();
  3712. public ScheduleManager() {
  3713. }
  3714. public class TimeScheduleUnit {
  3715. int type;
  3716. Calendar TimeSet;
  3717. String message;
  3718. TimeScheduleUnit(int sctype, Calendar target) {
  3719. type = sctype;
  3720. TimeSet = target;
  3721. }
  3722. TimeScheduleUnit(int sctype, Calendar target, String msg) {
  3723. Log.i("MAINSCREEN","TimeScheduleUnit Create "+sctype+" : MSG : "+msg);
  3724. type = sctype;
  3725. TimeSet = target;
  3726. message = msg;
  3727. }
  3728. public boolean isOver() {
  3729. Calendar cal_now = new GregorianCalendar();
  3730. if (cal_now.after(TimeSet)) {
  3731. return true;
  3732. }
  3733. return false;
  3734. }
  3735. }
  3736. private void CheckSysResetData() {
  3737. try {
  3738. Calendar today = new GregorianCalendar();
  3739. Log.i("MAINSCREEN","CheckSysResetData Schedule");
  3740. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3741. String[] ResetData = WsDB.GetResetSchedule();
  3742. if (!ResetData[0].equals("NONE")) {
  3743. int type = Integer.parseInt(ResetData[0]);
  3744. Log.i("MAINSCREEN","CheckSysResetData Schedule check typr : "+type + " Week : "+today.get(Calendar.DAY_OF_WEEK)+" Set Week : "+ResetData[1]);
  3745. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH)+1 == Integer.parseInt(ResetData[1])) ||
  3746. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == (Integer.parseInt(ResetData[1]))+1) )
  3747. {
  3748. if (today.get(Calendar.HOUR_OF_DAY) == Integer.parseInt(ResetData[2]) && today.get(Calendar.MINUTE) < 2) {
  3749. SendAppFinishReqBR();
  3750. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3751. Intent intent = new Intent(Intent.ACTION_MAIN);
  3752. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3753. intent.putExtra("updatesystem", "no");
  3754. intent.putExtra("updateapp", " no ");
  3755. intent.putExtra("rebootcmd", "reboot");
  3756. intent.setComponent(cn);
  3757. startActivity(intent);
  3758. }
  3759. }
  3760. }
  3761. WsDB.closeDB();
  3762. } catch (RuntimeException re) {
  3763. LogUtil.errorLogInfo("", TAG, re);
  3764. }
  3765. catch (Exception e) {
  3766. Log.e(TAG, "[Exception] CheckSysResetData()");
  3767. LogUtil.errorLogInfo("", TAG, e);
  3768. }
  3769. }
  3770. private boolean checkMorningCall() {
  3771. try {
  3772. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3773. int AlarmStatus = WsDB.GetAlarmStatus();
  3774. if (AlarmStatus != WallpadStatusData.ALARM_NONE && AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.ALARM_STOP) {
  3775. WsDB.closeDB();
  3776. return false;
  3777. }
  3778. Calendar today = new GregorianCalendar();
  3779. int MCStatus = WsDB.GetMorningCallStatus();
  3780. Log.i(TAG,"[checkMorningCall] GetMorningCallStatus : "+MCStatus);
  3781. if (MCStatus==WallpadStatusData.MORNINGCALL_ON) {
  3782. int MCPer = WsDB.GetMorningCallPeriod();
  3783. Log.i(TAG,"[checkMorningCall] GetMorningCallPeriod : "+MCPer);
  3784. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3785. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) ||
  3786. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) ||
  3787. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY )) {
  3788. Log.i(TAG,"[checkMorningCall] "+today.get(Calendar.HOUR_OF_DAY)+";"+WsDB.MorningHour + " -- " +today.get(Calendar.MINUTE)+":"+WsDB.MorningMin);
  3789. if (today.get(Calendar.HOUR_OF_DAY) == WsDB.MorningHour && today.get(Calendar.MINUTE) == WsDB.MorningMin) {
  3790. SendAppFinishReqBR();
  3791. mIOInterface.ctrlLcdWakeUp();
  3792. StartPopup(ID.POPUPS.POPUP_MORNINGCALL);
  3793. int[] MC_Doing = WsDB.GetMorningCallReserve();
  3794. if (MC_Doing != null && MC_Doing.length > 0) {
  3795. for (int k=0;k<MC_Doing.length;k++) {
  3796. switch (MC_Doing[k]) {
  3797. case WallpadStatusData.MCALLR_VENTIL_ON:
  3798. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  3799. break;
  3800. case WallpadStatusData.MCALLR_LIGHT_ON:
  3801. //에너지 미터인 경우 안방 조명을 켜도록 하고
  3802. //에너지 미터가 안 달린 경우 거실 조명을 켜도록 한다
  3803. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  3804. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3805. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3806. // 안방조명에 1번 조명만 제어하도록 한다
  3807. // 모닝콜이 울리면 일괄소등시나리오에 의해 일괄소등이 해제가 되겠네 ? 음.....이건 아닌데
  3808. // 모닝콜이 울리는 동안만 켜고 끄자 일괄소등 시나리오를 해제할까나? 그러면 팝업 화면에서 제어처리를?
  3809. Log.d(TAG, "[checkMorningCall] mSdbAPI Room 2 - Lamp 1 On");
  3810. if (mSdbAPI != null) {
  3811. int nResult = mSdbAPI.SetLightOnOff((byte) 0x01, (byte) 0x00, true);
  3812. Log.d(TAG, "[checkMorningCall] mSdbAPI nResult = " + nResult);
  3813. }
  3814. }
  3815. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3816. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  3817. Log.d(TAG, "[checkMorningCall] mIntLightAPI Living Room - Lamp 1 On");
  3818. if (mIntLightAPI != null) {
  3819. int nResult = mIntLightAPI.LightControl((byte) 0x01, true);
  3820. Log.d(TAG, "[checkMorningCall] mIntLightAPI nResult = " + nResult);
  3821. }
  3822. }
  3823. else {
  3824. // 대외향 구분하여 처리
  3825. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  3826. int[] retArray = devDB.Get_Light_info();
  3827. devDB.closeDB();
  3828. if (retArray!= null && retArray[0] == 1) {
  3829. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  3830. // 거실 스위치
  3831. if (m_LightCtrl != null) {
  3832. m_LightCtrl.Refresh(false);
  3833. m_LightCtrl.SetLightOnOff((byte)0x01, true);
  3834. }
  3835. }
  3836. else {
  3837. // 멀티 스위치
  3838. if (m_MultiSwitch != null) {
  3839. m_MultiSwitch.Refresh((byte)0x00, false);
  3840. if (m_MultiSwitch.data.DeviceCnt > 1) {
  3841. m_MultiSwitch.SetLightOnOff((byte)0x01 ,(byte)0x00 , true);
  3842. }
  3843. else if(m_MultiSwitch.data.DeviceCnt == 1) {
  3844. m_MultiSwitch.SetLightOnOff((byte)0x00 ,(byte)0x00 , true);
  3845. }
  3846. }
  3847. }
  3848. }
  3849. }
  3850. break;
  3851. case WallpadStatusData.MCALLR_CURTAIN_OPEN: //fill lather
  3852. break;
  3853. }
  3854. }
  3855. }
  3856. if (MCPer == WallpadStatusData.MORNINGCALL_ONCE) {
  3857. // Button morning = (Button)findViewById(R.id.top_alarm);
  3858. // morning.setVisibility(View.INVISIBLE);
  3859. WsDB.SetMorningCall(WallpadStatusData.MORNINGCALL_OFF, WsDB.MorningHour, WsDB.MorningMin);
  3860. }
  3861. }
  3862. }
  3863. }
  3864. WsDB.closeDB();
  3865. } catch (RuntimeException re) {
  3866. LogUtil.errorLogInfo("", TAG, re);
  3867. }
  3868. catch (Exception e) {
  3869. LogUtil.errorLogInfo("", TAG, e);
  3870. }
  3871. return false;
  3872. }
  3873. private void scheduleCheck()
  3874. {
  3875. try
  3876. {
  3877. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++");
  3878. Log.d("scheduleCheck", "Enter scheduleCheck "+GeneralData.size()+" : "+SchedulerData.size());
  3879. checkMorningCall();
  3880. if (GeneralData.size() > 0)
  3881. {
  3882. for (int i = 0;i < GeneralData.size(); i++)
  3883. {
  3884. TimeScheduleUnit scUnit = GeneralData.get(i);
  3885. if (scUnit.isOver())
  3886. {
  3887. switch (scUnit.type)
  3888. {
  3889. case SCHEDULE_TYPE_SYSRESET:
  3890. GeneralData.remove(scUnit);
  3891. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_SYSRESET");
  3892. SendAppFinishReqBR();
  3893. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3894. Intent intent = new Intent(Intent.ACTION_MAIN);
  3895. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3896. intent.putExtra("updatesystem", "no");
  3897. intent.putExtra("updateapp", "no");
  3898. intent.putExtra("rebootcmd", "reboot");
  3899. intent.setComponent(cn);
  3900. startActivity(intent);
  3901. break;
  3902. case SCHEDULE_TYPE_GETINFO:
  3903. GeneralData.remove(scUnit);
  3904. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_GETINFO");
  3905. WallPadiMAPNotifyAPI notifyAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  3906. notifyAPI.ReqGetSet();
  3907. break;
  3908. }
  3909. }
  3910. }
  3911. Log.d("scheduleCheck", "after scheduleCheck "+GeneralData.size() );
  3912. }
  3913. }
  3914. catch (RuntimeException re) {
  3915. LogUtil.errorLogInfo("", TAG, re);
  3916. }
  3917. catch (Exception e)
  3918. {
  3919. LogUtil.errorLogInfo("", TAG, e);
  3920. }
  3921. }
  3922. public void doSchedule(String mess, int cnt)
  3923. {
  3924. // SendAppFinishReqBR();
  3925. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  3926. // String SendMSG = mess;
  3927. // if (cnt > 1) SendMSG+=(" 외 "+cnt+"건을 알려드립니다.");
  3928. // intent.putExtra("MESSAGE", SendMSG);
  3929. // Log.i("MAINSCREEN","Call Schedule POPUP");
  3930. // startActivity(intent);
  3931. }
  3932. public void refreshSchedulerData()
  3933. {
  3934. try
  3935. {
  3936. SchedulerData.clear();
  3937. WallpadScheduleData schedata = new WallpadScheduleData(getApplicationContext());
  3938. List<WallpadScheduleData.ScheduleData> scheduledata = schedata.GetTodaySchedule();
  3939. Log.i("MAINSCREEN","refreshSchedulerData "+scheduledata.size());
  3940. for(int i=0;i<scheduledata.size();i++)
  3941. {
  3942. WallpadScheduleData.ScheduleData ScUnit = scheduledata.get(i);
  3943. int hour;
  3944. int min;
  3945. Log.i("MAINSCREEN","refreshSchedulerData "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : ");
  3946. if (ScUnit.inqatype.equals("no")) continue;
  3947. else if (ScUnit.inqatype.equals("intime")||ScUnit.inqatype.equals("day"))
  3948. {
  3949. hour = ScUnit.inqhour;
  3950. min = 0;
  3951. }
  3952. else if (ScUnit.inqatype.equals("hour"))
  3953. {
  3954. hour = ScUnit.inqhour-1;
  3955. if (hour < 0) continue;
  3956. min = 0;
  3957. }
  3958. else if (ScUnit.inqatype.equals("min"))
  3959. {
  3960. hour = ScUnit.inqhour-1;
  3961. if (hour < 0) continue;
  3962. min = 50;
  3963. }
  3964. else
  3965. continue;
  3966. Calendar today = new GregorianCalendar();
  3967. int MoonM = 0;
  3968. int MoonD = 0;
  3969. try
  3970. {
  3971. String Moon = schedata.GetLunarDate(String.format("%04d%02d%02d", today.get(Calendar.YEAR),today.get(Calendar.MONTH)+1,today.get(Calendar.DAY_OF_MONTH) ));
  3972. if(Moon!=null)
  3973. {
  3974. MoonM = Integer.parseInt(Moon.substring(4, 6));
  3975. MoonD = Integer.parseInt(Moon.substring(6, 8));
  3976. Log.i("MAINSCREEN", " Get Lunar Date "+Moon+" : "+MoonM+"/"+MoonD);
  3977. }
  3978. }
  3979. catch (RuntimeException re) {
  3980. LogUtil.errorLogInfo("", TAG, re);
  3981. }
  3982. catch (Exception e)
  3983. {
  3984. LogUtil.errorLogInfo("", TAG, e);
  3985. MoonM = 0;
  3986. MoonD = 0;
  3987. }
  3988. today.set(Calendar.HOUR_OF_DAY, hour);
  3989. today.set(Calendar.MINUTE, min);
  3990. String Mesg = String.format("%04d년 %02d월 %02d일 (음 %02d/%02d)\n",today.get(Calendar.YEAR),today.get(Calendar.MONTH)+1,today.get(Calendar.DAY_OF_MONTH), MoonM, MoonD)+ScUnit.inqmsg;
  3991. Log.i("MAINSCREEN","refreshSchedulerData add "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : "+Mesg);
  3992. TimeScheduleUnit newUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SCHEDULER, today, Mesg);
  3993. isSetted = true;
  3994. SchedulerData.add(newUnit);
  3995. }
  3996. schedata.closeDB();
  3997. }
  3998. catch (RuntimeException re) {
  3999. LogUtil.errorLogInfo("", TAG, re);
  4000. }
  4001. catch (Exception e)
  4002. {
  4003. LogUtil.errorLogInfo("", TAG, e);
  4004. }
  4005. }
  4006. public void refreshMorningCall()
  4007. {
  4008. try
  4009. {
  4010. for (int i = 0; i < GeneralData.size(); i++)
  4011. {
  4012. TimeScheduleUnit scUnit = SchedulerData.get(i);
  4013. if (scUnit.type == SCHEDULE_TYPE_MORNINGCALL)
  4014. {
  4015. SchedulerData.remove(i);
  4016. break;
  4017. }
  4018. }
  4019. SetMorningCallData();
  4020. }
  4021. catch (RuntimeException re) {
  4022. LogUtil.errorLogInfo("", TAG, re);
  4023. }
  4024. catch (Exception e)
  4025. {
  4026. LogUtil.errorLogInfo("", TAG, e);
  4027. }
  4028. }
  4029. private void SetMorningCallData()
  4030. {
  4031. try
  4032. {
  4033. Log.i("MAINSCREEN","SetMorningCallData Schedule");
  4034. Calendar today = new GregorianCalendar();
  4035. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  4036. int MCStatus = WsDB.GetMorningCallStatus();
  4037. if (MCStatus==WallpadStatusData.MORNINGCALL_ON)
  4038. {
  4039. int MCPer = WsDB.GetMorningCallPeriod();
  4040. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  4041. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) &&
  4042. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) &&
  4043. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY ))
  4044. {
  4045. today.set(Calendar.HOUR_OF_DAY, WsDB.MorningHour);
  4046. today.set(Calendar.MINUTE, WsDB.MorningMin);
  4047. today.set(Calendar.SECOND, 0);
  4048. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_MORNINGCALL, today);
  4049. if (!scUnit.isOver())
  4050. {
  4051. isSetted = true;
  4052. // Button morning = (Button)findViewById(R.id.top_alarm);
  4053. // morning.setVisibility(View.VISIBLE);
  4054. GeneralData.add(scUnit);
  4055. }
  4056. else
  4057. {
  4058. // Button morning = (Button)findViewById(R.id.top_alarm);
  4059. // morning.setVisibility(View.INVISIBLE);
  4060. }
  4061. }
  4062. }
  4063. WsDB.closeDB();
  4064. }
  4065. catch (RuntimeException re) {
  4066. LogUtil.errorLogInfo("", TAG, re);
  4067. }
  4068. catch (Exception e)
  4069. {
  4070. LogUtil.errorLogInfo("", TAG, e);
  4071. }
  4072. }
  4073. public void refreshsysreset()
  4074. {
  4075. try
  4076. {
  4077. Log.i("MAINSCREEN","refreshsysreset Schedule");
  4078. for (int i = 0; i < GeneralData.size(); i++)
  4079. {
  4080. TimeScheduleUnit scUnit = SchedulerData.get(i);
  4081. if (scUnit.type == SCHEDULE_TYPE_SYSRESET)
  4082. {
  4083. SchedulerData.remove(i);
  4084. break;
  4085. }
  4086. }
  4087. SetSysResetData();
  4088. }
  4089. catch (RuntimeException re) {
  4090. LogUtil.errorLogInfo("", TAG, re);
  4091. }
  4092. catch (Exception e)
  4093. {
  4094. LogUtil.errorLogInfo("", TAG, e);
  4095. }
  4096. }
  4097. private void SetSysResetData()
  4098. {
  4099. try
  4100. {
  4101. Calendar today = new GregorianCalendar();
  4102. Log.i("MAINSCREEN","SetSysResetData Schedule");
  4103. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  4104. String[] ResetData = WsDB.GetResetSchedule();
  4105. if (!ResetData[0].equals("NONE"))
  4106. {
  4107. int type = Integer.parseInt(ResetData[0]);
  4108. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH) == Integer.parseInt(ResetData[1])) ||
  4109. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == Integer.parseInt(ResetData[1])) )
  4110. {
  4111. Log.i("MAINSCREEN","SetSysResetData Setted");
  4112. today.set(Calendar.HOUR_OF_DAY, Integer.parseInt(ResetData[2]));
  4113. today.set(Calendar.MINUTE, 0);
  4114. today.set(Calendar.SECOND, 0);
  4115. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SYSRESET, today);
  4116. if (!scUnit.isOver())
  4117. {
  4118. isSetted = true;
  4119. GeneralData.add(scUnit);
  4120. }
  4121. }
  4122. }
  4123. WsDB.closeDB();
  4124. }
  4125. catch (RuntimeException re) {
  4126. LogUtil.errorLogInfo("", TAG, re);
  4127. }
  4128. catch (Exception e)
  4129. {
  4130. LogUtil.errorLogInfo("", TAG, e);
  4131. }
  4132. }
  4133. public void refreshSchedule()
  4134. {
  4135. try
  4136. {
  4137. Log.i("MAINSCREEN","Refresh Schedule");
  4138. GeneralData.clear();
  4139. Calendar today = new GregorianCalendar();
  4140. // 하루에 한번 가져오는 걸로 변경함
  4141. //if (today.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
  4142. {
  4143. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  4144. AddressSet addc = SetData.getAddressMGR();
  4145. SetData.closeDB();
  4146. int dong = Integer.parseInt(addc.Dong);
  4147. int ho = 101;
  4148. if(addc.UseOrNotRentHouse == true)
  4149. {
  4150. ho = addc.Ho_Integer;
  4151. }
  4152. else
  4153. {
  4154. ho = Integer.parseInt(addc.Ho);
  4155. }
  4156. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  4157. int hour;
  4158. int min;
  4159. int sec;
  4160. if (interval/3600 > 0)
  4161. {
  4162. hour = 3+interval/3600;
  4163. interval=interval%3600;
  4164. }
  4165. else hour = 3;
  4166. if (interval/60 > 0)
  4167. {
  4168. min = interval/60;
  4169. sec = interval%60;
  4170. }
  4171. else
  4172. {
  4173. min = 0;
  4174. sec = interval;
  4175. }
  4176. today.set(Calendar.HOUR_OF_DAY, hour);
  4177. today.set(Calendar.MINUTE, min);
  4178. today.set(Calendar.SECOND, sec);
  4179. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_GETINFO, today);
  4180. if (!scUnit.isOver())
  4181. GeneralData.add(scUnit);
  4182. }
  4183. SetMorningCallData();
  4184. SetSysResetData();
  4185. refreshSchedulerData();
  4186. }
  4187. catch (RuntimeException re) {
  4188. LogUtil.errorLogInfo("", TAG, re);
  4189. }
  4190. catch (Exception e)
  4191. {
  4192. LogUtil.errorLogInfo("", TAG, e);
  4193. }
  4194. }
  4195. }
  4196. class runCallServices extends Thread {
  4197. public runCallServices() {
  4198. super();
  4199. }
  4200. public void run() {
  4201. try {
  4202. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4203. if (getIsSubWallpad()) {
  4204. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a sub-wallpad ###############");
  4205. Intent SubWallpadServiceLauncher = new Intent ("kr.co.icontrols.callengine.subwallpad.SubWallPadSerialManager.StartService");
  4206. getApplicationContext().startService(SubWallpadServiceLauncher);
  4207. }
  4208. else {
  4209. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a main-wallpad ###############");
  4210. // SIP/Subphone 서비스 실행
  4211. Intent SIPServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4212. getApplicationContext().startService(SIPServiceLauncher);
  4213. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4214. getApplicationContext().startService(SubPhoneServiceLauncher);
  4215. if (GetRemoteCallUseInfo()) {
  4216. Intent remoteCallServiceLauncher = new Intent ("kr.co.icontrols.callengine.remotecall.RemoteCallManager.StartService");
  4217. getApplicationContext().startService(remoteCallServiceLauncher);
  4218. }
  4219. }
  4220. }
  4221. else {
  4222. int nModelType = Version.getModelType();
  4223. if (nModelType == MODEL_TYPE.IHN_750) {
  4224. // SIP 서비스만 실행
  4225. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4226. getApplicationContext().startService(sipServiceLauncher);
  4227. }
  4228. else {
  4229. // SIP/PSTN/Subphone 서비스 실행
  4230. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4231. getApplicationContext().startService(sipServiceLauncher);
  4232. Intent PSTNServiceLauncher = new Intent ("kr.co.icontrols.callengine.pstn.PSTNSerialManager.StartService");
  4233. getApplicationContext().startService(PSTNServiceLauncher);
  4234. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4235. getApplicationContext().startService(SubPhoneServiceLauncher);
  4236. }
  4237. }
  4238. } catch (RuntimeException re) {
  4239. LogUtil.errorLogInfo("", TAG, re);
  4240. }
  4241. catch (Exception e) {
  4242. Log.e(TAG, "[Exception] runCallServices().run()");
  4243. LogUtil.errorLogInfo("", TAG, e);
  4244. }
  4245. }
  4246. }
  4247. // 방문객원격통화 솔루션 사용여부 판별
  4248. private boolean GetRemoteCallUseInfo() {
  4249. try {
  4250. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  4251. if (mWallpadDeviceSet != null) {
  4252. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  4253. if (astrRemoteCall != null) {
  4254. if (astrRemoteCall[1].contains("사용함"))
  4255. return true;
  4256. } else {
  4257. Log.d(TAG, "[GetRemoteCallUseInfo] astrRemoteCall is null!!");
  4258. }
  4259. }
  4260. mWallpadDeviceSet.closeDB();
  4261. } catch (RuntimeException re) {
  4262. LogUtil.errorLogInfo("", TAG, re);
  4263. }
  4264. catch (Exception e) {
  4265. Log.e(TAG, "[Exception] GetRemoteCallUseInfo()");
  4266. LogUtil.errorLogInfo("", TAG, e);
  4267. }
  4268. return false;
  4269. }
  4270. int UNINSTALL_REQUEST_CODE = 1;
  4271. private void uninstallAnCCallApp(String strAPK) {
  4272. try {
  4273. Log.w(TAG, "[uninstallAnCCallApp] strAPK [" + strAPK + "]");
  4274. if (checkAppInstalled(strAPK)) {
  4275. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  4276. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  4277. mIntent.setData(Uri.parse("package:" + strAPK));
  4278. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  4279. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  4280. }
  4281. else {
  4282. Log.w(TAG, "[uninstallAnCCallApp] Not installed [" + strAPK + "]");
  4283. }
  4284. } catch (RuntimeException re) {
  4285. LogUtil.errorLogInfo("", TAG, re);
  4286. }
  4287. catch (Exception e) {;
  4288. Log.e(TAG, "[Exception] uninstallAnCCallApp()");
  4289. LogUtil.errorLogInfo("", TAG, e);
  4290. }
  4291. }
  4292. private boolean checkAppInstalled(String strAPK) {
  4293. try {
  4294. PackageManager mPackageManager = getPackageManager();
  4295. try {
  4296. mPackageManager.getPackageInfo(strAPK, PackageManager.GET_ACTIVITIES);
  4297. return true;
  4298. } catch (PackageManager.NameNotFoundException pne) {
  4299. Log.w(TAG, "[checkAppInstalled] No Package [" + strAPK + "]");
  4300. }
  4301. return false;
  4302. } catch (RuntimeException re) {
  4303. LogUtil.errorLogInfo("", TAG, re);
  4304. return false;
  4305. }
  4306. catch (Exception e) {
  4307. Log.e(TAG, "[Exception] checkAppInstalled(String strAPK)");
  4308. LogUtil.errorLogInfo("", TAG, e);
  4309. return false;
  4310. }
  4311. }
  4312. private boolean MainSubScreenLoadingComplite = false;
  4313. public boolean getMainSubScreenLoadingComplite() {
  4314. return MainSubScreenLoadingComplite;
  4315. }
  4316. /**
  4317. * 설치된 모든 어플의 이름/버전정보 Version DB에 저장하는 쓰레드. <br>
  4318. * main Activity 생성 시 최초 1회 실행 후 die
  4319. */
  4320. class getInstalledPackageInfo extends Thread {
  4321. @Override
  4322. public void run() {
  4323. super.run();
  4324. try {
  4325. Log.d(TAG, "[getInstalledPackageInfo] Started getting installed package infomation");
  4326. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  4327. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  4328. while (true) {
  4329. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages start!!");
  4330. try {
  4331. for (PackageInfo pack : PackageInfoList) {
  4332. Log.d(TAG, "# PackageName : " + pack.packageName);
  4333. Log.d(TAG, "# VersionName : " + pack.versionName);
  4334. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore")) || (pack.packageName.contains("dadam"))) {
  4335. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  4336. }
  4337. }
  4338. } catch (RuntimeException re) {
  4339. LogUtil.errorLogInfo("", TAG, re);
  4340. break;
  4341. }
  4342. catch (Exception e) {
  4343. LogUtil.errorLogInfo("", TAG, e);
  4344. break;
  4345. }
  4346. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  4347. break;
  4348. }
  4349. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages start!!");
  4350. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  4351. if (PackageVersionInfos != null) {
  4352. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  4353. WallpadDBMGR.UpdateVersionData(PackageVersionInfos.get(i).getPackageName(), PackageVersionInfos.get(i).getPackageVersion());
  4354. }
  4355. }
  4356. WallpadDBMGR.closeDB();
  4357. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages end!!");
  4358. try {
  4359. Thread.sleep(1500);
  4360. } catch (RuntimeException re) {
  4361. LogUtil.errorLogInfo("", TAG, re);
  4362. }
  4363. catch (Exception e) {
  4364. LogUtil.errorLogInfo("", TAG, e);
  4365. }
  4366. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  4367. try {
  4368. Thread.sleep(1000);
  4369. } catch (RuntimeException re) {
  4370. LogUtil.errorLogInfo("", TAG, re);
  4371. }
  4372. catch (Exception e) {
  4373. LogUtil.errorLogInfo("", TAG, e);
  4374. }
  4375. }
  4376. runOnUiThread(new Runnable() {
  4377. @Override
  4378. public void run() {
  4379. registerSubScreen();
  4380. }
  4381. });
  4382. try
  4383. {
  4384. WallpadScheduleData schedb = new WallpadScheduleData(getApplicationContext());
  4385. boolean bLunarTableExist = schedb.CheckLunarTable();
  4386. schedb.closeDB();
  4387. if (!bLunarTableExist) {
  4388. try {
  4389. Log.d(TAG, "DB File Copy Start");
  4390. copyDataBase(wallpaddbmgr.dblocation + "/" + wallpaddbmgr.Schedule_LunaDB);
  4391. Log.d(TAG, "DB File Copy End");
  4392. } catch (IOException e) {
  4393. LogUtil.errorLogInfo("", TAG, e);
  4394. }
  4395. }
  4396. } catch (RuntimeException re) {
  4397. LogUtil.errorLogInfo("", TAG, re);
  4398. }
  4399. catch (Exception e) {
  4400. LogUtil.errorLogInfo("", TAG, e);
  4401. }
  4402. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) checkDongHoSetting();
  4403. checkDongHoSetting();
  4404. if (Common.GetElevatorSampleMode(getApplicationContext())) {
  4405. int retCount = EnergyAlramPopupMgr.get_WallPadRebootingCount( getApplicationContext()) + 1;
  4406. EnergyAlramPopupMgr.set_WallPadRebootingCount(getApplicationContext(), retCount);
  4407. Log.d(TAG, "################################# rebooting Count : " + retCount );
  4408. }
  4409. // 하드웨어 키 샘플 모드 동작 여부 설정
  4410. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  4411. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  4412. sdata.closeDB();
  4413. WallPadInterface wpdifc = new WallPadInterface();
  4414. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  4415. wpdifc.DoControl(WallPadInterface.IOCTL_KEY_ONOFF_SET, 0);
  4416. CheckEnv();
  4417. }
  4418. catch (RuntimeException re) {
  4419. LogUtil.errorLogInfo("", TAG, re);
  4420. }
  4421. catch (Exception e)
  4422. {
  4423. LogUtil.errorLogInfo("", TAG, e);
  4424. }
  4425. try {Thread.sleep(5000);}
  4426. catch (RuntimeException re) {
  4427. LogUtil.errorLogInfo("", TAG, re);
  4428. MainSubScreenLoadingComplite = true;
  4429. }
  4430. catch (Exception e){LogUtil.errorLogInfo("", TAG, e);}
  4431. MainSubScreenLoadingComplite = true;
  4432. }
  4433. }
  4434. public static String DB_WALLPAD_WIDGET_INIT = "DB_WALLPAD_WIDGET_INIT";
  4435. public void set_WallPadWidgetInit(Context context) {
  4436. try {
  4437. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4438. boolean bRet = mgr.UpdateWallPADData(DB_WALLPAD_WIDGET_INIT, String.valueOf(1));
  4439. if (bRet == false ) {
  4440. Log.d(TAG, "----- DB_WALLPAD_WIDGET_INIT insert ==> false ");
  4441. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "1");
  4442. }
  4443. mgr.closeDB();
  4444. } catch (RuntimeException re) {
  4445. LogUtil.errorLogInfo("", TAG, re);
  4446. }
  4447. catch (Exception e) {
  4448. LogUtil.errorLogInfo("", TAG, e);
  4449. }
  4450. }
  4451. public int get_WallPadWidgetInit(Context context) {
  4452. int ret = 0;
  4453. try {
  4454. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4455. String strRet = mgr.GetWallPADData(DB_WALLPAD_WIDGET_INIT);
  4456. if (strRet == null) {
  4457. Log.d(TAG, "----- get_WallPadRebootingCount strRet == null && insert ==> false ");
  4458. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "0");
  4459. return 0;
  4460. }
  4461. ret = Integer.parseInt(strRet);
  4462. mgr.closeDB();
  4463. } catch (RuntimeException re) {
  4464. LogUtil.errorLogInfo("", TAG, re);
  4465. }
  4466. catch (Exception e) {
  4467. LogUtil.errorLogInfo("", TAG, e);
  4468. }
  4469. return ret;
  4470. }
  4471. /**
  4472. * 스케줄 관련 처리 핸들러 추가
  4473. * 모닝콜, 일정관리, 엘리베이터 호출상태, 에너지 사용량 확인
  4474. * 현재는 사용하지 않음. checkTimeTasks()로 대체
  4475. */
  4476. private int nDay, nHour, nMin;
  4477. Handler Checker = new Handler() {
  4478. public void handleMessage(Message msg) {
  4479. super.handleMessage(msg);
  4480. Calendar cal = new GregorianCalendar();
  4481. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4482. // 날짜가 바뀌었을때...
  4483. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4484. Log.d(TAG , "-----------------day change repeat");
  4485. if (SCManager != null) {
  4486. if (SYSTEM_TIME_SET)SCManager.refreshSchedule();
  4487. }
  4488. //
  4489. // Intent intent = new Intent();
  4490. // intent.setAction(define.NOTIFY_ACNAME);
  4491. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DAYCHANGED);
  4492. // getApplicationContext().sendBroadcast(intent);
  4493. //에너지사용량 알림 초기화
  4494. ClearEnergyUsage();
  4495. Log.d(TAG , "cal.get(Calendar.YEAR) :" + cal.get(Calendar.YEAR) );
  4496. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4497. //어제 시간 재입력
  4498. Log.d(TAG , "/**********************************************/");
  4499. Log.d(TAG , "GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4500. Log.d(TAG , "/**********************************************/");
  4501. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4502. Log.d(TAG , "DayofLastSecond : "+ DayofLastSecond);
  4503. }
  4504. }
  4505. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4506. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4507. DoScheduleHourUnit(cal);
  4508. }
  4509. if (cal.get(Calendar.MINUTE) != nMin) {
  4510. nMin = cal.get(Calendar.MINUTE);
  4511. /**
  4512. * A20월패드 BSP는 전자액자 실행을 시키지 않기때문에 main app에서 전자액자 실행 여부 확인하여
  4513. * 실행시킴
  4514. * **/
  4515. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  4516. Log.i(TAG, "[Checker handler] ========== JEFF 1 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4517. if (m_LiveMainActivity > 0) {
  4518. String LCD_Sleep_Status = null;
  4519. Runtime runtime = Runtime.getRuntime();
  4520. Process process;
  4521. try {
  4522. String cmd = "getprop persist.sys.display.lcdoff";
  4523. process = runtime.exec(cmd);
  4524. BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
  4525. String line;
  4526. while ((line = br.readLine()) != null) {
  4527. LCD_Sleep_Status = line;
  4528. }
  4529. } catch (RuntimeException re) {
  4530. LogUtil.errorLogInfo("", TAG, re);
  4531. }
  4532. catch (Exception e) {
  4533. e.fillInStackTrace();
  4534. Log.e("Process Manager", "Unable to execute top command");
  4535. }
  4536. if (LCD_Sleep_Status != null) {
  4537. Log.d(TAG, "The LCD_Sleep_Status : " + LCD_Sleep_Status);
  4538. if (LCD_Sleep_Status.equals("1") == true) {
  4539. // LCD 꺼져있음
  4540. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4541. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4542. if (SettData.StartAutoPictureAPP() == true) {
  4543. Log.d(TAG, "StartAutoPictureAPP is true");
  4544. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4545. // pm.userActivity(2, true);
  4546. // LCD backlight normal
  4547. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4548. Log.d(TAG, "PowerManager will be set");
  4549. }
  4550. else {
  4551. Log.d(TAG, "StartAutoPictureAPP is false");
  4552. }
  4553. }
  4554. else {
  4555. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4556. }
  4557. SettData.closeDB();
  4558. }
  4559. }
  4560. else {
  4561. Log.e(TAG, "The LCD_Sleep_Status is null");
  4562. }
  4563. }
  4564. }
  4565. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4566. Log.i(TAG, "[Checker handler] ========== JEFF 2 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4567. if (m_LiveMainActivity > 0) {
  4568. boolean bisScreenOn = false;
  4569. if (getCompareBSPVersion("2020.09.18")) {
  4570. bisScreenOn = checkLCDOnByCMD();
  4571. }
  4572. else {
  4573. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4574. bisScreenOn = mPowerManager.isScreenOn();
  4575. }
  4576. Log.i(TAG, "[Checker handler] bisScreenOn : " + bisScreenOn);
  4577. if (!bisScreenOn) {
  4578. if (getBlackoutStatus()) {
  4579. Log.i(TAG, "[Checker handler] getBlackoutStatus is true!!!");
  4580. sendBlackoutScreenRunBR();
  4581. }
  4582. else {
  4583. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4584. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4585. if (SettData.StartAutoPictureAPP() == true) {
  4586. Log.d(TAG, "StartAutoPictureAPP is true");
  4587. mIOInterface.ctrlLcdWakeUp();
  4588. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4589. Log.d(TAG, "PowerManager will be set");
  4590. }
  4591. else {
  4592. Log.d(TAG, "StartAutoPictureAPP is false");
  4593. }
  4594. }
  4595. else {
  4596. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4597. }
  4598. SettData.closeDB();
  4599. }
  4600. }
  4601. }
  4602. }
  4603. if ((nMin == 50) || (nMin == 0)) {
  4604. try {
  4605. checkScheduleReminder();
  4606. } catch (RuntimeException re) {
  4607. LogUtil.errorLogInfo("", TAG, re);
  4608. }
  4609. catch (Exception e) {
  4610. LogUtil.errorLogInfo("", TAG, e);
  4611. }
  4612. // 스케줄 일정 알람 팝업을 띄우도록 한다.
  4613. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  4614. // String SendMSG = doSchedule.get(0).inqmsg;
  4615. // if (doSchedule.size() > 1) SendMSG+=(" 외 "+doSchedule.size()+"건을 알려드립니다.");
  4616. // intent.putExtra("MESSAGE", SendMSG);
  4617. //
  4618. // startActivity(intent);
  4619. }
  4620. if (SCManager != null) SCManager.scheduleCheck();
  4621. //CheckElevator();
  4622. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4623. try {
  4624. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4625. iMAPMethod.ReqGetSet();
  4626. } catch (RuntimeException re) {
  4627. LogUtil.errorLogInfo("", TAG, re);
  4628. }
  4629. catch (Exception e) {
  4630. LogUtil.errorLogInfo("", TAG, e);
  4631. }
  4632. }
  4633. // 중복.... 이게 왜 있는겨....
  4634. // if ( cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY && SYSTEM_TIME_SET && cal.get(Calendar.DAY_OF_MONTH)!=LastTimeSync)
  4635. // {
  4636. // Calendar checktime = GetTimeSyncTime();
  4637. // if (checktime != null)
  4638. // {
  4639. // if (cal.after(checktime))
  4640. // {
  4641. // LastTimeSync = cal.get(Calendar.DAY_OF_MONTH);
  4642. // WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  4643. // wpd.SetLastTimeSyncDate(LastTimeSync);
  4644. // wpd.closeDB();
  4645. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4646. // iMAPMethod.ReqGetSet();
  4647. // }
  4648. // }
  4649. // }
  4650. //주차정보 관련 20분 마다 얻어오기
  4651. if (bUseofNot_ParkingInfo == true) {
  4652. cGetParkingMin++;
  4653. //테스트
  4654. /*
  4655. bSetMSG_GetParkingInfo = true;
  4656. LoadParkingDataFromServer();
  4657. */
  4658. if (cGetParkingMin >= 20) {
  4659. // 20분으로 고정
  4660. cGetParkingMin = 0;
  4661. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4662. //넥스파인 경우는 협의후 처리
  4663. switch (nParkingSystemType) {
  4664. case Common.PARKING_SYSTEM_ICONTROLS:
  4665. case Common.PARKING_SYSTEM_NEXPA:
  4666. case Common.PARKING_SYSTEM_UPIS:
  4667. case Common.PARKING_SYSTEM_IES_100:
  4668. break;
  4669. case Common.PARKING_SYSTEM_BASIC:
  4670. case Common.PARKING_SYSTEM_ETC:
  4671. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4672. break;
  4673. default:
  4674. break;
  4675. }
  4676. }
  4677. }
  4678. // 필요없는 코드 삭제 ( yskim 2015.03.31 )
  4679. // String checkDate = String.format("%04d%02d%02d",cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH));
  4680. // WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  4681. // String EnergyCheckData = energyData.GetEnergyCheckDate();
  4682. // energyData.closeDB();
  4683. // if (SYSTEM_TIME_SET)
  4684. // {
  4685. // Calendar checktime = GetEnergyDataLoadingTime();
  4686. // if (!checkDate.equals(EnergyCheckData))
  4687. // {
  4688. // if (checktime != null)
  4689. // {
  4690. //
  4691. // if (cal.after(checktime))
  4692. // {
  4693. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4694. // iMAPMethod.GetEnergyUsage();
  4695. // WallPadiMAPNotifyAPI iMAPMethod2 = new WallPadiMAPNotifyAPI(getApplicationContext());
  4696. // iMAPMethod2.GetEnergyUsageMonth();
  4697. // }
  4698. // }
  4699. // }
  4700. // }
  4701. }
  4702. // checkMainPage();
  4703. Checker.sendEmptyMessageDelayed(0, 1000);
  4704. }
  4705. };
  4706. /**
  4707. * JEFF, 2019.12.25
  4708. * 매 1초마다 실행되면서 스케쥴 확인하여 각 기능을 동작시킨다 (시간업데이트, 전자액자 등)
  4709. */
  4710. Handler handlerEverySecond = new Handler() {
  4711. public void handleMessage(Message msg) {
  4712. super.handleMessage(msg);
  4713. checkTimeTasks();
  4714. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  4715. }
  4716. };
  4717. private void checkTimeTasks() {
  4718. try {
  4719. // Log.d(TAG , "[checkTimeTasks] ===== START =====");
  4720. Calendar cal = new GregorianCalendar();
  4721. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4722. // 날짜 변경시
  4723. Log.d(TAG , "[checkTimeTasks] day changed!!");
  4724. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4725. if (SCManager != null) {
  4726. if (SYSTEM_TIME_SET) SCManager.refreshSchedule();
  4727. }
  4728. else {
  4729. Log.w(TAG , "[checkTimeTasks] SYSTEM_TIME_SET is null!!");
  4730. }
  4731. // 모바일연동 서비스로 원격검침 데이터를 전송
  4732. // getTelemeteringDataOnRandomTime();
  4733. // // 에너지사용량 알림 초기화
  4734. // ClearEnergyUsage();
  4735. Log.d(TAG , "[checkTimeTasks] Calendar.YEAR = " + cal.get(Calendar.YEAR) );
  4736. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4737. //어제 시간 재입력
  4738. Log.i(TAG , "[checkTimeTasks] GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4739. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4740. Log.d(TAG , "[checkTimeTasks] DayofLastSecond : "+ DayofLastSecond);
  4741. }
  4742. }
  4743. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4744. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4745. // 원격검침 데이터를 서버로부터 가져와 관련 기능모듈에 알린다.
  4746. getTelemeteringDataOnRandomTime();
  4747. DoScheduleHourUnit(cal);
  4748. }
  4749. if (getBlackoutStatus()) {
  4750. Log.i(TAG, "[checkTimeTasks] getBlackoutStatus is true!!!");
  4751. sendBlackoutScreenRunBR();
  4752. }
  4753. if (cal.get(Calendar.MINUTE) != nMin) {
  4754. nMin = cal.get(Calendar.MINUTE);
  4755. /**
  4756. * main app에서 전자액자 실행 여부 확인하여 실행시킴
  4757. * **/
  4758. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4759. Log.i(TAG, "[checkTimeTasks] m_LiveMainActivity : " + m_LiveMainActivity);
  4760. if (m_LiveMainActivity > 0) {
  4761. boolean bScreenOn = false;
  4762. if (getCompareBSPVersion("2020.09.18")) {
  4763. bScreenOn = checkLCDOnByCMD();
  4764. }
  4765. else {
  4766. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4767. bScreenOn = mPowerManager.isScreenOn();
  4768. }
  4769. Log.i(TAG, "[checkTimeTasks] bScreenOn : " + bScreenOn);
  4770. if (!bScreenOn && !getBlackoutStatus()) {
  4771. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4772. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4773. if (SettData.StartAutoPictureAPP() == true) {
  4774. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is true");
  4775. mIOInterface.ctrlLcdWakeUp();
  4776. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4777. Log.d(TAG, "[checkTimeTasks] PowerManager will be set");
  4778. }
  4779. else {
  4780. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is false");
  4781. }
  4782. }
  4783. else {
  4784. Log.d(TAG, "[checkTimeTasks] DecideAutoPictureAppStartOrNot(...) is false");
  4785. }
  4786. SettData.closeDB();
  4787. }
  4788. }
  4789. }
  4790. if ((nMin == 50) || (nMin == 0)) {
  4791. try {
  4792. checkScheduleReminder();
  4793. } catch (RuntimeException re) {
  4794. LogUtil.errorLogInfo("", TAG, re);
  4795. }
  4796. catch (Exception e) {
  4797. LogUtil.errorLogInfo("", TAG, e);
  4798. }
  4799. }
  4800. if (SCManager != null) SCManager.scheduleCheck();
  4801. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4802. try {
  4803. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4804. iMAPMethod.ReqGetSet();
  4805. } catch (RuntimeException re) {
  4806. LogUtil.errorLogInfo("", TAG, re);
  4807. }
  4808. catch (Exception e) {
  4809. LogUtil.errorLogInfo("", TAG, e);
  4810. }
  4811. }
  4812. //주차정보 관련 20분 마다 얻어오기
  4813. if (bUseofNot_ParkingInfo == true) {
  4814. cGetParkingMin++;
  4815. //테스트
  4816. /*
  4817. bSetMSG_GetParkingInfo = true;
  4818. LoadParkingDataFromServer();
  4819. */
  4820. if (cGetParkingMin >= 20) {
  4821. // 20분으로 고정
  4822. cGetParkingMin = 0;
  4823. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4824. //넥스파인 경우는 협의후 처리
  4825. switch(nParkingSystemType) {
  4826. case Common.PARKING_SYSTEM_ICONTROLS:
  4827. case Common.PARKING_SYSTEM_NEXPA:
  4828. case Common.PARKING_SYSTEM_UPIS:
  4829. case Common.PARKING_SYSTEM_IES_100:
  4830. break;
  4831. case Common.PARKING_SYSTEM_BASIC:
  4832. case Common.PARKING_SYSTEM_ETC:
  4833. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4834. break;
  4835. default:
  4836. break;
  4837. }
  4838. }
  4839. }
  4840. }
  4841. } catch (RuntimeException re) {
  4842. LogUtil.errorLogInfo("", TAG, re);
  4843. }
  4844. catch (Exception e) {
  4845. Log.e(TAG, "[Exception] checkTimeTasks()");
  4846. LogUtil.errorLogInfo("", TAG, e);
  4847. }
  4848. }
  4849. /**
  4850. * 일정 알림 팝업창 생성하는 함수<br>
  4851. * 김용성 과장님 이곳에서 팝업창 생성해주시기 바랍니다.
  4852. * @param popup_msg 팝업창에 띄울 메시지.
  4853. * **/
  4854. private void MakePopup_Schedule(String popup_msg) {
  4855. try {
  4856. Log.e(TAG, "[MakePopup_Schedule] popup_msg [" + popup_msg + "]");
  4857. DebugLogOutput("===================================");
  4858. DebugLogOutput(popup_msg);
  4859. DebugLogOutput("===================================");
  4860. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  4861. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  4862. boolean soundOut = mWallpadStatusData.GetSoundOutputOfEventAlarm();
  4863. mWallpadStatusData.closeDB();
  4864. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 1 ==========");
  4865. if (AlarmStatus != WallpadStatusData.ALARM_ARISE && AlarmStatus != WallpadStatusData.GUARD_OUT && AlarmStatus != WallpadStatusData.GUARD_OUT_WAIT) {
  4866. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 2 ==========");
  4867. if (!Common.bWallPadCallLive) {
  4868. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 3 ==========");
  4869. Common.SendAppFinishReqBR(getApplicationContext());
  4870. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4871. Log.d(TAG, "[MakePopup_Schedule] Screen On: " + mPowerManager.isScreenOn());
  4872. if (getCompareBSPVersion("2020.09.18")) {
  4873. if (!checkLCDOnByCMD()) {
  4874. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4875. }
  4876. }
  4877. else {
  4878. if (!mPowerManager.isScreenOn()) {
  4879. Log.d(TAG, "[MakePopup_Schedule] V40Interface LcdWakeUp Call!!");
  4880. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4881. }
  4882. }
  4883. ((MainActivity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4884. // 알람 소리를 내준다.
  4885. if (soundOut) {
  4886. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 4 ==========");
  4887. Sound().Play(SND.effect.EFFECT1);
  4888. }
  4889. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 5 ==========");
  4890. EnergyAlramPopupMgr.SchedulePopupMsg = popup_msg;
  4891. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 6 ==========");
  4892. StartPopup(ID.POPUPS.POPUP_SCHEDULENOTIFICATION);
  4893. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 7 ==========");
  4894. }
  4895. }
  4896. } catch (RuntimeException re) {
  4897. LogUtil.errorLogInfo("", TAG, re);
  4898. }
  4899. catch (Exception e) {
  4900. Log.e(TAG, "[Exception] MakePopup_Schedule(String popup_msg)");
  4901. LogUtil.errorLogInfo("", TAG, e);
  4902. }
  4903. }
  4904. /**
  4905. * 일정 알림 시간 비교!
  4906. * **/
  4907. private void checkScheduleReminder() {
  4908. try {
  4909. Calendar ScheduleCal = Calendar.getInstance();
  4910. Log.i(TAG, "[checkScheduleReminder] ScheduleCal: " + ScheduleCal.getTime());
  4911. WallpadScheduleData SCData = new WallpadScheduleData(getApplicationContext());
  4912. // List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.NewGetScheduleDataForMainActivity(ScheduleCal.get(Calendar.YEAR), ScheduleCal.get(Calendar.MONTH) + 1, ScheduleCal.get(Calendar.DAY_OF_MONTH));
  4913. List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.getScheduledInfoforMainActivity();
  4914. SCData.closeDB();
  4915. if (scheduleDataDB != null) {
  4916. Log.i(TAG, "scheduleDataDB.size() [" + scheduleDataDB.size() + "]");
  4917. for (int i = 0; i < scheduleDataDB.size(); i++) {
  4918. DebugLogOutput("[checkScheduleReminder] ===================================");
  4919. DebugLogOutput("[checkScheduleReminder] index [" + i + "], year [" + scheduleDataDB.get(i).inqyear + "], month [" + scheduleDataDB.get(i).inqmonth + "], day [" + scheduleDataDB.get(i).inqday + "], hour [" + scheduleDataDB.get(i).inqhour + "]");
  4920. DebugLogOutput("[checkScheduleReminder] msg [" + scheduleDataDB.get(i).inqmsg + "], seq [" + scheduleDataDB.get(i).seqnum + "]");
  4921. /**
  4922. * inqttype: 음력여부 - {"moon", "sun"}
  4923. * inqctype: 주기 - no:없음 or month:매월주기 or year:매년주기
  4924. * inqatype: 알림 - {"no","intime","min","hour","day"} := {안울림, 정각, 10분전, 1시간전, 하루전}
  4925. * inqitype: 행사 - {"birth","memorial","appoint","trip","first","wedding","tax","meeting","car","ancestor"} := {생일,기념일,약속,여행,돌,결혼,공과금,차량점검,제사}
  4926. */
  4927. DebugLogOutput("[checkScheduleReminder] lunar [" + scheduleDataDB.get(i).inqttype + "], cycle [" + scheduleDataDB.get(i).inqctype + "], remindtime [" + scheduleDataDB.get(i).inqatype + "], event [" + scheduleDataDB.get(i).inqitype + "]");
  4928. DebugLogOutput("[checkScheduleReminder] ===================================\n");
  4929. Calendar alarmCalendar = Calendar.getInstance();
  4930. if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("no") == true) {
  4931. //알림 사용하지 않음.
  4932. Log.i(TAG, "[checkScheduleReminder] ========== alarm off ==========");
  4933. }
  4934. else {
  4935. Log.i(TAG, "[checkScheduleReminder] ========== alarm on ==========");
  4936. if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("month")) {
  4937. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month ==========");
  4938. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4939. //정각인 경우
  4940. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> intime ==========");
  4941. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4942. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4943. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4944. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4945. AlarmScheduleCount++;
  4946. if (bAlarmScheduleString == false) {
  4947. bAlarmScheduleString = true;
  4948. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4949. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4950. }
  4951. else {
  4952. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4953. }
  4954. }
  4955. }
  4956. }
  4957. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4958. //10분 전
  4959. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 10 min before ==========");
  4960. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4961. alarmCalendar.add(Calendar.MINUTE, -10);
  4962. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4963. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4964. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4965. AlarmScheduleCount++;
  4966. if (bAlarmScheduleString == false) {
  4967. bAlarmScheduleString = true;
  4968. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4969. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4970. }
  4971. else {
  4972. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4973. }
  4974. }
  4975. }
  4976. }
  4977. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4978. //1시간 전
  4979. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 hour before ==========");
  4980. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4981. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4982. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4983. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4984. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4985. AlarmScheduleCount++;
  4986. if (bAlarmScheduleString == false) {
  4987. bAlarmScheduleString = true;
  4988. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4989. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4990. }
  4991. else {
  4992. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4993. }
  4994. }
  4995. }
  4996. }
  4997. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4998. //하루전
  4999. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 day before ==========");
  5000. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5001. alarmCalendar.add(Calendar.DATE, -1);
  5002. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  5003. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  5004. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.DAY_OF_MONTH): " + ScheduleCal.get(Calendar.DAY_OF_MONTH) + ", alarmCalendar.get(Calendar.DAY_OF_MONTH): " + alarmCalendar.get(Calendar.DAY_OF_MONTH));
  5005. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.HOUR_OF_DAY): " + ScheduleCal.get(Calendar.HOUR_OF_DAY) + ", alarmCalendar.get(Calendar.HOUR_OF_DAY): " + alarmCalendar.get(Calendar.HOUR_OF_DAY));
  5006. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  5007. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5008. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5009. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  5010. AlarmScheduleCount++;
  5011. if (bAlarmScheduleString == false) {
  5012. bAlarmScheduleString = true;
  5013. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5014. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5015. }
  5016. else {
  5017. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5018. }
  5019. }
  5020. }
  5021. }
  5022. }
  5023. else if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("year")) {
  5024. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year ==========");
  5025. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  5026. //정각인 경우
  5027. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> intime ==========");
  5028. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5029. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5030. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5031. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5032. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  5033. AlarmScheduleCount++;
  5034. if (bAlarmScheduleString == false) {
  5035. bAlarmScheduleString = true;
  5036. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5037. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5038. }
  5039. else {
  5040. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5041. }
  5042. }
  5043. }
  5044. }
  5045. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  5046. //10분 전
  5047. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 10 min before ==========");
  5048. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5049. alarmCalendar.add(Calendar.MINUTE, -10);
  5050. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5051. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5052. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5053. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5054. {
  5055. AlarmScheduleCount++;
  5056. if (bAlarmScheduleString == false) {
  5057. bAlarmScheduleString = true;
  5058. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5059. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5060. }
  5061. else {
  5062. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5063. }
  5064. }
  5065. }
  5066. }
  5067. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  5068. //1시간 전
  5069. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 hour before ==========");
  5070. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5071. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  5072. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5073. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5074. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5075. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5076. {
  5077. AlarmScheduleCount++;
  5078. if (bAlarmScheduleString == false) {
  5079. bAlarmScheduleString = true;
  5080. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5081. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5082. }
  5083. else {
  5084. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5085. }
  5086. }
  5087. }
  5088. }
  5089. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  5090. //하루전
  5091. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 day before ==========");
  5092. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5093. alarmCalendar.add(Calendar.DATE, -1);
  5094. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  5095. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  5096. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.DAY_OF_MONTH): " + ScheduleCal.get(Calendar.DAY_OF_MONTH) + ", alarmCalendar.get(Calendar.DAY_OF_MONTH): " + alarmCalendar.get(Calendar.DAY_OF_MONTH));
  5097. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.HOUR_OF_DAY): " + ScheduleCal.get(Calendar.HOUR_OF_DAY) + ", alarmCalendar.get(Calendar.HOUR_OF_DAY): " + alarmCalendar.get(Calendar.HOUR_OF_DAY));
  5098. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  5099. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5100. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5101. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5102. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5103. {
  5104. AlarmScheduleCount++;
  5105. if (bAlarmScheduleString == false) {
  5106. bAlarmScheduleString = true;
  5107. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5108. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5109. }
  5110. else {
  5111. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5112. }
  5113. }
  5114. }
  5115. }
  5116. }
  5117. else {
  5118. //반복 없는경우
  5119. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat ==========");
  5120. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  5121. //정각인 경우
  5122. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> intime ==========");
  5123. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5124. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5125. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5126. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5127. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5128. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5129. {
  5130. AlarmScheduleCount++;
  5131. if (bAlarmScheduleString == false) {
  5132. bAlarmScheduleString = true;
  5133. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5134. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5135. }
  5136. else {
  5137. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5138. }
  5139. }
  5140. }
  5141. }
  5142. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  5143. //10분 전
  5144. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 10 min before ==========");
  5145. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5146. alarmCalendar.add(Calendar.MINUTE, -10);
  5147. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5148. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5149. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5150. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5151. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5152. {
  5153. AlarmScheduleCount++;
  5154. if (bAlarmScheduleString == false) {
  5155. bAlarmScheduleString = true;
  5156. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5157. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5158. }
  5159. else {
  5160. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5161. }
  5162. }
  5163. }
  5164. }
  5165. else if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  5166. //1시간 전
  5167. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 hour before ==========");
  5168. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5169. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  5170. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5171. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5172. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5173. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5174. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5175. {
  5176. AlarmScheduleCount++;
  5177. if (bAlarmScheduleString == false) {
  5178. bAlarmScheduleString = true;
  5179. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5180. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5181. }
  5182. else {
  5183. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5184. }
  5185. }
  5186. }
  5187. }
  5188. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  5189. //하루전
  5190. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 day before ==========");
  5191. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5192. alarmCalendar.add(Calendar.DATE, -1);
  5193. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  5194. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  5195. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.DAY_OF_MONTH): " + ScheduleCal.get(Calendar.DAY_OF_MONTH) + ", alarmCalendar.get(Calendar.DAY_OF_MONTH): " + alarmCalendar.get(Calendar.DAY_OF_MONTH));
  5196. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.HOUR_OF_DAY): " + ScheduleCal.get(Calendar.HOUR_OF_DAY) + ", alarmCalendar.get(Calendar.HOUR_OF_DAY): " + alarmCalendar.get(Calendar.HOUR_OF_DAY));
  5197. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  5198. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5199. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5200. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5201. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5202. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5203. {
  5204. AlarmScheduleCount++;
  5205. if (bAlarmScheduleString == false) {
  5206. bAlarmScheduleString = true;
  5207. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5208. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5209. }
  5210. else {
  5211. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5212. }
  5213. }
  5214. }
  5215. }
  5216. else {
  5217. Log.w(TAG, "[checkScheduleReminder] Unsupported alarm type!! -> " + scheduleDataDB.get(i).inqatype);
  5218. }
  5219. }
  5220. }
  5221. }
  5222. Log.i(TAG, "[checkScheduleReminder] bAlarmScheduleString [" + bAlarmScheduleString + "], AlarmScheduleCount [" + AlarmScheduleCount + "]");
  5223. if (bAlarmScheduleString == true) {
  5224. if(AlarmScheduleCount == 1) {
  5225. //일정이 1개인 경우
  5226. AlarmScheduleString += " 일정이 있습니다.\r\n확인 하시겠습니까?";
  5227. }
  5228. else {
  5229. //일정이 1개보다 많은 경우
  5230. AlarmScheduleString += " 일정 외 "+(AlarmScheduleCount-1)+"건이 있습니다.\r\n확인 하시겠습니까?";
  5231. }
  5232. AlarmScheduleCount = 0;
  5233. bAlarmScheduleString = false;
  5234. MakePopup_Schedule(AlarmScheduleString);
  5235. }
  5236. }
  5237. else {
  5238. Log.w(TAG, "[checkScheduleReminder] scheduleDataDB is null!!");
  5239. }
  5240. } catch (RuntimeException re) {
  5241. LogUtil.errorLogInfo("", TAG, re);
  5242. }
  5243. catch (Exception e) {
  5244. Log.e(TAG, "[Exception] checkScheduleReminder(Calendar cal)");
  5245. LogUtil.errorLogInfo("", TAG, e);
  5246. }
  5247. }
  5248. // 프로토콜에 정의된 일정표 이벤트 종류를 변환하여 반환한다.
  5249. private String getScheduleEventType(String strEvent) {
  5250. try {
  5251. Log.i(TAG, "[getScheduleEventType] strEvent [" + strEvent + "]");
  5252. if (strEvent.equalsIgnoreCase("birth")) return "생일";
  5253. else if (strEvent.equalsIgnoreCase("memorial")) return "기념일";
  5254. else if (strEvent.equalsIgnoreCase("appoint")) return "약속";
  5255. else if (strEvent.equalsIgnoreCase("trip")) return "여행";
  5256. else if (strEvent.equalsIgnoreCase("first")) return "돌";
  5257. else if (strEvent.equalsIgnoreCase("wedding")) return "결혼";
  5258. else if (strEvent.equalsIgnoreCase("tax")) return "공과금";
  5259. else if (strEvent.equalsIgnoreCase("meeting")) return "모임";
  5260. else if (strEvent.equalsIgnoreCase("car")) return "생일";
  5261. else if (strEvent.equalsIgnoreCase("ancestor")) return "제사";
  5262. else return "알수없음";
  5263. } catch (RuntimeException re) {
  5264. LogUtil.errorLogInfo("", TAG, re);
  5265. return "알수없음";
  5266. }
  5267. catch (Exception e) {
  5268. Log.e(TAG, "[Exception] getScheduleEventType(String strEvent)");
  5269. LogUtil.errorLogInfo("", TAG, e);
  5270. return "알수없음";
  5271. }
  5272. }
  5273. private void getParkedVehicleLocationSysInfo() {
  5274. try {
  5275. DebugLogOutput("getParkedVehicleLocationSysInfo Init");
  5276. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5277. String[] ParkingDB = devSet.GetSettingData("주차확인");
  5278. devSet.closeDB();
  5279. if (ParkingDB!=null) {
  5280. try {
  5281. String devInfo = ParkingDB[1];
  5282. devInfo = devInfo.replace('(', '_');
  5283. devInfo = devInfo.replace(':', '_');
  5284. devInfo = devInfo.replace(')', '_');
  5285. String[] ParkingInfo = devInfo.split("_");
  5286. //ParkingInfo[3] -> 사용여부 <사용함 / else>
  5287. //ParkingInfo[5] -> 종류 <기본 / 아이콘트롤스 / NEXPA / UPIS / ETC / 비상벨 / else>
  5288. //ParkingInfo[7] -> IP정보
  5289. //ParkingInfo[8] -> 포트번호
  5290. if (ParkingInfo[3].equalsIgnoreCase("사용함") == true) {
  5291. bUseofNot_ParkingInfo = true;
  5292. }
  5293. if (ParkingInfo[5].equalsIgnoreCase("기본") == true) {
  5294. nParkingSystemType = Common.PARKING_SYSTEM_BASIC;
  5295. }
  5296. else if (ParkingInfo[5].equalsIgnoreCase("아이콘트롤스") == true) {
  5297. nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  5298. }
  5299. else if (ParkingInfo[5].equalsIgnoreCase("넥스파") == true) {
  5300. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5301. }
  5302. else if (ParkingInfo[5].equalsIgnoreCase("NEXPA") == true) {
  5303. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5304. }
  5305. else if (ParkingInfo[5].equalsIgnoreCase("UPIS") == true) {
  5306. nParkingSystemType = Common.PARKING_SYSTEM_UPIS;
  5307. }
  5308. else if (ParkingInfo[5].equalsIgnoreCase("ETC") == true) {
  5309. nParkingSystemType = Common.PARKING_SYSTEM_ETC;
  5310. }
  5311. else if (ParkingInfo[5].equalsIgnoreCase("비상벨") == true) {
  5312. nParkingSystemType = Common.PARKING_SYSTEM_IES_100;
  5313. }
  5314. else if (ParkingInfo[5].equalsIgnoreCase("다람정보") == true) {
  5315. nParkingSystemType = Common.PARKING_SYSTEM_DARAM;
  5316. }
  5317. ParkingServerIP = ParkingInfo[7];
  5318. ParkingServerPort = Integer.parseInt(ParkingInfo[8]);
  5319. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo [" + bUseofNot_ParkingInfo + ", nParkingSystemType ["+ nParkingSystemType + "]");
  5320. DebugLogOutput("[getParkedVehicleLocationSysInfo] ParkingServerIP ["+ParkingServerIP + "], ParkingServerPort [" + ParkingServerPort + "]");
  5321. } catch (RuntimeException re) {
  5322. LogUtil.errorLogInfo("", TAG, re);
  5323. bUseofNot_ParkingInfo = false;
  5324. }
  5325. catch (Exception e) {
  5326. LogUtil.errorLogInfo("", TAG, e);
  5327. bUseofNot_ParkingInfo = false;
  5328. }
  5329. }
  5330. else {
  5331. bUseofNot_ParkingInfo = false;
  5332. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo ["+bUseofNot_ParkingInfo + "]");
  5333. }
  5334. } catch (RuntimeException re) {
  5335. LogUtil.errorLogInfo("", TAG, re);
  5336. }
  5337. catch (Exception e) {
  5338. LogUtil.errorLogInfo("", TAG, e);
  5339. }
  5340. }
  5341. //20분 마다 한번씩 호출되는 주차관련 함수!
  5342. private void GetParkingInfo_RandomCheckHandler() {
  5343. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5344. if (DelayTime < 1) {
  5345. return;
  5346. }
  5347. DebugLogOutput("[GetParkingInfo] DelayTime : "+ DelayTime);
  5348. bSetMSG_GetParkingInfo = true;
  5349. mGetParkInfoRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  5350. }
  5351. private Handler mGetParkInfoRandomCheckHandler = new Handler()
  5352. {
  5353. @Override
  5354. public void handleMessage(Message msg)
  5355. {
  5356. if (msg.what == 0) {
  5357. DebugLogOutput("[GetParkingInfo] mGetParkInfoRandomCheckHandler() will be called");
  5358. //얻어오기
  5359. LoadParkingDataFromServer();
  5360. }
  5361. }
  5362. };
  5363. /**
  5364. * @description 주차정보 서버로부터 얻어오기<br>
  5365. * 호출 시에는 bSetMSG_GetParkingInfo = true 하고 호출해야함.
  5366. * **/
  5367. private void LoadParkingDataFromServer() {
  5368. try {
  5369. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5370. final AddressSet addc = SetData.getAddressMGR();
  5371. SetData.closeDB();
  5372. if (bSetMSG_GetParkingInfo == false) {
  5373. return;
  5374. }
  5375. if ((nParkingSystemType == Common.PARKING_SYSTEM_BASIC)
  5376. || (nParkingSystemType == Common.PARKING_SYSTEM_ICONTROLS)
  5377. || (nParkingSystemType == Common.PARKING_SYSTEM_NEXPA)
  5378. || (nParkingSystemType == Common.PARKING_SYSTEM_IES_100))
  5379. {
  5380. boolean bSSLEnable = true;
  5381. if (!ParkingServerIP.equals("10.0.1.1")) bSSLEnable = false;
  5382. iMAPcarParking = new iMAPCarParking(mContext, bSSLEnable);
  5383. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5384. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5385. DebugLogOutput("iMAPcarParking.DoWork()");
  5386. iMAPcarParking.DoWork();
  5387. iMAPcarParking.SetRetCtr(new RetProci(){
  5388. @Override
  5389. public void ProcSuccess() {
  5390. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5391. try {
  5392. iMAPcarParking.SetItem("home_info");
  5393. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5394. int park_info_count = iMAPcarParking.SetItem("park_info");
  5395. if (home_info_count != park_info_count) {
  5396. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5397. cGetParkingMin = 0;
  5398. bSetMSG_GetParkingInfo = false;
  5399. return;
  5400. }
  5401. if (park_info_count == 0) {
  5402. DebugLogOutput("park_info_count :" + park_info_count);
  5403. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5404. parkdb.DeleteAllParkInfo();
  5405. parkdb.closeDB();
  5406. cGetParkingMin = 0;
  5407. bSetMSG_GetParkingInfo = false;
  5408. /*
  5409. parkdb = new WallpadParkInfo(getApplicationContext());
  5410. int countRow = parkdb.RowCountCarParking();
  5411. parkdb.closeDB();
  5412. DebugLogOutput("countRow :" + countRow);
  5413. */
  5414. Intent intent = new Intent();
  5415. intent.setAction(define.NOTIFY_ACNAME);
  5416. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5417. getApplicationContext().sendBroadcast(intent);
  5418. return;
  5419. }
  5420. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5421. parkdb.DeleteAllParkInfo();
  5422. parkdb.closeDB();
  5423. for (int i = 0; i < park_info_count; i++) {
  5424. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5425. parkdb = new WallpadParkInfo(getApplicationContext());
  5426. parkdb.InputParkInfo(
  5427. iMAPcarParking.GetAttributeVal(i, "index"),
  5428. iMAPcarParking.GetAttributeVal(i, "dong"),
  5429. iMAPcarParking.GetAttributeVal(i, "ho"),
  5430. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5431. iMAPcarParking.GetAttributeVal(i, "uid"),
  5432. iMAPcarParking.GetAttributeVal(i, "sn"),
  5433. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5434. iMAPcarParking.GetAttributeVal(i, "time"),
  5435. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5436. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5437. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5438. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5439. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5440. iMAPcarParking.GetAttributeVal(i, "message"));
  5441. parkdb.closeDB();
  5442. }
  5443. }
  5444. //테스트
  5445. parkdb = new WallpadParkInfo(getApplicationContext());
  5446. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5447. parkdb.closeDB();
  5448. if (carParkingData != null) {
  5449. for (int j = 0; j < carParkingData.length; j++) {
  5450. DebugLogOutput(carParkingData[j].ToDebugString());
  5451. }
  5452. }
  5453. //테스트
  5454. Intent intent = new Intent();
  5455. intent.setAction(define.NOTIFY_ACNAME);
  5456. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5457. getApplicationContext().sendBroadcast(intent);
  5458. } catch (RuntimeException re) {
  5459. LogUtil.errorLogInfo("", TAG, re);
  5460. cGetParkingMin = 0;
  5461. bSetMSG_GetParkingInfo = false;
  5462. }
  5463. catch (Exception e) {
  5464. cGetParkingMin = 0;
  5465. bSetMSG_GetParkingInfo = false;
  5466. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5467. LogUtil.errorLogInfo("", TAG, e);
  5468. }
  5469. cGetParkingMin = 0;
  5470. bSetMSG_GetParkingInfo = false;
  5471. }
  5472. @Override
  5473. public void ProcError() {
  5474. cGetParkingMin = 0;
  5475. bSetMSG_GetParkingInfo = false;
  5476. DebugLogOutput("Load EMData From Server - ProcError");
  5477. }
  5478. @Override
  5479. public void ProcDoing() {
  5480. }
  5481. });
  5482. }
  5483. else if (nParkingSystemType == Common.PARKING_SYSTEM_DARAM) {
  5484. iMAPcarParking = new iMAPCarParking(mContext, false);
  5485. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5486. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5487. DebugLogOutput("iMAPcarParking.DoWork()");
  5488. iMAPcarParking.DoWork();
  5489. iMAPcarParking.SetRetCtr(new RetProci(){
  5490. @Override
  5491. public void ProcSuccess() {
  5492. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5493. try {
  5494. iMAPcarParking.SetItem("home_info");
  5495. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5496. int park_info_count = iMAPcarParking.SetItem("park_info");
  5497. if (home_info_count != park_info_count) {
  5498. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5499. cGetParkingMin = 0;
  5500. bSetMSG_GetParkingInfo = false;
  5501. return;
  5502. }
  5503. if (park_info_count == 0) {
  5504. DebugLogOutput("park_info_count :" + park_info_count);
  5505. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5506. parkdb.DeleteAllParkInfo();
  5507. parkdb.closeDB();
  5508. cGetParkingMin = 0;
  5509. bSetMSG_GetParkingInfo = false;
  5510. /*
  5511. parkdb = new WallpadParkInfo(getApplicationContext());
  5512. int countRow = parkdb.RowCountCarParking();
  5513. parkdb.closeDB();
  5514. DebugLogOutput("countRow :" + countRow);
  5515. */
  5516. Intent intent = new Intent();
  5517. intent.setAction(define.NOTIFY_ACNAME);
  5518. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5519. getApplicationContext().sendBroadcast(intent);
  5520. return;
  5521. }
  5522. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5523. parkdb.DeleteAllParkInfo();
  5524. parkdb.closeDB();
  5525. for (int i = 0; i < park_info_count; i++) {
  5526. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5527. parkdb = new WallpadParkInfo(getApplicationContext());
  5528. parkdb.InputParkInfo(
  5529. iMAPcarParking.GetAttributeVal(i, "index"),
  5530. iMAPcarParking.GetAttributeVal(i, "dong"),
  5531. iMAPcarParking.GetAttributeVal(i, "ho"),
  5532. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5533. iMAPcarParking.GetAttributeVal(i, "uid"),
  5534. iMAPcarParking.GetAttributeVal(i, "sn"),
  5535. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5536. iMAPcarParking.GetAttributeVal(i, "time"),
  5537. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5538. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5539. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5540. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5541. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5542. iMAPcarParking.GetAttributeVal(i, "message"));
  5543. parkdb.closeDB();
  5544. }
  5545. }
  5546. //테스트
  5547. parkdb = new WallpadParkInfo(getApplicationContext());
  5548. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5549. parkdb.closeDB();
  5550. if (carParkingData != null) {
  5551. for (int j = 0; j < carParkingData.length; j++) {
  5552. DebugLogOutput(carParkingData[j].ToDebugString());
  5553. }
  5554. }
  5555. //테스트
  5556. Intent intent = new Intent();
  5557. intent.setAction(define.NOTIFY_ACNAME);
  5558. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5559. getApplicationContext().sendBroadcast(intent);
  5560. } catch (RuntimeException re) {
  5561. LogUtil.errorLogInfo("", TAG, re);
  5562. cGetParkingMin = 0;
  5563. bSetMSG_GetParkingInfo = false;
  5564. }
  5565. catch (Exception e) {
  5566. cGetParkingMin = 0;
  5567. bSetMSG_GetParkingInfo = false;
  5568. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5569. LogUtil.errorLogInfo("", TAG, e);
  5570. }
  5571. cGetParkingMin = 0;
  5572. bSetMSG_GetParkingInfo = false;
  5573. }
  5574. @Override
  5575. public void ProcError() {
  5576. cGetParkingMin = 0;
  5577. bSetMSG_GetParkingInfo = false;
  5578. DebugLogOutput("Load EMData From Server - ProcError");
  5579. }
  5580. @Override
  5581. public void ProcDoing() {
  5582. }
  5583. });
  5584. }
  5585. else if (nParkingSystemType == Common.PARKING_SYSTEM_UPIS) {
  5586. iMapcarParking_UPIS = new iMAPCarParking_UPIS(mContext, false);
  5587. iMapcarParking_UPIS.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5588. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5589. DebugLogOutput("iMapcarParking_UPIS.DoWork()");
  5590. iMapcarParking_UPIS.DoWork();
  5591. iMapcarParking_UPIS.SetRetCtr(new RetProci(){
  5592. @Override
  5593. public void ProcSuccess() {
  5594. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5595. try {
  5596. iMapcarParking_UPIS.SetItem("home_info");
  5597. int home_info_count = Integer.parseInt(iMapcarParking_UPIS.GetAttributeVal(0, "count"));
  5598. int park_info_count = iMapcarParking_UPIS.SetItem("park_info");
  5599. if (home_info_count != park_info_count) {
  5600. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5601. cGetParkingMin = 0;
  5602. bSetMSG_GetParkingInfo = false;
  5603. return;
  5604. }
  5605. if (park_info_count == 0) {
  5606. DebugLogOutput("park_info_count :" + park_info_count);
  5607. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5608. parkdb.DeleteAllParkInfo();
  5609. parkdb.closeDB();
  5610. cGetParkingMin = 0;
  5611. bSetMSG_GetParkingInfo = false;
  5612. /*
  5613. parkdb = new WallpadParkInfo(getApplicationContext());
  5614. int countRow = parkdb.RowCountCarParking();
  5615. parkdb.closeDB();
  5616. DebugLogOutput("countRow :" + countRow);
  5617. */
  5618. Intent intent = new Intent();
  5619. intent.setAction(define.NOTIFY_ACNAME);
  5620. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5621. getApplicationContext().sendBroadcast(intent);
  5622. return;
  5623. }
  5624. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5625. parkdb.DeleteAllParkInfo();
  5626. parkdb.closeDB();
  5627. for (int i = 0; i < park_info_count; i++) {
  5628. if ((addc.Dong.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "ho")))) {
  5629. parkdb = new WallpadParkInfo(getApplicationContext());
  5630. parkdb.InputParkInfo(
  5631. iMapcarParking_UPIS.GetAttributeVal(i, "index"),
  5632. iMapcarParking_UPIS.GetAttributeVal(i, "dong"),
  5633. iMapcarParking_UPIS.GetAttributeVal(i, "ho"),
  5634. "null",
  5635. iMapcarParking_UPIS.GetAttributeVal(i, "uid"),
  5636. iMapcarParking_UPIS.GetAttributeVal(i, "sn"),
  5637. iMapcarParking_UPIS.GetAttributeVal(i, "card_type"),
  5638. iMapcarParking_UPIS.GetAttributeVal(i, "time"),
  5639. iMapcarParking_UPIS.GetAttributeVal(i, "location_2"),
  5640. iMapcarParking_UPIS.GetAttributeVal(i, "location_1"),
  5641. iMapcarParking_UPIS.GetAttributeVal(i, "car_info"),
  5642. "null",
  5643. "null",
  5644. iMapcarParking_UPIS.GetAttributeVal(i, "message"));
  5645. parkdb.closeDB();
  5646. }
  5647. }
  5648. //테스트
  5649. parkdb = new WallpadParkInfo(getApplicationContext());
  5650. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5651. parkdb.closeDB();
  5652. if (carParkingData != null) {
  5653. for (int j = 0; j < carParkingData.length; j++) {
  5654. DebugLogOutput(carParkingData[j].ToDebugString());
  5655. }
  5656. }
  5657. Intent intent = new Intent();
  5658. intent.setAction(define.NOTIFY_ACNAME);
  5659. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5660. getApplicationContext().sendBroadcast(intent);
  5661. } catch (RuntimeException re) {
  5662. LogUtil.errorLogInfo("", TAG, re);
  5663. cGetParkingMin = 0;
  5664. bSetMSG_GetParkingInfo = false;
  5665. }
  5666. catch (Exception e) {
  5667. cGetParkingMin = 0;
  5668. bSetMSG_GetParkingInfo = false;
  5669. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5670. LogUtil.errorLogInfo("", TAG, e);
  5671. }
  5672. cGetParkingMin = 0;
  5673. bSetMSG_GetParkingInfo = false;
  5674. }
  5675. @Override
  5676. public void ProcError() {
  5677. cGetParkingMin = 0;
  5678. bSetMSG_GetParkingInfo = false;
  5679. DebugLogOutput("Load EMData From Server - ProcError");
  5680. }
  5681. @Override
  5682. public void ProcDoing() {
  5683. }
  5684. });
  5685. }
  5686. } catch (RuntimeException re) {
  5687. LogUtil.errorLogInfo("", TAG, re);
  5688. }
  5689. catch (Exception e) {
  5690. Log.e(TAG, "[Exception] LoadParkingDataFromServer()");
  5691. LogUtil.errorLogInfo("", TAG, e);
  5692. }
  5693. }
  5694. // 한시간에 한번식 호출되는 함수임
  5695. private void DoScheduleHourUnit(Calendar cal) {
  5696. nHour = cal.get(Calendar.HOUR_OF_DAY);
  5697. // 매시 7시부터 매시간 정각에 계속해서 알려준다. 사용자가 확인하기 전까지...
  5698. // 사용자가 확인하게 되면 알림을 중지한다.
  5699. // 목표값 팝업 알림에 필요한 DB 정보
  5700. // 각각의 항목에 대한 초기화, 근접알림 발생, 근접알림 확인, 초과 알림 발생 , 초과알림 확인 5단계 구분 필요
  5701. // 달이 넘어가게 되면 초괴하 한다.
  5702. try {
  5703. if (nHour == GetEnergyAlarmTime()) {
  5704. if (GetEnergyAlarm() == true) {
  5705. if (bUseofNot_EnergyServer == true) {
  5706. if (ResultGetIntent == true) {
  5707. ResultGetIntent = false;
  5708. Intent intent = new Intent();
  5709. intent.setAction(define.NOTIFY_ACNAME);
  5710. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
  5711. intent.putExtra("elect_target", elect_target);
  5712. intent.putExtra("elect_used", elect_used);
  5713. intent.putExtra("elect_info", elect_info);
  5714. intent.putExtra("water_target", water_target);
  5715. intent.putExtra("water_used", water_used);
  5716. intent.putExtra("water_info", water_info);
  5717. intent.putExtra("gas_target", gas_target);
  5718. intent.putExtra("gas_used", gas_used);
  5719. intent.putExtra("gas_info", gas_info);
  5720. intent.putExtra("heating_target", heating_target);
  5721. intent.putExtra("heating_used", heating_used);
  5722. intent.putExtra("heating_info", heating_info);
  5723. intent.putExtra("hotwater_target", hotwater_target);
  5724. intent.putExtra("hotwater_used", hotwater_used);
  5725. intent.putExtra("hotwater_info", hotwater_info);
  5726. sendBroadcast(intent);
  5727. }
  5728. }
  5729. else {
  5730. CheckEnergyUsage();
  5731. }
  5732. }
  5733. }
  5734. } catch (RuntimeException re) {
  5735. LogUtil.errorLogInfo("", TAG, re);
  5736. }
  5737. catch (Exception e) {
  5738. LogUtil.errorLogInfo("", TAG, e);
  5739. }
  5740. if (SCManager != null ) SCManager.CheckSysResetData();
  5741. }
  5742. static boolean NeedCheckEnergy = false;
  5743. //에너지 사용량 확인
  5744. public void CheckEnergyUsage() {
  5745. Log.d(TAG, "***********************************************");
  5746. Log.d(TAG, "[CheckEnergyUsage] CheckEnergyUsage Function in");
  5747. Log.d(TAG, "***********************************************");
  5748. try {
  5749. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5750. int alarmstate = SetData.GetAlarmStatus();
  5751. SetData.closeDB();
  5752. if (alarmstate == WallpadStatusData.ALARM_ARISE || alarmstate == WallpadStatusData.GUARD_OUT)
  5753. return;
  5754. String strNear = "";
  5755. String strOver = "";
  5756. if (EnergyAlramPopupMgr.m_Elec_UseValue > 0 && EnergyAlramPopupMgr.m_Elec_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP)) {
  5757. if (EnergyAlramPopupMgr.m_Elec_UseValue >= EnergyAlramPopupMgr.m_Elec_GoalValue) {
  5758. strOver += "전기 ";
  5759. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5760. }
  5761. else {
  5762. double nNearValue = EnergyAlramPopupMgr.m_Elec_GoalValue * 0.9;
  5763. if (EnergyAlramPopupMgr.m_Elec_UseValue > nNearValue) {
  5764. strNear += "전기 ";
  5765. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5766. }
  5767. }
  5768. }
  5769. if (EnergyAlramPopupMgr.m_Water_UseValue > 0 && EnergyAlramPopupMgr.m_Water_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP)) {
  5770. if (EnergyAlramPopupMgr.m_Water_UseValue >= EnergyAlramPopupMgr.m_Water_GoalValue) {
  5771. strOver += "수도 ";
  5772. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5773. }
  5774. else {
  5775. double nNearValue = EnergyAlramPopupMgr.m_Water_GoalValue * 0.9;
  5776. if (EnergyAlramPopupMgr.m_Water_UseValue > nNearValue) {
  5777. strNear += "수도 ";
  5778. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5779. }
  5780. }
  5781. }
  5782. if (EnergyAlramPopupMgr.m_Gas_UseValue > 0 && EnergyAlramPopupMgr.m_Gas_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP)) {
  5783. if (EnergyAlramPopupMgr.m_Gas_UseValue >= EnergyAlramPopupMgr.m_Gas_GoalValue) {
  5784. strOver += "가스 ";
  5785. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5786. }
  5787. else {
  5788. double nNearValue = EnergyAlramPopupMgr.m_Gas_GoalValue * 0.9;
  5789. if (EnergyAlramPopupMgr.m_Gas_UseValue > nNearValue) {
  5790. strNear += "가스 ";
  5791. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5792. }
  5793. }
  5794. }
  5795. if (EnergyAlramPopupMgr.m_HotWater_UseValue > 0 && EnergyAlramPopupMgr.m_HotWater_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP)) {
  5796. if (EnergyAlramPopupMgr.m_HotWater_UseValue >= EnergyAlramPopupMgr.m_HotWater_GoalValue) {
  5797. strOver += "온수 ";
  5798. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5799. }
  5800. else {
  5801. double nNearValue = EnergyAlramPopupMgr.m_HotWater_GoalValue * 0.9;
  5802. if (EnergyAlramPopupMgr.m_HotWater_UseValue > nNearValue) {
  5803. strNear += "온수 ";
  5804. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5805. }
  5806. }
  5807. }
  5808. if (EnergyAlramPopupMgr.m_Heating_UseValue > 0 && EnergyAlramPopupMgr.m_Heating_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP)) {
  5809. if (EnergyAlramPopupMgr.m_Heating_UseValue >= EnergyAlramPopupMgr.m_Heating_GoalValue) {
  5810. strOver += "난방 ";
  5811. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5812. }
  5813. else {
  5814. double nNearValue = EnergyAlramPopupMgr.m_Heating_GoalValue * 0.9;
  5815. if (EnergyAlramPopupMgr.m_Heating_UseValue > nNearValue) {
  5816. strNear += "난방 ";
  5817. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5818. }
  5819. }
  5820. }
  5821. if (strNear.length() > 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이\n목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5822. else if (0 < strNear.length() && strNear.length() <= 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이 목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5823. else EnergyAlramPopupMgr.PopupMsg01 = "";
  5824. if (strOver.length() > 10) {
  5825. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이\n목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5826. }
  5827. else if (0 < strOver.length() && strOver.length() <= 10) {
  5828. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이 목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5829. }
  5830. else if(strOver.length() < 0){
  5831. EnergyAlramPopupMgr.PopupMsg02 = "";
  5832. }
  5833. if (EnergyAlramPopupMgr.PopupMsg01.length() > 0 || EnergyAlramPopupMgr.PopupMsg02.length() > 0) {
  5834. mIOInterface.ctrlLcdWakeUp();
  5835. StartPopup(ID.POPUPS.POPUP_ENERGYUSAGEALERT);
  5836. }
  5837. } catch (RuntimeException re) {
  5838. LogUtil.errorLogInfo("", TAG, re);
  5839. }
  5840. catch (Exception e) {
  5841. Log.e(TAG, "[Exception] CheckEnergyUsage()");
  5842. LogUtil.errorLogInfo("", TAG, e);
  5843. }
  5844. }
  5845. //시간 동기화를 위한 getinfo 실행 시간을 구함
  5846. protected Calendar GetTimeSyncTime()
  5847. {
  5848. Calendar retTime = new GregorianCalendar();
  5849. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5850. AddressSet addc = SetData.getAddressMGR();
  5851. SetData.closeDB();
  5852. try {
  5853. int dong = Integer.parseInt(addc.Dong);
  5854. int ho = 101;
  5855. if(addc.UseOrNotRentHouse == true)
  5856. {
  5857. ho = addc.Ho_Integer;
  5858. }
  5859. else
  5860. {
  5861. ho = Integer.parseInt(addc.Ho);
  5862. }
  5863. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5864. int hour;
  5865. int min;
  5866. int sec;
  5867. if (interval/3600 > 0)
  5868. {
  5869. hour = 3+interval/3600;
  5870. interval=interval%3600;
  5871. }
  5872. else hour = 6;
  5873. if (interval/60 > 0)
  5874. {
  5875. min = interval/60;
  5876. sec = interval%60;
  5877. }
  5878. else
  5879. {
  5880. min = 0;
  5881. sec = interval;
  5882. }
  5883. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5884. retTime.set(Calendar.MINUTE, min);
  5885. retTime.set(Calendar.SECOND, sec);
  5886. }
  5887. catch (RuntimeException re) {
  5888. LogUtil.errorLogInfo("", TAG, re);
  5889. return null;
  5890. }
  5891. catch (Exception e)
  5892. {
  5893. LogUtil.errorLogInfo("", TAG, e);
  5894. return null;
  5895. }
  5896. return retTime;
  5897. }
  5898. //에너지 사용량 확인을 위한 데이터 로딩 시간을 가져옴
  5899. protected Calendar GetEnergyDataLoadingTime()
  5900. {
  5901. Calendar retTime = new GregorianCalendar();
  5902. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5903. AddressSet addc = SetData.getAddressMGR();
  5904. SetData.closeDB();
  5905. try {
  5906. int dong = Integer.parseInt(addc.Dong);
  5907. int ho = 201;
  5908. if(addc.UseOrNotRentHouse == true)
  5909. {
  5910. ho = addc.Ho_Integer;
  5911. }
  5912. else
  5913. {
  5914. ho = Integer.parseInt(addc.Ho);
  5915. }
  5916. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5917. int hour;
  5918. int min;
  5919. int sec;
  5920. if (interval/3600 > 0)
  5921. {
  5922. hour = 6+interval/3600;
  5923. interval=interval%3600;
  5924. }
  5925. else hour = 6;
  5926. if (interval/60 > 0)
  5927. {
  5928. min = interval/60;
  5929. sec = interval%60;
  5930. }
  5931. else
  5932. {
  5933. min = 0;
  5934. sec = interval;
  5935. }
  5936. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5937. retTime.set(Calendar.MINUTE, min);
  5938. retTime.set(Calendar.SECOND, sec);
  5939. }
  5940. catch (RuntimeException re) {
  5941. LogUtil.errorLogInfo("", TAG, re);
  5942. return null;
  5943. }
  5944. catch (Exception e)
  5945. {
  5946. LogUtil.errorLogInfo("", TAG, e);
  5947. return null;
  5948. }
  5949. return retTime;
  5950. }
  5951. private void setNetworkAddr(int secNum, int thirdNum, int forthNum) {
  5952. try
  5953. {
  5954. String IPAddress = String.format("10.%d.%d.%d", secNum, thirdNum, forthNum);
  5955. String gateWayIPAddress = String.format("10.%d.%d.%d", secNum, Common.DEFAULT_GATEWAY_IP_THIRD, Common.DEFAULT_GATEWAY_IP_FORTH);
  5956. String MacAddr = String.format("00:0A:%02x:%02x:%02x:00", secNum, thirdNum, forthNum);
  5957. String serverIP = Common.DEFAULT_SERVER_IP;
  5958. int serverPort = Common.DEFAULT_SERVER_PORT;
  5959. String managePCIP = Common.DEFAULT_MANAGER_PC_IP;
  5960. int managePCPort = Common.DEFAULT_MANAGER_PC_PORT;
  5961. wallpaddbmgr dbmgr = new wallpaddbmgr(this);
  5962. AddressSet addc = dbmgr.getAddressMGR();
  5963. String mDong = String.format("%d%02d", 1, secNum);
  5964. String mHo = String.format("%d%02d", thirdNum, forthNum);
  5965. addc.setAddress(mDong, mHo);
  5966. addc.setIPAddress(IPAddress);
  5967. dbmgr.closeDB();
  5968. WallpadStatusData wallpadStatusData = new WallpadStatusData(this);
  5969. wallpadStatusData.SetServerIP(serverIP, serverPort);
  5970. wallpadStatusData.SetManagePC(managePCIP, managePCPort);
  5971. wallpadStatusData.closeDB();
  5972. EthernetDevInfo info = new EthernetDevInfo();
  5973. info.setIfName("eth0");
  5974. info.setConnectMode(EthernetDevInfo.ETH_CONN_MODE_MANUAL);
  5975. info.setIpAddress(IPAddress);
  5976. info.setRouteAddr(gateWayIPAddress);
  5977. info.setDnsAddr(Common.DNS_IP);
  5978. info.setNetMask(Common.SUBNET_MASK);
  5979. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  5980. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  5981. mEthManager.UpdateEthDevInfo(info);
  5982. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  5983. WallPadInterface wallPadInterface = new WallPadInterface();;
  5984. wallPadInterface.setMacAddr(MacAddr);
  5985. Log.d("MANAGERSETTING", " IP : "+IPAddress+" Mac : "+ MacAddr);
  5986. writeMacAddress(MacAddr);
  5987. }
  5988. catch (RuntimeException re) {
  5989. LogUtil.errorLogInfo("", TAG, re);
  5990. }
  5991. catch (Exception e)
  5992. {
  5993. LogUtil.errorLogInfo("", TAG, e);
  5994. }
  5995. }
  5996. private final String NETWORK_SETTING = "network_setting";
  5997. private final String MAC_ADDRESS_FILE_PATH = Common.CONTENTS_ROOT + NETWORK_SETTING + ".inc";
  5998. private boolean writeMacAddress(String MacAddr) {
  5999. boolean ret = false;
  6000. String read = null;
  6001. BufferedWriter bufferWriter = null;
  6002. try {
  6003. FileOutputStream fos = new FileOutputStream(MAC_ADDRESS_FILE_PATH, false);
  6004. OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
  6005. bufferWriter = new BufferedWriter(osr, 1024);
  6006. if ((bufferWriter != null) && (MacAddr != null)) {
  6007. bufferWriter.write(MacAddr, 0, MacAddr.length());
  6008. bufferWriter.newLine();
  6009. bufferWriter.flush();
  6010. ret = true;
  6011. }
  6012. } catch (RuntimeException re) {
  6013. LogUtil.errorLogInfo("", TAG, re);
  6014. }
  6015. catch (Exception e) {
  6016. LogUtil.errorLogInfo("", TAG, e);
  6017. } finally {
  6018. try {
  6019. if (bufferWriter != null) {
  6020. bufferWriter.close();
  6021. }
  6022. } catch (RuntimeException re) {
  6023. LogUtil.errorLogInfo("", TAG, re);
  6024. }
  6025. catch (Exception e) {
  6026. LogUtil.errorLogInfo("", TAG, e);
  6027. }
  6028. }
  6029. Log.d(TAG, "writeMacAddress() path : " + MAC_ADDRESS_FILE_PATH
  6030. + ", MacAddr : " + MacAddr
  6031. + ", ret : " + ret
  6032. );
  6033. return ret;
  6034. }
  6035. private void GetElectricCarInfo() {
  6036. try {
  6037. Log.d(TAG, "[GetElectricCarInfo] ===== START =====");
  6038. int retInt = -1;
  6039. WallpadDeviceSet mWallpadDeviceSet = null;
  6040. mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  6041. retInt = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  6042. mWallpadDeviceSet.closeDB();
  6043. Log.d(TAG, "[GetElectricCarInfo] retInt = " + retInt);
  6044. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  6045. Log.i(TAG, "[GetElectricCarInfo] Electronic car changing enabled!!");
  6046. GetElectricCarInfo_RandomCheckHandler();
  6047. }
  6048. else Log.i(TAG, "[GetElectricCarInfo] Electronic car changing disabled!!");
  6049. } catch (RuntimeException re) {
  6050. LogUtil.errorLogInfo("", TAG, re);
  6051. }
  6052. catch (Exception e) {
  6053. Log.e(TAG, "[Exception] GetElectricCarInfo()");
  6054. LogUtil.errorLogInfo("", TAG, e);
  6055. }
  6056. }
  6057. private void GetElectricCarInfo_RandomCheckHandler() {
  6058. try {
  6059. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] ===== START =====");
  6060. int nDelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  6061. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] nDelayTime : "+ nDelayTime);
  6062. if (nDelayTime < 1) {
  6063. Log.w(TAG, "[GetElectricCarInfo_RandomCheckHandler] DelayTime error!! -> nDelayTime = " + nDelayTime);
  6064. return;
  6065. }
  6066. mGetElecricCarRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * nDelayTime);
  6067. } catch (RuntimeException re) {
  6068. LogUtil.errorLogInfo("", TAG, re);
  6069. }
  6070. catch (Exception e) {
  6071. Log.e(TAG, "[Exception] GetElectricCarInfo_RandomCheckHandler()");
  6072. LogUtil.errorLogInfo("", TAG, e);
  6073. }
  6074. }
  6075. private Handler mGetElecricCarRandomCheckHandler = new Handler()
  6076. {
  6077. @Override
  6078. public void handleMessage(Message msg)
  6079. {
  6080. if (msg.what == 0) {
  6081. Log.i(TAG, "[GetElectricCarInfo] mGetElecricCarRandomCheckHandler() will be called!!");
  6082. //얻어오기
  6083. imapElecCarChargingInfo = new iMAPElecCarChargingInfo(getApplicationContext());
  6084. LoadElectricCarDataFromServer();
  6085. }
  6086. }
  6087. };
  6088. void LoadElectricCarDataFromServer() {
  6089. DebugLogOutput("LoadElectricCarDataFromServer");
  6090. imapElecCarChargingInfo.DoWork();
  6091. imapElecCarChargingInfo.SetRetCtr(new RetProci() {
  6092. @Override
  6093. public void ProcSuccess() {
  6094. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcSuccess");
  6095. try {
  6096. int SetItemResult = imapElecCarChargingInfo.SetItem("charging_cnt");
  6097. if(SetItemResult != 1) {
  6098. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  6099. nElecVehicleChangingCnt = 0;
  6100. return;
  6101. }
  6102. String sChargingCount = imapElecCarChargingInfo.GetItemVal(0);
  6103. int intChargingCount = Integer.parseInt(sChargingCount);
  6104. if (intChargingCount < 1) {
  6105. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - intChargingCount : "+ intChargingCount);
  6106. nElecVehicleChangingCnt = 0;
  6107. return;
  6108. }
  6109. SetItemResult = imapElecCarChargingInfo.SetItem("charger_info");
  6110. if (SetItemResult != intChargingCount) {
  6111. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  6112. nElecVehicleChangingCnt = 0;
  6113. return;
  6114. }
  6115. if (intChargingCount > 0) {
  6116. nElecVehicleChangingCnt = intChargingCount;
  6117. Intent intent = new Intent();
  6118. intent.setAction(define.NOTIFY_ACNAME);
  6119. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  6120. intent.putExtra("sCard_Num", imapElecCarChargingInfo.GetAttributeVal(0, "card_num"));
  6121. intent.putExtra("sCar_Num", imapElecCarChargingInfo.GetAttributeVal(0, "car_num"));
  6122. intent.putExtra("sCharger_Num", imapElecCarChargingInfo.GetAttributeVal(0, "charger_num"));
  6123. intent.putExtra("sCharger_Loc", imapElecCarChargingInfo.GetAttributeVal(0, "charger_loc"));
  6124. intent.putExtra("sCharging_Status", "charging");
  6125. intent.putExtra("sCharger_sort", imapElecCarChargingInfo.GetAttributeVal(0, "charger_sort"));
  6126. intent.putExtra("sCharging_Ratio", imapElecCarChargingInfo.GetAttributeVal(0, "charging_ratio"));
  6127. intent.putExtra("sStart_Time", imapElecCarChargingInfo.GetAttributeVal(0, "start_time"));
  6128. intent.putExtra("sRemain_Time", imapElecCarChargingInfo.GetAttributeVal(0, "remain_time"));
  6129. intent.putExtra("sMessage", imapElecCarChargingInfo.GetAttributeVal(0, "c_msg"));
  6130. getApplicationContext().sendBroadcast(intent);
  6131. }
  6132. } catch (RuntimeException re) {
  6133. LogUtil.errorLogInfo("", TAG, re);
  6134. }
  6135. catch (Exception e) {
  6136. Log.e(TAG, "[Exception] LoadElectricCarDataFromServer() -> ProcSuccess");
  6137. LogUtil.errorLogInfo("", TAG, e);
  6138. }
  6139. }
  6140. @Override
  6141. public void ProcError()
  6142. {
  6143. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcError");
  6144. }
  6145. @Override
  6146. public void ProcDoing()
  6147. {
  6148. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcDoing");
  6149. }
  6150. });
  6151. }
  6152. /**
  6153. * 대외향 Call 버튼 점멸 및 On Off 처리
  6154. */
  6155. @SuppressLint("HandlerLeak")
  6156. protected Handler mLedFlickerHandler = new Handler()
  6157. {
  6158. boolean Flicker = false;
  6159. @SuppressLint("HandlerLeak")
  6160. @Override
  6161. public void handleMessage(Message msg)
  6162. {
  6163. if(msg.what == 0) // 콜 수신시 또는 발신시 ...
  6164. {
  6165. // 점멸 시작 CallButton LED On
  6166. Flicker = true;
  6167. mLedFlickerHandler.sendEmptyMessageDelayed(1, 500);
  6168. WallPadInterface wpdifc = new WallPadInterface();
  6169. wpdifc.callLEDControll(true);
  6170. }
  6171. else if(msg.what == 1)
  6172. {
  6173. mLedFlickerHandler.sendEmptyMessageDelayed(0, 500);
  6174. WallPadInterface wpdifc = new WallPadInterface();
  6175. wpdifc.callLEDControll(false);
  6176. }
  6177. else if(msg.what == 2) // 통화중
  6178. {
  6179. Flicker = false;
  6180. }
  6181. else if(msg.what == 4) // 통화종료
  6182. {
  6183. Flicker = false;
  6184. }
  6185. }
  6186. };
  6187. public void GetEnergyServerInfo()
  6188. {
  6189. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  6190. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  6191. devSet.closeDB();
  6192. if (MetringDB != null)
  6193. {
  6194. try
  6195. {
  6196. String devInfo = MetringDB[1];
  6197. devInfo = devInfo.replace('(', '_');
  6198. devInfo = devInfo.replace(':', '_');
  6199. devInfo = devInfo.replace(')', '_');
  6200. String[] MetringInfo = devInfo.split("_");
  6201. // MetringInfo[1] -> 회로수
  6202. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  6203. // MetringInfo[4] -> IP
  6204. // MetringInfo[5] -> IP정보
  6205. // MetringInfo[6] -> 검침일사용자설정
  6206. // MetringInfo[7] -> 사용함 또는 사용안함
  6207. if(MetringInfo[3].equals("사용함") == true)
  6208. {
  6209. bUseofNot_EnergyServer = true;
  6210. }
  6211. }
  6212. catch (RuntimeException re) {
  6213. LogUtil.errorLogInfo("", TAG, re);
  6214. }
  6215. catch (Exception e)
  6216. {
  6217. LogUtil.errorLogInfo("", TAG, e);
  6218. }
  6219. }
  6220. else
  6221. {
  6222. }
  6223. Log.d(TAG, "[bUseofNot_EnergyServer] bUseofNot_EnergyServer :"+bUseofNot_EnergyServer);
  6224. }
  6225. /**
  6226. * 카카오 사용 여부 체크
  6227. * @return
  6228. */
  6229. public boolean getKakaoHomeCheck()
  6230. {
  6231. boolean result = false;
  6232. WallpadDeviceSet mWallpadDeviceSet = null;
  6233. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6234. try {
  6235. result = mWallpadDeviceSet.Get_KakaoUse();
  6236. }
  6237. catch (SQLException e)
  6238. {
  6239. LogUtil.errorLogInfo("", TAG, e);
  6240. }
  6241. mWallpadDeviceSet.closeDB();
  6242. return result;
  6243. }
  6244. /**
  6245. * 사용자 설정(카카오를 볼것인지 아닌지를 설정)
  6246. * @return
  6247. */
  6248. public boolean getShowKakaoCheck()
  6249. {
  6250. boolean result = false;
  6251. WallpadDeviceSet mWallpadDeviceSet = null;
  6252. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6253. try {
  6254. result = mWallpadDeviceSet.Get_KakaoShow();
  6255. }
  6256. catch (SQLException e)
  6257. {
  6258. LogUtil.errorLogInfo("", TAG, e);
  6259. }
  6260. return result;
  6261. }
  6262. public boolean GetEnergyAlarm()
  6263. {
  6264. boolean ret = false;
  6265. WallpadStatusData DBMGR = null;
  6266. DBMGR = new WallpadStatusData(getContext());
  6267. if( DBMGR != null )
  6268. {
  6269. try
  6270. {
  6271. ret = DBMGR.GetRemoteMetering_Alarm();
  6272. }
  6273. catch (RuntimeException re) {
  6274. LogUtil.errorLogInfo("", TAG, re);
  6275. ret = false;
  6276. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6277. }
  6278. catch (Exception e)
  6279. {
  6280. LogUtil.errorLogInfo("", TAG, e);
  6281. ret = false;
  6282. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6283. }
  6284. DBMGR.closeDB();
  6285. }
  6286. bUseofNot_EnergyAlarm = ret;
  6287. Log.d(TAG, "[bUseofNot_EnergyAlarm] bUseofNot_EnergyAlarm :"+bUseofNot_EnergyAlarm);
  6288. return ret;
  6289. }
  6290. /**
  6291. * @description
  6292. * 에너지 사용량 알림 시간 얻어오기
  6293. * @return int Hour시간 값
  6294. */
  6295. public int GetEnergyAlarmTime()
  6296. {
  6297. int ret = 12;
  6298. WallpadStatusData DBMGR = null;
  6299. DBMGR = new WallpadStatusData(getContext());
  6300. try
  6301. {
  6302. ret = DBMGR.GetRemoteMetering_AlarmTime();
  6303. }
  6304. catch (RuntimeException re) {
  6305. LogUtil.errorLogInfo("", TAG, re);
  6306. }
  6307. catch (Exception e)
  6308. {
  6309. LogUtil.errorLogInfo("", TAG, e);
  6310. }
  6311. DBMGR.closeDB();
  6312. Log.d(TAG, "[GetEnergyAlarmTime] GetEnergyAlarmTime :"+ret);
  6313. return ret;
  6314. }
  6315. public void ClearEnergyUsage()
  6316. {
  6317. ResultGetIntent = false;
  6318. elect_target = "Error";
  6319. elect_used = "Error";
  6320. elect_info = "Error";
  6321. water_target = "Error";
  6322. water_used = "Error";
  6323. water_info = "Error";
  6324. gas_target = "Error";
  6325. gas_used = "Error";
  6326. gas_info = "Error";
  6327. hotwater_target = "Error";
  6328. hotwater_used = "Error";
  6329. hotwater_info = "Error";
  6330. heating_target = "Error";
  6331. heating_used = "Error";
  6332. heating_info = "Error";
  6333. }
  6334. // 신규 통화어플 실행을 위한 코드 (JEFF, 2016.05.23)
  6335. // 통화주체를 다루는 enum
  6336. public enum CALLOWNER {
  6337. NONE,
  6338. WALLPAD,
  6339. MOBILE,
  6340. SUB_WALLPAD,
  6341. KITCHEN_TV,
  6342. BATH_PHONE,
  6343. BATH_TV,
  6344. UNIVERSAL_DEVICE,
  6345. ERROR;
  6346. }
  6347. public enum CALLEVENTTYPE {
  6348. RECEIVE_CALL, // 호출 수신 (호출 수신)
  6349. TRYING_CALL, // 호출 시도중 (호출 발신)
  6350. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  6351. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  6352. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  6353. CONNECT_CALL, // 통화 시작
  6354. TERMINATE_CALL, // 통화 종료
  6355. CANCEL_CALL, // 호출 취소
  6356. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  6357. REJECT_CALL, // 호출수신 거절
  6358. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  6359. FORWARD_CALL, // 착신전환 설정
  6360. CALLERID, // Caller ID_OLD
  6361. TIMEOUT_1STCALL, // 1st Call Timeout
  6362. TIMEOUT_2NDCALL, // 2nd Call Timeout
  6363. TIMEOUT_3RDCALL, // 3rd Call Timeout
  6364. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  6365. DOOR_OPEN, // 문열림 설정
  6366. DETECT_STRANGER, // 거동수상자 발생
  6367. NONE;
  6368. }
  6369. public enum CALLTYPE {
  6370. NONE,
  6371. FRONT,
  6372. RESIDENCE,
  6373. LOBBY,
  6374. GUARD,
  6375. PSTN,
  6376. IHUB,
  6377. HISTORY_CALL,
  6378. HISTORY_VISITORPIC,
  6379. FRONT_RECORD, // 현관_영상녹화
  6380. FRONT_TAKEPIC, // 현관_사진촬영
  6381. ERROR,
  6382. }
  6383. public static class CALLTRIGGER {
  6384. public static String CALLOWNER = "CALLOWNER";
  6385. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  6386. public static String CALLTYPE = "CALLTYPE";
  6387. public enum SOURCE {
  6388. USER,
  6389. CALL_RECEIVE,
  6390. SUBPHONE
  6391. }
  6392. public enum TYPE {
  6393. MENU,
  6394. FRONT,
  6395. LOBBY,
  6396. GUARD,
  6397. RESIDENCE,
  6398. PSTN
  6399. }
  6400. }
  6401. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  6402. public void runWallPadCallAPKByUX(int nScreen) {
  6403. try {
  6404. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "]");
  6405. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6406. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6407. CALLTYPE eCallType = CALLTYPE.GUARD;
  6408. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6409. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6410. else eCallOwner = CALLOWNER.WALLPAD;
  6411. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6412. eCallType = CALLTYPE.FRONT;
  6413. }
  6414. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6415. eCallType = CALLTYPE.FRONT;
  6416. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6417. }
  6418. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6419. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6420. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6421. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6422. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6423. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6424. else {
  6425. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6426. }
  6427. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6428. if (getIsSubWallpad()) {
  6429. // 서브월패드는 국선 기능을 제공하지 않는다.
  6430. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType);
  6431. }
  6432. else {
  6433. runCallMainActivity(eCallOwner, eEventType, eCallType);
  6434. }
  6435. } catch (RuntimeException re) {
  6436. LogUtil.errorLogInfo("", TAG, re);
  6437. }
  6438. catch (Exception e) {
  6439. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen)");
  6440. LogUtil.errorLogInfo("", TAG, e);
  6441. }
  6442. }
  6443. public void runWallPadCallAPKByUX(int nScreen, int nEmerState) {
  6444. try {
  6445. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "], nEmerState [" + nEmerState + "]");
  6446. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6447. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6448. CALLTYPE eCallType = CALLTYPE.GUARD;
  6449. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6450. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6451. else eCallOwner = CALLOWNER.WALLPAD;
  6452. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6453. eCallType = CALLTYPE.FRONT;
  6454. }
  6455. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6456. eCallType = CALLTYPE.FRONT;
  6457. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6458. }
  6459. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6460. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6461. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6462. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6463. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6464. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6465. else {
  6466. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6467. }
  6468. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6469. if (getIsSubWallpad()) {
  6470. // 서브월패드는 국선 기능을 제공하지 않는다.
  6471. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6472. }
  6473. else {
  6474. runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6475. }
  6476. } catch (RuntimeException re) {
  6477. LogUtil.errorLogInfo("", TAG, re);
  6478. }
  6479. catch (Exception e) {
  6480. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen, int nEmerState)");
  6481. LogUtil.errorLogInfo("", TAG, e);
  6482. }
  6483. }
  6484. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  6485. try {
  6486. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6487. if (!Common.bWallPadCallLive) {
  6488. // 통화어플을 실행시킨다.
  6489. sendLCDBacklightStatus(true);
  6490. if (bRecordStatus) {
  6491. if (eEventType == CALLEVENTTYPE.REQUEST_FRONT_MONITORING) {
  6492. Log.d(TAG, "[runCallMainActivity] Now Stranger Recording!!! bRecordStatus [" + bRecordStatus + "]");
  6493. // 거동수상자 녹화 중 현관 모니터링 실행하는 경우
  6494. stopStrangerRecord(true);
  6495. runNoticeStrangerRecord(false);
  6496. }
  6497. }
  6498. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6499. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6500. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6501. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6502. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6503. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6504. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6505. mIntent.setComponent(mComponentName);
  6506. startActivity(mIntent);
  6507. }
  6508. else {
  6509. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6510. }
  6511. } catch (RuntimeException re) {
  6512. LogUtil.errorLogInfo("", TAG, re);
  6513. }
  6514. catch (Exception e) {
  6515. Log.e(TAG, "[Exception] runCallMainActivity()");
  6516. LogUtil.errorLogInfo("", TAG, e);
  6517. }
  6518. }
  6519. /**
  6520. * Edited by jeff (2020.06.22)
  6521. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  6522. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  6523. * @param bOn
  6524. */
  6525. private void sendLCDBacklightStatus(boolean bOn) {
  6526. try {
  6527. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  6528. Intent mIntent = new Intent();
  6529. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6530. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6531. getApplicationContext().sendBroadcast(mIntent);
  6532. } catch (RuntimeException re) {
  6533. LogUtil.errorLogInfo("", TAG, re);
  6534. }
  6535. catch (Exception e) {
  6536. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  6537. LogUtil.errorLogInfo("", TAG, e);
  6538. }
  6539. }
  6540. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState) {
  6541. try {
  6542. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nEmerState [" + nEmerState + "]");
  6543. if (!Common.bWallPadCallLive) {
  6544. // 통화어플을 실행시킨다.
  6545. sendLCDBacklightStatus(true);
  6546. if (eEventType == CALLEVENTTYPE.DETECT_STRANGER) {
  6547. if (nEmerState >= 0) {
  6548. if (nEmerState != WallpadStatusData.GUARD_OUT)
  6549. Common.SendAppFinishReqBR(getApplicationContext());
  6550. }
  6551. }
  6552. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6553. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6554. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6555. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6556. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6557. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6558. mIntent.putExtra("EMERGENCY_STATE", nEmerState);
  6559. if (nEmerState != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  6560. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6561. mIntent.setComponent(mComponentName);
  6562. startActivity(mIntent);
  6563. }
  6564. else {
  6565. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6566. }
  6567. } catch (RuntimeException re) {
  6568. LogUtil.errorLogInfo("", TAG, re);
  6569. }
  6570. catch (Exception e) {
  6571. Log.e(TAG, "[Exception] runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState)");
  6572. LogUtil.errorLogInfo("", TAG, e);
  6573. }
  6574. }
  6575. private String getTopActivity() {
  6576. try {
  6577. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  6578. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  6579. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  6580. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  6581. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  6582. return mComponentName.getPackageName();
  6583. } catch (RuntimeException re) {
  6584. LogUtil.errorLogInfo("", TAG, re);
  6585. return null;
  6586. }
  6587. catch (Exception e) {
  6588. Log.e(TAG, "[Exception] getTopActivity()");
  6589. LogUtil.errorLogInfo("", TAG, e);
  6590. return null;
  6591. }
  6592. }
  6593. /**
  6594. * 월패드에 설치된 APP들의 패키지 명 및 버전을 저장하는 클래스
  6595. * **/
  6596. class PackageVersionInfo {
  6597. protected String strPackageName;
  6598. protected String strPackageVersion;
  6599. public PackageVersionInfo(String strName, String strVersion) {
  6600. strPackageName = strName;
  6601. strPackageVersion = strVersion;
  6602. }
  6603. public String getPackageName() {
  6604. return strPackageName;
  6605. }
  6606. public String getPackageVersion() {
  6607. return strPackageVersion;
  6608. }
  6609. }
  6610. /**
  6611. * 통화 타임아웃 DB정보 초기화 (무조건 사용함으로 변경)
  6612. * **/
  6613. public void setCallAppTimeoutAsDefault() {
  6614. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6615. try {
  6616. mWallpadDeviceSet.Set_CallAppCallTimeout(true);
  6617. mWallpadDeviceSet.closeDB();
  6618. } catch (RuntimeException re) {
  6619. LogUtil.errorLogInfo("", TAG, re);
  6620. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6621. }
  6622. catch (Exception e) {
  6623. Log.e(TAG, "[Exception] setCallAppTimeoutAsDefault()");
  6624. LogUtil.errorLogInfo("", TAG, e);
  6625. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6626. }
  6627. }
  6628. /**
  6629. * 동호 설정 화면 나오게 처리
  6630. * **/
  6631. private void startManagerSettingSetAddress() {
  6632. try {
  6633. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6634. MAINStatus = MAIN_WAIT_SETIP;
  6635. mIntent.setComponent(new ComponentName("com.artncore.managersetting", "com.artncore.managersetting.ui.activities.SetAddress"));
  6636. mIntent.putExtra("KIND", "SOLO");
  6637. startActivity(mIntent);
  6638. } catch (RuntimeException re) {
  6639. LogUtil.errorLogInfo("", TAG, re);
  6640. }
  6641. catch (Exception e) {
  6642. Log.e(TAG, "[Exception] startManagerSettingSetAddress()");
  6643. LogUtil.errorLogInfo("", TAG, e);
  6644. }
  6645. }
  6646. private Handler mGetCallHistoryCheckHandler = new Handler() {
  6647. @Override
  6648. public void handleMessage(Message msg) {
  6649. if (msg.what == 0) {
  6650. // CheckCallData_CalledCountAndVisitorCount();
  6651. checkEventNotifications();
  6652. }
  6653. }
  6654. };
  6655. /**
  6656. * 음력 데이터를 raw resource에서 wallpaddata폴더 밑으로 복사한다.
  6657. * **/
  6658. private void copyDataBase(String OutputDBPath) throws IOException {
  6659. // Open your local db as the input stream
  6660. //InputStream myInput = this.getAssets().open("luna_db.db");
  6661. InputStream myInput = getResources().openRawResource(R.raw.luna_db);
  6662. // Path to the just created empty db
  6663. String outFileName = OutputDBPath;
  6664. // Open the empty db as the output stream
  6665. OutputStream myOutput = new FileOutputStream(outFileName);
  6666. try {
  6667. // transfer bytes from the inputfile to the outputfile
  6668. byte[] buffer = new byte[1024];
  6669. int length;
  6670. while ((length = myInput.read(buffer)) > 0)
  6671. {
  6672. myOutput.write(buffer, 0, length);
  6673. }
  6674. // Close the streams
  6675. myOutput.flush();
  6676. }
  6677. catch (RuntimeException re) {
  6678. LogUtil.errorLogInfo("", TAG, re);
  6679. }
  6680. catch (Exception e)
  6681. {
  6682. LogUtil.errorLogInfo("", TAG, e);
  6683. }
  6684. finally {
  6685. if(myOutput!=null)
  6686. myOutput.close();
  6687. myOutput = null;
  6688. if(myInput!=null)
  6689. myInput.close();
  6690. myInput = null;
  6691. }
  6692. }
  6693. @SuppressLint("HandlerLeak")
  6694. protected Handler mLCD_SleepHandler = new Handler()
  6695. {
  6696. @SuppressLint("HandlerLeak")
  6697. @Override
  6698. public void handleMessage(Message msg)
  6699. {
  6700. if (msg.what == 0) {
  6701. try {
  6702. if (m_ModelHouseSleepModeRelease == true) {
  6703. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  6704. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6705. }
  6706. else {
  6707. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6708. }
  6709. Log.i(TAG, "[SAMPLE SLEEP MODE] Never Sleep Run ~~~");
  6710. }
  6711. } catch (RuntimeException re) {
  6712. LogUtil.errorLogInfo("", TAG, re);
  6713. }
  6714. catch (Exception e) {
  6715. LogUtil.errorLogInfo("", TAG, e);
  6716. }
  6717. }
  6718. }
  6719. };
  6720. public void runIcon(int nIconID) {
  6721. try {
  6722. Log.d(TAG, "[runIcon] nIconID [" + nIconID + "]");
  6723. if (nIconID == ID.ICONS.MENUS.MAIN_ELEVATOR.getID()) {
  6724. // DB를 체크해서 층표시이면 팝업을 띄우고 아니면 바로 호출하도록 한다
  6725. String strElevShortEnabled = Common.getSubDevListItem(this.getContext() ,Common.SETTING_ITEM_SUB_DEVICE_ELEVATOR);
  6726. if(strElevShortEnabled!=null)
  6727. {
  6728. Log.d(TAG, "[runIcon] strElevShortEnabled [" + strElevShortEnabled + "]");
  6729. if (strElevShortEnabled.contains("사용함") && strElevShortEnabled.contains("기본")) {
  6730. Sound().Play(SND.effect.TOUCH_LATCHED);
  6731. Intent intent = new Intent(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  6732. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN);
  6733. getContext().sendBroadcast(intent);
  6734. }
  6735. else {
  6736. ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.ElevatorPopupScreen);
  6737. }
  6738. }
  6739. }
  6740. else if (nIconID == ID.ICONS.MENUS.MAIN_LIGHTS_OUT.getID()) {
  6741. ((MainActivity)(getContext())).StartPopup(ID.POPUPS.POPUP_COLLECTIVELIGHTCTRL);
  6742. }
  6743. else if (nIconID == ID.ICONS.MENUS.MAIN_CALRENDAR.getID()) {
  6744. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6745. }
  6746. else if (nIconID == ID.ICONS.MENUS.MAIN_WEATHER.getID()) {
  6747. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6748. }
  6749. else if (nIconID == ID.ICONS.MENUS.TALK_FRONT.getID()) {
  6750. // Common.command_iGW200( this.getContext(), Common.IGW200_DOOR_MONITERING );
  6751. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door);
  6752. }
  6753. else if (nIconID == ID.ICONS.MENUS.TALK_LOBBY.getID()) {
  6754. // 로비는 수신시에만 출력되는 화면이므로 해당코드 없음
  6755. }
  6756. else if (nIconID == ID.ICONS.MENUS.TALK_NEIGHBOR.getID()) {
  6757. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Neighboor);
  6758. }
  6759. else if (nIconID == ID.ICONS.MENUS.TALK_GUARD.getID()) {
  6760. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Guard);
  6761. }
  6762. else if (nIconID == ID.ICONS.MENUS.TALK_PHONE.getID()) {
  6763. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Pstn);
  6764. }
  6765. else if (nIconID == ID.ICONS.MENUS.TALK_CALLHISTORY.getID()) {
  6766. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.CallList);
  6767. }
  6768. else if (nIconID == ID.ICONS.MENUS.TALK_VISITORPIC.getID()) {
  6769. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Visitor);
  6770. }
  6771. else if (nIconID == ID.ICONS.MENUS.CTRL_LIGHT.getID()) {
  6772. // 모델별 설정에 따라 구분하여 호출하는 기능 추가해야함
  6773. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6774. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6775. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6776. // for (int i = 0; i < naLightEnable.length; i++) Log.i(TAG, "[runIcon] naLightEnable[" + i + "] = " + naLightEnable[i]);
  6777. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6778. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Lamp);
  6779. }
  6780. else {
  6781. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_EachLamp);
  6782. }
  6783. }
  6784. else if (nIconID == ID.ICONS.MENUS.CTRL_HEATING.getID()) {
  6785. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Heating_V1);
  6786. }
  6787. else if (nIconID == ID.ICONS.MENUS.CTRL_GAS.getID()) {
  6788. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Gas);
  6789. }
  6790. else if (nIconID == ID.ICONS.MENUS.CTRL_DOORLOCK.getID()) {
  6791. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.DoorLockWL);
  6792. }
  6793. else if (nIconID == ID.ICONS.MENUS.CTRL_VENT.getID()) {
  6794. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ChangAir_Normal);
  6795. }
  6796. else if (nIconID == ID.ICONS.MENUS.CTRL_OUTLET.getID()) {
  6797. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6798. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6799. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6800. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6801. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Concent);
  6802. }
  6803. else {
  6804. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Concent);
  6805. }
  6806. }
  6807. else if (nIconID == ID.ICONS.MENUS.CTRL_LIVINGLIGHT.getID()) {
  6808. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_LivingLamp);
  6809. }
  6810. else if (nIconID == ID.ICONS.MENUS.CTRL_AIRQUALTY.getID()) {
  6811. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.AirQualty);
  6812. }
  6813. else if (nIconID == ID.ICONS.MENUS.CTRL_ELECCOOKTOP.getID()) {
  6814. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ElecCooktop);
  6815. }
  6816. else if (nIconID == ID.ICONS.MENUS.CTRL_PARKINGDOOR.getID()) {
  6817. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ParkingDoor);
  6818. }
  6819. else if (nIconID == ID.ICONS.MENUS.CTRL_COOKTOPOUTLET.getID()) {
  6820. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.CooktopOutlet);
  6821. }
  6822. else if (nIconID == ID.ICONS.MENUS.CTRL_SYSTEMAIRCON.getID()) {
  6823. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.SystemAircon);
  6824. }
  6825. else if (nIconID == ID.ICONS.MENUS.ADD_NOTICE.getID()) {
  6826. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Notice);
  6827. }
  6828. else if (nIconID == ID.ICONS.MENUS.ADD_WEATHER.getID()) {
  6829. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6830. }
  6831. else if (nIconID == ID.ICONS.MENUS.ADD_MEMO.getID()) {
  6832. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Memo);
  6833. }
  6834. else if (nIconID == ID.ICONS.MENUS.ADD_E_FRAME.getID()) {
  6835. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.AutoPicture);
  6836. }
  6837. else if (nIconID == ID.ICONS.MENUS.ADD_SCHEDULE.getID()) {
  6838. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Schedule);
  6839. }
  6840. else if (nIconID == ID.ICONS.MENUS.ADD_CCTV.getID()) {
  6841. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Cctv);
  6842. }
  6843. else if (nIconID == ID.ICONS.MENUS.ADD_PARKING.getID()) {
  6844. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Parking);
  6845. }
  6846. else if (nIconID == ID.ICONS.MENUS.ADD_PARKINGLIST.getID()) {
  6847. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ParkingList);
  6848. }
  6849. else if (nIconID == ID.ICONS.MENUS.ADD_ELECTRICCAR.getID()) {
  6850. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ElecCar);
  6851. }
  6852. else if (nIconID == ID.ICONS.MENUS.ADD_INTERLAYERNOISE.getID()) {
  6853. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.InterlayerNoiseHistory);
  6854. }
  6855. else if (nIconID == ID.ICONS.MENUS.ADD_VISITEDVEHICLEREGI.getID()) {
  6856. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.VisitedVehicleRegi);
  6857. }
  6858. else if (nIconID == ID.ICONS.MENUS.ADD_BANDLOCATION.getID()) {
  6859. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.BandLocation);
  6860. }
  6861. else if (nIconID == ID.ICONS.MENUS.ADD_GUARDINGSTREETLAMP.getID()) {
  6862. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.GuardingStreetLamp);
  6863. }
  6864. else if (nIconID == ID.ICONS.MENUS.SECURITY_SETARMED.getID()) {
  6865. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.SecurityMain);
  6866. }
  6867. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINK.getID()) {
  6868. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.LinkDeviceSet);
  6869. }
  6870. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINKSLEEP.getID()) {
  6871. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.lnkBedDeviceSet);
  6872. }
  6873. else if (nIconID == ID.ICONS.MENUS.SECURITY_ACCESSHISTORY.getID()) {
  6874. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.AccessHistoryDoor);
  6875. }
  6876. else if (nIconID == ID.ICONS.MENUS.SECURITY_VISITORVIDEO.getID()) {
  6877. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.VisitorVideo);
  6878. }
  6879. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTPANEL.getID()) {
  6880. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartPanel);
  6881. }
  6882. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTLIGHT.getID()) {
  6883. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartLight);
  6884. }
  6885. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTOUTLET.getID()) {
  6886. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartOutlet);
  6887. }
  6888. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYMETER.getID()) {
  6889. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.IEnergy);
  6890. }
  6891. else if (nIconID == ID.ICONS.MENUS.ENERGY_REMOTEMETER.getID()) {
  6892. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.RemoteMeter);
  6893. }
  6894. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCONSUMPTION.getID()) {
  6895. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.EnergyMgr);
  6896. }
  6897. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCOSTTABLE.getID()) {
  6898. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.CostTable);
  6899. }
  6900. else if (nIconID == ID.ICONS.MENUS.SETTING_CONFIG.getID()) {
  6901. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.Configuration);
  6902. }
  6903. else if (nIconID == ID.ICONS.MENUS.SETTING_CLREANSCREEN.getID()) {
  6904. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.CleanLcd);
  6905. }
  6906. else if (nIconID == ID.ICONS.MENUS.SETTING_PWCHANGE.getID()) {
  6907. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.PassWordChange);
  6908. }
  6909. else if (nIconID == ID.ICONS.MENUS.SETTING_MORNINGCALL.getID()) {
  6910. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MoningCall);
  6911. }
  6912. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTKEY.getID()) {
  6913. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartKey);
  6914. }
  6915. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTBAND.getID()) {
  6916. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartBand);
  6917. }
  6918. else if (nIconID == ID.ICONS.MENUS.SETTING_ACCESSCARD.getID()) {
  6919. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RfCard);
  6920. }
  6921. else if (nIconID == ID.ICONS.MENUS.SETTING_CALENDAR.getID()) {
  6922. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6923. }
  6924. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECALLUSER.getID()) {
  6925. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RemoteCallUser);
  6926. }
  6927. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECTRL.getID()) {
  6928. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MobileDeviceReg);
  6929. }
  6930. else if (nIconID == ID.ICONS.MENUS.SETTING_OCCUPANCYSENSOR.getID()) {
  6931. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.OccupancySensorConfig);
  6932. }
  6933. else if (nIconID == ID.ICONS.MENUS.SETTING_HSPLATFORM.getID()) {
  6934. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.HSPlatform);
  6935. }
  6936. else if (nIconID == ID.ICONS.MENUS.OCF_WIFI.getID()) {
  6937. m_CallSubMenuScreen.callStartOcfAPK(ID.LINKEDSCREEN.SubMenuOcf.WIFI);
  6938. }
  6939. else if (nIconID == ID.ICONS.MENUS.OCF_BRIDGE.getID()) {
  6940. m_CallSubMenuScreen.callStartOcfBridgeAPK();
  6941. }
  6942. else if (nIconID == ID.ICONS.MENUS.KAKAOI_SETTING.getID()) {
  6943. mContext.sendBroadcast(new Intent("com.kakao.i.hdc.service.setting"));
  6944. }
  6945. else {
  6946. Log.w(TAG, "[runShortcut] nIconID is not supported!! [" + nIconID + "]");
  6947. }
  6948. } catch (RuntimeException re) {
  6949. LogUtil.errorLogInfo("", TAG, re);
  6950. }
  6951. catch (Exception e) {
  6952. Log.e(TAG, "[Exception] runShortcut(int nIconID)");
  6953. LogUtil.errorLogInfo("", TAG, e);
  6954. }
  6955. }
  6956. public void runSecurityAPK(int nScreenID) {
  6957. try {
  6958. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  6959. int nSecurityMode = wdb.GetAlarmStatus();
  6960. wdb.closeDB();
  6961. Log.w(TAG, "[runSecurityAPK] nSecurityMode [" + nSecurityMode + "]");
  6962. if (nSecurityMode == WallpadStatusData.GUARD_IN) {
  6963. // 팝업 띄워서 재택모드 해제 유도
  6964. StartPopup(ID.POPUPS.POPUP_RELEASEINMODE);
  6965. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.SecurityReleasePopupScreen);
  6966. }
  6967. else if (nSecurityMode == WallpadStatusData.OUT_MODE) {
  6968. // 팝업 띄워서 외출모드 해제 유도
  6969. StartPopup(ID.POPUPS.POPUP_RELEASEOUTMODE);
  6970. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.OutModeReleasePopupScreen);
  6971. }
  6972. else if (nSecurityMode == WallpadStatusData.ALARM_STOP) {
  6973. // 알람 화면을 띄우도록 한다.
  6974. runEmergencyAPK(this, getAlarmType(), 2 , "모름");
  6975. }
  6976. else {
  6977. m_CallSubMenuScreen.callStartSecurityAPK(nScreenID);
  6978. }
  6979. } catch (RuntimeException re) {
  6980. LogUtil.errorLogInfo("", TAG, re);
  6981. }
  6982. catch (Exception e) {
  6983. Log.e(TAG, "[Exception] runSecurityAPK(int nScreenID)");
  6984. LogUtil.errorLogInfo("", TAG, e);
  6985. }
  6986. }
  6987. public void runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo) {
  6988. try {
  6989. // DB 체크 해서 띄우 도록 한다.
  6990. int [] m_EmerMenuList = new int[4];
  6991. m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6992. m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6993. m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6994. m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6995. Intent intent = new Intent(Intent.ACTION_MAIN);
  6996. intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList); // KEY : MENU_ID_LIST
  6997. intent.putExtra(Common.MENU_START_ID, nScreenID); // KEY : MENU_START_ID
  6998. intent.putExtra(Common.MENU_START_OPTION, startOption); // KEY : MENU_START_OPTION
  6999. intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo);
  7000. intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY ));
  7001. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  7002. context.startActivity(intent);
  7003. } catch (RuntimeException re) {
  7004. LogUtil.errorLogInfo("", TAG, re);
  7005. }
  7006. catch (Exception e) {
  7007. Log.e(TAG, "[Exception] runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo)");
  7008. LogUtil.errorLogInfo("", TAG, e);
  7009. }
  7010. }
  7011. public int getAlarmType() {
  7012. WallpadStatusData SetData = new WallpadStatusData(this.getContext());
  7013. int alarmtype = SetData.GetAlarmType();
  7014. SetData.closeDB();
  7015. int Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  7016. switch (alarmtype) {
  7017. case WallpadStatusData.ALARM_ALERT:
  7018. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  7019. break;
  7020. case WallpadStatusData.ALARM_EMM:
  7021. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  7022. break;
  7023. case WallpadStatusData.ALARM_EVAC:
  7024. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  7025. break;
  7026. case WallpadStatusData.ALARM_INVADE:
  7027. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  7028. break;
  7029. }
  7030. return Menu_Start_Option;
  7031. }
  7032. public void runGoogleLauncher() {
  7033. try {
  7034. ComponentName mComponentName = new ComponentName("com.android.launcher3", "com.android.launcher3.Launcher");
  7035. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  7036. mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  7037. mIntent.setComponent(mComponentName);
  7038. startActivity(mIntent);
  7039. } catch (RuntimeException re) {
  7040. LogUtil.errorLogInfo("", TAG, re);
  7041. }
  7042. catch (Exception e) {
  7043. Log.e(TAG, "[Exception] runGoogleLauncher()");
  7044. LogUtil.errorLogInfo("", TAG, e);
  7045. }
  7046. }
  7047. public void setCallAppRunning(boolean bRunning) {
  7048. try {
  7049. Log.i(TAG, "[setCallAppRunning] bRunning [" + bRunning + "]");
  7050. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  7051. DBMGR.SetCallAPKStatus(bRunning);
  7052. DBMGR.closeDB();
  7053. } catch (RuntimeException re) {
  7054. LogUtil.errorLogInfo("", TAG, re);
  7055. }
  7056. catch (Exception e) {
  7057. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  7058. LogUtil.errorLogInfo("", TAG, e);
  7059. }
  7060. }
  7061. private void registerMainActivityBR() {
  7062. try {
  7063. IntentFilter filter = new IntentFilter();
  7064. filter.addAction(Common.BR_REQUEST_APK_RUN);
  7065. filter.addAction(ACTION_TIME_TICK);
  7066. filter.addAction(Common.BR_PLAY_SOUND);
  7067. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  7068. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  7069. mContext.registerReceiver(MainActivityBroadcastReceiver, filter);
  7070. } catch (RuntimeException re) {
  7071. LogUtil.errorLogInfo("", TAG, re);
  7072. }
  7073. catch (Exception e) {
  7074. Log.e(TAG, "[Exception] registerMainActivityBR()");
  7075. LogUtil.errorLogInfo("", TAG, e);
  7076. }
  7077. }
  7078. String strAPKType = "APKType";
  7079. String strMenuType = "MenuType";
  7080. String strSoundID = "SoundID";
  7081. BroadcastReceiver MainActivityBroadcastReceiver = new BroadcastReceiver() {
  7082. @Override
  7083. public void onReceive(Context context, Intent intent) {
  7084. try {
  7085. if (((MainActivity)(getContext())).getMainSubScreenLoadingComplite() == false)
  7086. return;
  7087. String strActionName = intent.getAction();
  7088. Log.d(TAG,"[MainActivityBroadcastReceiver] strActionName [" + strActionName + "]");
  7089. if (strActionName.equals(Common.BR_REQUEST_APK_RUN)) {
  7090. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) BR_REQUEST_APK_RUN");
  7091. int nAPKType = intent.getIntExtra(strAPKType,0);
  7092. int nMenuType = intent.getIntExtra(strMenuType,0);
  7093. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM, 0);
  7094. Log.d(TAG, "[MainActivityBroadcastReceiver] nAPKType [" + nAPKType + "], nMenuType [" + nMenuType + "], nCardNum [" + nCardNum + "]");
  7095. if (nAPKType == ID.LINKEDSCREEN.SubCall.BASE) {
  7096. m_CallSubMenuScreen.callStartCallAPK(nMenuType);
  7097. }
  7098. else if (nAPKType == ID.LINKEDSCREEN.SubMenuAddService.BASE) {
  7099. m_CallSubMenuScreen.callStartAddServiceAPK(nMenuType, nCardNum);
  7100. }
  7101. }
  7102. else if (strActionName.equals(ACTION_TIME_TICK)) {
  7103. // checkTimeTasks();
  7104. if (bLCDKeeperUsage) ctrlLCDKeeper();
  7105. }
  7106. else if (strActionName.equals(Common.BR_PLAY_SOUND)) {
  7107. int nSoundID = intent.getIntExtra(strSoundID,0);
  7108. Sound().Play(nSoundID);
  7109. }
  7110. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON)) {
  7111. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_ON: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  7112. if (bLCDKeeperUsage) {
  7113. bLCDBacklightPower = true;
  7114. ctrlLCDKeeper();
  7115. }
  7116. }
  7117. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF)) {
  7118. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_OFF: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  7119. if (bLCDKeeperUsage) {
  7120. bLCDBacklightPower = false;
  7121. ctrlLCDKeeper();
  7122. }
  7123. }
  7124. else {
  7125. Log.w(TAG,"[MainActivityBroadcastReceiver] Not supported strActionName [" + strActionName + "]");
  7126. }
  7127. } catch (RuntimeException re) {
  7128. LogUtil.errorLogInfo("", TAG, re);
  7129. }
  7130. catch (Exception e) {
  7131. Log.e(TAG, "[Exception] MainActivityBroadcastReceiver()");
  7132. LogUtil.errorLogInfo("", TAG, e);
  7133. }
  7134. }
  7135. };
  7136. public Common.GUI_TYPE checkGUIType(Context context) {
  7137. try {
  7138. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(context);
  7139. String strGUIType = mWallpadDeviceSet.GetMainGUISelect();
  7140. mWallpadDeviceSet.closeDB();
  7141. if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_DEFAULT)) return Common.GUI_TYPE.STANDARD;
  7142. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_METRO)) return Common.GUI_TYPE.METRO;
  7143. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HYOSUNG)) return Common.GUI_TYPE.HYOSUNG;
  7144. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HIMCHAN)) return Common.GUI_TYPE.HIMCHAN;
  7145. else return Common.GUI_TYPE.STANDARD;
  7146. } catch (RuntimeException re) {
  7147. LogUtil.errorLogInfo("", TAG, re);
  7148. return Common.GUI_TYPE.STANDARD;
  7149. }
  7150. catch (Exception e) {
  7151. Log.e(TAG, "[Exception] checkGUIType(Context context)");
  7152. LogUtil.errorLogInfo("", TAG, e);
  7153. return Common.GUI_TYPE.STANDARD;
  7154. }
  7155. }
  7156. public void finishActivity() {
  7157. try {
  7158. Log.i(TAG, "[finishActivity]");
  7159. super.finish();
  7160. } catch (RuntimeException re) {
  7161. LogUtil.errorLogInfo("", TAG, re);
  7162. }
  7163. catch (Exception e) {
  7164. Log.e(TAG, "[Exception] finishActivity()");
  7165. LogUtil.errorLogInfo("", TAG, e);
  7166. }
  7167. }
  7168. // MainActivity Handler
  7169. public final class HANDLERMSG {
  7170. public final static int CHECK_FLIPPER_MAINSCREEN_ID = 100;
  7171. public final static int CHECK_WALLPAD_CAMERA_INIT = 200;
  7172. public final static int CHECK_WALLPAD_CAMERA_REMOVE = 300;
  7173. public final static int CHECK_WALLPAD_CAMERA_RESET = 400;
  7174. public final static int CHECK_WALLPAD_CAMERA_CHECK = 500;
  7175. public final static int MEDIA_RECORD_START = 600;
  7176. public final static int MEDIA_RECORD_START_REMOTECALL = 700;
  7177. public final static int FINISH_ACTIVITY = 999;
  7178. }
  7179. public Handler MainHandler = new Handler(Looper.getMainLooper()) {
  7180. public void handleMessage(Message msg) {
  7181. Log.d(TAG, "[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  7182. switch (msg.what) {
  7183. case HANDLERMSG.CHECK_FLIPPER_MAINSCREEN_ID:
  7184. // checkMainPage();
  7185. break;
  7186. case HANDLERMSG.CHECK_WALLPAD_CAMERA_INIT:
  7187. if (getWallPadCameraUsage()) {
  7188. initMyVideoSurfaceLayout();
  7189. sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE, 0, 0, 3000); // 월패드 카메라 영상을 띄우고 5초뒤에 없앤다.
  7190. }
  7191. break;
  7192. case HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE:
  7193. if (getWallPadCameraUsage()) removeMyVideoSurfaceLayout();
  7194. break;
  7195. case HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET:
  7196. if (getWallPadCameraUsage()) resetCameraService();
  7197. break;
  7198. case HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK:
  7199. checkCameraLoading();
  7200. break;
  7201. case HANDLERMSG.FINISH_ACTIVITY:
  7202. finishActivity();
  7203. break;
  7204. case HANDLERMSG.MEDIA_RECORD_START:
  7205. Log.d(TAG, "[TalkFrontHandler] MEDIA_RECORD_START");
  7206. showFrontCam(true);
  7207. mediaStartRecord();
  7208. break;
  7209. case HANDLERMSG.MEDIA_RECORD_START_REMOTECALL:
  7210. Log.d(TAG, "[TalkFrontHandler] MEDIA_RECORD_START_REMOTECALL");
  7211. bRecordStatus = true;
  7212. showFrontCam(true);
  7213. runNoticeStrangerRecord(true);
  7214. if (mRecordTimer != null) mRecordTimer.start();
  7215. break;
  7216. default:
  7217. Log.d(TAG, "MainHandler : " + msg.what);
  7218. break;
  7219. }
  7220. }
  7221. };
  7222. public void sendHandlerMsg(int what, int arg1, int arg2) {
  7223. try {
  7224. Log.i(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  7225. Message HandleMsg = MainHandler.obtainMessage();
  7226. HandleMsg.what = what;
  7227. HandleMsg.arg1 = arg1;
  7228. HandleMsg.arg2 = arg2;
  7229. MainHandler.sendMessage(HandleMsg);
  7230. } catch (RuntimeException re) {
  7231. LogUtil.errorLogInfo("", TAG, re);
  7232. }
  7233. catch (Exception e) {
  7234. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  7235. LogUtil.errorLogInfo("", TAG, e);
  7236. }
  7237. }
  7238. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
  7239. try {
  7240. Log.i(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  7241. Message HandleMsg = MainHandler.obtainMessage();
  7242. HandleMsg.what = what;
  7243. HandleMsg.arg1 = arg1;
  7244. HandleMsg.arg2 = arg2;
  7245. MainHandler.sendMessageDelayed(HandleMsg, delay);
  7246. } catch (RuntimeException re) {
  7247. LogUtil.errorLogInfo("", TAG, re);
  7248. }
  7249. catch (Exception e) {
  7250. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  7251. LogUtil.errorLogInfo("", TAG, e);
  7252. }
  7253. }
  7254. private boolean savePresetValue(String strPresetValues) {
  7255. try {
  7256. Log.i(TAG, "[savePresetValue] strPresetValues [" + strPresetValues + "]");
  7257. String[] strParse_01 = strPresetValues.split("/");
  7258. int presetid = Integer.parseInt(strParse_01[0]);
  7259. String[] strParse_02 = strParse_01[1].split(":");
  7260. String onoff = strParse_02[0];
  7261. int dim = Integer.parseInt(strParse_02[1]);
  7262. int color = Integer.parseInt(strParse_02[2]);
  7263. WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext);
  7264. boolean result = mWallpadStatusData.setLivinglightModeCtrlUnitValues(presetid, 0, "on", dim, color);
  7265. mWallpadStatusData.closeDB();
  7266. Log.d(TAG, "[savePresetValue] result [" + result + "], onoff [" + onoff + "], dim [" + dim + "], color [" + color + "]");
  7267. if (result) {
  7268. mLightInfo.mPreset[presetid].mLights[0].ONOFF = onoff;
  7269. mLightInfo.mPreset[presetid].mLights[0].DIM = dim;
  7270. mLightInfo.mPreset[presetid].mLights[0].COLOR = color;
  7271. Log.d(TAG,"[savePresetValue] OnOff [" + mLightInfo.mPreset[presetid].mLights[0].ONOFF + "], Level [" + mLightInfo.mPreset[presetid].mLights[0].DIM + "], Color [" + mLightInfo.mPreset[presetid].mLights[0].COLOR + "]");
  7272. return true;
  7273. }
  7274. else {
  7275. Log.w(TAG,"[savePresetValue] Fail to save light preset values!!");
  7276. return false;
  7277. }
  7278. } catch (RuntimeException re) {
  7279. LogUtil.errorLogInfo("", TAG, re);
  7280. return false;
  7281. }
  7282. catch (Exception e) {
  7283. Log.e(TAG, "[Exception] savePresetValue(String strPresetValues)");
  7284. LogUtil.errorLogInfo("", TAG, e);
  7285. return false;
  7286. }
  7287. }
  7288. private void initProximitySensor() {
  7289. try {
  7290. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  7291. int nProximitySensorLevel = mWallpadStatusData.GetCloseSensorValue();
  7292. mWallpadStatusData.closeDB();
  7293. Log.i(TAG, "[initProximitySensor] nProximitySensorLevel = " + nProximitySensorLevel);
  7294. if (nProximitySensorLevel < 0 || 5 < nProximitySensorLevel) {
  7295. Log.w(TAG, "[initProximitySensor] nProximitySensorLevel is out of range!!");
  7296. nProximitySensorLevel = 5;
  7297. }
  7298. int nResult = mIOInterface.setProximitySensorLevel(nProximitySensorLevel * 3);
  7299. Log.i(TAG, "[initProximitySensor] nResult = " + nResult);
  7300. } catch (RuntimeException re) {
  7301. LogUtil.errorLogInfo("", TAG, re);
  7302. }
  7303. catch (Exception e) {
  7304. Log.e(TAG, "[Exception] initProximitySensor()");
  7305. LogUtil.errorLogInfo("", TAG, e);
  7306. }
  7307. }
  7308. private boolean checkInterFloorNoiseError() {
  7309. try {
  7310. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7311. String stSensorStatus = wsd.Get_InterlayerSensor_Status();
  7312. wsd.closeDB();
  7313. // 센서 정상 : false, 센서 이상 : true
  7314. Log.i(TAG, "[checkInterFloorNoiseError] stSensorStatus : " + stSensorStatus);
  7315. if (stSensorStatus.equalsIgnoreCase(define.INTERLAYER_NOISE_STATUS_NORMAL)) return false;
  7316. else return true;
  7317. } catch (RuntimeException re) {
  7318. LogUtil.errorLogInfo("", TAG, re);
  7319. return false;
  7320. }
  7321. catch (Exception e) {
  7322. Log.e(TAG, "[Exception] checkInterFloorNoiseError()");
  7323. LogUtil.errorLogInfo("", TAG, e);
  7324. return false;
  7325. }
  7326. }
  7327. private boolean checkInterFloorNoiseFuncUsage() {
  7328. try {
  7329. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7330. boolean bUsage = wsd.GetNoisePopupUse();
  7331. wsd.closeDB();
  7332. return bUsage;
  7333. } catch (RuntimeException re) {
  7334. LogUtil.errorLogInfo("", TAG, re);
  7335. return false;
  7336. }
  7337. catch (Exception e) {
  7338. Log.e(TAG, "[Exception] checkInterFloorNoiseFuncUsage()");
  7339. LogUtil.errorLogInfo("", TAG, e);
  7340. return false;
  7341. }
  7342. }
  7343. /**
  7344. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  7345. *
  7346. * @param nKeyCode - (int) 송신할 keycode
  7347. * @return (int) - >=0 : 성공, <0 : 실패
  7348. */
  7349. private int sendKeyEventBR(int nKeyCode) {
  7350. try {
  7351. Log.i(TAG, "[sendKeyEventBR] nKeyCode [" + nKeyCode +"] -> EVENT_DEVICE_CONTROL");
  7352. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  7353. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  7354. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  7355. intent.putExtra("keycode",nKeyCode);
  7356. sendBroadcast(intent);
  7357. } catch (RuntimeException re) {
  7358. LogUtil.errorLogInfo("", TAG, re);
  7359. return -100;
  7360. }
  7361. catch (Exception e) {
  7362. Log.e(TAG, "[Exception] sendKeyEventBR(int nKeyCode) [" + nKeyCode + "]");
  7363. LogUtil.errorLogInfo("", TAG, e);
  7364. return -100;
  7365. }
  7366. return 0;
  7367. }
  7368. // 카카오 연동 관련
  7369. public static boolean bKakaoiEnable = false;
  7370. /**
  7371. * 이진규
  7372. * kakaohome 서비스 사용 유무 판단
  7373. */
  7374. protected boolean bKakaoHomeEnable = false;
  7375. // run Kakao i floating button 실행
  7376. private void startKakaoiFloatingBTN() {
  7377. try {
  7378. Log.i(TAG, "[startKakaoiFloatingBTN] ========== Run Kakao i floating button ==========");
  7379. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadglobalbutton", "kr.co.icontrols.wallpadglobalbutton.MainActivity");
  7380. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  7381. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  7382. mIntent.setComponent(mComponentName);
  7383. startActivity(mIntent);
  7384. } catch (RuntimeException re) {
  7385. LogUtil.errorLogInfo("", TAG, re);
  7386. }
  7387. catch (Exception e) {
  7388. Log.e(TAG, "[Exception] startKakaoiFloatingBTN()");
  7389. LogUtil.errorLogInfo("", TAG, e);
  7390. }
  7391. }
  7392. public void Send_NotiSmartSwitch(int nNoticeCnt, int nParcelCnt, int nVisitorPicCnt)
  7393. {
  7394. try
  7395. {
  7396. Intent intentBR = new Intent();
  7397. intentBR.setAction(define.DRIVER_ISD_NOTIINFO);
  7398. //if( m_NoticeCNT > 0 || m_ParcelCNT > 0 || m_InCallCNT > 0 || m_VisitorCNT > 0 )
  7399. {
  7400. // 아이콘 활성화
  7401. if( nNoticeCnt > 0 )
  7402. {
  7403. Log.d(TAG, "LOG : NOTICE CNT INCREASED ++");
  7404. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, nNoticeCnt);
  7405. Log.d(TAG, "NoticeCNT BroadCast Added");
  7406. }
  7407. else
  7408. {
  7409. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, 0);
  7410. Log.d(TAG, "NoticeCNT ZERO Added");
  7411. }
  7412. if( nParcelCnt > 0 )
  7413. {
  7414. Log.d(TAG, "LOG : Parcel CNT INCREASED ++");
  7415. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, nParcelCnt);
  7416. Log.d(TAG, "ParcelCNT BroadCast Added");
  7417. }
  7418. else
  7419. {
  7420. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, 0);
  7421. Log.d(TAG, "ParcelCNT ZERO Added");
  7422. }
  7423. if( nVisitorPicCnt > 0 )
  7424. {
  7425. Log.d(TAG, "LOG : VISITOR CNT INCREASED ++");
  7426. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7427. Log.d(TAG, "VisitorCNT BroadCast Added");
  7428. }
  7429. else
  7430. {
  7431. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7432. Log.d(TAG, "VisitorCNT ZERO Added");
  7433. }
  7434. // 알림정보 intent BroadCast
  7435. getContext().sendBroadcast(intentBR);
  7436. }
  7437. }
  7438. catch (RuntimeException re) {
  7439. LogUtil.errorLogInfo("", TAG, re);
  7440. }
  7441. catch (Exception e)
  7442. {
  7443. Log.e(TAG, e.toString());
  7444. LogUtil.errorLogInfo("", TAG, e);
  7445. }
  7446. }
  7447. // private void startKakaoiVoiceAgent() {
  7448. // try {
  7449. // Log.i(TAG, "[startKakaoiVoiceAgent] ========== Start Kakao i Voice Agent ==========");
  7450. // Intent mIntent = new Intent("com.kakao.i.agent.START_SERVICE").setPackage("com.kakao.i.test.sandbox");
  7451. // ContextCompat.startForegroundService(this, mIntent);
  7452. // } catch (RuntimeException re) {
  7453. // LogUtil.errorLogInfo("", TAG, re);
  7454. // }
  7455. // catch (Exception e) {
  7456. // Log.e(TAG, "[Exception] startKakaoiVoiceAgent()");
  7457. // e.printStackTrace();
  7458. // }
  7459. // }
  7460. //
  7461. // private void enableKakaoiVoiceAgent() {
  7462. // try {
  7463. // Log.i(TAG, "[enableKakaoiVoiceAgent] ========== Enable Kakao i Voice Agent ==========");
  7464. // Intent mIntent = new Intent("com.kakao.i.agent.ENABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7465. // ContextCompat.startForegroundService(this, mIntent);
  7466. // } catch (RuntimeException re) {
  7467. // LogUtil.errorLogInfo("", TAG, re);
  7468. // }
  7469. // catch (Exception e) {
  7470. // Log.e(TAG, "[Exception] enableKakaoiVoiceAgent()");
  7471. // e.printStackTrace();
  7472. // }
  7473. // }
  7474. //
  7475. // private void diableKakaoiVoiceAgent() {
  7476. // try {
  7477. // Log.i(TAG, "[diableKakaoiVoiceAgent] ========== Disable Kakao i Voice Agent ==========");
  7478. // Intent mIntent = new Intent("com.kakao.i.agent.DISABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7479. // ContextCompat.startForegroundService(this, mIntent);
  7480. // } catch (RuntimeException re) {
  7481. // LogUtil.errorLogInfo("", TAG, re);
  7482. // }
  7483. // catch (Exception e) {
  7484. // Log.e(TAG, "[Exception] diableKakaoiVoiceAgent()");
  7485. // e.printStackTrace();
  7486. // }
  7487. // }
  7488. /**
  7489. * JEFF, 2019.08.06
  7490. * 동탄현장 월패드 죽는 이슈 원인 분석을 위한 월패드 App 삭제 코드
  7491. * 메인App만 남기고 모두 삭제
  7492. */
  7493. UninstallAPKs mUninstallAPKs = new UninstallAPKs();
  7494. class UninstallAPKs extends Thread {
  7495. @Override
  7496. public void run() {
  7497. super.run();
  7498. try {
  7499. Log.d(TAG, "[UninstallAPKs.run()] Started getting installed package infomation");
  7500. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  7501. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  7502. while (true) {
  7503. Log.d(TAG, "[UninstallAPKs.run()] Get installed packages start!!");
  7504. try {
  7505. for (PackageInfo pack : PackageInfoList) {
  7506. // Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + pack.packageName + "]");
  7507. // Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + pack.versionName + "]");
  7508. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore"))) {
  7509. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  7510. }
  7511. }
  7512. } catch (RuntimeException re) {
  7513. LogUtil.errorLogInfo("", TAG, re);
  7514. break;
  7515. } catch (Exception e) {
  7516. LogUtil.errorLogInfo("", TAG, e);
  7517. break;
  7518. }
  7519. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  7520. break;
  7521. }
  7522. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  7523. Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + PackageVersionInfos.get(i).getPackageName() + "]");
  7524. Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + PackageVersionInfos.get(i).strPackageVersion + "]");
  7525. uninstallWallPadApp(PackageVersionInfos.get(i).getPackageName());
  7526. try {
  7527. Thread.sleep(5000);
  7528. } catch (RuntimeException re) {
  7529. LogUtil.errorLogInfo("", TAG, re);
  7530. } catch (Exception e) {
  7531. LogUtil.errorLogInfo("", TAG, e);
  7532. }
  7533. }
  7534. } catch (RuntimeException re) {
  7535. LogUtil.errorLogInfo("", TAG, re);
  7536. } catch (Exception e) {
  7537. Log.e(TAG, "[Exception] UninstallAPKs.run()");
  7538. LogUtil.errorLogInfo("", TAG, e);
  7539. }
  7540. // try {Thread.sleep(5000);}catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  7541. }
  7542. }
  7543. private void uninstallWallPadApp(String strAPK) {
  7544. try {
  7545. Log.w(TAG, "[uninstallWallPadApp] strAPK [" + strAPK + "]");
  7546. if (checkAppInstalled(strAPK)) {
  7547. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  7548. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  7549. mIntent.setData(Uri.parse("package:" + strAPK));
  7550. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  7551. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  7552. }
  7553. else {
  7554. Log.w(TAG, "[uninstallWallPadApp] Not installed [" + strAPK + "]");
  7555. }
  7556. } catch (RuntimeException re) {
  7557. LogUtil.errorLogInfo("", TAG, re);
  7558. }
  7559. catch (Exception e) {;
  7560. Log.e(TAG, "[Exception] uninstallWallPadApp()");
  7561. LogUtil.errorLogInfo("", TAG, e);
  7562. }
  7563. }
  7564. iMAPRemotemeter miMAPRemotemeter;
  7565. boolean mEMS_Enable;
  7566. int nEnergyTypeCnt;
  7567. private boolean mCostInfo_Enable = false;
  7568. private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
  7569. int CalendarYear;
  7570. int CalendarMonth;
  7571. int CalendarDate;
  7572. int ShowNowEnergyIndex = 0;
  7573. String[] ShowListEnergyType_String = {
  7574. "전기",
  7575. "수도",
  7576. "가스",
  7577. "온수",
  7578. "난방",
  7579. "탄소"
  7580. };
  7581. // 원격검침 월사용량 데이터 클래스
  7582. MonthTableClass monthTableClass[] = new MonthTableClass[6];
  7583. class MonthTableClass {
  7584. private String Use;
  7585. private String SamePyungUse;
  7586. private String Rank;
  7587. private String Goal;
  7588. private String Price;
  7589. public MonthTableClass (String Use, String SamePyungUse, String Rank, String Goal) {
  7590. this.Use = Use;
  7591. this.SamePyungUse = SamePyungUse;
  7592. this.Rank = Rank;
  7593. this.Goal = Goal;
  7594. }
  7595. public String getUse(){return Use;}
  7596. public String getSamePyungUse(){return SamePyungUse;}
  7597. public String getRank(){return Rank;}
  7598. public String getGoal(){return Goal;}
  7599. public String getPrice(){return Price;}
  7600. }
  7601. public void GetMeteringCount()
  7602. {
  7603. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  7604. String[] MetringDB = devSet.GetSettingData("원격검침");
  7605. devSet.closeDB();
  7606. if (MetringDB != null)
  7607. {
  7608. try
  7609. {
  7610. String devInfo = MetringDB[1];
  7611. devInfo = devInfo.replace('(', '_');
  7612. devInfo = devInfo.replace(':', '_');
  7613. devInfo = devInfo.replace(')', '_');
  7614. String[] MetringInfo = devInfo.split("_");
  7615. // MetringInfo[1] -> 회로수
  7616. // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
  7617. if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6))
  7618. {
  7619. nEnergyTypeCnt = Integer.parseInt(MetringInfo[1]);
  7620. }
  7621. else
  7622. {
  7623. nEnergyTypeCnt = 5;
  7624. }
  7625. if (MetringInfo[5].equals("사용함"))
  7626. {
  7627. mEMS_Enable = true;
  7628. }
  7629. else
  7630. {
  7631. mEMS_Enable = false;
  7632. }
  7633. if(MetringInfo[7].equals("사용함"))
  7634. {
  7635. mCostInfo_Enable = true;
  7636. }
  7637. else
  7638. {
  7639. mCostInfo_Enable = false;
  7640. }
  7641. }
  7642. catch (RuntimeException re) {
  7643. LogUtil.errorLogInfo("", TAG, re);
  7644. nEnergyTypeCnt = 5;
  7645. mEMS_Enable = true;
  7646. }
  7647. catch (Exception e)
  7648. {
  7649. LogUtil.errorLogInfo("", TAG, e);
  7650. nEnergyTypeCnt = 5;
  7651. mEMS_Enable = true;
  7652. }
  7653. }
  7654. else
  7655. {
  7656. nEnergyTypeCnt = 5;
  7657. mEMS_Enable = true;
  7658. }
  7659. }
  7660. /**
  7661. * @description
  7662. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  7663. * @param
  7664. * InputType 0 당월, 1 일별<br>
  7665. * @param
  7666. * //year - 연도<br>
  7667. * @param
  7668. * //month - 월<br>
  7669. * @param
  7670. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  7671. */
  7672. private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy, final boolean bSendToMobile) {
  7673. final int inputType = InputType;
  7674. final int year = Year;
  7675. final int month = (Month+1);
  7676. try {
  7677. Log.i(TAG, "[LoadRemotemeterDataFromServer] InputType [" + InputType + "], Year [" + Year + "], Month [" + Month + "], Energy [" + Energy + "], bSendToMobile [" + bSendToMobile + "]");
  7678. Log.i(TAG, "[LoadRemotemeterDataFromServer] inputType [" + inputType + "], year [" + year + "], month [" + month + "]");
  7679. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  7680. switch(inputType) {
  7681. case 0: //당월
  7682. miMAPRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
  7683. break;
  7684. case 1: //일별
  7685. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  7686. break;
  7687. default:
  7688. break;
  7689. }
  7690. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7691. @Override
  7692. public void ProcSuccess() {
  7693. String TempString = null;
  7694. // DB
  7695. WallpadStatusData StatusDBMGR = null;
  7696. try {
  7697. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7698. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7699. boolean result = false;
  7700. switch (inputType) {
  7701. case 0: // 당월
  7702. EnergyDataGetCal = Calendar.getInstance();
  7703. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7704. if (NumberOfValuelist != 0) {
  7705. for (int i = 0; i < NumberOfValuelist; i++) {
  7706. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7707. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7708. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7709. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7710. result = true;
  7711. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7712. if (Temp_mNumberOfEnergy == 2) {
  7713. Temp_mNumberOfEnergy = 3;
  7714. }
  7715. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7716. switch (j) {
  7717. case 0:
  7718. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7719. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7720. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7721. monthTableClass[j].Use = "0";
  7722. }
  7723. else {
  7724. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7725. }
  7726. }
  7727. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize") != null) {
  7728. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize").equals("null") == true) {
  7729. monthTableClass[j].SamePyungUse = "0";
  7730. }
  7731. else {
  7732. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize");
  7733. }
  7734. }
  7735. if ((miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7736. if (miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize").equals("null") == true) {
  7737. TempString = "- / ";
  7738. }
  7739. else {
  7740. TempString = miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") + " / ";
  7741. }
  7742. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7743. TempString = TempString + "-";
  7744. }
  7745. else {
  7746. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7747. }
  7748. monthTableClass[j].Rank = TempString;
  7749. }
  7750. //가격정보
  7751. if (mCostInfo_Enable == true) {
  7752. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price") != null) {
  7753. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price").equals("null") == true) {
  7754. monthTableClass[j].Price = "";
  7755. }
  7756. else {
  7757. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "elect_price");
  7758. }
  7759. }
  7760. }
  7761. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7762. //DebugLogOutput("전기");
  7763. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7764. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7765. break;
  7766. case 1:
  7767. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7768. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7769. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7770. monthTableClass[j].Use = "0";
  7771. }
  7772. else {
  7773. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7774. }
  7775. }
  7776. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize") != null) {
  7777. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize").equals("null") == true) {
  7778. monthTableClass[j].SamePyungUse = "0";
  7779. }
  7780. else {
  7781. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize");
  7782. }
  7783. }
  7784. if ((miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7785. if (miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize").equals("null") == true) {
  7786. TempString = "- / ";
  7787. }
  7788. else {
  7789. TempString = miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") + " / ";
  7790. }
  7791. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7792. TempString = TempString + "-";
  7793. }
  7794. else {
  7795. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7796. }
  7797. monthTableClass[j].Rank = TempString;
  7798. }
  7799. //가격정보
  7800. if (mCostInfo_Enable == true) {
  7801. if (miMAPRemotemeter.GetAttributeVal(i, "water_price") != null) {
  7802. if (miMAPRemotemeter.GetAttributeVal(i, "water_price").equals("null") == true) {
  7803. monthTableClass[j].Price = "";
  7804. }
  7805. else {
  7806. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "water_price");
  7807. }
  7808. }
  7809. }
  7810. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7811. //DebugLogOutput("수도");
  7812. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7813. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7814. break;
  7815. case 2:
  7816. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7817. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7818. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7819. monthTableClass[j].Use = "0";
  7820. }
  7821. else {
  7822. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7823. }
  7824. }
  7825. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize") != null) {
  7826. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize").equals("null") == true) {
  7827. monthTableClass[j].SamePyungUse = "0";
  7828. }
  7829. else {
  7830. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize");
  7831. }
  7832. }
  7833. if ((miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7834. if (miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize").equals("null") == true) {
  7835. TempString = "- / ";
  7836. }
  7837. else {
  7838. TempString = miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") + " / ";
  7839. }
  7840. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7841. TempString = TempString + "-";
  7842. }
  7843. else {
  7844. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7845. }
  7846. monthTableClass[j].Rank = TempString;
  7847. }
  7848. //가격정보
  7849. if (mCostInfo_Enable == true) {
  7850. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price") != null) {
  7851. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price").equals("null") == true) {
  7852. monthTableClass[j].Price = "";
  7853. }
  7854. else {
  7855. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "gas_price");
  7856. }
  7857. }
  7858. }
  7859. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7860. //DebugLogOutput("가스");
  7861. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7862. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7863. break;
  7864. case 3:
  7865. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7866. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7867. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7868. monthTableClass[j].Use = "0";
  7869. }
  7870. else {
  7871. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7872. }
  7873. }
  7874. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize") != null) {
  7875. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize").equals("null") == true) {
  7876. monthTableClass[j].SamePyungUse = "0";
  7877. }
  7878. else {
  7879. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize");
  7880. }
  7881. }
  7882. if ((miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7883. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize").equals("null") == true) {
  7884. TempString = "- / ";
  7885. }
  7886. else {
  7887. TempString = miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") + " / ";
  7888. }
  7889. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7890. TempString = TempString + "-";
  7891. }
  7892. else {
  7893. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7894. }
  7895. monthTableClass[j].Rank = TempString;
  7896. }
  7897. //가격정보
  7898. if (mCostInfo_Enable == true) {
  7899. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price") != null) {
  7900. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price").equals("null") == true) {
  7901. monthTableClass[j].Price = "";
  7902. }
  7903. else {
  7904. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "hotwater_price");
  7905. }
  7906. }
  7907. }
  7908. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7909. //DebugLogOutput("온수");
  7910. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7911. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7912. break;
  7913. case 4:
  7914. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7915. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7916. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7917. monthTableClass[j].Use = "0";
  7918. }
  7919. else {
  7920. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7921. }
  7922. }
  7923. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize") != null) {
  7924. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize").equals("null") == true) {
  7925. monthTableClass[j].SamePyungUse = "0";
  7926. }
  7927. else {
  7928. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize");
  7929. }
  7930. }
  7931. if ((miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7932. if (miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize").equals("null") == true) {
  7933. TempString = "- / ";
  7934. }
  7935. else {
  7936. TempString = miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") + " / ";
  7937. }
  7938. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7939. TempString = TempString + "-";
  7940. }
  7941. else {
  7942. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7943. }
  7944. monthTableClass[j].Rank = TempString;
  7945. }
  7946. //가격정보
  7947. if (mCostInfo_Enable == true) {
  7948. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price") != null) {
  7949. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price").equals("null") == true) {
  7950. monthTableClass[j].Price = "";
  7951. }
  7952. else {
  7953. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "energy_price");
  7954. }
  7955. }
  7956. }
  7957. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7958. //DebugLogOutput("열량");
  7959. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7960. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7961. break;
  7962. case 5:
  7963. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7964. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used") != null) {
  7965. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used").equals("1000000") == true) {
  7966. monthTableClass[j].Use = "0";
  7967. }
  7968. else {
  7969. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "carbon_used");
  7970. }
  7971. }
  7972. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize") != null) {
  7973. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize").equals("null") == true) {
  7974. monthTableClass[j].SamePyungUse = "0";
  7975. }
  7976. else {
  7977. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize");
  7978. }
  7979. }
  7980. if ((miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7981. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize").equals("null") == true) {
  7982. TempString = "- / ";
  7983. }
  7984. else {
  7985. TempString = miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") + " / ";
  7986. }
  7987. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7988. TempString = TempString + "-";
  7989. }
  7990. else {
  7991. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7992. }
  7993. monthTableClass[j].Rank = TempString;
  7994. }
  7995. //가격정보
  7996. if (mCostInfo_Enable == true) {
  7997. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price") != null) {
  7998. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price").equals("null") == true) {
  7999. monthTableClass[j].Price = "";
  8000. }
  8001. else {
  8002. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "carbon_price");
  8003. }
  8004. }
  8005. }
  8006. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  8007. //DebugLogOutput("탄소");
  8008. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  8009. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  8010. break;
  8011. default:
  8012. break;
  8013. }
  8014. }
  8015. }
  8016. }
  8017. if (result) {
  8018. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  8019. Intent intent = new Intent();
  8020. intent.setAction(define.NOTIFY_ACNAME);
  8021. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  8022. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  8023. if (nEnergyTypeCnt == 2) {
  8024. elect_target = monthTableClass[0].Goal;
  8025. elect_used = monthTableClass[0].Use;
  8026. water_target = monthTableClass[1].Goal;
  8027. water_used = monthTableClass[1].Use;
  8028. }
  8029. else if (nEnergyTypeCnt == 3) {
  8030. elect_target = monthTableClass[0].Goal;
  8031. elect_used = monthTableClass[0].Use;
  8032. water_target = monthTableClass[1].Goal;
  8033. water_used = monthTableClass[1].Use;
  8034. gas_target = monthTableClass[2].Goal;
  8035. gas_used = monthTableClass[2].Use;
  8036. }
  8037. else if (nEnergyTypeCnt == 4) {
  8038. elect_target = monthTableClass[0].Goal;
  8039. elect_used = monthTableClass[0].Use;
  8040. water_target = monthTableClass[1].Goal;
  8041. water_used = monthTableClass[1].Use;
  8042. hotwater_target = monthTableClass[2].Goal;
  8043. hotwater_used = monthTableClass[2].Use;
  8044. heating_target = monthTableClass[3].Goal;
  8045. heating_used = monthTableClass[3].Use;
  8046. }
  8047. else if (nEnergyTypeCnt == 5) {
  8048. elect_target = monthTableClass[0].Goal;
  8049. elect_used = monthTableClass[0].Use;
  8050. water_target = monthTableClass[1].Goal;
  8051. water_used = monthTableClass[1].Use;
  8052. gas_target = monthTableClass[2].Goal;
  8053. gas_used = monthTableClass[2].Use;
  8054. hotwater_target = monthTableClass[3].Goal;
  8055. hotwater_used = monthTableClass[3].Use;
  8056. heating_target = monthTableClass[4].Goal;
  8057. heating_used = monthTableClass[4].Use;
  8058. }
  8059. else {
  8060. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8061. return;
  8062. }
  8063. getApplicationContext().sendBroadcast(intent);
  8064. if (bSendToMobile) sendRemotemeterDataToMobile();
  8065. }
  8066. else {
  8067. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8068. }
  8069. return;
  8070. }
  8071. else {
  8072. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  8073. }
  8074. }
  8075. break;
  8076. default:
  8077. break;
  8078. }
  8079. StatusDBMGR.closeDB();
  8080. } catch (RuntimeException re) {
  8081. if (StatusDBMGR != null) {
  8082. StatusDBMGR.closeDB();
  8083. }
  8084. LogUtil.errorLogInfo("", TAG, re);
  8085. }
  8086. catch (Exception e) {
  8087. if (StatusDBMGR != null) {
  8088. StatusDBMGR.closeDB();
  8089. }
  8090. LogUtil.errorLogInfo("", TAG, e);
  8091. }
  8092. }
  8093. @Override
  8094. public void ProcError() {
  8095. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  8096. }
  8097. @Override
  8098. public void ProcDoing() {
  8099. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  8100. }
  8101. });
  8102. } catch (RuntimeException re) {
  8103. LogUtil.errorLogInfo("", TAG, re);
  8104. }
  8105. catch (Exception e) {
  8106. Log.e(TAG, "[Exception] LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy)");
  8107. LogUtil.errorLogInfo("", TAG, e);
  8108. }
  8109. }
  8110. /**
  8111. * @description
  8112. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  8113. * @param
  8114. * //year - 연도<br>
  8115. * @param
  8116. * //month - 월<br>
  8117. * @param
  8118. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  8119. */
  8120. private void getTelemeringDailyUsageData(final int nYear, final int nMonth, final int nDate) {
  8121. try {
  8122. Log.i(TAG, "[getTelemeringDailyUsageData] nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8123. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  8124. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, nYear, nMonth);
  8125. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8126. @Override
  8127. public void ProcSuccess() {
  8128. String strTempValue = null;
  8129. int nEnergyTypeCnt = 5;
  8130. try {
  8131. boolean bResult = false;
  8132. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8133. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8134. if (nDataCnt != 0) {
  8135. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8136. for (int i = 0; i < nDataCnt; i++) {
  8137. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8138. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8139. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8140. bResult = true;
  8141. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8142. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8143. if (j == 0) {
  8144. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8145. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8146. strElecUsage = "0";
  8147. }
  8148. else {
  8149. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8150. }
  8151. }
  8152. }
  8153. else if (j == 1) {
  8154. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8155. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8156. strWaterUsage = "0";
  8157. }
  8158. else {
  8159. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8160. }
  8161. }
  8162. }
  8163. else if (j == 2) {
  8164. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8165. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8166. strGasUsage = "0";
  8167. }
  8168. else {
  8169. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8170. }
  8171. }
  8172. }
  8173. else if (j == 3) {
  8174. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8175. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8176. strHotwaterUsage = "0";
  8177. }
  8178. else {
  8179. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8180. }
  8181. }
  8182. }
  8183. else if (j == 4) {
  8184. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8185. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8186. strHeatingUsage = "0";
  8187. }
  8188. else {
  8189. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8190. }
  8191. }
  8192. }
  8193. }
  8194. }
  8195. }
  8196. if (bResult) {
  8197. Intent mIntent = new Intent();
  8198. mIntent.setAction(define.NOTIFY_ACNAME);
  8199. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8200. mIntent.putExtra("elect_used", strElecUsage);
  8201. mIntent.putExtra("water_used", strWaterUsage);
  8202. mIntent.putExtra("gas_used", strGasUsage);
  8203. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8204. mIntent.putExtra("heating_used", strHeatingUsage);
  8205. getApplicationContext().sendBroadcast(mIntent);
  8206. }
  8207. else {
  8208. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8209. }
  8210. }
  8211. } catch (RuntimeException re) {
  8212. LogUtil.errorLogInfo("", TAG, re);
  8213. }
  8214. catch (Exception e) {
  8215. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8216. LogUtil.errorLogInfo("", TAG, e);
  8217. }
  8218. }
  8219. @Override
  8220. public void ProcError() {
  8221. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8222. }
  8223. @Override
  8224. public void ProcDoing() {
  8225. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8226. }
  8227. });
  8228. } catch (RuntimeException re) {
  8229. LogUtil.errorLogInfo("", TAG, re);
  8230. }
  8231. catch (Exception e) {
  8232. Log.e(TAG, "[Exception] getTelemeringDailyData(int nYear, int nMonth)");
  8233. LogUtil.errorLogInfo("", TAG, e);
  8234. }
  8235. }
  8236. public void sendRemotemeterDataToMobile() {
  8237. try {
  8238. Log.i(TAG, "[sendRemotemeterDataToMobile] ========== START ==========");
  8239. Intent intent = new Intent();
  8240. intent.setAction(define.NOTIFY_ACNAME);
  8241. intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
  8242. intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, nEnergyTypeCnt);
  8243. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
  8244. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH)+1));
  8245. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
  8246. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
  8247. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
  8248. if (nEnergyTypeCnt == 2) {
  8249. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8250. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8251. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8252. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8253. }
  8254. else if (nEnergyTypeCnt == 3) {
  8255. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8256. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8257. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8258. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8259. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8260. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8261. }
  8262. else if (nEnergyTypeCnt == 4) {
  8263. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8264. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8265. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8266. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8267. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8268. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8269. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8270. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8271. }
  8272. else if (nEnergyTypeCnt == 5) {
  8273. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8274. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8275. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8276. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8277. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8278. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8279. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8280. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8281. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8282. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8283. }
  8284. getContext().sendBroadcast(intent);
  8285. Log.i(TAG, "[sendRemotemeterDataToMobile] Sent ENERGY_INTENT_ BR "+define.NOTIFY_ENERGY_DATA);
  8286. } catch (RuntimeException re) {
  8287. LogUtil.errorLogInfo("", TAG, re);
  8288. }
  8289. catch (Exception e) {
  8290. Log.e(TAG, "[Exception] sendRemotemeterDataToMobile()");
  8291. LogUtil.errorLogInfo("", TAG, e);
  8292. }
  8293. }
  8294. private void getTelemeteringDataOnRandomTime() {
  8295. try {
  8296. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  8297. if (DelayTime < 1) {
  8298. return;
  8299. }
  8300. Log.i(TAG, "[getTelemeteringDataOnRandomTime] DelayTime : "+ DelayTime);
  8301. getTelemeteringDataHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  8302. } catch (RuntimeException re) {
  8303. LogUtil.errorLogInfo("", TAG, re);
  8304. return;
  8305. }
  8306. catch (Exception e) {
  8307. Log.e(TAG, "[Exception] getTelemeteringDataOnRandomTime()");
  8308. LogUtil.errorLogInfo("", TAG, e);
  8309. return;
  8310. }
  8311. }
  8312. @SuppressLint("HandlerLeak")
  8313. private Handler getTelemeteringDataHandler = new Handler() {
  8314. @SuppressLint("HandlerLeak")
  8315. @Override
  8316. public void handleMessage(Message msg) {
  8317. if (msg.what == 0) {
  8318. getRemoteMeterDataFromServer(true);
  8319. }
  8320. }
  8321. };
  8322. boolean bTelemeteringToISS = false;
  8323. private void checkISSEnergyType() {
  8324. try {
  8325. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplication());
  8326. int nEnergyKind = mWallpadDeviceSet.Get_SmartSwitchEnergy_Kind();
  8327. mWallpadDeviceSet.closeDB();
  8328. if (nEnergyKind == WallpadDeviceSet.SMARTSWITCH_ENERGY_REMOTE) bTelemeteringToISS = true;
  8329. else bTelemeteringToISS = false;
  8330. } catch (RuntimeException re) {
  8331. LogUtil.errorLogInfo("", TAG, re);
  8332. }
  8333. catch (Exception e) {
  8334. Log.e(TAG, "[Exception] checkISSEnergyType()");
  8335. LogUtil.errorLogInfo("", TAG, e);
  8336. }
  8337. }
  8338. public void getRemoteMeterDataFromServer(boolean bSendToMobile) {
  8339. try {
  8340. nowCal = Calendar.getInstance();
  8341. CalendarYear = nowCal.get(Calendar.YEAR);
  8342. CalendarMonth = nowCal.get(Calendar.MONTH);
  8343. CalendarDate = nowCal.get(Calendar.DATE);
  8344. GetMeteringCount();
  8345. LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex, bSendToMobile);
  8346. if (bTelemeteringToISS) getTelemeringDailyUsageData(CalendarYear, CalendarMonth + 1, CalendarDate);
  8347. } catch (RuntimeException re) {
  8348. LogUtil.errorLogInfo("", TAG, re);
  8349. }
  8350. catch (Exception e) {
  8351. Log.e(TAG, "[Exception] getRemoteMeterDataFromServer()");
  8352. LogUtil.errorLogInfo("", TAG, e);
  8353. }
  8354. }
  8355. private boolean getBlackoutStatus() {
  8356. try {
  8357. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  8358. return mSharedPreferences.getBoolean("status", false);
  8359. } catch (RuntimeException re) {
  8360. LogUtil.errorLogInfo("", TAG, re);
  8361. return false;
  8362. }
  8363. catch (Exception e) {
  8364. Log.e(TAG, "[Exception] getBlackoutStatus()");
  8365. LogUtil.errorLogInfo("", TAG, e);
  8366. return false;
  8367. }
  8368. }
  8369. private void sendBlackoutScreenRunBR() {
  8370. try {
  8371. Log.i(TAG, "[sendBlackoutScreenRunBR] ========== START ==========");
  8372. Intent mIntent = new Intent(Common.BR_BLACKOUT_SCREEN_RUN, null);
  8373. mContext.sendBroadcast(mIntent);
  8374. } catch (RuntimeException re) {
  8375. LogUtil.errorLogInfo("", TAG, re);
  8376. }
  8377. catch (Exception e) {
  8378. Log.e(TAG, "[Exception] sendBlackoutScreenRunBR()");
  8379. LogUtil.errorLogInfo("", TAG, e);
  8380. }
  8381. }
  8382. /**
  8383. * 월패드 타입 판별
  8384. * @return bResult
  8385. * false: 메인월패드
  8386. * true: 서브월패드
  8387. */
  8388. public boolean getIsSubWallpad() {
  8389. boolean bResult = false;
  8390. try {
  8391. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  8392. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  8393. mWallpadDeviceSet.closeDB();
  8394. if (DBinfo == null) bResult = false;
  8395. else {
  8396. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  8397. else bResult = false;
  8398. }
  8399. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  8400. return bResult;
  8401. } catch (RuntimeException re) {
  8402. LogUtil.errorLogInfo("", TAG, re);
  8403. return false;
  8404. }
  8405. catch (Exception e) {
  8406. Log.e(TAG, "[Exception] getIsSubWallpad()");
  8407. LogUtil.errorLogInfo("", TAG, e);
  8408. return false;
  8409. }
  8410. }
  8411. /**
  8412. * JEFF, 2020.01.14
  8413. * 월패드 카메라의 초기화를 위한 코드 삽입
  8414. * 월패드 카메라 preview 실행시, 최초 1회에 한하여 카메라 화면에 녹색이 보이는 증상을 해결하기 위함
  8415. */
  8416. /* ================================================================================================
  8417. * 내 영상
  8418. ================================================================================================ */
  8419. // SurfaceLayout 구성
  8420. RelativeLayout MyVideoLayout; // MoIP 카메라 영상
  8421. SurfaceHolder MyVideoHolder;
  8422. SurfaceView MyVideoSurface;
  8423. RelativeLayout SurfaceLayout; // 영상표시 화면
  8424. public Camera mMyCamera;
  8425. public void toggleMyVideo() {
  8426. try {
  8427. if (MyVideoLayout == null) {
  8428. Log.e(TAG, "[toggleMyVideo] Show My Video!!!");
  8429. initMyVideoSurfaceLayout();
  8430. }
  8431. else {
  8432. Log.e(TAG, "[toggleMyVideo] Remove My Video!!!");
  8433. removeMyVideoSurfaceLayout();
  8434. }
  8435. } catch (RuntimeException re) {
  8436. LogUtil.errorLogInfo("", TAG, re);
  8437. }
  8438. catch (Exception e) {
  8439. Log.e(TAG, "[Exception] toggleMyVideo()");
  8440. LogUtil.errorLogInfo("", TAG, e);
  8441. }
  8442. }
  8443. public void initMyVideoSurfaceLayout() {
  8444. try {
  8445. // LOG_INFO("[initMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8446. if (MyVideoLayout != null) {
  8447. MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  8448. MyVideoLayout.removeAllViews();
  8449. MyVideoLayout = null;
  8450. }
  8451. MyVideoLayout = new RelativeLayout(mContext);
  8452. WpadUtil.LayoutRegistration(SurfaceLayout, MyVideoLayout, 1024, 600, 0, 0, ID.MAINACTIVITY.LAYOUT.MYVIDEO);
  8453. MyVideoSurface = new SurfaceView(mContext);
  8454. MyVideoHolder = MyVideoSurface.getHolder();
  8455. WpadRelativeLayoutParams MyVideoParams = new WpadRelativeLayoutParams(320, 240);
  8456. // MyVideoParams.setMargins(10, 10, 0, 0); // 보이게
  8457. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  8458. MyVideoLayout.addView(MyVideoSurface, MyVideoParams);
  8459. MyVideoSurface.getHolder().addCallback(MyVideoCallback);
  8460. MyVideoSurface.setZOrderOnTop(true);
  8461. } catch (RuntimeException re) {
  8462. LogUtil.errorLogInfo("", TAG, re);
  8463. }
  8464. catch (Exception e) {
  8465. Log.e(TAG, "[Exception] initMyVideoSurfaceLayout()");
  8466. LogUtil.errorLogInfo("", TAG, e);
  8467. }
  8468. }
  8469. public void removeMyVideoSurfaceLayout() {
  8470. try {
  8471. Log.i(TAG, "[removeMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8472. if (MyVideoLayout != null) {
  8473. MyVideoLayout.removeAllViews();
  8474. MyVideoLayout = null;
  8475. }
  8476. } catch (RuntimeException re) {
  8477. LogUtil.errorLogInfo("", TAG, re);
  8478. }
  8479. catch (Exception e) {
  8480. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  8481. LogUtil.errorLogInfo("", TAG, e);
  8482. }
  8483. }
  8484. private SurfaceHolder.Callback MyVideoCallback = new SurfaceHolder.Callback() {
  8485. @Override
  8486. public void surfaceCreated(SurfaceHolder holder) {
  8487. try {
  8488. Log.i(TAG, "[MyVideoCallback] surfaceCreated!!");
  8489. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8490. mIOInterface.ctrlWallPadCamPower(true);
  8491. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  8492. Camera.Parameters params = mMyCamera.getParameters();
  8493. params.setPictureSize(320, 240);
  8494. mMyCamera.setParameters(params);
  8495. mMyCamera.setPreviewDisplay(holder);
  8496. } else {
  8497. Log.w(TAG, "[MyVideoCallback] surfaceCreated!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8498. }
  8499. } catch (RuntimeException re) {
  8500. LogUtil.errorLogInfo("", TAG, re);
  8501. }
  8502. catch (Exception e) {
  8503. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  8504. LogUtil.errorLogInfo("", TAG, e);
  8505. }
  8506. }
  8507. @Override
  8508. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  8509. try {
  8510. Log.i(TAG, "[MyVideoCallback] surfaceChanged!!");
  8511. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8512. mMyCamera.startPreview();
  8513. } else {
  8514. Log.w(TAG, "[MyVideoCallback] surfaceChanged!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8515. }
  8516. } catch (RuntimeException re) {
  8517. LogUtil.errorLogInfo("", TAG, re);
  8518. }
  8519. catch (Exception e) {
  8520. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceChanged(SurfaceHolder holder, int format, int width, int height)");
  8521. LogUtil.errorLogInfo("", TAG, e);
  8522. // if (getWallPadCameraUsage()) sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET, 0, 0, 3000); // 3초후 카메라 서비스를 재실행한다.
  8523. }
  8524. }
  8525. @Override
  8526. public void surfaceDestroyed(SurfaceHolder holder) {
  8527. try {
  8528. Log.i(TAG, "[MyVideoCallback] surfaceDestroyed!!");
  8529. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8530. mIOInterface.ctrlWallPadCamPower(false);
  8531. if (mMyCamera != null) {
  8532. mMyCamera.stopPreview();
  8533. mMyCamera.release();
  8534. mMyCamera = null;
  8535. }
  8536. } else {
  8537. Log.w(TAG, "[MyVideoCallback] surfaceDestroyed!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8538. }
  8539. } catch (RuntimeException re) {
  8540. LogUtil.errorLogInfo("", TAG, re);
  8541. }
  8542. catch (Exception e) {
  8543. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  8544. LogUtil.errorLogInfo("", TAG, e);
  8545. }
  8546. }
  8547. };
  8548. private boolean getWallPadCameraUsage() {
  8549. boolean bResult = false;
  8550. try {
  8551. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  8552. int nResult = mWallpadDeviceSet.GetDeviceSetted("월패드카메라");
  8553. mWallpadDeviceSet.closeDB();
  8554. if (nResult == WallpadDeviceSet.DEV_DATA_ENABLE) bResult = true;
  8555. else bResult = false;
  8556. } catch (RuntimeException re) {
  8557. LogUtil.errorLogInfo("", TAG, re);
  8558. }
  8559. catch (Exception e) {
  8560. Log.e(TAG, "[Exception] getWallPadCameraUsage()");
  8561. LogUtil.errorLogInfo("", TAG, e);
  8562. }
  8563. Log.i(TAG, "[getWallPadCameraUsage] bResult [" + bResult + "]");
  8564. return bResult;
  8565. }
  8566. private void forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable) {
  8567. try {
  8568. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  8569. DBMGR.SetStrangerRecordingOnOff(bEnable);
  8570. DBMGR.closeDB();
  8571. } catch (RuntimeException re) {
  8572. LogUtil.errorLogInfo("", TAG, re);
  8573. }
  8574. catch (Exception e) {
  8575. Log.e(TAG, "[Exception] forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable)");
  8576. LogUtil.errorLogInfo("", TAG, e);
  8577. }
  8578. }
  8579. private void registerLCDKeeper() {
  8580. try {
  8581. Log.i(TAG, "[registerLCDKeeper] ===== START =====");
  8582. if (!bLCDKeeperUsage) {
  8583. Log.w(TAG, "[registerLCDKeeper] bLCDKeeperUsage is false!!!");
  8584. return;
  8585. }
  8586. if (Build.VERSION.SDK_INT < 24) {
  8587. Log.w(TAG, "[registerLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8588. return;
  8589. }
  8590. IMG_LCD_KEEPER = (ImageView) findViewById(R.id.view_lcdkeeper);
  8591. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8592. Log.i(TAG, "[registerLCDKeeper] ===== END =====");
  8593. } catch (RuntimeException re) {
  8594. LogUtil.errorLogInfo("", TAG, re);
  8595. }
  8596. catch (Exception e) {
  8597. Log.e(TAG, "[Exception] registerLCDKeeper()");
  8598. LogUtil.errorLogInfo("", TAG, e);
  8599. }
  8600. }
  8601. int LCDKEEPER_MODE_NONE = 0; // 동작중 아님
  8602. int LCDKEEPER_MODE_RESTROE = 1; // 복구모드
  8603. int LCDKEEPER_MODE_PROTECT = 2; // 보호모드
  8604. boolean bLCDBacklightPower = true; // LCD backlight on/off 여부 (true: on, false: off)
  8605. int nLCDKeeperRunMode = LCDKEEPER_MODE_NONE; // LCD Keeper 동작 모드 (0: 동작중 아님, 1: 복구모드, 2: 예방모드)
  8606. private void runLCDKeeper(int nKeeperMode) {
  8607. try {
  8608. if (!bLCDKeeperUsage) {
  8609. Log.w(TAG, "[registerLCDKeeper] bLCDKeeperUsage is false!!!");
  8610. return;
  8611. }
  8612. Log.i(TAG, "[runLCDKeeper] nKeeperMode [" + nKeeperMode +"], bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8613. if (Build.VERSION.SDK_INT < 24) {
  8614. Log.w(TAG, "[registerLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8615. return;
  8616. }
  8617. if (IMG_LCD_KEEPER == null) {
  8618. Log.w(TAG, "[runLCDKeeper] IMG_LCD_KEEPER is null!!");
  8619. return;
  8620. }
  8621. // check run mode
  8622. if (nLCDKeeperRunMode == nKeeperMode) {
  8623. // already run LCDKeeper!!
  8624. Log.w(TAG, "[runLCDKeeper] LCD Keeper mode is same -> Asis [" + nLCDKeeperRunMode + "], Tobe [" + nKeeperMode + "]");
  8625. return;
  8626. }
  8627. nLCDKeeperRunMode = nKeeperMode;
  8628. if (nKeeperMode == LCDKEEPER_MODE_NONE) {
  8629. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8630. }
  8631. else if (nKeeperMode == LCDKEEPER_MODE_RESTROE) {
  8632. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  8633. Glide.with(this).asGif().load(R.drawable.lcd_restore_1280).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8634. }
  8635. else {
  8636. Glide.with(this).asGif().load(R.drawable.lcd_restore_1024).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8637. }
  8638. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8639. }
  8640. else if (nKeeperMode == LCDKEEPER_MODE_PROTECT) {
  8641. IMG_LCD_KEEPER.setBackgroundColor(Color.BLACK);
  8642. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8643. }
  8644. else {
  8645. Log.w(TAG, "[runLCDKeeper] Not supported mode!! -> " + nKeeperMode);
  8646. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8647. }
  8648. } catch (RuntimeException re) {
  8649. LogUtil.errorLogInfo("", TAG, re);
  8650. }
  8651. catch (Exception e) {
  8652. Log.e(TAG, "[Exception] runLCDKeeper(int nKeeperMode)");
  8653. LogUtil.errorLogInfo("", TAG, e);
  8654. }
  8655. }
  8656. private void ctrlLCDKeeper() {
  8657. try {
  8658. if (!bLCDKeeperUsage) {
  8659. Log.w(TAG, "[ctrlLCDKeeper] bLCDKeeperUsage is false!!");
  8660. return;
  8661. }
  8662. if (Build.VERSION.SDK_INT < 24) {
  8663. Log.w(TAG, "[ctrlLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8664. return;
  8665. }
  8666. if (IMG_LCD_KEEPER == null) {
  8667. Log.w(TAG, "[ctrlLCDKeeper] IMG_LCD_KEEPER is null!!");
  8668. return;
  8669. }
  8670. Log.i(TAG, "[ctrlLCDKeeper] bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8671. if (bLCDBacklightPower) {
  8672. // backlight on시 lcd keeper를 비활성화 한다.
  8673. runLCDKeeper(LCDKEEPER_MODE_NONE);
  8674. }
  8675. else {
  8676. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) {
  8677. // LCD backlight off시, LCD protect 화면을 구동한다.
  8678. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8679. }
  8680. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) {
  8681. // LCD backlight off시, LCD restore 화면을 구동한다.
  8682. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8683. }
  8684. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  8685. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동하고, 나머지 시간에는 LCD protect 화면을 구동한다.
  8686. // 화면에 스모그 또는 미러 글라스 적용이 아닌 경우에는 LCD 보호모드(블랙)만 사용을 권장한다. (LCD RGBW rolling시 컬러가 화면에 비침)
  8687. Calendar LCDCal = Calendar.getInstance();
  8688. int nYear = LCDCal.get(Calendar.YEAR);
  8689. int nMonth = LCDCal.get(Calendar.MONTH) + 1;
  8690. int nDay = LCDCal.get(Calendar.DAY_OF_MONTH);
  8691. int nHour = LCDCal.get(Calendar.HOUR_OF_DAY);
  8692. Log.i(TAG, "[ctrlLCDKeeper] nYear [" + nYear +"], nMonth [" + nMonth +"], nDay [" + nDay +"], nHour [" + nHour +"]");
  8693. if (3 >= nHour && nHour >= 2) {
  8694. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동한다.
  8695. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8696. }
  8697. else {
  8698. // 새벽 2:00 ~ 3:59 이외의 시간에는 LCD protect 화면을 구동한다.
  8699. if (nYear == 2020 && ((nMonth < 8 && nDay < 20) || (nMonth < 7))) {
  8700. // 단, 이미 증상이 발생한 현장의 LCD 복구를 위해 2020년 7월 19일까지는 protection 화면 대신 restore 화면을 구동한다.
  8701. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8702. }
  8703. else {
  8704. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8705. }
  8706. }
  8707. }
  8708. }
  8709. } catch (RuntimeException re) {
  8710. LogUtil.errorLogInfo("", TAG, re);
  8711. }
  8712. catch (Exception e) {
  8713. Log.e(TAG, "[Exception] ctrlLCDKeeper()");
  8714. LogUtil.errorLogInfo("", TAG, e);
  8715. }
  8716. }
  8717. private boolean checkTranslucentGlassUsage() {
  8718. try {
  8719. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  8720. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  8721. || Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2
  8722. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  8723. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410
  8724. || Version.getModelType() == MODEL_TYPE.IHN_T1010 || Version.getModelType() == MODEL_TYPE.IHN_T1010_I
  8725. || Version.getModelType() == MODEL_TYPE.IHN_1303_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  8726. return true;
  8727. }
  8728. else return false;
  8729. } catch (RuntimeException re) {
  8730. LogUtil.errorLogInfo("", TAG, re);
  8731. return false;
  8732. }
  8733. catch (Exception e) {
  8734. Log.e(TAG, "[Exception] checkTranslucentGlassUsage()");
  8735. LogUtil.errorLogInfo("", TAG, e);
  8736. return false;
  8737. }
  8738. }
  8739. /**
  8740. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8741. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8742. * Jeff, 2020.09.07
  8743. * @return true: LCD backlight On, false: LCD backlight Off
  8744. */
  8745. public boolean checkLCDOnByCMD() {
  8746. try {
  8747. Runtime mRuntime = Runtime.getRuntime();
  8748. Process mProcess;
  8749. String cmd = "getprop persist.sys.lcdcon";
  8750. mProcess = mRuntime.exec(cmd);
  8751. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8752. String line;
  8753. String strResult = null;
  8754. while ((line = br.readLine()) != null) {
  8755. strResult = line;
  8756. }
  8757. if(strResult!=null)
  8758. {
  8759. if (strResult.equals("0")) {
  8760. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8761. return true;
  8762. }
  8763. else if (strResult.equals("1")) {
  8764. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8765. return false;
  8766. }
  8767. else {
  8768. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8769. return false;
  8770. }
  8771. }
  8772. else return false;
  8773. } catch (RuntimeException re) {
  8774. LogUtil.errorLogInfo("", TAG, re);
  8775. return false;
  8776. }
  8777. catch (Exception e) {
  8778. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8779. LogUtil.errorLogInfo("", TAG, e);
  8780. return false;
  8781. }
  8782. }
  8783. /**
  8784. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8785. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8786. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8787. */
  8788. public boolean getCompareBSPVersion(String strVer) {
  8789. try {
  8790. StringBuilder strBSPVersion = new StringBuilder();
  8791. StringBuffer sysInfoBuffer = new StringBuffer();
  8792. sysInfoBuffer.append(Build.DISPLAY);
  8793. strBSPVersion.append(sysInfoBuffer.toString());
  8794. String result = strBSPVersion.toString();
  8795. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8796. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8797. Date date = simpleDateFormat.parse(result);
  8798. Date standardDate = simpleDateFormat.parse(strVer); // 비교 기준 BSP 버전
  8799. if (date.compareTo(standardDate) >= 0) {
  8800. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8801. return true;
  8802. }
  8803. } catch (RuntimeException re) {
  8804. LogUtil.errorLogInfo("", TAG, re);
  8805. }
  8806. catch (Exception e) {
  8807. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8808. LogUtil.errorLogInfo("", TAG, e);
  8809. }
  8810. return false;
  8811. }
  8812. /**
  8813. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 생겨 카메라 화면이 안나오는 경우 발생
  8814. * WallPadMain에서 부팅시 카메라를 확인하여 Exception이 발생하는 경우
  8815. * 카메라 서비스를 재실행한다.
  8816. * (Edited by jeff, 2020.09.08)
  8817. */
  8818. public void resetCameraService() {
  8819. try {
  8820. Log.e(TAG, "[resetCameraService] start!!");
  8821. Runtime mRuntime = Runtime.getRuntime();
  8822. String cmd = "setprop persist.sys.fakeactivitydel 1";
  8823. mRuntime.exec(cmd);
  8824. } catch (RuntimeException re) {
  8825. LogUtil.errorLogInfo("", TAG, re);
  8826. }
  8827. catch (Exception e) {
  8828. Log.e(TAG, "[Exception] resetCameraService()");
  8829. LogUtil.errorLogInfo("", TAG, e);
  8830. }
  8831. }
  8832. /**
  8833. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 발생하여
  8834. * 카메라서비스 정상동작 여부를 확인하기위한 함수를 정의한다.
  8835. * 카메라서비스 정상: 정상적으로 카메라가 open되며, camera object가 null이 아니면 카메라를 release한다.
  8836. * 카메라 서비스 비정상: 카메라 open시 Exception이 발생하며 resetCameraService() 함수를 실행하여 카메라서비스를 재실행한다.
  8837. * (Edited by jeff, 2020.09.08)
  8838. */
  8839. public void checkCameraLoading() {
  8840. try {
  8841. Camera checkCamera = Camera.open();
  8842. if (checkCamera != null) {
  8843. Log.e(TAG, "[checkCameraLoading] checkCamera is not null!!");
  8844. checkCamera.release();
  8845. }
  8846. else {
  8847. Log.e(TAG, "[checkCameraLoading] checkCamera is null!!");
  8848. resetCameraService();
  8849. }
  8850. } catch (RuntimeException re) {
  8851. LogUtil.errorLogInfo("", TAG, re);
  8852. resetCameraService();
  8853. }
  8854. catch (Exception e) {
  8855. Log.e(TAG, "[Exception] checkCameraLoading()");
  8856. LogUtil.errorLogInfo("", TAG, e);
  8857. resetCameraService();
  8858. }
  8859. }
  8860. private synchronized void FileDelete(File file)
  8861. {
  8862. if(file!=null && file.exists())
  8863. {
  8864. file.delete();
  8865. }
  8866. }
  8867. /***************************************************************************************
  8868. * 거동수상자 녹화 시나리오 수정 (통화 앱 => 메인 앱에서 녹화)
  8869. * > 거동수상자 발생시 반투명 이미지 위에 거동수상자 녹화중 문구 표기 + 화면보기 버튼
  8870. * > 화면보기 버튼 클릭시 숨어있던 영상 (SurfaceView) 이동 (사용자에게 보이도록)
  8871. **************************************************************************************/
  8872. public boolean getStrangerRecordingManagerSetting() {
  8873. boolean bResult = false;
  8874. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  8875. try {
  8876. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  8877. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  8878. mWallpadDeviceSet.closeDB();
  8879. if (nFrontCam[0] == 1) {
  8880. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  8881. if (bRecord) bResult = true;
  8882. else bResult = false;
  8883. }
  8884. else bResult = false;
  8885. }
  8886. else bResult = false;
  8887. } catch (RuntimeException re) {
  8888. LogUtil.errorLogInfo("", TAG, re);
  8889. mWallpadDeviceSet.closeDB();
  8890. }
  8891. catch (Exception e) {
  8892. mWallpadDeviceSet.closeDB();
  8893. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  8894. //e.printStackTrace();
  8895. LogUtil.errorLogInfo("", TAG, e);
  8896. }
  8897. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  8898. return bResult;
  8899. }
  8900. private boolean getStrangerRecordingUserSetting() {
  8901. boolean bResult = false;
  8902. WallpadStatusData DBMGR = new WallpadStatusData(this);
  8903. try {
  8904. bResult = DBMGR.GetStrangerRecordingOnOff();
  8905. DBMGR.closeDB();
  8906. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  8907. } catch (RuntimeException re) {
  8908. LogUtil.errorLogInfo("", TAG, re);
  8909. DBMGR.closeDB();
  8910. bResult = false;
  8911. }
  8912. catch (Exception e) {
  8913. DBMGR.closeDB();
  8914. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  8915. //e.printStackTrace();
  8916. LogUtil.errorLogInfo("", TAG, e);
  8917. bResult = false;
  8918. }
  8919. return bResult;
  8920. }
  8921. private void registerNoticeStrangerRecord() {
  8922. try {
  8923. Log.d(TAG, "[registerNoticeStrangerRecord]");
  8924. IMG_NOTICE_STRANGER_RECORD = (ImageView) findViewById(R.id.view_noticerecord);
  8925. IMG_NOTICE_STRANGER_RECORD.setVisibility(View.INVISIBLE);
  8926. IMG_NOTICE_STRANGER_RECORD.setClickable(true);
  8927. TXT_NOTICE_STRANGER_RECORD = (TextView) findViewById(R.id.text_noticerecord);
  8928. TXT_NOTICE_STRANGER_RECORD.setVisibility(View.INVISIBLE);
  8929. BTN_STRANGER_RECORD_VIEW = (Button) findViewById(R.id.btn_noticerecord_ok);
  8930. BTN_STRANGER_RECORD_VIEW.setVisibility(View.INVISIBLE);
  8931. BTN_STRANGER_RECORD_VIEW.setOnClickListener(new View.OnClickListener() {
  8932. @Override
  8933. public void onClick(View view) {
  8934. Log.d(TAG, "BTN_STRANGER_RECORD_VIEW Click!!");
  8935. showFrontVideo(true);
  8936. }
  8937. });
  8938. BTN_STRANGER_RECORD_CANCEL = (Button) findViewById(R.id.btn_noticerecord_cancel);
  8939. BTN_STRANGER_RECORD_CANCEL.setVisibility(View.INVISIBLE);
  8940. BTN_STRANGER_RECORD_CANCEL.setOnClickListener(new View.OnClickListener() {
  8941. @Override
  8942. public void onClick(View view) {
  8943. Log.d(TAG, "BTN_STRANGER_RECORD_CANCEL Click!!");
  8944. stopStrangerRecord(false);
  8945. showFrontCam(false);
  8946. runNoticeStrangerRecord(false);
  8947. Intent intent = new Intent(); // 녹화 종료 BR 전송
  8948. intent.setAction(define.NOTIFY_ACNAME);
  8949. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_RECORD_STRANGER);
  8950. getApplicationContext().sendBroadcast(intent);
  8951. intent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  8952. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK);
  8953. getApplicationContext().sendBroadcast(intent);
  8954. }
  8955. });
  8956. } catch (RuntimeException re) {
  8957. LogUtil.errorLogInfo("", TAG, re);
  8958. }
  8959. catch (Exception e) {
  8960. Log.e(TAG, "[Exception] registerNoticeStrangerRecord()");
  8961. LogUtil.errorLogInfo("", TAG, e);
  8962. }
  8963. }
  8964. private void runNoticeStrangerRecord(boolean bRun) {
  8965. try {
  8966. Log.d(TAG, "[runNoticeStrangerRecord] === START === bRun [" + bRun + "]");
  8967. if (IMG_NOTICE_STRANGER_RECORD == null || TXT_NOTICE_STRANGER_RECORD == null || BTN_STRANGER_RECORD_VIEW == null || BTN_STRANGER_RECORD_CANCEL == null) {
  8968. Log.w(TAG, "[runNoticeStrangerRecord] NoticeView is null!!");
  8969. registerNoticeStrangerRecord();
  8970. }
  8971. if (bRun) {
  8972. IMG_NOTICE_STRANGER_RECORD.setVisibility(View.VISIBLE);
  8973. TXT_NOTICE_STRANGER_RECORD.setVisibility(View.VISIBLE);
  8974. BTN_STRANGER_RECORD_VIEW.setVisibility(View.VISIBLE);
  8975. BTN_STRANGER_RECORD_CANCEL.setVisibility(View.VISIBLE);
  8976. } else {
  8977. IMG_NOTICE_STRANGER_RECORD.setVisibility(View.INVISIBLE);
  8978. TXT_NOTICE_STRANGER_RECORD.setVisibility(View.INVISIBLE);
  8979. BTN_STRANGER_RECORD_VIEW.setVisibility(View.INVISIBLE);
  8980. BTN_STRANGER_RECORD_CANCEL.setVisibility(View.INVISIBLE);
  8981. }
  8982. } catch (RuntimeException re) {
  8983. LogUtil.errorLogInfo("", TAG, re);
  8984. } catch (Exception e) {
  8985. Log.e(TAG, "[Exception] runNoticeStrangerRecord()");
  8986. LogUtil.errorLogInfo("", TAG, e);
  8987. }
  8988. }
  8989. // 영상 녹화 시작
  8990. private boolean startStrangerRecord() {
  8991. try {
  8992. Log.d(TAG, "[startStrangerRecord] bRecordStatus [" + bRecordStatus + "]");
  8993. if (mRecordTimer != null) {
  8994. mRecordTimer.cancel();
  8995. mIOInterface.ctrlLcdWakeUp(); // 녹화 시작시 LCD On
  8996. WallpadStatusData SetData = new WallpadStatusData(mContext);
  8997. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  8998. SetData.closeDB();
  8999. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  9000. // 녹화 시작
  9001. if (getRemoteCallUse()) sendHandlerMsgDelayed(HANDLERMSG.MEDIA_RECORD_START_REMOTECALL, 0, 0, 0);
  9002. else sendHandlerMsgDelayed(HANDLERMSG.MEDIA_RECORD_START, 0, 0, 0);
  9003. return true;
  9004. } else Log.w(TAG, "[startStrangerRecord] mRecordTime is null!");
  9005. } catch (RuntimeException re) {
  9006. LogUtil.errorLogInfo("", TAG, re);
  9007. } catch (Exception e) {
  9008. Log.e(TAG, "[Exception] startStrangerRecord()");
  9009. //e.printStackTrace();
  9010. LogUtil.errorLogInfo("", TAG, e);
  9011. }
  9012. return false;
  9013. }
  9014. /** 영상 녹화 종료
  9015. * - 녹화 중 문열림 발생시 영상을 저장하지 않으므로 임시 폴더에 저장 후 추후 판별함
  9016. * @param bTemp 임시 폴더 저장 여부
  9017. */
  9018. private void stopStrangerRecord(boolean bTemp) {
  9019. try {
  9020. Log.d(TAG, "[stopStrangerRecord] bRecordStatus [" + bRecordStatus + "], bTemp [" + bTemp + "]");
  9021. if (bRecordStatus) {
  9022. bRecordStatus = false;
  9023. mediaStopRecord();
  9024. if (mCurRecordTime <= 3) {
  9025. File tempFile = new File(VIDEO_TEMP_PATH);
  9026. if (tempFile.isFile()) {
  9027. tempFile.delete();
  9028. }
  9029. }
  9030. saveStrangerRecordFile(bTemp);
  9031. }
  9032. } catch (RuntimeException re) {
  9033. LogUtil.errorLogInfo("", TAG, re);
  9034. } catch (Exception e) {
  9035. Log.e(TAG, "[Exception] stopStrangerRecord(boolean bSave)");
  9036. //e.printStackTrace();
  9037. LogUtil.errorLogInfo("", TAG, e);
  9038. }
  9039. }
  9040. // 영상 녹화 파일 저장
  9041. private void saveStrangerRecordFile(boolean bTemp) {
  9042. try {
  9043. Log.d(TAG, "[saveStrangerRecordFile] bTemp [" + bTemp + "]");
  9044. if (!getRemoteCallUse()) { // 방문객원격통화를 사용하는 경우에는 월패드에서 파일 저장하지 않음
  9045. reOrderRecordFile(); // 최신순으로 정렬하여 오래된 영상 삭제
  9046. File tempFile = new File(VIDEO_TEMP_PATH);
  9047. Calendar data = Calendar.getInstance();
  9048. String strDate = String.format("%04d%02d%02d", data.get(Calendar.YEAR), data.get(Calendar.MONTH) + 1, data.get(Calendar.DATE));
  9049. int nHour = 0;
  9050. if (data.get(Calendar.AM_PM) == 1) nHour = 12;
  9051. String strTime = String.format("%02d%02d%02d", data.get(Calendar.HOUR) + nHour, data.get(Calendar.MINUTE), data.get(Calendar.SECOND));
  9052. String strPath = "";
  9053. if (bTemp) strPath = VISITOR_VIDEO_TEMP_PATH + "VisitorVideo_" + strDate + "_" + strTime + ".mp4";
  9054. else strPath = VISITOR_VIDEO_PATH + "VisitorVideo_" + strDate + "_" + strTime + ".mp4";
  9055. File recordingFile = new File(strPath);
  9056. if (tempFile.isFile()) moveRecordFile(tempFile, recordingFile);
  9057. }
  9058. Intent intent = new Intent(); // 녹화 종료 BR 전송
  9059. intent.setAction(define.NOTIFY_ACNAME);
  9060. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_RECORD_STRANGER);
  9061. getContext().sendBroadcast(intent);
  9062. } catch (RuntimeException re) {
  9063. LogUtil.errorLogInfo("", TAG, re);
  9064. } catch (Exception e) {
  9065. Log.e(TAG, "[Exception] saveRecordingFile()");
  9066. //e.printStackTrace();
  9067. LogUtil.errorLogInfo("", TAG, e);
  9068. }
  9069. }
  9070. private void moveRecordFile(File fOri, File fTarget) {
  9071. try {
  9072. Log.d(TAG, "[moveRecordFile] fOri.getPath [" + fOri.getPath() + "], fTarget.getPath [" + fTarget.getPath() + "]");
  9073. if (!fTarget.isFile()) {
  9074. File fParent = new File(fTarget.getParent());
  9075. if (!fParent.exists()) {
  9076. fParent.mkdir();
  9077. }
  9078. } else Log.w(TAG, "[moveRecordFile] " + fTarget.getPath() + " is not File!!");
  9079. fOri.renameTo(fTarget);
  9080. } catch (RuntimeException re) {
  9081. LogUtil.errorLogInfo("", TAG, re);
  9082. } catch (Exception e) {
  9083. Log.e(TAG, "[Exception] moveRecordFile(File fOri, File fTarget)");
  9084. //e.printStackTrace();
  9085. LogUtil.errorLogInfo("", TAG, e);
  9086. }
  9087. }
  9088. private void reOrderRecordFile() {
  9089. try {
  9090. String MAKE_BESTIN_PATH = define.BESTIN_LOCATION;
  9091. File makeFolder = new File(MAKE_BESTIN_PATH);
  9092. if (!makeFolder.isDirectory()) {
  9093. boolean bRet = makeFolder.mkdir();
  9094. Log.d(TAG, "[reOrderRecordFile] makeFolder [bRet1] " + bRet);
  9095. }
  9096. makeFolder = new File(VISITOR_VIDEO_PATH);
  9097. if (!makeFolder.isDirectory()) {
  9098. boolean bRet = makeFolder.mkdir();
  9099. Log.d(TAG, "[reOrderRecordFile] makeFolder [bRet2] " + bRet);
  9100. }
  9101. File folderCheck = new File(VISITOR_VIDEO_PATH);
  9102. if (folderCheck.isDirectory()) {
  9103. File[] arrFile = folderCheck.listFiles();
  9104. if (arrFile != null) {
  9105. if (arrFile.length < VISITOR_VIDEO_MAX_COUNT) return;
  9106. else {
  9107. Date[] tempFile = new Date[arrFile.length];
  9108. Log.d(TAG, "[reOrderRecordFile(1)] arrFile.length [" + arrFile.length + "]");
  9109. for (int i = 0; i < arrFile.length; i++) {
  9110. File file = arrFile[i];
  9111. int startPos = file.getName().indexOf("_");
  9112. int endPos = file.getName().indexOf(".");
  9113. String strDate = file.getName().substring(startPos + 1, endPos).replace("_", "");
  9114. Calendar calendar = Calendar.getInstance();
  9115. calendar.set(Integer.parseInt(strDate.substring(0, 4)), Integer.parseInt(strDate.substring(4, 6)), Integer.parseInt(strDate.substring(6, 8)), Integer.parseInt(strDate.substring(8, 10)), Integer.parseInt(strDate.substring(10, 12)), Integer.parseInt(strDate.substring(12, 14)));
  9116. tempFile[i] = calendar.getTime();
  9117. }
  9118. Date min = tempFile[0];
  9119. int idx = 0;
  9120. for (int i = 0; i < tempFile.length; i++) {
  9121. if (tempFile[i].compareTo(min) < 0) {
  9122. idx = i;
  9123. Log.d(TAG, "[reOrderRecordFile] idx [" + idx + "]");
  9124. }
  9125. }
  9126. File file = new File(arrFile[idx].getPath());
  9127. if (file.isFile()) {
  9128. file.delete();
  9129. Log.d(TAG, "[reOrderRecordFile] FILE [" + arrFile[idx].getPath() + "] is deleted!!");
  9130. }
  9131. }
  9132. }
  9133. } else {
  9134. Log.w(TAG, "[reOrderRecordFile] " + folderCheck.getPath() + " is not directory!!");
  9135. }
  9136. } catch (RuntimeException re) {
  9137. LogUtil.errorLogInfo("", TAG, re);
  9138. } catch (Exception e) {
  9139. Log.e(TAG, "[Exception] reOrderRecordFile()");
  9140. //e.printStackTrace();
  9141. LogUtil.errorLogInfo("", TAG, e);
  9142. }
  9143. }
  9144. /**
  9145. * 임시 폴더에 있는 거동수상자 영상 삭제
  9146. * 현관 통화 중 문열림 발생시 영상 삭제
  9147. */
  9148. private void deleteTempRecordFile() {
  9149. try {
  9150. Log.d(TAG, "[deleteTempRecordFile]");
  9151. File folder = new File(VISITOR_VIDEO_TEMP_PATH);
  9152. if (folder.exists()) {
  9153. File[] listFiles = folder.listFiles();
  9154. int fileCnt = listFiles.length;
  9155. Log.d(TAG, "[deleteTempRecordFile] fileCnt [" + fileCnt + "]");
  9156. for (int i = 0; i < fileCnt; i++) {
  9157. Log.d(TAG, "[deleteTempRecordFile] listFiles [" + i + "] is deleted!!!");
  9158. listFiles[i].delete();
  9159. }
  9160. if (folder.isDirectory()) {
  9161. Log.d(TAG, "[deleteTempRecordFile] Directory Deleted!!!");
  9162. folder.delete();
  9163. }
  9164. }
  9165. } catch (RuntimeException re) {
  9166. LogUtil.errorLogInfo("", TAG, re);
  9167. } catch (Exception e) {
  9168. Log.e(TAG, "[Exception] deleteTempRecordFile()");
  9169. //e.printStackTrace();
  9170. LogUtil.errorLogInfo("", TAG, e);
  9171. }
  9172. }
  9173. /**
  9174. * 임시 폴더에 있는 거동수상자 영상 옮기기
  9175. * 현관 통화가 문열림 없이 종료되는 경우 임시 폴더에서 일반 폴더로 파일 이동
  9176. */
  9177. private void moveTempRecordFile() {
  9178. try {
  9179. Log.d(TAG, "[moveTempRecordFile]");
  9180. File tempFolder = new File(VISITOR_VIDEO_TEMP_PATH);
  9181. if (tempFolder.exists()) {
  9182. File[] listFiles = tempFolder.listFiles();
  9183. int fileCnt = listFiles.length;
  9184. Log.d(TAG, "[moveTempRecordFile] fileCnt [" + fileCnt + "]");
  9185. for (int i = 0; i < fileCnt; i++) {
  9186. String filePath = listFiles[i].getPath().replace("/temp", "");
  9187. Log.d(TAG, "[moveTempRecordFile] filePath [" + filePath + "]");
  9188. File file = new File(filePath);
  9189. listFiles[i].renameTo(file);
  9190. }
  9191. if (tempFolder.isDirectory()) {
  9192. Log.d(TAG, "[moveTempRecordFile] Directory Deleted!!!");
  9193. tempFolder.delete();
  9194. }
  9195. } else {
  9196. Log.w(TAG, "[moveTempRecordFile] " + VISITOR_VIDEO_TEMP_PATH + " directory not exist!!!");
  9197. }
  9198. } catch (RuntimeException re) {
  9199. LogUtil.errorLogInfo("", TAG, re);
  9200. } catch (Exception e) {
  9201. Log.e(TAG, "[Exception] moveTempRecordFile()");
  9202. //e.printStackTrace();
  9203. LogUtil.errorLogInfo("", TAG, e);
  9204. }
  9205. }
  9206. // 영상 녹화시간 타이머 구동
  9207. private void checkRecordTimer() {
  9208. try {
  9209. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  9210. RECORD_TIME = DBMGR.GetSmartDoorCamRecordTime();
  9211. DBMGR.closeDB();
  9212. Log.d(TAG, "[checkRecordTimer] RECORD_TIME [" + RECORD_TIME + "]");
  9213. mCurRecordTime = 0;
  9214. if (RECORD_TIME > 0) {
  9215. mRecordTimer = new CountDownTimer((RECORD_TIME + 1) * 1000, 1000) {
  9216. @Override
  9217. public void onTick(long millisUntilFinished) {
  9218. if (bRecordStatus) {
  9219. mCurRecordTime++;
  9220. Log.d(TAG, "[checkRecordTimer] mCurRecordTime [" + mCurRecordTime + "]");
  9221. }
  9222. }
  9223. @Override
  9224. public void onFinish() {
  9225. Log.d(TAG, "[checkRecordTimer] onFinish!! bRemoteCall [" + getRemoteCallUse() + "]");
  9226. if (getRemoteCallUse()) {
  9227. mediaStopRecord();
  9228. showFrontCam(false);
  9229. } else {
  9230. stopStrangerRecord(false);
  9231. showFrontCam(false);
  9232. runNoticeStrangerRecord(false);
  9233. }
  9234. Intent intent = new Intent(); // 녹화 종료 BR 전송
  9235. intent.setAction(define.NOTIFY_ACNAME);
  9236. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_RECORD_STRANGER);
  9237. getApplicationContext().sendBroadcast(intent);
  9238. intent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9239. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK);
  9240. getApplicationContext().sendBroadcast(intent);
  9241. }
  9242. };
  9243. } else {
  9244. Log.w(TAG, "[checkRecordTimer] Invalid RECORD TIME!! [" + RECORD_TIME + "]");
  9245. }
  9246. } catch (RuntimeException re) {
  9247. LogUtil.errorLogInfo("", TAG, re);
  9248. } catch (Exception e) {
  9249. Log.e(TAG, "[Exception] checkRecordTimer()");
  9250. //e.printStackTrace();
  9251. LogUtil.errorLogInfo("", TAG, e);
  9252. }
  9253. }
  9254. // 영상 녹화 타이머 해제
  9255. private void resetRecordTimer() {
  9256. try {
  9257. Log.d(TAG, "[resetRecordTimer]");
  9258. if (mRecordTimer != null) {
  9259. mRecordTimer.cancel();
  9260. mRecordTimer = null;
  9261. }
  9262. } catch (RuntimeException re) {
  9263. LogUtil.errorLogInfo("", TAG, re);
  9264. } catch (Exception e) {
  9265. Log.e(TAG, "[Exception] resetRecordTimer()");
  9266. //e.printStackTrace();
  9267. LogUtil.errorLogInfo("", TAG, e);
  9268. }
  9269. }
  9270. private void mediaStartRecord() {
  9271. try {
  9272. Log.d(TAG, "[mediaStartRecord]");
  9273. if (mMediaRecorder != null) {
  9274. mMediaRecorder.stop();
  9275. mMediaRecorder.reset();
  9276. mMediaRecorder.release();
  9277. mMediaRecorder = null;
  9278. }
  9279. mFrontCamOpenCheckHandler.sendEmptyMessage(0); // camera open check 이후 녹화 시작
  9280. } catch (RuntimeException re) {
  9281. LogUtil.errorLogInfo("", TAG,re);
  9282. bRecordStatus = false;
  9283. } catch (Throwable t) {
  9284. bRecordStatus = false;
  9285. Log.e(TAG, "[Exception] mediaStartRecord()");
  9286. //t.printStackTrace();
  9287. LogUtil.errorLogInfo("", TAG, t);
  9288. }
  9289. }
  9290. private void mediaStopRecord() {
  9291. try {
  9292. Log.d(TAG, "[mediaStopRecord]");
  9293. bRecordDelay = true;
  9294. Message msg = recordDelayHandler.obtainMessage();
  9295. recordDelayHandler.sendMessageDelayed(msg, 90 * 1000); // 녹화 종료 후 1분 30초 동안 녹화를 막는다.
  9296. bRecordStatus = false; // 녹화 종료
  9297. resetRecordTimer();
  9298. if (mMediaRecorder != null) {
  9299. mMediaRecorder.stop();
  9300. mMediaRecorder.reset();
  9301. mMediaRecorder.release();
  9302. mMediaRecorder = null;
  9303. }
  9304. showFrontVideo(false);
  9305. FrontVideoLayout.removeView(FrontVideoSurface);
  9306. } catch (RuntimeException re) {
  9307. LogUtil.errorLogInfo("", TAG, re);
  9308. } catch (Exception e) {
  9309. Log.e(TAG, "[Exception] mediaStopRecord()");
  9310. //e.printStackTrace();
  9311. LogUtil.errorLogInfo("", TAG, e);
  9312. }
  9313. }
  9314. // 영상 오류 발생하였을 경우 설정 초기화
  9315. private void resetRecordSetting() {
  9316. try {
  9317. Log.d(TAG, "[resetRecordSetting]");
  9318. runNoticeStrangerRecord(false);
  9319. if (mMediaRecorder != null) {
  9320. mMediaRecorder.release();
  9321. mMediaRecorder = null;
  9322. }
  9323. resetRecordTimer();
  9324. bRecordStatus = false;
  9325. } catch (RuntimeException re) {
  9326. LogUtil.errorLogInfo("", TAG, re);
  9327. } catch (Exception e) {
  9328. Log.e(TAG, "[Exception] resetRecordSetting()");
  9329. //e.printStackTrace();
  9330. LogUtil.errorLogInfo("", TAG, e);
  9331. }
  9332. }
  9333. // 현관카메라 종류
  9334. private int getDoorCamType() {
  9335. int doorCamType = WallpadDeviceSet.DOORTYPE_NONE;
  9336. try {
  9337. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  9338. int[] anFrontCameraType = deviceSet.Get_RFDoorCAM_Info(); // 현관카메라 종류
  9339. deviceSet.closeDB();
  9340. if (anFrontCameraType != null) {
  9341. doorCamType = anFrontCameraType[1];
  9342. Log.d(TAG, "[mFrontCamOpenCheckHandler] doorCamType [" + doorCamType + "]");
  9343. }
  9344. } catch (RuntimeException re) {
  9345. LogUtil.errorLogInfo("", TAG, re);
  9346. }
  9347. catch (Exception e) {
  9348. Log.e(TAG, "[Exception] getDoorCamType()");
  9349. LogUtil.errorLogInfo("", TAG, e);
  9350. }
  9351. return doorCamType;
  9352. }
  9353. // 현관카메라 거동수상자 감지시간
  9354. private byte getSmartDoorCamDuration() {
  9355. try {
  9356. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getContext());
  9357. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  9358. wallpadDeviceSet.closeDB();
  9359. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  9360. return duration;
  9361. } catch (RuntimeException re) {
  9362. LogUtil.errorLogInfo("", TAG, re);
  9363. }
  9364. catch (Exception e) {
  9365. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  9366. //e.printStackTrace();
  9367. LogUtil.errorLogInfo("", TAG, e);
  9368. }
  9369. return (byte) 0x05;
  9370. }
  9371. // 방문객원격통화 사용 여부
  9372. private boolean getRemoteCallUse() {
  9373. try {
  9374. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  9375. String[] astrRemoteCall = deviceSet.GetSettingData("방문객원격통화"); // 방문객 원격통화 솔루션
  9376. deviceSet.closeDB();
  9377. boolean bRemoteCall = false;
  9378. if (astrRemoteCall != null) {
  9379. if (astrRemoteCall[1].contains("방문객원격통화")) {
  9380. if (astrRemoteCall[1].contains("사용함")) bRemoteCall = true;
  9381. }
  9382. }
  9383. return bRemoteCall;
  9384. } catch (RuntimeException re) {
  9385. LogUtil.errorLogInfo("", TAG, re);
  9386. return false;
  9387. }
  9388. catch (Exception e) {
  9389. Log.e(TAG, "[Exception] getRemoteCallUse()");
  9390. LogUtil.errorLogInfo("", TAG, e);
  9391. return false;
  9392. }
  9393. }
  9394. SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  9395. // 스마트현관카메라 MODE 제어
  9396. private void ctrlSmartIOTCamStatusMode(byte mode) {
  9397. try {
  9398. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  9399. if (mSmartKeyRfDoorAPI != null) {
  9400. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  9401. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  9402. }
  9403. else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  9404. } catch (RuntimeException re) {
  9405. LogUtil.errorLogInfo("", TAG, re);
  9406. }
  9407. catch (Exception e) {
  9408. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  9409. //e.printStackTrace();
  9410. LogUtil.errorLogInfo("", TAG, e);
  9411. }
  9412. }
  9413. // 스마트현관카메라 LED 상태 제어
  9414. private void ctrlSmartIOTCamLEDMode(byte mode) {
  9415. try {
  9416. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  9417. if (mSmartKeyRfDoorAPI != null) {
  9418. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  9419. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  9420. }
  9421. else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  9422. } catch (RuntimeException re) {
  9423. LogUtil.errorLogInfo("", TAG, re);
  9424. }
  9425. catch (Exception e) {
  9426. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  9427. //e.printStackTrace();
  9428. LogUtil.errorLogInfo("", TAG, e);
  9429. }
  9430. }
  9431. ////////////////////////////////////////////////
  9432. // 현관카메라, Surfaceview 구성
  9433. ////////////////////////////////////////////////
  9434. Camera mFrontCamera;
  9435. RelativeLayout FrontSurfaceLayout;
  9436. RelativeLayout FrontVideoLayout;
  9437. SurfaceHolder FrontVideoHolder;
  9438. SurfaceView FrontVideoSurface;
  9439. private void initFrontVideoLayout() {
  9440. try {
  9441. if (getDoorCamType() != WallpadDeviceSet.DOORTYPE_IOT_SMART && getDoorCamType() != WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART && getDoorCamType() != WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) return;
  9442. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  9443. if (FrontSurfaceLayout == null) {
  9444. Log.d(TAG, "[initFrontVideoLayout] FrontSurfaceLayout Created!!! === nViewFlipperIndex [" + nViewFlipperIndex + "]");
  9445. FrontSurfaceLayout = new RelativeLayout(this);
  9446. RelativeLayout layout = MainLayout;
  9447. if (nViewFlipperIndex == 0) layout = MainLayout;
  9448. else if (nViewFlipperIndex == 1) layout = SubLayout_01;
  9449. else if (nViewFlipperIndex == 2) layout = SubLayout_02;
  9450. WpadUtil.LayoutRegistration(layout, FrontSurfaceLayout, WpadScale.getWidthPixels(), WpadScale.getWidthPixels(), 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  9451. }
  9452. FrontVideoLayout = new RelativeLayout(mContext);
  9453. WpadUtil.LayoutRegistration(FrontSurfaceLayout, FrontVideoLayout, 1024, 600, 0, 0, ID.MAINACTIVITY.LAYOUT.FRONTVIDEO);
  9454. FrontVideoSurface = new SurfaceView(mContext);
  9455. FrontVideoHolder = FrontVideoSurface.getHolder();
  9456. WpadRelativeLayoutParams FrontVideoParams;
  9457. FrontVideoParams = new WpadRelativeLayoutParams(480, 360);
  9458. FrontVideoParams.setMargins(280, 115, 0, 0);
  9459. FrontVideoLayout.addView(FrontVideoSurface, FrontVideoParams);
  9460. FrontVideoLayout.setVisibility(View.INVISIBLE);
  9461. FrontVideoSurface.getHolder().addCallback(FrontVideoCallback);
  9462. FrontVideoSurface.setZOrderOnTop(true);
  9463. } catch (RuntimeException re) {
  9464. LogUtil.errorLogInfo("", TAG, re);
  9465. } catch (Exception e) {
  9466. Log.e(TAG, "[Exception] initFrontVideoLayout()");
  9467. //e.printStackTrace();
  9468. LogUtil.errorLogInfo("", TAG, e);
  9469. }
  9470. }
  9471. private void removeFrontVideoLayout() {
  9472. try {
  9473. Log.d(TAG, "[removeFrontVideoLayout]");
  9474. if (FrontSurfaceLayout != null) {
  9475. FrontSurfaceLayout.setVisibility(View.GONE);
  9476. FrontSurfaceLayout = null;
  9477. }
  9478. if (FrontVideoSurface != null) {
  9479. FrontVideoSurface.setVisibility(View.GONE);
  9480. FrontVideoSurface.getHolder().removeCallback(FrontVideoCallback);
  9481. FrontVideoSurface = null;
  9482. }
  9483. if (FrontVideoLayout != null) {
  9484. FrontVideoLayout.setVisibility(View.GONE);
  9485. FrontVideoLayout.removeAllViews();
  9486. FrontVideoLayout = null;
  9487. }
  9488. } catch (RuntimeException re) {
  9489. LogUtil.errorLogInfo("", TAG, re);
  9490. } catch (Exception e) {
  9491. Log.e(TAG, "[Exception] removeFrontVideoLayout()");
  9492. //e.printStackTrace();
  9493. LogUtil.errorLogInfo("", TAG, e);
  9494. }
  9495. }
  9496. private void showFrontVideo(boolean bShow) {
  9497. try {
  9498. Log.d(TAG, "[showFrontVideo] bShow [" + bShow + "]");
  9499. if (FrontVideoSurface == null) {
  9500. Log.w(TAG, "[showFrontVideo] FrontVideoSurface is null!!!");
  9501. return;
  9502. }
  9503. WpadRelativeLayoutParams FrontVideoParams;
  9504. FrontVideoParams = new WpadRelativeLayoutParams(480, 360);
  9505. if (bShow) FrontVideoParams.setMargins(280, 115, 0, 0);
  9506. else FrontVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  9507. FrontVideoSurface.setLayoutParams(FrontVideoParams);
  9508. } catch (RuntimeException re) {
  9509. LogUtil.errorLogInfo("", TAG, re);
  9510. } catch (Exception e) {
  9511. Log.e(TAG, "[Exception] showFrontVideo(boolean bShow)");
  9512. //e.printStackTrace();
  9513. LogUtil.errorLogInfo("", TAG, e);
  9514. }
  9515. }
  9516. private void showFrontCam(boolean bOn) {
  9517. try {
  9518. Log.d(TAG, "[showFrontCam] bOn [" + bOn + "]");
  9519. if (getDoorCamType() != WallpadDeviceSet.DOORTYPE_IOT_SMART && getDoorCamType() != WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART && getDoorCamType() != WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) return;
  9520. if (bOn) {
  9521. // on
  9522. mIOInterface.selectFrontCam(false);
  9523. mIOInterface.ctrlFrontCamPower(bOn);
  9524. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_ON);
  9525. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  9526. mIOInterface.interfaceIGW300(Common.IGW300CMD.VIDEO_MOIP);
  9527. initFrontVideoLayout();
  9528. showFrontVideo(false);
  9529. } else {
  9530. // off
  9531. showFrontVideo(false);
  9532. removeFrontVideoLayout();
  9533. mIOInterface.ctrlFrontCamPower(bOn);
  9534. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  9535. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  9536. }
  9537. } catch (RuntimeException re) {
  9538. LogUtil.errorLogInfo("", TAG,re);
  9539. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  9540. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  9541. if (mIOInterface != null) {
  9542. mIOInterface.selectFrontCam(false);
  9543. mIOInterface.ctrlFrontCamPower(false);
  9544. }
  9545. } catch (Exception e) {
  9546. Log.e(TAG, "[Exception] showFrontCam(boolean bOn)");
  9547. //e.printStackTrace();
  9548. LogUtil.errorLogInfo("", TAG, e);
  9549. // 영상 오류 발생할 경우 카메라 전원 off
  9550. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  9551. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  9552. if (mIOInterface != null) {
  9553. mIOInterface.selectFrontCam(false);
  9554. mIOInterface.ctrlFrontCamPower(false);
  9555. }
  9556. }
  9557. }
  9558. private SurfaceHolder.Callback FrontVideoCallback = new SurfaceHolder.Callback() {
  9559. @Override
  9560. public void surfaceCreated(SurfaceHolder holder) {
  9561. try {
  9562. Log.d(TAG, "[FrontVideoCallback] front camera surfaceCreated!!");
  9563. boolean bAOS7 = false; // 한국생산(다담, AOS 6.0.1)과 중국생산(사니코, 7.1.1) 구분 (true: 중국생산, false: 한국생산)
  9564. if (Build.VERSION.SDK_INT > 23) bAOS7 = true;
  9565. Log.d(TAG, "[FrontVideoCallback] Version.getModelType() [" + Version.getModelType() + "], bAOS7 [" + bAOS7 + "]");
  9566. if (Version.getModelType() == MODEL_TYPE.IHN_D101) {
  9567. if (bAOS7) {
  9568. // AOS 7.1.1
  9569. mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  9570. }
  9571. else {
  9572. // AOS 6.0.1
  9573. if (getDoorCamType() == WallpadDeviceSet.DOORTYPE_IOT_SMART) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  9574. else mFrontCamera = Camera.open();
  9575. }
  9576. }
  9577. else {
  9578. if (bAOS7) {
  9579. // AOS 7.1.1
  9580. if (Version.getModelType() == MODEL_TYPE.IHN_1020B_I && !getCompareBSPVersion("2020.09.08")) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  9581. else if (Version.getModelType() == MODEL_TYPE.IHN_HS101_I && !getCompareBSPVersion("2020.06.11")) mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  9582. else mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  9583. }
  9584. else {
  9585. // AOS 6.0.1
  9586. mFrontCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  9587. }
  9588. }
  9589. if (getDoorCamType() == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  9590. Camera.Parameters params = mFrontCamera.getParameters();
  9591. params.setPictureSize(1280, 720);
  9592. mFrontCamera.setParameters(params);
  9593. }
  9594. else {
  9595. Camera.Parameters params = mFrontCamera.getParameters();
  9596. params.setPictureSize(640, 480);
  9597. mFrontCamera.setParameters(params);
  9598. }
  9599. mFrontCamera.setPreviewDisplay(holder);
  9600. mFrontCamera.setErrorCallback(FrontVideoErrorCallback);
  9601. } catch (RuntimeException re) {
  9602. LogUtil.errorLogInfo("", TAG, re);
  9603. } catch (Exception e) {
  9604. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  9605. //e.printStackTrace();
  9606. LogUtil.errorLogInfo("", TAG, e);
  9607. }
  9608. }
  9609. @Override
  9610. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  9611. try {
  9612. Log.d(TAG, "[FrontVideoCallback] surfaceChanged!!");
  9613. if (mFrontCamera != null) {
  9614. mFrontCamera.startPreview();
  9615. }
  9616. if (Common.OPTION_TAB_ANMI_ENABLE) {
  9617. Animation Anmi = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.screen_on);
  9618. FrontVideoLayout.startAnimation(Anmi);
  9619. }
  9620. } catch (RuntimeException re) {
  9621. LogUtil.errorLogInfo("", TAG, re);
  9622. } catch (Exception e) {
  9623. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceChanged(SurfaceHolder holder)");
  9624. //e.printStackTrace();
  9625. LogUtil.errorLogInfo("", TAG, e);
  9626. }
  9627. }
  9628. @Override
  9629. public void surfaceDestroyed(SurfaceHolder holder) {
  9630. try {
  9631. Log.d(TAG, "[FrontVideoCallback] surfaceDestroyed!!");
  9632. if (mFrontCamera != null) {
  9633. mFrontCamera.stopPreview();
  9634. mFrontCamera.release();
  9635. mFrontCamera = null;
  9636. }
  9637. } catch (RuntimeException re) {
  9638. LogUtil.errorLogInfo("", TAG, re);
  9639. } catch (Exception e) {
  9640. Log.e(TAG, "[Exception] FrontVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  9641. //e.printStackTrace();
  9642. LogUtil.errorLogInfo("", TAG, e);
  9643. }
  9644. }
  9645. };
  9646. private Camera.ErrorCallback FrontVideoErrorCallback = new Camera.ErrorCallback() {
  9647. @Override
  9648. public void onError(int error, Camera camera) {
  9649. switch (error) {
  9650. case Camera.CAMERA_ERROR_SERVER_DIED:
  9651. Log.e(TAG, "[FrontVideoErrorCallback] CAMERA_ERROR_SERVER_DIED");
  9652. camera.stopPreview();
  9653. camera.setPreviewCallback(null);
  9654. camera.release();
  9655. camera = null;
  9656. break;
  9657. case Camera.CAMERA_ERROR_UNKNOWN:
  9658. Log.e(TAG, "[FrontVideoErrorCallback] CAMERA_ERROR_UNKNOWN");
  9659. break;
  9660. }
  9661. }
  9662. };
  9663. int camOpenCheckCnt = 0;
  9664. int handlerMaxCnt = 100;
  9665. /**
  9666. * 현관카메라 OPEN CHECK Handler!!!
  9667. */
  9668. private Handler mFrontCamOpenCheckHandler = new Handler() {
  9669. @Override
  9670. public void handleMessage(Message msg) {
  9671. if (msg.what == 0) {
  9672. camOpenCheckCnt++;
  9673. if (camOpenCheckCnt > handlerMaxCnt) {
  9674. Log.w(TAG, "[mFrontCamOpenCheckHandler] camOpenCheckCnt is over!! [" + camOpenCheckCnt + "]");
  9675. mFrontCamOpenCheckHandler.removeMessages(0);
  9676. mFrontCamOpenCheckHandler.removeMessages(1);
  9677. camOpenCheckCnt = 0;
  9678. resetRecordSetting();
  9679. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  9680. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  9681. } else {
  9682. if (mFrontCamera != null) mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(1, 100);
  9683. else mFrontCamOpenCheckHandler.sendEmptyMessageDelayed(0, 100);
  9684. }
  9685. } else if (msg.what == 1) {
  9686. camOpenCheckCnt = 0;
  9687. // ************ 스마트현관카메라 영상 녹화 시작!! ************
  9688. Log.d(TAG, "[mFrontCamOpenCheckHandler] [CAMERA OPEN] STRANGER RECORD START");
  9689. if (mFrontCamera != null) {
  9690. if (getDoorCamType() == WallpadDeviceSet.DOORTYPE_IOT_SMART) mFrontCamera.stopPreview();
  9691. mFrontCamera.unlock();
  9692. mMediaRecorder = new MediaRecorder();
  9693. mMediaRecorder.setCamera(mFrontCamera);
  9694. mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  9695. mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  9696. if (getDoorCamType() == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  9697. mMediaRecorder.setVideoSize(1280, 720);
  9698. mMediaRecorder.setVideoEncodingBitRate(3000000);
  9699. }
  9700. else {
  9701. mMediaRecorder.setVideoSize(640, 480);
  9702. mMediaRecorder.setVideoFrameRate(24);
  9703. }
  9704. mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
  9705. mMediaRecorder.setOutputFile(VIDEO_TEMP_PATH);
  9706. mMediaRecorder.setPreviewDisplay(FrontVideoHolder.getSurface());
  9707. try {
  9708. Log.d(TAG, "[mFrontCamOpenCheckHandler] mMediaRecorder.prepare");
  9709. mMediaRecorder.prepare();
  9710. } catch (IllegalStateException e) {
  9711. Log.e(TAG, "[IllegalStateException] mFrontCamOpenCheckHandler.prepare");
  9712. //e.printStackTrace();
  9713. LogUtil.errorLogInfo("", TAG, e);
  9714. resetRecordSetting();
  9715. } catch (IOException e) {
  9716. Log.e(TAG, "[IOException] mFrontCamOpenCheckHandler.prepare");
  9717. //e.printStackTrace();
  9718. LogUtil.errorLogInfo("", TAG, e);
  9719. resetRecordSetting();
  9720. } catch (Exception e) {
  9721. Log.e(TAG, "[Exception] mFrontCamOpenCheckHandler.prepare");
  9722. LogUtil.errorLogInfo("", TAG, e);
  9723. resetRecordSetting();
  9724. }
  9725. try {
  9726. bRecordStatus = true;
  9727. runNoticeStrangerRecord(true);
  9728. if (mRecordTimer != null) mRecordTimer.start();
  9729. Log.d(TAG, "[mFrontCamOpenCheckHandler] mMediaRecorder.start");
  9730. mMediaRecorder.start();
  9731. } catch (IllegalStateException e) {
  9732. Log.e(TAG, "[IllegalStateException] mFrontCamOpenCheckHandler.start");
  9733. //e.printStackTrace();
  9734. LogUtil.errorLogInfo("", TAG, e);
  9735. resetRecordSetting();
  9736. } catch (Exception e) {
  9737. Log.e(TAG, "[Exception] mFrontCamOpenCheckHandler.start");
  9738. //e.printStackTrace();
  9739. LogUtil.errorLogInfo("", TAG, e);
  9740. resetRecordSetting();
  9741. }
  9742. }
  9743. }
  9744. }
  9745. };
  9746. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  9747. private void getResidentSafetyCheckSetting() {
  9748. try {
  9749. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  9750. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  9751. mWallpadDeviceSet.closeDB();
  9752. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  9753. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) Version.setResidentSafety();
  9754. else Version.unsetResidentSafety();
  9755. } catch (RuntimeException re) {
  9756. LogUtil.errorLogInfo("", TAG, re);
  9757. } catch (Exception e) {
  9758. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  9759. //e.printStackTrace();
  9760. LogUtil.errorLogInfo("", TAG, e);
  9761. }
  9762. }
  9763. /**
  9764. * 멀티제어 관련.
  9765. *
  9766. * */
  9767. //멀티기기 정보 제공을 위한 추가 madeinlab
  9768. private Messenger mServiceMessenger = null;
  9769. private boolean mIsBound;
  9770. private ServiceConnection mConnection = new ServiceConnection() {
  9771. @Override
  9772. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  9773. Log.d("test","onServiceConnected");
  9774. mServiceMessenger = new Messenger(iBinder);
  9775. try {
  9776. Message msg = Message.obtain(null, iMapServer.MSG_REGISTER_CLIENT);
  9777. msg.replyTo = mMessenger;
  9778. mServiceMessenger.send(msg);
  9779. }
  9780. catch (RemoteException e) {
  9781. }
  9782. }
  9783. @Override
  9784. public void onServiceDisconnected(ComponentName componentName) {
  9785. }
  9786. };
  9787. /** Service 로 부터 message를 받음 */
  9788. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  9789. @Override
  9790. public boolean handleMessage(Message msg) {
  9791. Log.i("test","act : what "+msg.what);
  9792. switch (msg.what) {
  9793. case iMapServer.MSG_SEND_TO_ACTIVITY:
  9794. int value1 = msg.getData().getInt("fromService");
  9795. Log.i("test","act : value1 "+value1);
  9796. //iMapService에 요청하면 디바이스 정보를 가져올 수 있도록 한다.
  9797. for(int i=1; i<4; i++) {
  9798. ((MainActivity) mContext).requestMultiControl(handler, Common.JSON.MENU.DEVICE_INFO, Common.JSON.REASON.DeviceInfo, i);
  9799. }
  9800. break;
  9801. }
  9802. return false;
  9803. }
  9804. }));
  9805. /** Service 로 메시지를 보냄 */
  9806. private void sendMessageToService(int index, String str) {
  9807. if (mIsBound) {
  9808. if (mServiceMessenger != null) {
  9809. try {
  9810. Message msg = null;
  9811. if(index==1) {
  9812. msg = Message.obtain(null, iMapServer.MSG_SEND_TO_SERVICE_DEVICES1, str);
  9813. } else if(index==2) {
  9814. msg = Message.obtain(null, iMapServer.MSG_SEND_TO_SERVICE_DEVICES2, str);
  9815. } else if(index==3) {
  9816. msg = Message.obtain(null, iMapServer.MSG_SEND_TO_SERVICE_DEVICES3, str);
  9817. } else if(index==4) {
  9818. msg = Message.obtain(null, 1111, str);
  9819. }
  9820. if(msg!=null) {
  9821. msg.replyTo = mMessenger;
  9822. mServiceMessenger.send(msg);
  9823. }
  9824. } catch (RemoteException e) {
  9825. }
  9826. }
  9827. }
  9828. }
  9829. @SuppressLint("HandlerLeak")
  9830. final Handler handler = new Handler() {
  9831. Gson gson = new Gson();
  9832. @Override
  9833. public void handleMessage(Message msg) {
  9834. switch (msg.what) {
  9835. case 1000:
  9836. try {
  9837. Bundle bundle = msg.getData();
  9838. String response = bundle.getString("response");
  9839. int index = bundle.getInt("index");
  9840. // 메시지를 서비스로 전달
  9841. String test2 = "<devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n" +
  9842. "<devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n" +
  9843. "<devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n" +
  9844. "<devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n" +
  9845. "<devinfo name=\"thermostat\" value=\"8\" floor=\"2\"/>\r\n" +
  9846. "<devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n" +
  9847. "<devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n" +
  9848. "<devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n" ;
  9849. String test3 = "<devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n" +
  9850. "<devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n" +
  9851. "<devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n" +
  9852. "<devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n" +
  9853. "<devinfo name=\"thermostat\" value=\"8\" floor=\"3\"/>\r\n" +
  9854. "<devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n" +
  9855. "<devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n" +
  9856. "<devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n" ;
  9857. sendMessageToService(index, response);
  9858. } catch (Exception e) {
  9859. e.printStackTrace();
  9860. }
  9861. break;
  9862. default:
  9863. break;
  9864. }
  9865. }
  9866. };
  9867. public String millToDate(long mills) {
  9868. String pattern = "yyyy-MM-dd'T'HH:mm:ss";
  9869. SimpleDateFormat formatter = new SimpleDateFormat(pattern);
  9870. String date = (String) formatter.format(new Timestamp(mills));
  9871. return date;
  9872. }
  9873. class ClientThread extends Thread {
  9874. private Handler handler;
  9875. private int menu, reason, position;
  9876. public ClientThread(Handler handler, int menu, int reason, int position) {
  9877. this.handler = handler;
  9878. this.menu = menu;
  9879. this.reason = reason;
  9880. this.position = position;
  9881. }
  9882. public void run() {
  9883. //String host = "10.1.1.1";
  9884. String host = "10.1."+position+".1";
  9885. int port = 9998;
  9886. String json = "";
  9887. JSONObject jsonObject = new JSONObject();
  9888. try {
  9889. jsonObject.accumulate("type", "request");
  9890. jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
  9891. jsonObject.accumulate("wallpadip", myIP);
  9892. jsonObject.accumulate("menu", menu);
  9893. jsonObject.accumulate("reason", reason);
  9894. jsonObject.accumulate("position", position);
  9895. } catch (JSONException e) {
  9896. e.printStackTrace();
  9897. }
  9898. // convert JSONObject to JSON to String
  9899. json = jsonObject.toString();
  9900. try {
  9901. Socket socket = new Socket();
  9902. InetSocketAddress ipep = new InetSocketAddress(host, port); // 방법 2
  9903. socket.connect(ipep);
  9904. ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
  9905. outputStream.writeObject(json);
  9906. Log.d("ClientThread", "서버로 보냄.");
  9907. ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
  9908. StringBuffer stb = new StringBuffer();
  9909. String data;
  9910. while (true) {
  9911. try {
  9912. socket.setSoTimeout(5000);
  9913. data = (String) inputStream.readObject();
  9914. if (data == null) {
  9915. break;
  9916. }
  9917. stb.append(data);
  9918. } catch (Exception e) {
  9919. if (socket != null) {
  9920. socket.close();
  9921. }
  9922. if (inputStream != null) {
  9923. inputStream.close();
  9924. }
  9925. if (outputStream != null) {
  9926. outputStream.close();
  9927. }
  9928. break;
  9929. }
  9930. }
  9931. final String response = String.valueOf(stb);
  9932. Log.d("ClientThread", "response=" + response);
  9933. final String finalResponse = response;
  9934. Message message = handler.obtainMessage();
  9935. message.what = 1000;
  9936. Bundle bundle = new Bundle();
  9937. bundle.putString("response", finalResponse);
  9938. bundle.putInt("index", position);
  9939. message.setData(bundle);
  9940. handler.sendMessage(message);
  9941. } catch (Exception e) {
  9942. e.printStackTrace();
  9943. }
  9944. }
  9945. }
  9946. String myIP = "NONE";
  9947. int ho = 0;
  9948. public void requestMultiControl(Handler handler, int menu, int reason, int position) {
  9949. if(position!=ho) {
  9950. ClientThread thread = new ClientThread(handler, menu, reason, position);
  9951. thread.start();
  9952. }
  9953. }
  9954. }